Skip to content

Conversation

@ahejlsberg
Copy link
Member

In this PR:

  • Error elaborations and spelling suggestions.
  • Checking of enum declarations.
  • Checking of module declarations.
  • Checking of import declarations.
  • Checking of import-equals declarations.
  • Checking of export declarations.
  • Checking of alias symbols.
  • Nullish checking.

props []string
}

var getFeatureMap = sync.OnceValue(func() map[string][]FeatureMapEntry {
Copy link
Member

@jakebailey jakebailey Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably just be a global; I don't think we need this to be lazy. Though I doubt the compiler is actually able to statically create this for us (so will in effect just create an init method to do it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like having it be lazy. That way, in a program with no errors it will never be created.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like that's somewhat overkill given all of our other globals that will also never be used most of the time, but, it is what the old code did, so 😄

return scanner.GetRangeOfTokenAtPosition(ast.GetSourceFileOfNode(node), pos)
}

func symbolName(symbol *ast.Symbol) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is duplicated with ast.SymbolName.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup

}

func (p *Program) GetEmitModuleFormatOfFile(sourceFile *ast.SourceFile) core.ModuleKind {
return p.GetEmitModuleFormatOfFileWorker(sourceFile, p.compilerOptions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the workers here if we're just directly calling them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, I just ported what was there.

minJ = 1
}
maxJ := int(math.Floor(maxValue + float64(i)))
if maxJ > len(s2) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the merge conflicts go away and CI runs, I suspect that some of this will have lint messages asking to use max/min.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it.

"tscBuild": null
}
Output::
project/index.ts(1,19): error TS2307: Cannot find module '../utils' or its corresponding type declarations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this is interesting; implies we aren't resolving something anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the issue is that we weren't resolving previously. I'm not sure what the purpose of this test is, but it looks like the error is legit.

@ahejlsberg ahejlsberg merged commit ff2b0e3 into main Feb 21, 2025
16 checks passed
@jakebailey
Copy link
Member

Hm, this seems to have broken tests in #275, with traces like:

=== FAIL: internal/testutil/runner TestCompilerBaselinesSubmodule/compiler/isolatedModulesReExportType.ts (0.01s)
    testutil.go:33: Panic on compiling test /home/jabaile/work/TypeScript-go/_submodules/TypeScript/tests/cases/compiler/isolatedModulesReExportType.ts:
        runtime error: invalid memory address or nil pointer dereference
        goroutine 7794 [running]:
        runtime/debug.Stack()
                /usr/local/go/src/runtime/debug/stack.go:26 +0x5e
        github.com/microsoft/typescript-go/internal/testutil.RecoverAndFail(0xc007103dc0, {0xc058457170, 0x83})
                /home/jabaile/work/TypeScript-go/internal/testutil/testutil.go:32 +0x58
        panic({0xf103e0?, 0x20af920?})
                /usr/local/go/src/runtime/panic.go:787 +0x132
        github.com/microsoft/typescript-go/internal/ast.GetSourceFileOfNode(...)
                /home/jabaile/work/TypeScript-go/internal/ast/utilities.go:836
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkAliasSymbol(0xc0620e1008, 0xc044ae1080)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:6103 +0x952
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkExportSpecifier(0xc0620e1008, 0xc044ae1080)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:4992 +0x25
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkExportDeclaration(0xc0620e1008, 0xc059e752d0)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:4969 +0x28a
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkSourceElementWorker(0xc0620e1008, 0xc059e752d0)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:2116 +0x3c5
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkSourceElement(0xc0620e1008, 0x1474360?)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:1995 +0x4e
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkSourceElements(...)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:1986
        github.com/microsoft/typescript-go/internal/checker.(*Checker).CheckSourceFile(0xc0620e1008, 0xc065d92008)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:1978 +0xb1
        github.com/microsoft/typescript-go/internal/compiler.(*Program).CheckSourceFiles.func1()
                /home/jabaile/work/TypeScript-go/internal/compiler/program.go:196 +0x3b
        github.com/microsoft/typescript-go/internal/core.(*singleThreadedWorkGroup).RunAndWait(0xc0664c87b0)
                /home/jabaile/work/TypeScript-go/internal/core/workgroup.go:83 +0x4b
        github.com/microsoft/typescript-go/internal/compiler.(*Program).CheckSourceFiles(0xc063d48f00)
                /home/jabaile/work/TypeScript-go/internal/compiler/program.go:200 +0x12b
        github.com/microsoft/typescript-go/internal/compiler.(*Program).getDiagnosticsHelper(0xc063d48f00, 0xc05e390d38?, 0x88?, 0x1?, 0xc087575708)
                /home/jabaile/work/TypeScript-go/internal/compiler/program.go:369 +0x54
        github.com/microsoft/typescript-go/internal/compiler.(*Program).GetSemanticDiagnostics(...)
                /home/jabaile/work/TypeScript-go/internal/compiler/program.go:268
        github.com/microsoft/typescript-go/internal/testutil/harnessutil.compileFilesWithHost({0x1471df8?, 0xc05e390d38?}, {0xc0854511f0?, 0x1b?, 0xee0f20?}, 0xc0840abb88, 0xc05e320780)
                /home/jabaile/work/TypeScript-go/internal/testutil/harnessutil/harnessutil.go:469 +0x1ef
        github.com/microsoft/typescript-go/internal/testutil/harnessutil.CompileFiles(0xc007103dc0, {0xc061e6e738, 0x1, 0x0?}, {0xc062087680, 0x7, 0xc05e390ca8?}, 0xc007112ba0, 0xc00715faa8, {0x1070014, ...}, ...)
                /home/jabaile/work/TypeScript-go/internal/testutil/harnessutil/harnessutil.go:161 +0x791
        github.com/microsoft/typescript-go/internal/testutil/runner.newCompilerTest(0xc007103dc0, {0xc0027d04d0, 0x6b}, 0xc00715fe90, 0xc006126bb8)
                /home/jabaile/work/TypeScript-go/internal/testutil/runner/compiler_runner.go:289 +0x8ee
        github.com/microsoft/typescript-go/internal/testutil/runner.(*CompilerBaselineRunner).runSingleConfigTest(0xc000140000, 0xc007103dc0, 0xc0076af240, 0xc006126bb8)
                /home/jabaile/work/TypeScript-go/internal/testutil/runner/compiler_runner.go:169 +0x16b
        github.com/microsoft/typescript-go/internal/testutil/runner.(*CompilerBaselineRunner).runTest.func1(0xc007103dc0?)
                /home/jabaile/work/TypeScript-go/internal/testutil/runner/compiler_runner.go:157 +0x25
        testing.tRunner(0xc007103dc0, 0xc007d48f40)
                /usr/local/go/src/testing/testing.go:1792 +0xf4
        created by testing.(*T).Run in goroutine 17
                /usr/local/go/src/testing/testing.go:1851 +0x413
=== FAIL: internal/testutil/runner TestCompilerBaselinesSubmodule/compiler/importAssertionNonstring.ts (0.01s)
    testutil.go:33: Panic on compiling test /home/jabaile/work/TypeScript-go/_submodules/TypeScript/tests/cases/compiler/importAssertionNonstring.ts:
        runtime error: invalid memory address or nil pointer dereference
        goroutine 6756 [running]:
        runtime/debug.Stack()
                /usr/local/go/src/runtime/debug/stack.go:26 +0x5e
        github.com/microsoft/typescript-go/internal/testutil.RecoverAndFail(0xc005a5a1c0, {0xc05d3ec300, 0x80})
                /home/jabaile/work/TypeScript-go/internal/testutil/testutil.go:32 +0x58
        panic({0xf103e0?, 0x20af920?})
                /usr/local/go/src/runtime/panic.go:787 +0x132
        github.com/microsoft/typescript-go/internal/ast.IsSourceFile(...)
                /home/jabaile/work/TypeScript-go/internal/ast/ast.go:7930
        github.com/microsoft/typescript-go/internal/checker.(*Checker).getTypeOfVariableOrParameterOrPropertyWorker(0xc10007f008, 0x1474ae0?)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:14419 +0x3b
        github.com/microsoft/typescript-go/internal/checker.(*Checker).getTypeOfVariableOrParameterOrProperty(0xc10007f008, 0xc1050a86a8)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:14375 +0x4d
        github.com/microsoft/typescript-go/internal/checker.(*Checker).getTypeOfSymbol(0xc10007f008?, 0xc0431ecc2c?)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:14335 +0xa6
        github.com/microsoft/typescript-go/internal/checker.(*Checker).getNonMissingTypeOfSymbol(0xc10007f008, 0xc1050a86a8)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:14353 +0x1d
        github.com/microsoft/typescript-go/internal/checker.(*Relater).membersRelatedToIndexInfo(0xc10107c840, 0xc10107c790, 0xc10107b940, 0x1, 0x0)
                /home/jabaile/work/TypeScript-go/internal/checker/relater.go:4544 +0x1ba
        github.com/microsoft/typescript-go/internal/checker.(*Relater).typeRelatedToIndexInfo(0xc10107c840, 0xc10107c790, 0xc10107b940, 0x1, 0x0)
                /home/jabaile/work/TypeScript-go/internal/checker/relater.go:4507 +0xa6
        github.com/microsoft/typescript-go/internal/checker.(*Relater).indexSignaturesRelatedTo(0xc10107c840, 0xc10107c790, 0xc1050ca300?, 0x0, 0x1, 0x0)
                /home/jabaile/work/TypeScript-go/internal/checker/relater.go:4488 +0x1b4
        github.com/microsoft/typescript-go/internal/checker.(*Relater).structuredTypeRelatedToWorker(0xc10107c840, 0xc10107c790, 0xc1050ca300, 0x1, 0x0)
                /home/jabaile/work/TypeScript-go/internal/checker/relater.go:3789 +0x2e68
        github.com/microsoft/typescript-go/internal/checker.(*Relater).structuredTypeRelatedTo(0xc10107c840, 0xc10107c790, 0xc1050ca300, 0x1, 0x0)
                /home/jabaile/work/TypeScript-go/internal/checker/relater.go:3123 +0x65
        github.com/microsoft/typescript-go/internal/checker.(*Relater).recursiveTypeRelatedTo(0xc10107c840, 0xc10107c790, 0xc1050ca300, 0x1, 0x0, 0x3)
                /home/jabaile/work/TypeScript-go/internal/checker/relater.go:3064 +0x771
        github.com/microsoft/typescript-go/internal/checker.(*Relater).isRelatedToEx(0xc10107c840, 0xc10107c790, 0xc1050ca300, 0x3, 0x1, 0x0, 0x0)
                /home/jabaile/work/TypeScript-go/internal/checker/relater.go:2632 +0x9a5
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkTypeRelatedToEx(0xc10007f008, 0xc10107c790, 0xc1050ca300, 0xc00a32bae8, 0xc094fed630, 0x0, 0x0)
                /home/jabaile/work/TypeScript-go/internal/checker/relater.go:375 +0x23a
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkTypeAssignableTo(...)
                /home/jabaile/work/TypeScript-go/internal/checker/relater.go:342
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkImportAttributes(0xc10007f008, 0xc105085b60)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:4856 +0xf3
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkImportDeclaration(0xc10007f008, 0xc105085b60)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:4774 +0x2a5
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkSourceElementWorker(0xc10007f008, 0xc105085b60)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:2112 +0x3b3
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkSourceElement(0xc10007f008, 0x1474360?)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:1995 +0x4e
        github.com/microsoft/typescript-go/internal/checker.(*Checker).checkSourceElements(...)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:1986
        github.com/microsoft/typescript-go/internal/checker.(*Checker).CheckSourceFile(0xc10007f008, 0xc09baddb88)
                /home/jabaile/work/TypeScript-go/internal/checker/checker.go:1978 +0xb1
        github.com/microsoft/typescript-go/internal/compiler.(*Program).CheckSourceFiles.func1()
                /home/jabaile/work/TypeScript-go/internal/compiler/program.go:196 +0x3b
        github.com/microsoft/typescript-go/internal/core.(*singleThreadedWorkGroup).RunAndWait(0xc1050a3680)
                /home/jabaile/work/TypeScript-go/internal/core/workgroup.go:83 +0x4b
        github.com/microsoft/typescript-go/internal/compiler.(*Program).CheckSourceFiles(0xc1043ec000)
                /home/jabaile/work/TypeScript-go/internal/compiler/program.go:200 +0x12b
        github.com/microsoft/typescript-go/internal/compiler.(*Program).getDiagnosticsHelper(0xc1043ec000, 0xc0686cc3a8?, 0x88?, 0x1?, 0xc0b1f43708)
                /home/jabaile/work/TypeScript-go/internal/compiler/program.go:369 +0x54
        github.com/microsoft/typescript-go/internal/compiler.(*Program).GetSemanticDiagnostics(...)
                /home/jabaile/work/TypeScript-go/internal/compiler/program.go:268
        github.com/microsoft/typescript-go/internal/testutil/harnessutil.compileFilesWithHost({0x1471df8?, 0xc0686cc3a8?}, {0xc073e77ea0?, 0xd?, 0xee0f20?}, 0xc0ff4fc588, 0xc0ca8e2960)
                /home/jabaile/work/TypeScript-go/internal/testutil/harnessutil/harnessutil.go:469 +0x1ef
        github.com/microsoft/typescript-go/internal/testutil/harnessutil.CompileFiles(0xc005a5a1c0, {0xc0854bbb48, 0x1, 0x0?}, {0x0, 0x0, 0xc0ca8dd000?}, 0xc0058fe150, 0xc005b1caa8, {0x1070014, ...}, ...)
                /home/jabaile/work/TypeScript-go/internal/testutil/harnessutil/harnessutil.go:161 +0x791
        github.com/microsoft/typescript-go/internal/testutil/runner.newCompilerTest(0xc005a5a1c0, {0xc0027c1960, 0x68}, 0xc005b1ce90, 0xc00564de90)
                /home/jabaile/work/TypeScript-go/internal/testutil/runner/compiler_runner.go:289 +0x8ee
        github.com/microsoft/typescript-go/internal/testutil/runner.(*CompilerBaselineRunner).runSingleConfigTest(0xc000140000, 0xc005a5a1c0, 0xc0023b8200, 0xc00564de90)
                /home/jabaile/work/TypeScript-go/internal/testutil/runner/compiler_runner.go:169 +0x16b
        github.com/microsoft/typescript-go/internal/testutil/runner.(*CompilerBaselineRunner).runTest.func1(0xc005a5a1c0?)
                /home/jabaile/work/TypeScript-go/internal/testutil/runner/compiler_runner.go:157 +0x25
        testing.tRunner(0xc005a5a1c0, 0xc005bd25a0)
                /usr/local/go/src/testing/testing.go:1792 +0xf4
        created by testing.(*T).Run in goroutine 17
                /usr/local/go/src/testing/testing.go:1851 +0x413

Should really get those tests in now that they're fast.

@jakebailey jakebailey deleted the more-types-30 branch February 27, 2025 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants