Skip to content

Commit 64bd5d8

Browse files
dependabot[bot]github-actions[bot]buke
authored
deps(deps): bump microsoft/typescript-go from c9d2894 to 7cf22f6 (#20)
* deps(deps): bump microsoft/typescript-go from `c9d2894` to `7cf22f6` Bumps [microsoft/typescript-go](https://github.com/microsoft/typescript-go) from `c9d2894` to `7cf22f6`. - [Commits](microsoft/typescript-go@c9d2894...7cf22f6) --- updated-dependencies: - dependency-name: microsoft/typescript-go dependency-version: 7cf22f66ba7489920686d27951a48bbac3cb6e9a dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * chore(sync): mirror internal packages into pkg/ (auto) (#21) Co-authored-by: buke <1013738+buke@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: buke <1013738+buke@users.noreply.github.com>
1 parent f88215e commit 64bd5d8

File tree

135 files changed

+974
-1670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+974
-1670
lines changed

microsoft/typescript-go

Submodule typescript-go updated 134 files

pkg/ast/ast.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10757,7 +10757,9 @@ type SourceFile struct {
1075710757
NodeCount int
1075810758
TextCount int
1075910759
CommonJSModuleIndicator *Node
10760-
ExternalModuleIndicator *Node
10760+
// If this is the SourceFile itself, then this module was "forced"
10761+
// to be an external module (previously "true").
10762+
ExternalModuleIndicator *Node
1076110763

1076210764
// Fields set by binder
1076310765

pkg/ast/kind.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ const (
339339
KindEnumMember
340340
// Top-level nodes
341341
KindSourceFile
342-
KindBundle
343342
// JSDoc nodes
344343
KindJSDocTypeExpression
345344
KindJSDocNameReference

pkg/ast/kind_stringer_generated.go

Lines changed: 49 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/binder/binder.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,9 @@ func (b *Binder) bind(node *ast.Node) bool {
683683
case ast.KindInterfaceDeclaration:
684684
b.bindBlockScopedDeclaration(node, ast.SymbolFlagsInterface, ast.SymbolFlagsInterfaceExcludes)
685685
case ast.KindCallExpression:
686-
b.bindCallExpression(node)
686+
if ast.IsInJSFile(node) {
687+
b.bindCallExpression(node)
688+
}
687689
case ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration:
688690
b.bindBlockScopedDeclaration(node, ast.SymbolFlagsTypeAlias, ast.SymbolFlagsTypeAliasExcludes)
689691
case ast.KindEnumDeclaration:
@@ -910,16 +912,24 @@ func (b *Binder) bindFunctionExpression(node *ast.Node) {
910912
}
911913

912914
func (b *Binder) bindCallExpression(node *ast.Node) {
913-
// !!! for ModuleDetectionKind.Force, external module indicator is forced to `true` in Strada for source files, in which case
914-
// we should set the commonjs module indicator but not call b.bindSourceFileAsExternalModule
915-
// !!! && file.externalModuleIndicator !== true (used for ModuleDetectionKind.Force)
916-
if ast.IsInJSFile(node) &&
917-
b.file.ExternalModuleIndicator == nil &&
918-
b.file.CommonJSModuleIndicator == nil &&
919-
ast.IsRequireCall(node, false /*requireStringLiteralLikeArgument*/) {
915+
// We're only inspecting call expressions to detect CommonJS modules, so we can skip
916+
// this check if we've already seen the module indicator
917+
if b.file.CommonJSModuleIndicator == nil && ast.IsRequireCall(node, false /*requireStringLiteralLikeArgument*/) {
918+
b.setCommonJSModuleIndicator(node)
919+
}
920+
}
921+
922+
func (b *Binder) setCommonJSModuleIndicator(node *ast.Node) bool {
923+
if b.file.ExternalModuleIndicator != nil && b.file.ExternalModuleIndicator != b.file.AsNode() {
924+
return false
925+
}
926+
if b.file.CommonJSModuleIndicator == nil {
920927
b.file.CommonJSModuleIndicator = node
921-
b.bindSourceFileAsExternalModule()
928+
if b.file.ExternalModuleIndicator == nil {
929+
b.bindSourceFileAsExternalModule()
930+
}
922931
}
932+
return true
923933
}
924934

925935
func (b *Binder) bindClassLikeDeclaration(node *ast.Node) {

pkg/checker/checker.go

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ func isSameScopeDescendentOf(initial *ast.Node, parent *ast.Node, stopAt *ast.No
20032003
return false
20042004
}
20052005

2006-
// stopAtAnyPropertyDeclaration is used for detecting ES-standard class field use-before-def errors
2006+
// isPropertyImmediatelyReferencedWithinDeclaration is used for detecting ES-standard class field use-before-def errors
20072007
func isPropertyImmediatelyReferencedWithinDeclaration(declaration *ast.Node, usage *ast.Node, stopAtAnyPropertyDeclaration bool) bool {
20082008
// always legal if usage is after declaration
20092009
if usage.End() > declaration.End() {
@@ -5539,7 +5539,7 @@ func (c *Checker) checkExternalModuleExports(node *ast.Node) {
55395539
links := c.moduleSymbolLinks.Get(moduleSymbol)
55405540
if !links.exportsChecked {
55415541
exportEqualsSymbol := moduleSymbol.Exports[ast.InternalSymbolNameExportEquals]
5542-
if exportEqualsSymbol != nil && c.hasExportedMembers(moduleSymbol) {
5542+
if exportEqualsSymbol != nil && c.hasExportedMembers(moduleSymbol, exportEqualsSymbol.ValueDeclaration.Kind == ast.KindJSExportAssignment) {
55435543
declaration := core.OrElse(c.getDeclarationOfAliasSymbol(exportEqualsSymbol), exportEqualsSymbol.ValueDeclaration)
55445544
if declaration != nil && !isTopLevelInExternalModuleAugmentation(declaration) {
55455545
c.error(declaration, diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements)
@@ -5575,10 +5575,17 @@ func (c *Checker) checkExternalModuleExports(node *ast.Node) {
55755575
}
55765576
}
55775577

5578-
func (c *Checker) hasExportedMembers(moduleSymbol *ast.Symbol) bool {
5578+
func (c *Checker) hasExportedMembers(moduleSymbol *ast.Symbol, isCommonJS bool) bool {
55795579
for id := range moduleSymbol.Exports {
55805580
if id != ast.InternalSymbolNameExportEquals {
5581-
return true
5581+
if !isCommonJS {
5582+
return true
5583+
}
5584+
for _, declaration := range moduleSymbol.Exports[id].Declarations {
5585+
if declaration.Kind != ast.KindJSTypeAliasDeclaration {
5586+
return true
5587+
}
5588+
}
55825589
}
55835590
}
55845591
return false
@@ -14440,7 +14447,7 @@ func (c *Checker) canHaveSyntheticDefault(file *ast.Node, moduleSymbol *ast.Symb
1444014447
}
1444114448

1444214449
// JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
14443-
return !ast.IsExternalModule(file.AsSourceFile()) && c.resolveExportByName(moduleSymbol, "__esModule", nil /*sourceNode*/, dontResolveAlias) == nil
14450+
return (file.AsSourceFile().ExternalModuleIndicator == nil || file.AsSourceFile().ExternalModuleIndicator == file) && c.resolveExportByName(moduleSymbol, "__esModule", nil /*sourceNode*/, dontResolveAlias) == nil
1444414451
}
1444514452

1444614453
func (c *Checker) getEmitSyntaxForModuleSpecifierExpression(usage *ast.Node) core.ResolutionMode {
@@ -15333,13 +15340,27 @@ func (c *Checker) resolveEntityName(name *ast.Node, meaning ast.SymbolFlags, ign
1533315340
if resolveLocation == nil {
1533415341
resolveLocation = name
1533515342
}
15336-
symbol = c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), meaning, message, true /*isUse*/, false /*excludeGlobals*/))
15343+
if meaning == ast.SymbolFlagsNamespace {
15344+
symbol = c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), meaning, nil, true /*isUse*/, false /*excludeGlobals*/))
15345+
if symbol == nil {
15346+
alias := c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), ast.SymbolFlagsAlias, nil, true /*isUse*/, false /*excludeGlobals*/))
15347+
if alias != nil && alias.Name == ast.InternalSymbolNameExportEquals {
15348+
// resolve typedefs exported from commonjs, stored on the module symbol
15349+
symbol = alias.Parent
15350+
}
15351+
}
15352+
if symbol == nil && message != nil {
15353+
c.resolveName(resolveLocation, name.Text(), meaning, message, true /*isUse*/, false /*excludeGlobals*/)
15354+
}
15355+
} else {
15356+
symbol = c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), meaning, message, true /*isUse*/, false /*excludeGlobals*/))
15357+
}
1533715358
case ast.KindQualifiedName:
1533815359
qualified := name.AsQualifiedName()
15339-
symbol = c.resolveQualifiedName(name, qualified.Left, qualified.Right, meaning, ignoreErrors, dontResolveAlias, location)
15360+
symbol = c.resolveQualifiedName(name, qualified.Left, qualified.Right, meaning, ignoreErrors, location)
1534015361
case ast.KindPropertyAccessExpression:
1534115362
access := name.AsPropertyAccessExpression()
15342-
symbol = c.resolveQualifiedName(name, access.Expression, access.Name(), meaning, ignoreErrors, dontResolveAlias, location)
15363+
symbol = c.resolveQualifiedName(name, access.Expression, access.Name(), meaning, ignoreErrors, location)
1534315364
default:
1534415365
panic("Unknown entity name kind")
1534515366
}
@@ -15357,7 +15378,7 @@ func (c *Checker) resolveEntityName(name *ast.Node, meaning ast.SymbolFlags, ign
1535715378
return symbol
1535815379
}
1535915380

15360-
func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *ast.Node, meaning ast.SymbolFlags, ignoreErrors bool, dontResolveAlias bool, location *ast.Node) *ast.Symbol {
15381+
func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *ast.Node, meaning ast.SymbolFlags, ignoreErrors bool, location *ast.Node) *ast.Symbol {
1536115382
namespace := c.resolveEntityName(left, ast.SymbolFlagsNamespace, ignoreErrors, false /*dontResolveAlias*/, location)
1536215383
if namespace == nil || ast.NodeIsMissing(right) {
1536315384
return nil
@@ -15713,12 +15734,26 @@ func (c *Checker) getExportsOfModuleWorker(moduleSymbol *ast.Symbol) (exports as
1571315734
}
1571415735
return symbols
1571515736
}
15737+
var originalModule *ast.Symbol
15738+
if moduleSymbol != nil {
15739+
if c.resolveSymbolEx(moduleSymbol.Exports[ast.InternalSymbolNameExportEquals], false /*dontResolveAlias*/) != nil {
15740+
originalModule = moduleSymbol
15741+
}
15742+
}
1571615743
// A module defined by an 'export=' consists of one export that needs to be resolved
1571715744
moduleSymbol = c.resolveExternalModuleSymbol(moduleSymbol, false /*dontResolveAlias*/)
1571815745
exports = visit(moduleSymbol, nil, false)
1571915746
if exports == nil {
1572015747
exports = make(ast.SymbolTable)
1572115748
}
15749+
// A CommonJS module defined by an 'export=' might also export typedefs, stored on the original module
15750+
if originalModule != nil && len(originalModule.Exports) > 1 {
15751+
for _, symbol := range originalModule.Exports {
15752+
if symbol.Flags&ast.SymbolFlagsType != 0 && symbol.Name != ast.InternalSymbolNameExportEquals && exports[symbol.Name] == nil {
15753+
exports[symbol.Name] = symbol
15754+
}
15755+
}
15756+
}
1572215757
for name := range nonTypeOnlyNames.Keys() {
1572315758
delete(typeOnlyExportStarMap, name)
1572415759
}
@@ -23972,6 +24007,13 @@ func (c *Checker) getTypeFromImportTypeNode(node *ast.Node) *Type {
2397224007
symbolFromVariable = c.getPropertyOfTypeEx(c.getTypeOfSymbol(mergedResolvedSymbol), current.Text(), false /*skipObjectFunctionPropertyAugment*/, true /*includeTypeOnlyMembers*/)
2397324008
} else {
2397424009
symbolFromModule = c.getSymbol(c.getExportsOfSymbol(mergedResolvedSymbol), current.Text(), meaning)
24010+
if symbolFromModule == nil {
24011+
// a CommonJS module might have typedefs exported alongside an export=
24012+
immediateModuleSymbol := c.resolveExternalModuleSymbol(innerModuleSymbol, true /*dontResolveAlias*/)
24013+
if immediateModuleSymbol != nil && core.Some(immediateModuleSymbol.Declarations, func(d *ast.Node) bool { return d.Kind == ast.KindJSExportAssignment }) {
24014+
symbolFromModule = c.getSymbol(c.getExportsOfSymbol(immediateModuleSymbol.Parent), current.Text(), meaning)
24015+
}
24016+
}
2397524017
}
2397624018
next := core.OrElse(symbolFromModule, symbolFromVariable)
2397724019
if next == nil {

pkg/checker/grammarchecks.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,9 +2093,7 @@ func (c *Checker) checkGrammarNumericLiteral(node *ast.NumericLiteral) {
20932093
// We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "."
20942094
// e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`.
20952095
isFractional := strings.ContainsRune(nodeText, '.')
2096-
// !!!
2097-
// isScientific := node.NumericLiteralFlags & ast.TokenFlagsScientific
2098-
isScientific := strings.ContainsRune(nodeText, 'e')
2096+
isScientific := node.TokenFlags&ast.TokenFlagsScientific != 0
20992097

21002098
// Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint
21012099
// Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway

pkg/checker/nodebuilderimpl.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,6 @@ func (b *NodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overri
11791179
if ok {
11801180
return result
11811181
}
1182-
isBundle := false // !!! remove me
11831182
// For declaration bundles, we need to generate absolute paths relative to the common source dir for imports,
11841183
// just like how the declaration emitter does for the ambient module declarations - we can easily accomplish this
11851184
// using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative
@@ -1191,13 +1190,6 @@ func (b *NodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overri
11911190
if resolutionMode == core.ResolutionModeESM {
11921191
endingPref = modulespecifiers.ImportModuleSpecifierEndingPreferenceJs
11931192
}
1194-
if isBundle {
1195-
// !!! relies on option cloning and specifier host implementation
1196-
// specifierCompilerOptions = &core.CompilerOptions{BaseUrl: host.CommonSourceDirectory()}
1197-
// TODO: merge with b.ch.compilerOptions
1198-
specifierPref = modulespecifiers.ImportModuleSpecifierPreferenceNonRelative
1199-
endingPref = modulespecifiers.ImportModuleSpecifierEndingPreferenceMinimal
1200-
}
12011193

12021194
allSpecifiers := modulespecifiers.GetModuleSpecifiers(
12031195
symbol,

pkg/evaluator/evaluator.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ func evaluateTemplateExpression(expr *ast.Node, location *ast.Node, evaluate Eva
140140
}
141141

142142
func AnyToString(v any) string {
143-
// !!! This function should behave identically to the expression `"" + v` in JS
144143
switch v := v.(type) {
145144
case string:
146145
return v
@@ -155,7 +154,6 @@ func AnyToString(v any) string {
155154
}
156155

157156
func IsTruthy(v any) bool {
158-
// !!! This function should behave identically to the expression `!!v` in JS
159157
switch v := v.(type) {
160158
case string:
161159
return len(v) != 0

pkg/execute/tsc.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
func CommandLine(sys tsc.System, commandLineArgs []string, testing tsc.CommandLineTesting) tsc.CommandLineResult {
2525
if len(commandLineArgs) > 0 {
26-
// !!! build mode
2726
switch strings.ToLower(commandLineArgs[0]) {
2827
case "-b", "--b", "-build", "--build":
2928
return tscBuildCompilation(sys, tsoptions.ParseBuildCommandLine(commandLineArgs, sys), testing)

0 commit comments

Comments
 (0)