Skip to content

Commit d1ceeb0

Browse files
dependabot[bot]github-actions[bot]buke
authored
deps(deps): bump microsoft/typescript-go from 3e97dac to beeea27 (#14)
* deps(deps): bump microsoft/typescript-go from `3e97dac` to `beeea27` Bumps [microsoft/typescript-go](https://github.com/microsoft/typescript-go) from `3e97dac` to `beeea27`. - [Commits](microsoft/typescript-go@3e97dac...beeea27) --- updated-dependencies: - dependency-name: microsoft/typescript-go dependency-version: beeea27a9c180e6eb81b5730ad99eaf0837d1688 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * chore(sync): mirror internal packages into pkg/ (auto) (#15) 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 1a8b7db commit d1ceeb0

File tree

244 files changed

+8324
-260
lines changed

Some content is hidden

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

244 files changed

+8324
-260
lines changed

microsoft/typescript-go

Submodule typescript-go updated 243 files

pkg/ast/parseoptions.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ func isFileProbablyExternalModule(sourceFile *SourceFile) *Node {
112112
}
113113

114114
func isAnExternalModuleIndicatorNode(node *Node) bool {
115-
if node.Flags&NodeFlagsReparsed != 0 {
116-
return false
117-
}
118115
return HasSyntacticModifier(node, ModifierFlagsExport) ||
119116
IsImportEqualsDeclaration(node) && IsExternalModuleReference(node.AsImportEqualsDeclaration().ModuleReference) ||
120117
IsImportDeclaration(node) || IsExportAssignment(node) || IsExportDeclaration(node)

pkg/ast/utilities.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,10 +1391,6 @@ func GetNameOfDeclaration(declaration *Node) *Node {
13911391
return nil
13921392
}
13931393

1394-
func GetImportClauseOfDeclaration(declaration *Declaration) *ImportClause {
1395-
return declaration.ImportClause().AsImportClause()
1396-
}
1397-
13981394
func GetNonAssignedNameOfDeclaration(declaration *Node) *Node {
13991395
// !!!
14001396
switch declaration.Kind {

pkg/astnav/tokens.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,3 +672,60 @@ func shouldSkipChild(node *ast.Node) bool {
672672
ast.IsJSDocLinkLike(node) ||
673673
ast.IsJSDocTag(node)
674674
}
675+
676+
// FindChildOfKind searches for a child node or token of the specified kind within a containing node.
677+
// This function scans through both AST nodes and intervening tokens to find the first match.
678+
func FindChildOfKind(containingNode *ast.Node, kind ast.Kind, sourceFile *ast.SourceFile) *ast.Node {
679+
lastNodePos := containingNode.Pos()
680+
scan := scanner.GetScannerForSourceFile(sourceFile, lastNodePos)
681+
682+
var foundChild *ast.Node
683+
visitNode := func(node *ast.Node) bool {
684+
if node == nil || node.Flags&ast.NodeFlagsReparsed != 0 {
685+
return false
686+
}
687+
// Look for child in preceding tokens.
688+
startPos := lastNodePos
689+
for startPos < node.Pos() {
690+
tokenKind := scan.Token()
691+
tokenFullStart := scan.TokenFullStart()
692+
tokenEnd := scan.TokenEnd()
693+
token := sourceFile.GetOrCreateToken(tokenKind, tokenFullStart, tokenEnd, containingNode)
694+
if tokenKind == kind {
695+
foundChild = token
696+
return true
697+
}
698+
startPos = tokenEnd
699+
scan.Scan()
700+
}
701+
if node.Kind == kind {
702+
foundChild = node
703+
return true
704+
}
705+
706+
lastNodePos = node.End()
707+
scan.ResetPos(lastNodePos)
708+
return false
709+
}
710+
711+
ast.ForEachChildAndJSDoc(containingNode, sourceFile, visitNode)
712+
713+
if foundChild != nil {
714+
return foundChild
715+
}
716+
717+
// Look for child in trailing tokens.
718+
startPos := lastNodePos
719+
for startPos < containingNode.End() {
720+
tokenKind := scan.Token()
721+
tokenFullStart := scan.TokenFullStart()
722+
tokenEnd := scan.TokenEnd()
723+
token := sourceFile.GetOrCreateToken(tokenKind, tokenFullStart, tokenEnd, containingNode)
724+
if tokenKind == kind {
725+
return token
726+
}
727+
startPos = tokenEnd
728+
scan.Scan()
729+
}
730+
return nil
731+
}

pkg/binder/binder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func GetSymbolNameForPrivateIdentifier(containingClassSymbol *ast.Symbol, descri
377377

378378
func (b *Binder) declareModuleMember(node *ast.Node, symbolFlags ast.SymbolFlags, symbolExcludes ast.SymbolFlags) *ast.Symbol {
379379
container := b.container
380-
if node.Kind == ast.KindCommonJSExport {
380+
if ast.IsCommonJSExport(node) {
381381
container = b.file.AsNode()
382382
}
383383
hasExportModifier := ast.GetCombinedModifierFlags(node)&ast.ModifierFlagsExport != 0 || ast.IsImplicitlyExportedJSTypeAlias(node)
@@ -402,7 +402,7 @@ func (b *Binder) declareModuleMember(node *ast.Node, symbolFlags ast.SymbolFlags
402402
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
403403
// and this case is specially handled. Module augmentations should only be merged with original module definition
404404
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
405-
if !ast.IsAmbientModule(node) && (hasExportModifier || container.Flags&ast.NodeFlagsExportContext != 0) {
405+
if !ast.IsAmbientModule(node) && (hasExportModifier || ast.IsCommonJSExport(node) || container.Flags&ast.NodeFlagsExportContext != 0) {
406406
if !ast.IsLocalsContainer(container) || (ast.HasSyntacticModifier(node, ast.ModifierFlagsDefault) && b.getDeclarationName(node) == ast.InternalSymbolNameMissing) || ast.IsCommonJSExport(node) {
407407
return b.declareSymbol(ast.GetExports(container.Symbol()), container.Symbol(), node, symbolFlags, symbolExcludes)
408408
// No local symbol for an unnamed default!

pkg/checker/checker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,7 +2859,7 @@ func (c *Checker) getDeprecatedSuggestionNode(node *ast.Node) *ast.Node {
28592859
case ast.KindTaggedTemplateExpression:
28602860
return c.getDeprecatedSuggestionNode(node.AsTaggedTemplateExpression().Tag)
28612861
case ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement:
2862-
return c.getDeprecatedSuggestionNode(getTagNameOfNode(node))
2862+
return c.getDeprecatedSuggestionNode(node.TagName())
28632863
case ast.KindElementAccessExpression:
28642864
return node.AsElementAccessExpression().ArgumentExpression
28652865
case ast.KindPropertyAccessExpression:
@@ -30342,7 +30342,7 @@ func (c *Checker) hasContextualTypeWithNoGenericTypes(node *ast.Node, checkMode
3034230342
// If check mode has `CheckMode.RestBindingElement`, we skip binding pattern contextual types,
3034330343
// as we want the type of a rest element to be generic when possible.
3034430344
if (ast.IsIdentifier(node) || ast.IsPropertyAccessExpression(node) || ast.IsElementAccessExpression(node)) &&
30345-
!((ast.IsJsxOpeningElement(node.Parent) || ast.IsJsxSelfClosingElement(node.Parent)) && getTagNameOfNode(node.Parent) == node) {
30345+
!((ast.IsJsxOpeningElement(node.Parent) || ast.IsJsxSelfClosingElement(node.Parent)) && node.Parent.TagName() == node) {
3034630346
contextualType := c.getContextualType(node, core.IfElse(checkMode&CheckModeRestBindingElement != 0, ContextFlagsSkipBindingPatterns, ContextFlagsNone))
3034730347
if contextualType != nil {
3034830348
return !c.isGenericType(contextualType)

pkg/checker/exports.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,15 @@ func (c *Checker) GetIndexSignaturesAtLocation(node *ast.Node) []*ast.Node {
170170
func (c *Checker) GetResolvedSymbol(node *ast.Node) *ast.Symbol {
171171
return c.getResolvedSymbol(node)
172172
}
173+
174+
func (c *Checker) GetJsxNamespace(location *ast.Node) string {
175+
return c.getJsxNamespace(location)
176+
}
177+
178+
func (c *Checker) ResolveName(name string, location *ast.Node, meaning ast.SymbolFlags, excludeGlobals bool) *ast.Symbol {
179+
return c.resolveName(location, name, meaning, nil, true, excludeGlobals)
180+
}
181+
182+
func (c *Checker) GetSymbolFlags(symbol *ast.Symbol) ast.SymbolFlags {
183+
return c.getSymbolFlags(symbol)
184+
}

pkg/checker/grammarchecks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,8 @@ func (c *Checker) checkGrammarArrowFunction(node *ast.Node, file *ast.SourceFile
798798
}
799799

800800
equalsGreaterThanToken := arrowFunc.EqualsGreaterThanToken
801-
startLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, equalsGreaterThanToken.Pos())
802-
endLine, _ := scanner.GetECMALineAndCharacterOfPosition(file, equalsGreaterThanToken.End())
801+
startLine := scanner.GetECMALineOfPosition(file, equalsGreaterThanToken.Pos())
802+
endLine := scanner.GetECMALineOfPosition(file, equalsGreaterThanToken.End())
803803
return startLine != endLine && c.grammarErrorOnNode(equalsGreaterThanToken, diagnostics.Line_terminator_not_permitted_before_arrow)
804804
}
805805

pkg/checker/utilities.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,13 @@ func IsKnownSymbol(symbol *ast.Symbol) bool {
971971
return isLateBoundName(symbol.Name)
972972
}
973973

974+
func IsPrivateIdentifierSymbol(symbol *ast.Symbol) bool {
975+
if symbol == nil {
976+
return false
977+
}
978+
return strings.HasPrefix(symbol.Name, ast.InternalSymbolNamePrefix+"#")
979+
}
980+
974981
func isLateBoundName(name string) bool {
975982
return len(name) >= 2 && name[0] == '\xfe' && name[1] == '@'
976983
}
@@ -1061,10 +1068,6 @@ func isNonNullAccess(node *ast.Node) bool {
10611068
return ast.IsAccessExpression(node) && ast.IsNonNullExpression(node.Expression())
10621069
}
10631070

1064-
func getTagNameOfNode(node *ast.Node) *ast.Node {
1065-
return node.TagName()
1066-
}
1067-
10681071
func getBindingElementPropertyName(node *ast.Node) *ast.Node {
10691072
return node.PropertyNameOrName()
10701073
}

pkg/compiler/program.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ func (p *Program) getDiagnosticsWithPrecedingDirectives(sourceFile *ast.SourceFi
10821082
// Build map of directives by line number
10831083
directivesByLine := make(map[int]ast.CommentDirective)
10841084
for _, directive := range sourceFile.CommentDirectives {
1085-
line, _ := scanner.GetECMALineAndCharacterOfPosition(sourceFile, directive.Loc.Pos())
1085+
line := scanner.GetECMALineOfPosition(sourceFile, directive.Loc.Pos())
10861086
directivesByLine[line] = directive
10871087
}
10881088
lineStarts := scanner.GetECMALineStarts(sourceFile)

0 commit comments

Comments
 (0)