From 3d522a8816608d0dfbfcc48a55f5cf162cb8b324 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 23 Jun 2025 21:38:50 -0700 Subject: [PATCH 01/10] Set parent pointers as nodes are ready in parser, rather than all at once as parse is complete --- internal/checker/checker.go | 2 +- internal/parser/jsdoc.go | 4 ++ internal/parser/parser.go | 57 +++++++++++++++---- internal/parser/reparser.go | 41 +++++++++++++ .../checkJsdocSatisfiesTag1.errors.txt | 45 +++++++++++++++ .../checkJsdocSatisfiesTag10.errors.txt | 5 +- .../checkJsdocSatisfiesTag4.errors.txt | 20 +++++++ .../checkJsdocSatisfiesTag7.errors.txt | 5 +- .../checkJsdocSatisfiesTag9.errors.txt | 20 +++++++ .../checkJsdocSatisfiesTag1.errors.txt.diff | 57 +++++-------------- .../checkJsdocSatisfiesTag10.errors.txt.diff | 11 ++-- .../checkJsdocSatisfiesTag4.errors.txt.diff | 31 +++++----- .../checkJsdocSatisfiesTag7.errors.txt.diff | 11 ++-- .../checkJsdocSatisfiesTag9.errors.txt.diff | 24 -------- 14 files changed, 223 insertions(+), 110 deletions(-) create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 870af0b9c6..a4a1b622b9 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -30194,7 +30194,7 @@ func (c *Checker) getSymbolOfNameOrPropertyAccessExpression(name *ast.Node) *ast return c.getSymbolOfNode(name.Parent) } - if name.Parent.Kind == ast.KindExportAssignment && ast.IsEntityNameExpression(name) { + if (name.Parent.Kind == ast.KindExportAssignment || name.Parent.Kind == ast.KindJSExportAssignment) && ast.IsEntityNameExpression(name) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression success := c.resolveEntityName( name, diff --git a/internal/parser/jsdoc.go b/internal/parser/jsdoc.go index 1da7b9511d..82e657fe7d 100644 --- a/internal/parser/jsdoc.go +++ b/internal/parser/jsdoc.go @@ -44,6 +44,7 @@ func (p *Parser) withJSDoc(node *ast.Node, hasJSDoc bool) []*ast.Node { pos := node.Pos() for _, comment := range ranges { if parsed := p.parseJSDocComment(node, comment.Pos(), comment.End(), pos); parsed != nil { + parsed.Parent = node jsdoc = append(jsdoc, parsed) pos = parsed.End() } @@ -979,6 +980,9 @@ func (p *Parser) parseTypedefTag(start int, tagName *ast.IdentifierNode, indent typedefTag := p.factory.NewJSDocTypedefTag(tagName, typeExpression, fullName, comment) p.finishNodeWithEnd(typedefTag, start, end) + if typeExpression != nil { + typeExpression.Parent = typedefTag // forcibly overwrite parent potentially set by inner type expression parse + } return typedefTag } diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 5ed34c4e42..6296253324 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -77,6 +77,8 @@ type Parser struct { jsdocTagCommentsSpace []string reparseList []*ast.Node commonJSModuleIndicator *ast.Node + + currentParent *ast.Node } var viableKeywordSuggestions = scanner.GetViableKeywordSuggestions() @@ -353,14 +355,6 @@ func (p *Parser) finishSourceFile(result *ast.SourceFile, isDeclarationFile bool result.IdentifierCount = p.identifierCount result.SetJSDocCache(p.jsdocCache) - ast.SetParentInChildren(result.AsNode()) - for parent, children := range p.jsdocCache { - for _, child := range children { - child.Parent = parent - ast.SetParentInChildren(child) - } - } - ast.SetExternalModuleIndicator(result, p.opts.ExternalModuleIndicatorOptions) } @@ -466,7 +460,11 @@ func (p *Parser) reparseTopLevelAwait(sourceFile *ast.SourceFile) *ast.Node { } } - return p.factory.NewSourceFile(sourceFile.ParseOptions(), p.sourceText, p.newNodeList(sourceFile.Statements.Loc, statements)) + result := p.factory.NewSourceFile(sourceFile.ParseOptions(), p.sourceText, p.newNodeList(sourceFile.Statements.Loc, statements)) + for _, s := range statements { + s.Parent = result.AsNode() // force (re)set parent to reparsed source file + } + return result } func (p *Parser) parseListIndex(kind ParsingContext, parseElement func(p *Parser, index int) *ast.Node) *ast.NodeList { @@ -3571,6 +3569,7 @@ func (p *Parser) parseTupleElementType() *ast.TypeNode { node := p.factory.NewOptionalTypeNode(typeNode.Type()) node.Flags = typeNode.Flags node.Loc = typeNode.Loc + typeNode.Parent = node return node } return typeNode @@ -4692,6 +4691,16 @@ func (p *Parser) parseJsxElementOrSelfClosingElementOrFragment(inExpressionConte p.finishNodeWithEnd(newClosingElement, end, end) newLast := p.factory.NewJsxElement(lastChild.AsJsxElement().OpeningElement, lastChild.AsJsxElement().Children, newClosingElement) p.finishNodeWithEnd(newLast, lastChild.AsJsxElement().OpeningElement.Pos(), end) + // force reset parent pointers from discarded parse result + if lastChild.AsJsxElement().OpeningElement != nil { + lastChild.AsJsxElement().OpeningElement.Parent = newLast + } + if lastChild.AsJsxElement().Children != nil { + for _, c := range lastChild.AsJsxElement().Children.Nodes { + c.Parent = newLast + } + } + newClosingElement.Parent = newLast children = p.newNodeList(core.NewTextRange(children.Pos(), newLast.End()), append(children.Nodes[0:len(children.Nodes)-1], newLast)) closingElement = lastChild.AsJsxElement().ClosingElement } else { @@ -4708,6 +4717,7 @@ func (p *Parser) parseJsxElementOrSelfClosingElementOrFragment(inExpressionConte } result = p.factory.NewJsxElement(opening, children, closingElement) p.finishNode(result, pos) + closingElement.Parent = result // force reset parent pointers from possibly discarded parse result case ast.KindJsxOpeningFragment: result = p.factory.NewJsxFragment(opening, p.parseJsxChildren(opening), p.parseJsxClosingFragment(inExpressionContext)) p.finishNode(result, pos) @@ -5315,7 +5325,9 @@ func (p *Parser) parseMemberExpressionRest(pos int, expression *ast.Expression, if p.isTemplateStartOfTaggedTemplate() { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments if questionDotToken == nil && ast.IsExpressionWithTypeArguments(expression) { - expression = p.parseTaggedTemplateRest(pos, expression.AsExpressionWithTypeArguments().Expression, questionDotToken, expression.AsExpressionWithTypeArguments().TypeArguments) + original := expression.AsExpressionWithTypeArguments() + expression = p.parseTaggedTemplateRest(pos, original.Expression, questionDotToken, original.TypeArguments) + p.unparseExpressionWithTypeArguments(original.Expression, original.TypeArguments, expression) } else { expression = p.parseTaggedTemplateRest(pos, expression, questionDotToken, nil /*typeArguments*/) } @@ -5430,10 +5442,12 @@ func (p *Parser) parseCallExpressionRest(pos int, expression *ast.Expression) *a typeArguments = expression.AsExpressionWithTypeArguments().TypeArguments expression = expression.AsExpressionWithTypeArguments().Expression } + inner := expression argumentList := p.parseArgumentList() isOptionalChain := questionDotToken != nil || p.tryReparseOptionalChain(expression) expression = p.factory.NewCallExpression(expression, questionDotToken, typeArguments, argumentList, core.IfElse(isOptionalChain, ast.NodeFlagsOptionalChain, ast.NodeFlagsNone)) p.finishNode(expression, pos) + p.unparseExpressionWithTypeArguments(inner, typeArguments, expression) continue } if questionDotToken != nil { @@ -5714,6 +5728,18 @@ func (p *Parser) parseDecoratedExpression() *ast.Expression { return result } +func (p *Parser) unparseExpressionWithTypeArguments(expression *ast.Node, typeArguments *ast.NodeList, result *ast.Node) { + // force overwrite the `.Parent` of the expression and type arguments to erase the fact that they may have originally been parsed as an ExpressionWithTypeArguments and be parented to such + if expression != nil { + expression.Parent = result + } + if typeArguments != nil { + for _, a := range typeArguments.Nodes { + a.Parent = result + } + } +} + func (p *Parser) parseNewExpressionOrNewDotTarget() *ast.Node { pos := p.nodePos() p.parseExpected(ast.KindNewKeyword) @@ -5740,6 +5766,7 @@ func (p *Parser) parseNewExpressionOrNewDotTarget() *ast.Node { } result := p.factory.NewNewExpression(expression, typeArguments, argumentList) p.finishNode(result, pos) + p.unparseExpressionWithTypeArguments(expression, typeArguments, result) return result } @@ -5888,6 +5915,16 @@ func (p *Parser) finishNodeWithEnd(node *ast.Node, pos int, end int) { node.Flags |= ast.NodeFlagsThisNodeHasError p.hasParseError = false } + p.currentParent = node + node.ForEachChild(p.setParent) +} + +func (p *Parser) setParent(node *ast.Node) bool { + if node.Parent == nil { + node.Parent = p.currentParent + } + // TODO: panic if attempt to overwrite .Parent with new, different .Parent when jsdoc reparser is fixed to not reuse the same nodes in many places + return false } func (p *Parser) nextTokenIsSlash() bool { diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index 20113b6888..3d42ed8ba0 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -5,6 +5,11 @@ import ( "github.com/microsoft/typescript-go/internal/core" ) +func (p *Parser) finishReparsedNode(node *ast.Node) { + p.currentParent = node + node.ForEachChild(p.setParent) +} + func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { if p.scriptKind != core.ScriptKindJS && p.scriptKind != core.ScriptKindJSX { return @@ -31,6 +36,7 @@ func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { p.reparseList = append(p.reparseList, export) p.commonJSModuleIndicator = export p.reparseTags(export, jsdoc) + p.finishReparsedNode(export) } } @@ -81,6 +87,7 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod typeAlias.AsTypeAliasDeclaration().Type = t typeAlias.Loc = tag.Loc typeAlias.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.finishReparsedNode(typeAlias) p.reparseList = append(p.reparseList, typeAlias) case ast.KindJSDocCallbackTag: callbackTag := tag.AsJSDocCallbackTag() @@ -98,6 +105,7 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod typeAlias.AsTypeAliasDeclaration().TypeParameters = p.gatherTypeParameters(jsDoc, tag, typeAlias) typeAlias.Loc = tag.Loc typeAlias.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.finishReparsedNode(typeAlias) p.reparseList = append(p.reparseList, typeAlias) case ast.KindJSDocImportTag: importTag := tag.AsJSDocImportTag() @@ -108,10 +116,12 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod importDeclaration.Loc = tag.Loc importDeclaration.Flags = p.contextFlags | ast.NodeFlagsReparsed importTag.JSImportDeclaration = importDeclaration.AsImportDeclaration() + p.finishReparsedNode(importDeclaration) p.reparseList = append(p.reparseList, importDeclaration) case ast.KindJSDocOverloadTag: if fun, ok := getFunctionLikeHost(parent); ok { p.reparseList = append(p.reparseList, p.reparseJSDocSignature(tag.AsJSDocOverloadTag().TypeExpression, fun, jsDoc, tag)) + p.finishReparsedNode(fun) } } } @@ -155,6 +165,7 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD } parameter.Loc = param.Loc parameter.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.finishReparsedNode(parameter) parameters = append(parameters, parameter) } signature.FunctionLikeData().Parameters = p.newNodeList(jsSignature.AsJSDocSignature().Parameters.Loc, parameters) @@ -167,6 +178,7 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD signature.Loc = tag.AsJSDocOverloadTag().TagName.Loc } signature.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.finishReparsedNode(signature) return signature } @@ -183,12 +195,14 @@ func (p *Parser) reparseJSDocTypeLiteral(t *ast.TypeNode, host *ast.Node) *ast.N property.AsPropertySignatureDeclaration().Type = p.reparseJSDocTypeLiteral(jsprop.TypeExpression, property) property.Loc = prop.Loc property.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.finishReparsedNode(property) properties = append(properties, property) } loc := t.Loc t = p.factory.NewTypeLiteralNode(p.newNodeList(loc, properties)) t.Loc = loc t.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.finishReparsedNode(t) } return t } @@ -237,6 +251,7 @@ func (p *Parser) gatherTypeParameters(j *ast.Node, tagWithTypeParameters *ast.No panic("JSDoc type parameter already has a host: " + tag.AsJSDocTemplateTag().Host.Kind.String()) } reparse.Flags |= ast.NodeFlagsReparsed + p.finishReparsedNode(reparse) typeParameters = append(typeParameters, reparse) firstTypeParameter = false } @@ -257,6 +272,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) for _, declaration := range parent.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes { if declaration.AsVariableDeclaration().Type == nil { declaration.AsVariableDeclaration().Type = setHost(tag.AsJSDocTypeTag().TypeExpression, declaration) + p.finishReparsedNode(declaration) break } } @@ -264,43 +280,52 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) case ast.KindVariableDeclaration: if parent.AsVariableDeclaration().Type == nil { parent.AsVariableDeclaration().Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) + p.finishReparsedNode(parent) } case ast.KindCommonJSExport: export := parent.AsCommonJSExport() if export.Type == nil { export.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) + p.finishReparsedNode(parent) } case ast.KindPropertyDeclaration: declaration := parent.AsPropertyDeclaration() if declaration.Type == nil { declaration.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) + p.finishReparsedNode(parent) } case ast.KindPropertyAssignment: prop := parent.AsPropertyAssignment() if prop.Type == nil { prop.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) + p.finishReparsedNode(parent) } case ast.KindShorthandPropertyAssignment: prop := parent.AsShorthandPropertyAssignment() if prop.Type == nil { prop.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) + p.finishReparsedNode(parent) } case ast.KindExportAssignment, ast.KindJSExportAssignment: export := parent.AsExportAssignment() if export.Type == nil { export.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) + p.finishReparsedNode(parent) } case ast.KindReturnStatement: ret := parent.AsReturnStatement() ret.Expression = p.makeNewCast(setHost(tag.AsJSDocTypeTag().TypeExpression, nil), ret.Expression, true /*isAssertion*/) + p.finishReparsedNode(parent) case ast.KindParenthesizedExpression: paren := parent.AsParenthesizedExpression() paren.Expression = p.makeNewCast(setHost(tag.AsJSDocTypeTag().TypeExpression, nil), paren.Expression, true /*isAssertion*/) + p.finishReparsedNode(parent) case ast.KindExpressionStatement: if parent.AsExpressionStatement().Expression.Kind == ast.KindBinaryExpression { bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() if kind := ast.GetAssignmentDeclarationKind(bin); kind != ast.JSDeclarationKindNone { bin.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent.AsExpressionStatement().Expression) + p.finishReparsedNode(parent) } } } @@ -308,21 +333,25 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) if parent.Kind == ast.KindParenthesizedExpression { paren := parent.AsParenthesizedExpression() paren.Expression = p.makeNewCast(setHost(tag.AsJSDocSatisfiesTag().TypeExpression, nil), paren.Expression, false /*isAssertion*/) + p.finishReparsedNode(parent) } case ast.KindJSDocTemplateTag: if fun, ok := getFunctionLikeHost(parent); ok { if fun.TypeParameters() == nil { fun.FunctionLikeData().TypeParameters = p.gatherTypeParameters(jsDoc, nil /*tagWithTypeParameters*/, fun) + p.finishReparsedNode(fun) } } else if parent.Kind == ast.KindClassDeclaration { class := parent.AsClassDeclaration() if class.TypeParameters == nil { class.TypeParameters = p.gatherTypeParameters(jsDoc, nil /*tagWithTypeParameters*/, parent) + p.finishReparsedNode(parent) } } else if parent.Kind == ast.KindClassExpression { class := parent.AsClassExpression() if class.TypeParameters == nil { class.TypeParameters = p.gatherTypeParameters(jsDoc, nil /*tagWithTypeParameters*/, parent) + p.finishReparsedNode(parent) } } case ast.KindJSDocParameterTag: @@ -337,6 +366,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) param.QuestionToken = question } } + p.finishReparsedNode(param.AsNode()) } } case ast.KindJSDocThisTag: @@ -354,6 +384,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) thisParam.AsParameterDeclaration().Type = setHost(tag.AsJSDocThisTag().TypeExpression, thisParam) thisParam.Loc = tag.AsJSDocThisTag().TagName.Loc thisParam.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.finishReparsedNode(thisParam) newParams := p.nodeSlicePool.NewSlice(len(params) + 1) newParams[0] = thisParam @@ -362,12 +393,14 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } fun.FunctionLikeData().Parameters = p.newNodeList(thisParam.Loc, newParams) + p.finishReparsedNode(fun) } } case ast.KindJSDocReturnTag: if fun, ok := getFunctionLikeHost(parent); ok { if fun.Type() == nil { fun.FunctionLikeData().Type = setHost(tag.AsJSDocReturnTag().TypeExpression, fun) + p.finishReparsedNode(fun) } } case ast.KindJSDocReadonlyTag, ast.KindJSDocPrivateTag, ast.KindJSDocPublicTag, ast.KindJSDocProtectedTag, ast.KindJSDocOverrideTag: @@ -403,6 +436,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) loc = parent.Modifiers().Loc } parent.AsMutable().SetModifiers(p.newModifierList(loc, nodes)) + p.finishReparsedNode(parent) } case ast.KindJSDocImplementsTag: if class := getClassLikeData(parent); class != nil { @@ -413,6 +447,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) return node.AsHeritageClause().Token == ast.KindImplementsKeyword }); implementsClause != nil { implementsClause.AsHeritageClause().Types.Nodes = append(implementsClause.AsHeritageClause().Types.Nodes, implementsTag.ClassName) + p.finishReparsedNode(implementsClause) return } } @@ -422,6 +457,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) heritageClause := p.factory.NewHeritageClause(ast.KindImplementsKeyword, typesList) heritageClause.Loc = implementsTag.ClassName.Loc heritageClause.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.finishReparsedNode(heritageClause) if class.HeritageClauses == nil { heritageClauses := p.newNodeList(implementsTag.ClassName.Loc, p.nodeSlicePool.NewSlice1(heritageClause)) @@ -429,6 +465,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } else { class.HeritageClauses.Nodes = append(class.HeritageClauses.Nodes, heritageClause) } + p.finishReparsedNode(parent) } case ast.KindJSDocAugmentsTag: if class := getClassLikeData(parent); class != nil && class.HeritageClauses != nil { @@ -443,6 +480,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) for _, typeArg := range source.TypeArguments.Nodes { typeArg.Flags |= ast.NodeFlagsReparsed } + p.finishReparsedNode(target.AsNode()) } return } @@ -504,6 +542,9 @@ func (p *Parser) makeNewCast(t *ast.TypeNode, e *ast.Node, isAssertion bool) *as } assert.Flags = p.contextFlags | ast.NodeFlagsReparsed assert.Loc = core.NewTextRange(e.Pos(), e.End()) + p.finishReparsedNode(assert) + t.Parent = assert // force reset parent to the new expression injected into the AST + e.Parent = assert return assert } diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt new file mode 100644 index 0000000000..501d8cad97 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt @@ -0,0 +1,45 @@ +/a.js(21,44): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. +/a.js(22,38): error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. +/a.js(31,49): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. + + +==== /a.js (3 errors) ==== + /** + * @typedef {Object} T1 + * @property {number} a + */ + + /** + * @typedef {Object} T2 + * @property {"a" | "b"} a + */ + + /** + * @typedef {(x: string) => string} T3 + */ + + /** + * @typedef {Object} T4 + * @property {string} a + */ + + const t1 = /** @satisfies {T1} */ ({ a: 1 }); + const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); + ~ +!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. + const t3 = /** @satisfies {T1} */ ({}); + ~ +!!! error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. +!!! related TS2728 /a.js:3:23: 'a' is declared here. + + /** @type {T2} */ + const t4 = /** @satisfies {T2} */ ({ a: "a" }); + + /** @type {(m: string) => string} */ + const t5 = /** @satisfies {T3} */((m) => m.substring(0)); + const t6 = /** @satisfies {[number, number]} */ ([1, 2]); + const t7 = /** @satisfies {T4} */ ({ a: 'test' }); + const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); + ~ +!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt index c6a17d12f4..86e01bf5f8 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt @@ -1,13 +1,16 @@ +/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** @typedef {"a" | "b" | "c" | "d"} Keys */ const p = /** @satisfies {Partial>} */ ({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. }); // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt new file mode 100644 index 0000000000..17573f218b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt @@ -0,0 +1,20 @@ +/a.js(5,43): error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. + + +==== /a.js (1 errors) ==== + /** + * @typedef {Object} Foo + * @property {number} a + */ + export default /** @satisfies {Foo} */ ({}); + ~ +!!! error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. +!!! related TS2728 /a.js:3:23: 'a' is declared here. + +==== /b.js (0 errors) ==== + /** + * @typedef {Object} Foo + * @property {number} a + */ + + export default /** @satisfies {Foo} */ ({ a: 1 }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt index 3a364a6628..ad8f001736 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt @@ -1,13 +1,16 @@ +/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record<"a" | "b" | "c" | "d", unknown>'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** @typedef {"a" | "b" | "c" | "d"} Keys */ const p = /** @satisfies {Record} */ ({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record<"a" | "b" | "c" | "d", unknown>'. }) // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt new file mode 100644 index 0000000000..41ef78bd24 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt @@ -0,0 +1,20 @@ +/a.js(11,26): error TS2353: Object literal may only specify known properties, and 'd' does not exist in type 'Color'. + + +==== /a.js (1 errors) ==== + /** + * @typedef {Object} Color + * @property {number} r + * @property {number} g + * @property {number} b + */ + + // All of these should be Colors, but I only use some of them here. + export const Palette = /** @satisfies {Record} */ ({ + white: { r: 255, g: 255, b: 255 }, + black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' + ~ +!!! error TS2353: Object literal may only specify known properties, and 'd' does not exist in type 'Color'. + blue: { r: 0, g: 0, b: 255 }, + }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff index 5a96ab6f2a..ade10090ef 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff @@ -1,51 +1,24 @@ --- old.checkJsdocSatisfiesTag1.errors.txt +++ new.checkJsdocSatisfiesTag1.errors.txt @@= skipped -0, +0 lines =@@ --/a.js(21,44): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. + /a.js(21,44): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. -/a.js(22,17): error TS1360: Type '{}' does not satisfy the expected type 'T1'. - Property 'a' is missing in type '{}' but required in type 'T1'. --/a.js(31,49): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. -- -- --==== /a.js (3 errors) ==== -- /** -- * @typedef {Object} T1 -- * @property {number} a -- */ -- -- /** -- * @typedef {Object} T2 -- * @property {"a" | "b"} a -- */ -- -- /** -- * @typedef {(x: string) => string} T3 -- */ -- -- /** -- * @typedef {Object} T4 -- * @property {string} a -- */ -- -- const t1 = /** @satisfies {T1} */ ({ a: 1 }); -- const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); -- ~ --!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. -- const t3 = /** @satisfies {T1} */ ({}); ++/a.js(22,38): error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. + /a.js(31,49): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. + + +@@= skipped -28, +27 lines =@@ + ~ + !!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. + const t3 = /** @satisfies {T1} */ ({}); - ~~~~~~~~~ -!!! error TS1360: Type '{}' does not satisfy the expected type 'T1'. -!!! error TS1360: Property 'a' is missing in type '{}' but required in type 'T1'. -!!! related TS2728 /a.js:3:4: 'a' is declared here. -- -- /** @type {T2} */ -- const t4 = /** @satisfies {T2} */ ({ a: "a" }); -- -- /** @type {(m: string) => string} */ -- const t5 = /** @satisfies {T3} */((m) => m.substring(0)); -- const t6 = /** @satisfies {[number, number]} */ ([1, 2]); -- const t7 = /** @satisfies {T4} */ ({ a: 'test' }); -- const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); -- ~ --!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. -- -+ \ No newline at end of file ++ ~ ++!!! error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. ++!!! related TS2728 /a.js:3:23: 'a' is declared here. + + /** @type {T2} */ + const t4 = /** @satisfies {T2} */ ({ a: "a" }); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff index dd3f1b3f02..26a2207f38 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff @@ -2,19 +2,16 @@ +++ new.checkJsdocSatisfiesTag10.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. ++/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. --==== /a.js (2 errors) ==== -+==== /a.js (1 errors) ==== - /** @typedef {"a" | "b" | "c" | "d"} Keys */ - - const p = /** @satisfies {Partial>} */ ({ - a: 0, +@@= skipped -9, +9 lines =@@ b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' -- ~ + ~ -!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. ++!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. }); // Should be OK -- retain info that a is number and b is string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff index 8753ec0e9d..50185c3ada 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff @@ -3,24 +3,21 @@ @@= skipped -0, +0 lines =@@ -/a.js(5,21): error TS1360: Type '{}' does not satisfy the expected type 'Foo'. - Property 'a' is missing in type '{}' but required in type 'Foo'. -- -- --==== /a.js (1 errors) ==== -- /** -- * @typedef {Object} Foo -- * @property {number} a -- */ -- export default /** @satisfies {Foo} */ ({}); ++/a.js(5,43): error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. + + + ==== /a.js (1 errors) ==== +@@= skipped -7, +6 lines =@@ + * @property {number} a + */ + export default /** @satisfies {Foo} */ ({}); - ~~~~~~~~~ -!!! error TS1360: Type '{}' does not satisfy the expected type 'Foo'. -!!! error TS1360: Property 'a' is missing in type '{}' but required in type 'Foo'. -!!! related TS2728 /a.js:3:4: 'a' is declared here. -- --==== /b.js (0 errors) ==== -- /** -- * @typedef {Object} Foo -- * @property {number} a -- */ -- -- export default /** @satisfies {Foo} */ ({ a: 1 }); -+ \ No newline at end of file ++ ~ ++!!! error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. ++!!! related TS2728 /a.js:3:23: 'a' is declared here. + + ==== /b.js (0 errors) ==== + /** \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff index 04f0c99ec4..aa1be201c2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff @@ -2,19 +2,16 @@ +++ new.checkJsdocSatisfiesTag7.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. ++/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record<"a" | "b" | "c" | "d", unknown>'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. --==== /a.js (2 errors) ==== -+==== /a.js (1 errors) ==== - /** @typedef {"a" | "b" | "c" | "d"} Keys */ - - const p = /** @satisfies {Record} */ ({ - a: 0, +@@= skipped -9, +9 lines =@@ b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' -- ~ + ~ -!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. ++!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record<"a" | "b" | "c" | "d", unknown>'. }) // Should be OK -- retain info that a is number and b is string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff deleted file mode 100644 index 3d3d4bb240..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.checkJsdocSatisfiesTag9.errors.txt -+++ new.checkJsdocSatisfiesTag9.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(11,26): error TS2353: Object literal may only specify known properties, and 'd' does not exist in type 'Color'. -- -- --==== /a.js (1 errors) ==== -- /** -- * @typedef {Object} Color -- * @property {number} r -- * @property {number} g -- * @property {number} b -- */ -- -- // All of these should be Colors, but I only use some of them here. -- export const Palette = /** @satisfies {Record} */ ({ -- white: { r: 255, g: 255, b: 255 }, -- black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' -- ~ --!!! error TS2353: Object literal may only specify known properties, and 'd' does not exist in type 'Color'. -- blue: { r: 0, g: 0, b: 255 }, -- }); -- -+ \ No newline at end of file From 8f6b8ad508569e089e70d48f605cb6ad5d2cdc8f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 24 Jun 2025 11:40:40 -0700 Subject: [PATCH 02/10] Test parent invariant, violations everywhere --- internal/compiler/fileloader.go | 4 +-- internal/parser/parser.go | 2 +- internal/parser/reparser.go | 11 +++++--- internal/testrunner/compiler_runner.go | 35 ++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 9396bc89d5..b60ca1ca45 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -485,13 +485,13 @@ func getDefaultResolutionModeForFile(fileName string, meta ast.SourceFileMetaDat } func getModeForUsageLocation(fileName string, meta ast.SourceFileMetaData, usage *ast.StringLiteralLike, options *core.CompilerOptions) core.ResolutionMode { - if ast.IsImportDeclaration(usage.Parent) || ast.IsExportDeclaration(usage.Parent) || ast.IsJSDocImportTag(usage.Parent) { + if ast.IsImportDeclaration(usage.Parent) || usage.Parent.Kind == ast.KindJSImportDeclaration || ast.IsExportDeclaration(usage.Parent) || ast.IsJSDocImportTag(usage.Parent) { isTypeOnly := ast.IsExclusivelyTypeOnlyImportOrExport(usage.Parent) if isTypeOnly { var override core.ResolutionMode var ok bool switch usage.Parent.Kind { - case ast.KindImportDeclaration: + case ast.KindImportDeclaration, ast.KindJSImportDeclaration: override, ok = usage.Parent.AsImportDeclaration().Attributes.GetResolutionModeOverride() case ast.KindExportDeclaration: override, ok = usage.Parent.AsExportDeclaration().Attributes.GetResolutionModeOverride() diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 6296253324..df72949ab7 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -3569,7 +3569,7 @@ func (p *Parser) parseTupleElementType() *ast.TypeNode { node := p.factory.NewOptionalTypeNode(typeNode.Type()) node.Flags = typeNode.Flags node.Loc = typeNode.Loc - typeNode.Parent = node + typeNode.Type().Parent = node return node } return typeNode diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index 3d42ed8ba0..fc5e49fd4b 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -7,7 +7,12 @@ import ( func (p *Parser) finishReparsedNode(node *ast.Node) { p.currentParent = node - node.ForEachChild(p.setParent) + node.ForEachChild(p.setParentOverride) +} + +func (p *Parser) setParentOverride(node *ast.Node) bool { + node.Parent = p.currentParent // this overrides an existing parent - the jsdoc reparser does this when it moves nodes from jsdoc into concrete expressions + return false } func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { @@ -37,6 +42,7 @@ func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { p.commonJSModuleIndicator = export p.reparseTags(export, jsdoc) p.finishReparsedNode(export) + p.finishReparsedNode(bin.AsNode()) // TODO: the same node appears in both the new export declaration and the original binary expression - both locations cannot have correct `.Parent` pointers. For now, the binary expression being correctly parented is baselined behavior, since it appears first in the AST. } } @@ -112,6 +118,7 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod importClause := importTag.ImportClause importClause.Flags |= ast.NodeFlagsReparsed importClause.AsImportClause().IsTypeOnly = true + p.finishReparsedNode(importClause) importDeclaration := p.factory.NewJSImportDeclaration(importTag.Modifiers(), importClause, importTag.ModuleSpecifier, importTag.Attributes) importDeclaration.Loc = tag.Loc importDeclaration.Flags = p.contextFlags | ast.NodeFlagsReparsed @@ -543,8 +550,6 @@ func (p *Parser) makeNewCast(t *ast.TypeNode, e *ast.Node, isAssertion bool) *as assert.Flags = p.contextFlags | ast.NodeFlagsReparsed assert.Loc = core.NewTextRange(e.Pos(), e.End()) p.finishReparsedNode(assert) - t.Parent = assert // force reset parent to the new expression injected into the AST - e.Parent = assert return assert } diff --git a/internal/testrunner/compiler_runner.go b/internal/testrunner/compiler_runner.go index 920ac47653..4c0ba6f403 100644 --- a/internal/testrunner/compiler_runner.go +++ b/internal/testrunner/compiler_runner.go @@ -10,6 +10,7 @@ import ( "strings" "testing" + "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/repo" @@ -174,6 +175,7 @@ func (r *CompilerBaselineRunner) runSingleConfigTest(t *testing.T, testName stri // !!! Verify all baselines compilerTest.verifyUnionOrdering(t) + compilerTest.verifyParentPointers(t) } type compilerFileBasedTest struct { @@ -506,6 +508,39 @@ func (c *compilerTest) verifyUnionOrdering(t *testing.T) { }) } +func (c *compilerTest) verifyParentPointers(t *testing.T) { + t.Run("source file parent pointers", func(t *testing.T) { + var parent *ast.Node + var verifier func(n *ast.Node) bool + verifier = func(n *ast.Node) bool { + assert.Assert(t, n.Parent != nil, "parent node does not exist") + elab := "" + if !ast.NodeIsSynthesized(n) { + elab += ast.GetSourceFileOfNode(n).Text()[n.Loc.Pos():n.Loc.End()] + } else { + elab += "!synthetic! no text available" + } + if n.Parent.Kind == ast.KindBinaryExpression && parent.Kind == ast.KindJSExportAssignment { + // known current violation of parent pointer invariant, ignore + } else { + assert.Assert(t, n.Parent == parent, "parent node does not match traversed parent: "+n.Kind.String()+": "+elab) + } + oldParent := parent + parent = n + n.ForEachChild(verifier) + parent = oldParent + return false + } + for _, f := range c.result.Program.GetSourceFiles() { + if f.HasNoDefaultLib { + continue + } + parent = f.AsNode() + f.AsNode().ForEachChild(verifier) + } + }) +} + func (c *compilerTest) containsUnsupportedOptions() bool { if len(c.result.Program.UnsupportedExtensions()) != 0 { return true From 3371416314105226e2b8cf68b54a16fb076ca2d7 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 24 Jun 2025 11:43:10 -0700 Subject: [PATCH 03/10] Use inlinable closures instead of methods --- internal/parser/parser.go | 19 +++++++------------ internal/parser/reparser.go | 11 ++++------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index df72949ab7..6e1901d910 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -77,8 +77,6 @@ type Parser struct { jsdocTagCommentsSpace []string reparseList []*ast.Node commonJSModuleIndicator *ast.Node - - currentParent *ast.Node } var viableKeywordSuggestions = scanner.GetViableKeywordSuggestions() @@ -5915,16 +5913,13 @@ func (p *Parser) finishNodeWithEnd(node *ast.Node, pos int, end int) { node.Flags |= ast.NodeFlagsThisNodeHasError p.hasParseError = false } - p.currentParent = node - node.ForEachChild(p.setParent) -} - -func (p *Parser) setParent(node *ast.Node) bool { - if node.Parent == nil { - node.Parent = p.currentParent - } - // TODO: panic if attempt to overwrite .Parent with new, different .Parent when jsdoc reparser is fixed to not reuse the same nodes in many places - return false + node.ForEachChild(func(n *ast.Node) bool { + if n.Parent == nil { + n.Parent = node + } + // TODO: panic if attempt to overwrite .Parent with new, different .Parent when jsdoc reparser is fixed to not reuse the same nodes in many places + return false + }) } func (p *Parser) nextTokenIsSlash() bool { diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index fc5e49fd4b..a504ebc0b8 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -6,13 +6,10 @@ import ( ) func (p *Parser) finishReparsedNode(node *ast.Node) { - p.currentParent = node - node.ForEachChild(p.setParentOverride) -} - -func (p *Parser) setParentOverride(node *ast.Node) bool { - node.Parent = p.currentParent // this overrides an existing parent - the jsdoc reparser does this when it moves nodes from jsdoc into concrete expressions - return false + node.ForEachChild(func(n *ast.Node) bool { + n.Parent = node // this overrides an existing parent - the jsdoc reparser does this when it moves nodes from jsdoc into concrete expressions + return false + }) } func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { From b9666f6eaef48ba29ebe94e042b931dc009363bb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 24 Jun 2025 12:51:23 -0700 Subject: [PATCH 04/10] You know, forEachChild is basically a go iterator already --- internal/ast/ast.go | 20 ++++++++++++++++++-- internal/parser/parser.go | 5 ++--- internal/parser/reparser.go | 5 ++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 2cee364661..6feb8c50db 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -2,6 +2,7 @@ package ast import ( "fmt" + "iter" "strings" "sync" "sync/atomic" @@ -214,6 +215,7 @@ func (n *Node) AsNode() *Node { return n } func (n *Node) Pos() int { return n.Loc.Pos() } func (n *Node) End() int { return n.Loc.End() } func (n *Node) ForEachChild(v Visitor) bool { return n.data.ForEachChild(v) } +func (n *Node) IterChildren() iter.Seq[*Node] { return n.data.IterChildren() } func (n *Node) Clone(f NodeFactoryCoercible) *Node { return n.data.Clone(f) } func (n *Node) VisitEachChild(v *NodeVisitor) *Node { return n.data.VisitEachChild(v) } func (n *Node) Name() *DeclarationName { return n.data.Name() } @@ -1645,6 +1647,7 @@ func (n *Node) AsSyntaxList() *SyntaxList { type nodeData interface { AsNode() *Node ForEachChild(v Visitor) bool + IterChildren() iter.Seq[*Node] VisitEachChild(v *NodeVisitor) *Node Clone(v NodeFactoryCoercible) *Node Name() *DeclarationName @@ -1671,8 +1674,21 @@ type NodeDefault struct { Node } -func (node *NodeDefault) AsNode() *Node { return &node.Node } -func (node *NodeDefault) ForEachChild(v Visitor) bool { return false } +func invert(yield func(v *Node) bool) Visitor { + return func(n *Node) bool { + return !yield(n) + } +} + +func (node *NodeDefault) AsNode() *Node { return &node.Node } +func (node *NodeDefault) ForEachChild(v Visitor) bool { return false } +func (node *NodeDefault) forEachChildIter(yield func(v *Node) bool) { + node.data.ForEachChild(invert(yield)) // `true` is return early for a ts visitor, `false` is return early for a go iterator yield function +} + +func (node *NodeDefault) IterChildren() iter.Seq[*Node] { + return node.forEachChildIter +} func (node *NodeDefault) VisitEachChild(v *NodeVisitor) *Node { return node.AsNode() } func (node *NodeDefault) Clone(v NodeFactoryCoercible) *Node { return nil } func (node *NodeDefault) Name() *DeclarationName { return nil } diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 6e1901d910..9f135129fd 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -5913,13 +5913,12 @@ func (p *Parser) finishNodeWithEnd(node *ast.Node, pos int, end int) { node.Flags |= ast.NodeFlagsThisNodeHasError p.hasParseError = false } - node.ForEachChild(func(n *ast.Node) bool { + for n := range node.IterChildren() { if n.Parent == nil { n.Parent = node } // TODO: panic if attempt to overwrite .Parent with new, different .Parent when jsdoc reparser is fixed to not reuse the same nodes in many places - return false - }) + } } func (p *Parser) nextTokenIsSlash() bool { diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index a504ebc0b8..5cf88ce1a3 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -6,10 +6,9 @@ import ( ) func (p *Parser) finishReparsedNode(node *ast.Node) { - node.ForEachChild(func(n *ast.Node) bool { + for n := range node.IterChildren() { n.Parent = node // this overrides an existing parent - the jsdoc reparser does this when it moves nodes from jsdoc into concrete expressions - return false - }) + } } func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { From 2d79a74eb8b70a94b2de8aa23b033c187baf1583 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 24 Jun 2025 13:16:02 -0700 Subject: [PATCH 05/10] Why is the performant thing not the idiomatic thing? This looks horrid. --- internal/ast/utilities.go | 69 +++++++++++++++++++++++++++++++++++++ internal/parser/parser.go | 7 +--- internal/parser/reparser.go | 4 +-- 3 files changed, 71 insertions(+), 9 deletions(-) diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index d1c046a4d4..4fa79f9484 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -923,6 +923,75 @@ func SetParentInChildren(node *Node) { fn(node) } +var setParentInImmediateChildrenPool = sync.Pool{ + New: func() any { + return newParentInImmediateChildrenSetter() + }, +} + +func newParentInImmediateChildrenSetter() func(node *Node) bool { + // Consolidate state into one allocation. + // Similar to https://go.dev/cl/552375. + var state struct { + parent *Node + visit func(*Node) bool + } + + state.visit = func(node *Node) bool { + if state.parent != nil && node.Parent == nil { + node.Parent = state.parent + } + // TODO: panic if attempt to overwrite .Parent with new, different .Parent when jsdoc reparser is fixed to not reuse the same nodes in many places + if state.parent == nil { + state.parent = node + node.ForEachChild(state.visit) + } + return false + } + + return state.visit +} + +func SetParentInImmediateChildren(node *Node) { + fn := setParentInImmediateChildrenPool.Get().(func(node *Node) bool) + defer setParentInImmediateChildrenPool.Put(fn) + fn(node) +} + +var overrideParentInImmediateChildrenPool = sync.Pool{ + New: func() any { + return newOverrideParentInImmediateChildrenSetter() + }, +} + +func newOverrideParentInImmediateChildrenSetter() func(node *Node) bool { + // Consolidate state into one allocation. + // Similar to https://go.dev/cl/552375. + var state struct { + parent *Node + visit func(*Node) bool + } + + state.visit = func(node *Node) bool { + if state.parent != nil { + node.Parent = state.parent + } + if state.parent == nil { + state.parent = node + node.ForEachChild(state.visit) + } + return false + } + + return state.visit +} + +func OverrideParentInImmediateChildren(node *Node) { + fn := overrideParentInImmediateChildrenPool.Get().(func(node *Node) bool) + defer overrideParentInImmediateChildrenPool.Put(fn) + fn(node) +} + // This should never be called outside the parser func SetImportsOfSourceFile(node *SourceFile, imports []*LiteralLikeNode) { node.imports = imports diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 9f135129fd..ba614478b4 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -5913,12 +5913,7 @@ func (p *Parser) finishNodeWithEnd(node *ast.Node, pos int, end int) { node.Flags |= ast.NodeFlagsThisNodeHasError p.hasParseError = false } - for n := range node.IterChildren() { - if n.Parent == nil { - n.Parent = node - } - // TODO: panic if attempt to overwrite .Parent with new, different .Parent when jsdoc reparser is fixed to not reuse the same nodes in many places - } + ast.SetParentInImmediateChildren(node) } func (p *Parser) nextTokenIsSlash() bool { diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index 5cf88ce1a3..f9d41f5deb 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -6,9 +6,7 @@ import ( ) func (p *Parser) finishReparsedNode(node *ast.Node) { - for n := range node.IterChildren() { - n.Parent = node // this overrides an existing parent - the jsdoc reparser does this when it moves nodes from jsdoc into concrete expressions - } + ast.OverrideParentInImmediateChildren(node) } func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { From 4d434d40ead61af7fe0be971567645efa91e50d6 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 24 Jun 2025 14:13:54 -0700 Subject: [PATCH 06/10] bugfix, still assertion failures to track down and except --- internal/ast/utilities.go | 5 +++-- internal/testrunner/compiler_runner.go | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index 4fa79f9484..01de7aa2b0 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -945,6 +945,7 @@ func newParentInImmediateChildrenSetter() func(node *Node) bool { if state.parent == nil { state.parent = node node.ForEachChild(state.visit) + state.parent = nil } return false } @@ -975,10 +976,10 @@ func newOverrideParentInImmediateChildrenSetter() func(node *Node) bool { state.visit = func(node *Node) bool { if state.parent != nil { node.Parent = state.parent - } - if state.parent == nil { + } else { state.parent = node node.ForEachChild(state.visit) + state.parent = nil } return false } diff --git a/internal/testrunner/compiler_runner.go b/internal/testrunner/compiler_runner.go index 4c0ba6f403..817905145a 100644 --- a/internal/testrunner/compiler_runner.go +++ b/internal/testrunner/compiler_runner.go @@ -513,6 +513,9 @@ func (c *compilerTest) verifyParentPointers(t *testing.T) { var parent *ast.Node var verifier func(n *ast.Node) bool verifier = func(n *ast.Node) bool { + if n == nil { + return false + } assert.Assert(t, n.Parent != nil, "parent node does not exist") elab := "" if !ast.NodeIsSynthesized(n) { From 7b9adb423fce883d52900a1f9a57d9be88e3a250 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 24 Jun 2025 15:04:51 -0700 Subject: [PATCH 07/10] Catalogue the remainder of the current exceptions to the parent pointer invariant maufactured by the js reparser --- internal/parser/parser.go | 2 +- internal/parser/reparser.go | 2 +- internal/testrunner/compiler_runner.go | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index ba614478b4..8800e515d5 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -5913,7 +5913,7 @@ func (p *Parser) finishNodeWithEnd(node *ast.Node, pos int, end int) { node.Flags |= ast.NodeFlagsThisNodeHasError p.hasParseError = false } - ast.SetParentInImmediateChildren(node) + ast.OverrideParentInImmediateChildren(node) } func (p *Parser) nextTokenIsSlash() bool { diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index f9d41f5deb..8daeee9dd7 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -326,7 +326,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() if kind := ast.GetAssignmentDeclarationKind(bin); kind != ast.JSDeclarationKindNone { bin.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent.AsExpressionStatement().Expression) - p.finishReparsedNode(parent) + p.finishReparsedNode(bin.AsNode()) } } } diff --git a/internal/testrunner/compiler_runner.go b/internal/testrunner/compiler_runner.go index 817905145a..d2c7fbd599 100644 --- a/internal/testrunner/compiler_runner.go +++ b/internal/testrunner/compiler_runner.go @@ -523,8 +523,10 @@ func (c *compilerTest) verifyParentPointers(t *testing.T) { } else { elab += "!synthetic! no text available" } - if n.Parent.Kind == ast.KindBinaryExpression && parent.Kind == ast.KindJSExportAssignment { - // known current violation of parent pointer invariant, ignore + if ((n.Parent.Kind == ast.KindBinaryExpression || n.Parent.Kind == ast.KindPropertyAccessExpression || n.Parent.Kind == ast.KindElementAccessExpression) && (parent.Kind == ast.KindJSExportAssignment || parent.Kind == ast.KindCommonJSExport)) || + ((parent.Kind == ast.KindBinaryExpression || parent.Kind == ast.KindPropertyAccessExpression || parent.Kind == ast.KindElementAccessExpression) && (n.Parent.Kind == ast.KindJSExportAssignment || n.Parent.Kind == ast.KindCommonJSExport)) || + (ast.IsFunctionLike(n.Parent) && ast.IsFunctionLike(parent)) { + // known current violation of parent pointer invariant, ignore (type nodes on js exports/binary expressions, names on signatures) } else { assert.Assert(t, n.Parent == parent, "parent node does not match traversed parent: "+n.Kind.String()+": "+elab) } From aa5d59893262e7a7ed97313c0787d1ca4fa14463 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 24 Jun 2025 15:17:12 -0700 Subject: [PATCH 08/10] The slight differences in which parent are selected for jsdoc reparsing cause these diffs - they seem like improvements, at least --- .../checkJsTypeDefNoUnusedLocalMarked.types | 10 +- ...tuallyTypedParametersOptionalInJSDoc.types | 4 +- .../expandoFunctionContextualTypesJs.types | 46 ++--- .../compiler/exportDefaultWithJSDoc1.types | 6 +- .../compiler/exportDefaultWithJSDoc2.types | 8 +- ...ExportAssignmentNonMutableLocation.symbols | 1 + ...tAssignmentNonMutableLocation.symbols.diff | 2 +- ...jsExportAssignmentNonMutableLocation.types | 2 +- ...emberMergedWithModuleAugmentation3.symbols | 1 + ...MergedWithModuleAugmentation3.symbols.diff | 1 + ...tMemberMergedWithModuleAugmentation3.types | 2 +- .../compiler/pushTypeGetTypeOfAlias.symbols | 1 + .../pushTypeGetTypeOfAlias.symbols.diff | 2 +- .../strictOptionalProperties3.errors.txt | 4 +- .../compiler/strictOptionalProperties3.types | 2 +- .../assertionTypePredicates2.types | 16 +- .../assertionsAndNonReturningFunctions.types | 4 +- .../checkJsdocSatisfiesTag10.errors.txt | 4 +- .../checkJsdocSatisfiesTag7.errors.txt | 4 +- .../conformance/checkJsdocTypeTag4.types | 2 +- .../conformance/commonJSAliasedExport.symbols | 1 + .../commonJSAliasedExport.symbols.diff | 2 +- .../conformance/commonJSAliasedExport.types | 2 +- ...ontextualTypedSpecialAssignment.errors.txt | 2 +- .../contextualTypedSpecialAssignment.types | 38 ++-- .../conformance/extendsTag5.errors.txt | 8 +- .../conformance/importTag23.errors.txt | 6 +- ...DeclarationsClassExtendsVisibility.symbols | 1 + ...rationsClassExtendsVisibility.symbols.diff | 5 +- ...jsDeclarationsClassExtendsVisibility.types | 2 +- .../jsDeclarationsClassStatic.symbols | 1 + .../jsDeclarationsClassStatic.symbols.diff | 4 +- .../jsDeclarationsClassStatic.types | 2 +- .../jsDeclarationsCrossfileMerge.symbols | 1 + .../jsDeclarationsCrossfileMerge.symbols.diff | 5 +- .../jsDeclarationsCrossfileMerge.types | 2 +- ...nedClassExpressionAnonymousWithSub.symbols | 1 + ...assExpressionAnonymousWithSub.symbols.diff | 2 +- ...ignedClassExpressionAnonymousWithSub.types | 2 +- ...rtAssignedClassExpressionShadowing.symbols | 1 + ...ignedClassExpressionShadowing.symbols.diff | 2 +- ...portAssignedClassExpressionShadowing.types | 2 +- ...ationsExportAssignedClassInstance3.symbols | 1 + ...sExportAssignedClassInstance3.symbols.diff | 2 +- ...arationsExportAssignedClassInstance3.types | 2 +- ...AssignedConstructorFunctionWithSub.symbols | 1 + ...nedConstructorFunctionWithSub.symbols.diff | 1 + ...rtAssignedConstructorFunctionWithSub.types | 2 +- ...tAssignmentExpressionPlusSecondary.symbols | 1 + ...gnmentExpressionPlusSecondary.symbols.diff | 2 +- ...ortAssignmentExpressionPlusSecondary.types | 2 +- ...onsExportDoubleAssignmentInClosure.symbols | 1 + ...portDoubleAssignmentInClosure.symbols.diff | 4 +- ...tionsExportDoubleAssignmentInClosure.types | 2 +- ...jsDeclarationsExportSubAssignments.symbols | 1 + ...larationsExportSubAssignments.symbols.diff | 2 +- .../jsDeclarationsExportSubAssignments.types | 2 +- ...nsFunctionClassesCjsExportAssignment.types | 18 +- .../jsDeclarationsImportTypeBundled.types | 24 +-- .../jsDeclarationsTypeAliases.types | 14 +- .../jsDeclarationsTypedefFunction.types | 8 +- .../conformance/jsdocTemplateClass.types | 6 +- .../conformance/jsdocTemplateTag6.errors.txt | 112 ------------ .../conformance/jsdocTemplateTag7.errors.txt | 5 +- .../conformance/jsdocTemplateTagDefault.types | 8 +- .../conformance/moduleExportAlias.symbols | 14 ++ .../moduleExportAlias.symbols.diff | 100 +++++------ .../conformance/moduleExportAlias.types | 28 +-- .../conformance/moduleExportAlias4.symbols | 1 + .../moduleExportAlias4.symbols.diff | 1 + .../conformance/moduleExportAlias4.types | 2 +- ...leExportAliasElementAccessExpression.types | 4 +- .../moduleExportAliasImported.symbols | 1 + .../moduleExportAliasImported.symbols.diff | 2 +- .../moduleExportAliasImported.types | 2 +- .../moduleExportAliasUnknown.symbols | 1 + .../moduleExportAliasUnknown.symbols.diff | 2 +- .../moduleExportAssignment4.symbols | 1 + .../moduleExportAssignment4.symbols.diff | 2 +- .../conformance/moduleExportAssignment4.types | 2 +- .../moduleExportAssignment5.symbols | 1 + .../moduleExportAssignment5.symbols.diff | 2 +- .../conformance/moduleExportAssignment5.types | 2 +- ...uleExportPropertyAssignmentDefault.symbols | 1 + ...portPropertyAssignmentDefault.symbols.diff | 2 +- ...oduleExportPropertyAssignmentDefault.types | 2 +- ...ExportWithExportPropertyAssignment.symbols | 1 + ...tWithExportPropertyAssignment.symbols.diff | 2 +- ...leExportWithExportPropertyAssignment.types | 2 +- ...xportWithExportPropertyAssignment2.symbols | 1 + ...WithExportPropertyAssignment2.symbols.diff | 2 +- ...eExportWithExportPropertyAssignment2.types | 2 +- ...xportWithExportPropertyAssignment3.symbols | 5 +- ...WithExportPropertyAssignment3.symbols.diff | 8 +- ...eExportWithExportPropertyAssignment3.types | 6 +- ...xportWithExportPropertyAssignment4.symbols | 5 +- ...WithExportPropertyAssignment4.symbols.diff | 6 +- ...eExportWithExportPropertyAssignment4.types | 6 +- ...moduleExportsElementAccessAssignment.types | 8 +- .../recursiveTypeReferences2.errors.txt | 16 +- .../recursiveTypeReferences2.types | 2 +- .../submodule/conformance/thisTag3.types | 4 +- .../typeFromContextualThisType.symbols | 8 +- .../typeFromContextualThisType.symbols.diff | 19 +- .../conformance/typeTagNoErasure.types | 6 +- .../typeTagOnFunctionReferencesGeneric.types | 4 +- .../conformance/typedefCrossModule.types | 6 +- .../conformance/typedefCrossModule2.symbols | 2 + .../typedefCrossModule2.symbols.diff | 4 +- .../conformance/typedefCrossModule2.types | 4 +- .../typedefMultipleTypeParameters.types | 4 +- .../conformance/typedefOnStatements.types | 70 ++++---- .../conformance/typedefTagWrapping.types | 26 +-- ...eckJsTypeDefNoUnusedLocalMarked.types.diff | 13 +- ...yTypedParametersOptionalInJSDoc.types.diff | 20 +-- ...xpandoFunctionContextualTypesJs.types.diff | 96 ++--------- .../exportDefaultWithJSDoc1.types.diff | 6 +- .../exportDefaultWithJSDoc2.types.diff | 14 +- ...ortAssignmentNonMutableLocation.types.diff | 2 +- ...erMergedWithModuleAugmentation3.types.diff | 3 +- .../strictOptionalProperties3.errors.txt.diff | 26 +-- .../strictOptionalProperties3.types.diff | 11 -- .../assertionTypePredicates2.types.diff | 41 ----- ...ertionsAndNonReturningFunctions.types.diff | 19 +- .../checkJsdocSatisfiesTag10.errors.txt.diff | 17 -- .../checkJsdocSatisfiesTag7.errors.txt.diff | 17 -- .../conformance/checkJsdocTypeTag4.types.diff | 8 - .../commonJSAliasedExport.types.diff | 3 +- ...tualTypedSpecialAssignment.errors.txt.diff | 2 +- ...ontextualTypedSpecialAssignment.types.diff | 69 ++------ .../conformance/extendsTag5.errors.txt.diff | 30 ---- .../conformance/importTag23.errors.txt.diff | 24 --- ...larationsClassExtendsVisibility.types.diff | 5 +- .../jsDeclarationsClassStatic.types.diff | 5 +- .../jsDeclarationsCrossfileMerge.types.diff | 3 +- ...ClassExpressionAnonymousWithSub.types.diff | 3 +- ...ssignedClassExpressionShadowing.types.diff | 3 +- ...onsExportAssignedClassInstance3.types.diff | 3 +- ...ignedConstructorFunctionWithSub.types.diff | 2 +- ...signmentExpressionPlusSecondary.types.diff | 3 +- ...ExportDoubleAssignmentInClosure.types.diff | 5 +- ...eclarationsExportSubAssignments.types.diff | 3 +- ...ctionClassesCjsExportAssignment.types.diff | 21 +-- ...jsDeclarationsImportTypeBundled.types.diff | 37 ++-- .../jsDeclarationsTypeAliases.types.diff | 29 +--- .../jsDeclarationsTypedefFunction.types.diff | 24 --- .../conformance/jsdocTemplateClass.types.diff | 22 +-- .../jsdocTemplateTag6.errors.txt.diff | 116 ------------- .../jsdocTemplateTag7.errors.txt.diff | 22 --- .../jsdocTemplateTagDefault.types.diff | 31 ---- .../conformance/moduleExportAlias.types.diff | 163 +++++++----------- .../conformance/moduleExportAlias4.types.diff | 2 +- ...ortAliasElementAccessExpression.types.diff | 8 +- .../moduleExportAliasImported.types.diff | 3 +- .../moduleExportAssignment4.types.diff | 4 +- .../moduleExportAssignment5.types.diff | 3 +- ...ExportPropertyAssignmentDefault.types.diff | 2 +- ...ortWithExportPropertyAssignment.types.diff | 2 +- ...rtWithExportPropertyAssignment2.types.diff | 3 +- ...rtWithExportPropertyAssignment3.types.diff | 7 +- ...rtWithExportPropertyAssignment4.types.diff | 7 +- ...eExportsElementAccessAssignment.types.diff | 14 +- .../recursiveTypeReferences2.errors.txt.diff | 34 ---- .../recursiveTypeReferences2.types.diff | 9 - .../conformance/thisTag3.types.diff | 13 -- .../conformance/typeTagNoErasure.types.diff | 23 --- ...eTagOnFunctionReferencesGeneric.types.diff | 15 +- .../conformance/typedefCrossModule.types.diff | 6 +- .../typedefCrossModule2.types.diff | 6 +- .../typedefMultipleTypeParameters.types.diff | 16 -- .../typedefOnStatements.types.diff | 118 ------------- .../conformance/typedefTagWrapping.types.diff | 69 +------- 172 files changed, 579 insertions(+), 1543 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.types.diff diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types index 3494d23bc9..6567e94d77 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types @@ -24,11 +24,11 @@ export = Foo; /** @typedef {(foo: Foo) => string} FooFun */ module.exports = /** @type {FooFun} */(void 0); ->module.exports = /** @type {FooFun} */(void 0) : (foo: typeof import("./file")) => string ->module.exports : (foo: typeof import("./file")) => string ->module : { "export=": (foo: typeof import("./file")) => string; } ->exports : (foo: typeof import("./file")) => string ->(void 0) : (foo: typeof import("./file")) => string +>module.exports = /** @type {FooFun} */(void 0) : FooFun +>module.exports : FooFun +>module : { "export=": FooFun; } +>exports : FooFun +>(void 0) : FooFun >void 0 : undefined >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types index 7fe7125499..899c9f7088 100644 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types +++ b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types @@ -15,7 +15,7 @@ function acceptNum(num) {} /** @type {Fn} */ const fn1 = ->fn1 : (a: string, b: number) => void +>fn1 : Fn /** * @param [b] @@ -46,7 +46,7 @@ const fn1 = /** @type {Fn} */ const fn2 = ->fn2 : (a: string, b: number) => void +>fn2 : Fn /** * @param {number} [b] diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types index 6b5aa2cc49..3c24f4522c 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types @@ -11,15 +11,15 @@ * @type {StatelessComponent} */ const MyComponent = () => /* @type {any} */(null); ->MyComponent : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } +>MyComponent : StatelessComponent >() => /* @type {any} */(null) : { (): any; defaultProps: { color: "red"; }; } >(null) : null MyComponent.defaultProps = { >MyComponent.defaultProps = { color: "red"} : { color: "red"; } ->MyComponent.defaultProps : Partial<{ color: "blue" | "red"; }> ->MyComponent : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } ->defaultProps : Partial<{ color: "blue" | "red"; }> +>MyComponent.defaultProps : Partial +>MyComponent : StatelessComponent +>defaultProps : Partial >{ color: "red"} : { color: "red"; } color: "red" @@ -29,17 +29,17 @@ MyComponent.defaultProps = { }; const MyComponent2 = () => null; ->MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } ->() => null : { (): any; defaultProps: { color: "blue" | "red"; }; } +>MyComponent2 : { (): any; defaultProps: MyComponentProps; } +>() => null : { (): any; defaultProps: MyComponentProps; } /** * @type {MyComponentProps} */ MyComponent2.defaultProps = { >MyComponent2.defaultProps = { color: "red"} : { color: "red"; } ->MyComponent2.defaultProps : { color: "blue" | "red"; } ->MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } ->defaultProps : { color: "blue" | "red"; } +>MyComponent2.defaultProps : MyComponentProps +>MyComponent2 : { (): any; defaultProps: MyComponentProps; } +>defaultProps : MyComponentProps >{ color: "red"} : { color: "red"; } color: "red" @@ -51,16 +51,16 @@ MyComponent2.defaultProps = { * @type {StatelessComponent} */ const check = MyComponent2; ->check : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } ->MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } +>check : StatelessComponent +>MyComponent2 : { (): any; defaultProps: MyComponentProps; } /** * * @param {{ props: MyComponentProps }} p */ function expectLiteral(p) {} ->expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void ->p : { props: { color: "blue" | "red"; }; } +>expectLiteral : (p: { props: MyComponentProps; }) => void +>p : { props: MyComponentProps; } function foo() { >foo : () => void @@ -79,7 +79,7 @@ function foo() { expectLiteral(this); >expectLiteral(this) : void ->expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void +>expectLiteral : (p: { props: MyComponentProps; }) => void >this : any } @@ -88,9 +88,9 @@ function foo() { */ module.exports = { >module.exports = { color: "red"} : { color: "red"; } ->module.exports : { color: "blue" | "red"; } ->module : { "export=": { color: "blue" | "red"; }; } ->exports : { color: "blue" | "red"; } +>module.exports : MyComponentProps +>module : { "export=": MyComponentProps; } +>exports : MyComponentProps >{ color: "red"} : { color: "red"; } color: "red" @@ -100,10 +100,10 @@ module.exports = { expectLiteral({ props: module.exports }); >expectLiteral({ props: module.exports }) : void ->expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void ->{ props: module.exports } : { props: { color: "blue" | "red"; }; } ->props : { color: "blue" | "red"; } ->module.exports : { color: "blue" | "red"; } ->module : { "export=": { color: "blue" | "red"; }; } ->exports : { color: "blue" | "red"; } +>expectLiteral : (p: { props: MyComponentProps; }) => void +>{ props: module.exports } : { props: MyComponentProps; } +>props : MyComponentProps +>module.exports : MyComponentProps +>module : { "export=": MyComponentProps; } +>exports : MyComponentProps diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types index 4b4791a5e4..21fee2342a 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types @@ -12,10 +12,10 @@ === b.ts === import A from './a' ->A : (string | number)[] +>A : import("./a").NumberLike[] A[0] ->A[0] : string | number ->A : (string | number)[] +>A[0] : import("./a").NumberLike +>A : import("./a").NumberLike[] >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types index f20c6945f4..614d4e1573 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types @@ -7,15 +7,15 @@ */ export default /** @type {NumberLike[]} */([ ]); ->([ ]) : (string | number)[] +>([ ]) : NumberLike[] >[ ] : undefined[] === b.ts === import A from './a' ->A : (string | number)[] +>A : import("./a").NumberLike[] A[0] ->A[0] : string | number ->A : (string | number)[] +>A[0] : import("./a").NumberLike +>A : import("./a").NumberLike[] >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols index 916f7562f3..c6faa1ec8d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols @@ -18,5 +18,6 @@ module.exports = { exports.customSymbol2 = Symbol("custom"); >exports : Symbol("file", Decl(file.js, 0, 0)) +>customSymbol2 : Symbol(customSymbol2, Decl(file.js, 5, 2)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols.diff index a3d9141331..05b6d05104 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.symbols.diff @@ -19,6 +19,6 @@ exports.customSymbol2 = Symbol("custom"); ->exports.customSymbol2 : Symbol(customSymbol2, Decl(file.js, 5, 2)) ->exports : Symbol(customSymbol2, Decl(file.js, 5, 2)) -->customSymbol2 : Symbol(customSymbol2, Decl(file.js, 5, 2)) +>exports : Symbol("file", Decl(file.js, 0, 0)) + >customSymbol2 : Symbol(customSymbol2, Decl(file.js, 5, 2)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.types b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.types index 7cf7bc14ae..bdc838d831 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.types +++ b/testdata/baselines/reference/submodule/compiler/jsExportAssignmentNonMutableLocation.types @@ -24,7 +24,7 @@ exports.customSymbol2 = Symbol("custom"); >exports.customSymbol2 = Symbol("custom") : symbol >exports.customSymbol2 : any >exports : typeof import("./file") ->customSymbol2 : any +>customSymbol2 : symbol >Symbol("custom") : symbol >Symbol : SymbolConstructor >"custom" : "custom" diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols index ec76d78072..c24099df56 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols @@ -5,6 +5,7 @@ module.exports.x = 1; >module.exports : Symbol(export=, Decl(x.js, 0, 21)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(x.js, 0, 21)) +>x : Symbol(x, Decl(x.js, 0, 0)) module.exports = require("./y.js"); >module.exports : Symbol(export=, Decl(x.js, 0, 21)) diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols.diff index 4f7e0ab0db..af7d240bef 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.symbols.diff @@ -12,6 +12,7 @@ +>module.exports : Symbol(export=, Decl(x.js, 0, 21)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(x.js, 0, 21)) ++>x : Symbol(x, Decl(x.js, 0, 0)) module.exports = require("./y.js"); ->module.exports : Symbol(module.exports, Decl(x.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.types b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.types index 62f3736bfb..ee4e91419b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.types +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation3.types @@ -7,7 +7,7 @@ module.exports.x = 1; >module.exports : typeof import("./y.js") >module : { "export=": typeof import("./y.js"); } >exports : typeof import("./y.js") ->x : any +>x : 1 >1 : 1 module.exports = require("./y.js"); diff --git a/testdata/baselines/reference/submodule/compiler/pushTypeGetTypeOfAlias.symbols b/testdata/baselines/reference/submodule/compiler/pushTypeGetTypeOfAlias.symbols index 738988b717..3be97da01d 100644 --- a/testdata/baselines/reference/submodule/compiler/pushTypeGetTypeOfAlias.symbols +++ b/testdata/baselines/reference/submodule/compiler/pushTypeGetTypeOfAlias.symbols @@ -8,5 +8,6 @@ module.exports = function () {}; exports.blah = exports.someProp; >exports : Symbol("bar", Decl(bar.js, 0, 0)) +>blah : Symbol(blah, Decl(bar.js, 0, 32)) >exports : Symbol("bar", Decl(bar.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/compiler/pushTypeGetTypeOfAlias.symbols.diff b/testdata/baselines/reference/submodule/compiler/pushTypeGetTypeOfAlias.symbols.diff index 0866617f76..cfcf13c667 100644 --- a/testdata/baselines/reference/submodule/compiler/pushTypeGetTypeOfAlias.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/pushTypeGetTypeOfAlias.symbols.diff @@ -13,6 +13,6 @@ exports.blah = exports.someProp; ->exports.blah : Symbol(blah, Decl(bar.js, 0, 32)) ->exports : Symbol(blah, Decl(bar.js, 0, 32)) -->blah : Symbol(blah, Decl(bar.js, 0, 32)) +>exports : Symbol("bar", Decl(bar.js, 0, 0)) + >blah : Symbol(blah, Decl(bar.js, 0, 32)) >exports : Symbol("bar", Decl(bar.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt index ae46bda792..80175c8972 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt @@ -1,4 +1,4 @@ -a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. +a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. Types of property 'value' are incompatible. Type 'undefined' is not assignable to type 'number'. @@ -19,7 +19,7 @@ a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type /** @type {B} */ const b = { value: undefined }; // error ~ -!!! error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. +!!! error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. !!! error TS2375: Types of property 'value' are incompatible. !!! error TS2375: Type 'undefined' is not assignable to type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.types b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.types index 72d35c1e04..d831b6afc4 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.types +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.types @@ -19,7 +19,7 @@ const a = { value: undefined }; // error /** @type {B} */ const b = { value: undefined }; // error ->b : { value?: number; } +>b : B >{ value: undefined } : { value: undefined; } >value : undefined >undefined : undefined diff --git a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types index 6acd8d393f..4defda8da8 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types +++ b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types @@ -14,15 +14,15 @@ * @returns { asserts a is B } */ const foo = (a) => { ->foo : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } ->(a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); return undefined;} : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } ->a : { x: number; } +>foo : (a: A) => asserts a is B +>(a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); return undefined;} : (a: A) => asserts a is B +>a : A if (/** @type { B } */ (a).y !== 0) throw TypeError(); >(a).y !== 0 : boolean >(a).y : number ->(a) : { x: number; } & { y: number; } ->a : { x: number; } +>(a) : B +>a : A >y : number >0 : 0 >TypeError() : TypeError @@ -39,15 +39,15 @@ export const main = () => { /** @type { A } */ const a = { x: 1 }; ->a : { x: number; } +>a : A >{ x: 1 } : { x: number; } >x : number >1 : 1 foo(a); >foo(a) : void ->foo : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } ->a : { x: number; } +>foo : (a: A) => asserts a is B +>a : A }; diff --git a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.types b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.types index 460c077286..7959286888 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.types +++ b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.types @@ -5,7 +5,7 @@ /** @type {AssertFunc} */ const assert = check => { ->assert : (check: boolean) => asserts check +>assert : AssertFunc >check => { if (!check) throw new Error();} : (check: boolean) => void >check : boolean @@ -72,7 +72,7 @@ function f1(x) { assert(typeof x === "string"); >assert(typeof x === "string") : void ->assert : (check: boolean) => asserts check +>assert : AssertFunc >typeof x === "string" : boolean >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" >x : any diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt index 86e01bf5f8..4b23f0cb68 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt @@ -1,4 +1,4 @@ -/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. +/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. @@ -10,7 +10,7 @@ b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' ~ -!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. }); // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt index ad8f001736..509ca8498b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt @@ -1,4 +1,4 @@ -/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record<"a" | "b" | "c" | "d", unknown>'. +/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. @@ -10,7 +10,7 @@ b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' ~ -!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record<"a" | "b" | "c" | "d", unknown>'. +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. }) // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types index ac41a8e0d4..cfec71866a 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types @@ -16,5 +16,5 @@ var a; /** @type {B} */ var b; ->b : { b: number; } +>b : B diff --git a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.symbols b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.symbols index 8c3b8e0421..bfad582d2d 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.symbols +++ b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.symbols @@ -37,5 +37,6 @@ module.exports.funky = funky; >module.exports : Symbol(donkey, Decl(commonJSAliasedExport.js, 0, 5)) >module : Symbol(module.exports) >exports : Symbol(donkey, Decl(commonJSAliasedExport.js, 0, 5)) +>funky : Symbol(funky, Decl(commonJSAliasedExport.js, 5, 24)) >funky : Symbol(funky, Decl(commonJSAliasedExport.js, 0, 29)) diff --git a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.symbols.diff b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.symbols.diff index 57e789428e..823745175a 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.symbols.diff @@ -17,8 +17,8 @@ ->module.exports : Symbol(funky, Decl(commonJSAliasedExport.js, 5, 24)) ->module : Symbol(module, Decl(commonJSAliasedExport.js, 4, 1)) ->exports : Symbol(module.exports, Decl(commonJSAliasedExport.js, 0, 0)) -->funky : Symbol(funky, Decl(commonJSAliasedExport.js, 5, 24)) +>module.exports : Symbol(donkey, Decl(commonJSAliasedExport.js, 0, 5)) +>module : Symbol(module.exports) +>exports : Symbol(donkey, Decl(commonJSAliasedExport.js, 0, 5)) + >funky : Symbol(funky, Decl(commonJSAliasedExport.js, 5, 24)) >funky : Symbol(funky, Decl(commonJSAliasedExport.js, 0, 29)) diff --git a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.types b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.types index b4d9bc810d..9fa899723e 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.types +++ b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.types @@ -45,6 +45,6 @@ module.exports.funky = funky; >module.exports : (ast: any) => any >module : { readonly donkey: (ast: any) => any; } >exports : (ast: any) => any ->funky : any +>funky : (declaration: any) => boolean >funky : (declaration: any) => boolean diff --git a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt index 7d3dce2d04..104d117c37 100644 --- a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt @@ -22,7 +22,7 @@ test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. status: 'done', ~~~~~~ !!! error TS2322: Type 'string' is not assignable to type '"done"'. -!!! related TS6500 test.js:2:5: The expected type comes from property 'status' which is declared here on type '{ status: "done"; m(n: number): void; }' +!!! related TS6500 test.js:2:5: The expected type comes from property 'status' which is declared here on type 'DoneStatus' m(n) { } ~ !!! error TS7006: Parameter 'n' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.types b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.types index 1898c7166f..d3739a557a 100644 --- a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.types @@ -8,15 +8,15 @@ // property assignment var ns = {} ->ns : { x: { status: "done"; m(n: number): void; }; } ->{} : { x: { status: "done"; m(n: number): void; }; } +>ns : { x: DoneStatus; } +>{} : { x: DoneStatus; } /** @type {DoneStatus} */ ns.x = { >ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } ->ns.x : { status: "done"; m(n: number): void; } ->ns : { x: { status: "done"; m(n: number): void; }; } ->x : { status: "done"; m(n: number): void; } +>ns.x : DoneStatus +>ns : { x: DoneStatus; } +>x : DoneStatus >{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } status: 'done', @@ -30,9 +30,9 @@ ns.x = { ns.x = { >ns.x = { status: 'done', m(n) { }} : { status: string; m(n: any): void; } ->ns.x : { status: "done"; m(n: number): void; } ->ns : { x: { status: "done"; m(n: number): void; }; } ->x : { status: "done"; m(n: number): void; } +>ns.x : DoneStatus +>ns : { x: DoneStatus; } +>x : DoneStatus >{ status: 'done', m(n) { }} : { status: string; m(n: any): void; } status: 'done', @@ -44,9 +44,9 @@ ns.x = { >n : any } ns.x ->ns.x : { status: "done"; m(n: number): void; } ->ns : { x: { status: "done"; m(n: number): void; }; } ->x : { status: "done"; m(n: number): void; } +>ns.x : DoneStatus +>ns : { x: DoneStatus; } +>x : DoneStatus // this-property assignment @@ -57,9 +57,9 @@ class Thing { /** @type {DoneStatus} */ this.s = { >this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } ->this.s : { status: "done"; m(n: number): void; } +>this.s : DoneStatus >this : this ->s : { status: "done"; m(n: number): void; } +>s : DoneStatus >{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } status: 'done', @@ -77,9 +77,9 @@ class Thing { this.s = { >this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } ->this.s : { status: "done"; m(n: number): void; } +>this.s : DoneStatus >this : this ->s : { status: "done"; m(n: number): void; } +>s : DoneStatus >{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } status: 'done', @@ -169,14 +169,14 @@ Thing.prototype.x // prototype assignment function F() { ->F : { (): void; prototype: { status: "done"; m(n: number): void; }; } +>F : { (): void; prototype: DoneStatus; } } /** @type {DoneStatus} */ F.prototype = { >F.prototype = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } ->F.prototype : { status: "done"; m(n: number): void; } ->F : { (): void; prototype: { status: "done"; m(n: number): void; }; } ->prototype : { status: "done"; m(n: number): void; } +>F.prototype : DoneStatus +>F : { (): void; prototype: DoneStatus; } +>prototype : DoneStatus >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } status: "done", diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt index c513efe5ed..8c2c3e3e07 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt @@ -1,7 +1,7 @@ -/a.js(29,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint '{ a: string | number; b: boolean | string[]; }'. +/a.js(29,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. Types of property 'b' are incompatible. Type 'string' is not assignable to type 'boolean | string[]'. -/a.js(42,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint '{ a: string | number; b: boolean | string[]; }'. +/a.js(42,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. Types of property 'b' are incompatible. Type 'string' is not assignable to type 'boolean | string[]'. @@ -43,7 +43,7 @@ ~~~~~~~~~~~~~~~~ * }>} ~~~~ -!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint '{ a: string | number; b: boolean | string[]; }'. +!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. !!! error TS2344: Types of property 'b' are incompatible. !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. */ @@ -57,7 +57,7 @@ /** * @extends {A<{a: string, b: string}>} ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint '{ a: string | number; b: boolean | string[]; }'. +!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. !!! error TS2344: Types of property 'b' are incompatible. !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. */ diff --git a/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt index bb525a810c..03bedf5694 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt @@ -1,4 +1,3 @@ -/b.js(5,18): error TS1361: 'NS' cannot be used as a value because it was imported using 'import type'. /b.js(6,14): error TS2420: Class 'C' incorrectly implements interface 'I'. Property 'foo' is missing in type 'C' but required in type 'I'. @@ -8,15 +7,12 @@ foo(): void; } -==== /b.js (2 errors) ==== +==== /b.js (1 errors) ==== /** * @import * as NS from './a' */ /** @implements {NS.I} */ - ~~ -!!! error TS1361: 'NS' cannot be used as a value because it was imported using 'import type'. -!!! related TS1376 /b.js:2:17: 'NS' was imported here. export class C {} ~ !!! error TS2420: Class 'C' incorrectly implements interface 'I'. diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.symbols index bd1cc110ec..41ca988325 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.symbols @@ -30,6 +30,7 @@ module.exports.Strings = Strings; >module.exports : Symbol(Foo, Decl(cls.js, 4, 2)) >module : Symbol(module.exports) >exports : Symbol(Foo, Decl(cls.js, 4, 2)) +>Strings : Symbol(Strings, Decl(cls.js, 6, 21)) >Strings : Symbol(Strings, Decl(cls.js, 1, 5)) === bar.js === diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.symbols.diff index 92f53b9b9c..81e6807cec 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.symbols.diff @@ -17,14 +17,13 @@ ->module.exports : Symbol(Strings, Decl(cls.js, 6, 21)) ->module : Symbol(module, Decl(cls.js, 5, 24)) ->exports : Symbol(module.exports, Decl(cls.js, 0, 0)) -->Strings : Symbol(Strings, Decl(cls.js, 6, 21)) +>module.exports : Symbol(Foo, Decl(cls.js, 4, 2)) +>module : Symbol(module.exports) +>exports : Symbol(Foo, Decl(cls.js, 4, 2)) + >Strings : Symbol(Strings, Decl(cls.js, 6, 21)) >Strings : Symbol(Strings, Decl(cls.js, 1, 5)) - === bar.js === -@@= skipped -18, +16 lines =@@ +@@= skipped -18, +17 lines =@@ >Bar : Symbol(Bar, Decl(bar.js, 0, 0)) module.exports = Bar; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.types index d2474b76c9..5cf45c94be 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.types @@ -37,7 +37,7 @@ module.exports.Strings = Strings; >module.exports : typeof Foo >module : { Foo: typeof Foo; } >exports : typeof Foo ->Strings : any +>Strings : { a: string; b: string; } >Strings : { a: string; b: string; } === bar.js === diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.symbols index 1ac50eb1ca..edbfc17ea6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.symbols @@ -39,6 +39,7 @@ module.exports.Strings = Strings >module.exports : Symbol(Handler, Decl(source.js, 0, 0)) >module : Symbol(module.exports) >exports : Symbol(Handler, Decl(source.js, 0, 0)) +>Strings : Symbol(Strings, Decl(source.js, 14, 25)) >Strings : Symbol(Strings, Decl(source.js, 9, 5)) /** diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.symbols.diff index 073884c653..cb7eb9a942 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.symbols.diff @@ -47,10 +47,8 @@ ->module.exports : Symbol(Strings, Decl(source.js, 14, 25)) ->module : Symbol(module, Decl(source.js, 12, 1)) ->exports : Symbol(module.exports, Decl(source.js, 0, 0)) -->Strings : Symbol(Strings, Decl(source.js, 14, 25)) +>module.exports : Symbol(Handler, Decl(source.js, 0, 0)) +>module : Symbol(module.exports) +>exports : Symbol(Handler, Decl(source.js, 0, 0)) + >Strings : Symbol(Strings, Decl(source.js, 14, 25)) >Strings : Symbol(Strings, Decl(source.js, 9, 5)) - - /** \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.types index 3901dc7659..160a039d38 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.types @@ -48,7 +48,7 @@ module.exports.Strings = Strings >module.exports : typeof Handler >module : { Handler: typeof Handler; } >exports : typeof Handler ->Strings : any +>Strings : { a: string; b: string; } >Strings : { a: string; b: string; } /** diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.symbols index b9ba0605bd..5f4b9038b2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.symbols @@ -18,6 +18,7 @@ module.exports.memberName = "thing"; >module.exports : Symbol(validate, Decl(exporter.js, 0, 0)) >module : Symbol(module.exports) >exports : Symbol(validate, Decl(exporter.js, 0, 0)) +>memberName : Symbol(memberName, Decl(index.js, 2, 27)) === exporter.js === function validate() {} diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.symbols.diff index 7d0dc8fb9a..8cdda24efc 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.symbols.diff @@ -25,10 +25,9 @@ ->module.exports : Symbol(memberName, Decl(index.js, 2, 27)) ->module : Symbol(module, Decl(index.js, 0, 32)) ->exports : Symbol(module.exports, Decl(index.js, 0, 0)) -->memberName : Symbol(memberName, Decl(index.js, 2, 27)) +>module.exports : Symbol(validate, Decl(exporter.js, 0, 0)) +>module : Symbol(module.exports) +>exports : Symbol(validate, Decl(exporter.js, 0, 0)) + >memberName : Symbol(memberName, Decl(index.js, 2, 27)) - === exporter.js === - function validate() {} \ No newline at end of file + === exporter.js === \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.types index b61fc27bfe..bfa141dd6c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.types @@ -22,7 +22,7 @@ module.exports.memberName = "thing"; >module.exports : () => void >module : { validate(): void; } >exports : () => void ->memberName : any +>memberName : "thing" >"thing" : "thing" === exporter.js === diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols index d41006552a..42fcda9dbb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols @@ -23,6 +23,7 @@ module.exports.Sub = class { >module.exports : Symbol(exports, Decl(index.js, 0, 16)) >module : Symbol(module.exports) >exports : Symbol(exports, Decl(index.js, 0, 16)) +>Sub : Symbol(Sub, Decl(index.js, 7, 1)) constructor() { this.instance = new module.exports(10); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols.diff index ae78b1e9d9..ed8774b8e7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols.diff @@ -30,10 +30,10 @@ ->module.exports : Symbol(Sub, Decl(index.js, 7, 1)) ->module : Symbol(module, Decl(index.js, 0, 0), Decl(index.js, 10, 27)) ->exports : Symbol(module.exports, Decl(index.js, 0, 0)) -->Sub : Symbol(Sub, Decl(index.js, 7, 1)) +>module.exports : Symbol(exports, Decl(index.js, 0, 16)) +>module : Symbol(module.exports) +>exports : Symbol(exports, Decl(index.js, 0, 16)) + >Sub : Symbol(Sub, Decl(index.js, 7, 1)) constructor() { this.instance = new module.exports(10); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types index c652b6029e..0a80cd5e49 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types @@ -30,7 +30,7 @@ module.exports.Sub = class { >module.exports : typeof import(".") >module : { "\uFFFDclass": typeof import("."); } >exports : typeof import(".") ->Sub : any +>Sub : typeof Sub >class { constructor() { this.instance = new module.exports(10); }} : typeof Sub constructor() { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.symbols index 4fcf0449c5..a1bd4f9755 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.symbols @@ -32,5 +32,6 @@ module.exports.Another = Q; >module.exports : Symbol(Q, Decl(index.js, 6, 16)) >module : Symbol(module.exports) >exports : Symbol(Q, Decl(index.js, 6, 16)) +>Another : Symbol(Another, Decl(index.js, 10, 1)) >Q : Symbol(Q, Decl(index.js, 2, 1)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.symbols.diff index 6ca85363f6..9d9f791cdc 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.symbols.diff @@ -39,8 +39,8 @@ ->module.exports : Symbol(Another, Decl(index.js, 10, 1)) ->module : Symbol(module, Decl(index.js, 5, 1)) ->exports : Symbol(module.exports, Decl(index.js, 0, 0)) -->Another : Symbol(Another, Decl(index.js, 10, 1)) +>module.exports : Symbol(Q, Decl(index.js, 6, 16)) +>module : Symbol(module.exports) +>exports : Symbol(Q, Decl(index.js, 6, 16)) + >Another : Symbol(Another, Decl(index.js, 10, 1)) >Q : Symbol(Q, Decl(index.js, 2, 1)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.types index 5df299934a..832f5e4420 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.types @@ -40,6 +40,6 @@ module.exports.Another = Q; >module.exports : typeof import(".") >module : { Q: typeof import("."); } >exports : typeof import(".") ->Another : any +>Another : typeof Q >Q : typeof Q diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.symbols index 7d970daaef..b0e05682b1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.symbols @@ -21,4 +21,5 @@ module.exports.additional = 20; >module.exports : Symbol(export=, Decl(index.js, 3, 1)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(index.js, 3, 1)) +>additional : Symbol(additional, Decl(index.js, 5, 27)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.symbols.diff index b7b0d03fcd..2a34a4e086 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.symbols.diff @@ -25,7 +25,7 @@ ->module.exports : Symbol(additional, Decl(index.js, 5, 27)) ->module : Symbol(module, Decl(index.js, 3, 1)) ->exports : Symbol(module.exports, Decl(index.js, 0, 0)) -->additional : Symbol(additional, Decl(index.js, 5, 27)) +>module.exports : Symbol(export=, Decl(index.js, 3, 1)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(index.js, 3, 1)) + >additional : Symbol(additional, Decl(index.js, 5, 27)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.types index d8d5961fa5..46201f1ec5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.types @@ -27,6 +27,6 @@ module.exports.additional = 20; >module.exports : Foo >module : { "export=": Foo; } >exports : Foo ->additional : any +>additional : 20 >20 : 20 diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.symbols index 472779ff9e..7309a8814b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.symbols @@ -17,6 +17,7 @@ module.exports.Sub = function() { >module.exports : Symbol(export=, Decl(jsDeclarationsExportAssignedConstructorFunctionWithSub.js, 0, 0)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(jsDeclarationsExportAssignedConstructorFunctionWithSub.js, 0, 0)) +>Sub : Symbol(Sub, Decl(jsDeclarationsExportAssignedConstructorFunctionWithSub.js, 5, 1)) this.instance = new module.exports(10); >module.exports : Symbol(export=, Decl(jsDeclarationsExportAssignedConstructorFunctionWithSub.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.symbols.diff index c239422c61..bed12d2407 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.symbols.diff @@ -26,6 +26,7 @@ +>module.exports : Symbol(export=, Decl(jsDeclarationsExportAssignedConstructorFunctionWithSub.js, 0, 0)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(jsDeclarationsExportAssignedConstructorFunctionWithSub.js, 0, 0)) ++>Sub : Symbol(Sub, Decl(jsDeclarationsExportAssignedConstructorFunctionWithSub.js, 5, 1)) this.instance = new module.exports(10); ->this.instance : Symbol(Sub.instance, Decl(jsDeclarationsExportAssignedConstructorFunctionWithSub.js, 6, 33)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.types index 175998a419..3c764a6b5d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.types @@ -27,7 +27,7 @@ module.exports.Sub = function() { >module.exports : (p: any) => void >module : { "export=": (p: any) => void; } >exports : (p: any) => void ->Sub : any +>Sub : () => void >function() { this.instance = new module.exports(10);} : () => void this.instance = new module.exports(10); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols index b2e68c2f07..1dcdb59470 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols @@ -33,5 +33,6 @@ module.exports.Strings = Strings; >module.exports : Symbol(export=, Decl(index.js, 3, 2)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(index.js, 3, 2)) +>Strings : Symbol(Strings, Decl(index.js, 10, 2)) >Strings : Symbol(Strings, Decl(index.js, 0, 5)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols.diff index d625cf320c..321f9314d2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.symbols.diff @@ -19,8 +19,8 @@ ->module.exports : Symbol(Strings, Decl(index.js, 10, 2)) ->module : Symbol(module, Decl(index.js, 3, 2)) ->exports : Symbol(module.exports, Decl(index.js, 0, 0)) -->Strings : Symbol(Strings, Decl(index.js, 10, 2)) +>module.exports : Symbol(export=, Decl(index.js, 3, 2)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(index.js, 3, 2)) + >Strings : Symbol(Strings, Decl(index.js, 10, 2)) >Strings : Symbol(Strings, Decl(index.js, 0, 5)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.types index 934820272b..ba5dc7573c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.types @@ -44,6 +44,6 @@ module.exports.Strings = Strings; >module.exports : { thing: string; also: string; desc: { item: string; }; } >module : { "export=": { thing: string; also: string; desc: { item: string; }; }; } >exports : { thing: string; also: string; desc: { item: string; }; } ->Strings : any +>Strings : { a: string; b: string; } >Strings : { a: string; b: string; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.symbols index d03e2da5ce..7fa53c9314 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.symbols @@ -25,6 +25,7 @@ function foo() { } exports.methods = m; >exports : Symbol("index", Decl(index.js, 0, 0)) +>methods : Symbol(methods, Decl(index.js, 7, 5)) >m : Symbol(m, Decl(index.js, 5, 9)) } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.symbols.diff index 10a3348251..622ebe70e3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.symbols.diff @@ -16,7 +16,7 @@ } exports.methods = m; ->exports : Symbol(methods, Decl(index.js, 7, 5)) -->methods : Symbol(methods, Decl(index.js, 7, 5)) +>exports : Symbol("index", Decl(index.js, 0, 0)) + >methods : Symbol(methods, Decl(index.js, 7, 5)) >m : Symbol(m, Decl(index.js, 5, 9)) - } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.types index cd082c13a1..eb97480cb0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.types @@ -41,7 +41,7 @@ function foo() { >exports.methods = m : () => void >exports.methods : any >exports : typeof import(".") ->methods : any +>methods : () => void >m : () => void } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.symbols index b68cc7cae5..e6f5b059ca 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.symbols @@ -24,5 +24,6 @@ module.exports.Strings = Strings; >module.exports : Symbol(Foo, Decl(cls.js, 3, 2)) >module : Symbol(module.exports) >exports : Symbol(Foo, Decl(cls.js, 3, 2)) +>Strings : Symbol(Strings, Decl(cls.js, 5, 21)) >Strings : Symbol(Strings, Decl(cls.js, 0, 5)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.symbols.diff index fbda01c9ed..9dd6a0c1a3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.symbols.diff @@ -17,8 +17,8 @@ ->module.exports : Symbol(Strings, Decl(cls.js, 5, 21)) ->module : Symbol(module, Decl(cls.js, 4, 12)) ->exports : Symbol(module.exports, Decl(cls.js, 0, 0)) -->Strings : Symbol(Strings, Decl(cls.js, 5, 21)) +>module.exports : Symbol(Foo, Decl(cls.js, 3, 2)) +>module : Symbol(module.exports) +>exports : Symbol(Foo, Decl(cls.js, 3, 2)) + >Strings : Symbol(Strings, Decl(cls.js, 5, 21)) >Strings : Symbol(Strings, Decl(cls.js, 0, 5)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.types index 2bc348dc16..2232cf861d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.types @@ -30,6 +30,6 @@ module.exports.Strings = Strings; >module.exports : typeof Foo >module : { Foo: typeof Foo; } >exports : typeof Foo ->Strings : any +>Strings : { a: string; b: string; } >Strings : { a: string; b: string; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types index 1f12a7c093..fbaba50105 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types @@ -30,22 +30,22 @@ module.exports = Timer; * @param {HookHandler} handle */ function Hook(handle) { ->Hook : (handle: (arg: any) => void) => void ->handle : (arg: any) => void +>Hook : (handle: HookHandler) => void +>handle : HookHandler this.handle = handle; ->this.handle = handle : (arg: any) => void +>this.handle = handle : HookHandler >this.handle : any >this : any >handle : any ->handle : (arg: any) => void +>handle : HookHandler } module.exports = Hook; ->module.exports = Hook : (handle: (arg: any) => void) => void ->module.exports : (handle: (arg: any) => void) => void ->module : { Hook(handle: (arg: any) => void): void; } ->exports : (handle: (arg: any) => void) => void ->Hook : (handle: (arg: any) => void) => void +>module.exports = Hook : (handle: HookHandler) => void +>module.exports : (handle: HookHandler) => void +>module : { Hook(handle: HookHandler): void; } +>exports : (handle: HookHandler) => void +>Hook : (handle: HookHandler) => void === context.js === /** diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.types index 4eb595b0e1..49f3bef3d1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.types @@ -8,31 +8,31 @@ * @type {Item}; */ const x = {x: 12}; ->x : { x: number; } +>x : Item >{x: 12} : { x: number; } >x : number >12 : 12 module.exports = x; ->module.exports = x : { x: number; } ->module.exports : { x: number; } ->module : { readonly x: { x: number; }; } ->exports : { x: number; } ->x : { x: number; } +>module.exports = x : Item +>module.exports : Item +>module : { readonly x: Item; } +>exports : Item +>x : Item === index.js === /** @type {(typeof import("./folder/mod1"))[]} */ const items = [{x: 12}]; ->items : { x: number; }[] +>items : import("./folder/mod1").Item[] >[{x: 12}] : { x: number; }[] >{x: 12} : { x: number; } >x : number >12 : 12 module.exports = items; ->module.exports = items : { x: number; }[] ->module.exports : { x: number; }[] ->module : { readonly items: { x: number; }[]; } ->exports : { x: number; }[] ->items : { x: number; }[] +>module.exports = items : import("./folder/mod1").Item[] +>module.exports : import("./folder/mod1").Item[] +>module : { readonly items: import("./folder/mod1").Item[]; } +>exports : import("./folder/mod1").Item[] +>items : import("./folder/mod1").Item[] diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.types index 1d1480068b..677dc340b5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.types @@ -38,7 +38,7 @@ export {}; // flag file as module * @returns {SomeType} */ function doTheThing(x) { ->doTheThing : (x: number) => number | ExportedThing | LocalThing | { x: string; } +>doTheThing : (x: number) => SomeType >x : number return {x: ""+x}; @@ -56,14 +56,14 @@ class ExportedThing { >"ok" : "ok" } module.exports = { ->module.exports = { doTheThing, ExportedThing,} : { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; } ->module.exports : { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; } ->module : { "export=": { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; }; } ->exports : { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; } ->{ doTheThing, ExportedThing,} : { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; } +>module.exports = { doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } +>module.exports : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } +>module : { "export=": { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; }; } +>exports : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } +>{ doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } doTheThing, ->doTheThing : (x: number) => number | ExportedThing | LocalThing | { x: string; } +>doTheThing : (x: number) => SomeType ExportedThing, >ExportedThing : typeof ExportedThing diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.types index f0d37471f2..7189bdfc45 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.types @@ -16,9 +16,9 @@ let id = 0 * @returns {Promise} */ const send = handlers => new Promise((resolve, reject) => { ->send : (handlers: { [id: string]: [Function, Function]; }) => Promise ->handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : (handlers: { [id: string]: [Function, Function]; }) => Promise ->handlers : { [id: string]: [Function, Function]; } +>send : (handlers: ResolveRejectMap) => Promise +>handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : (handlers: ResolveRejectMap) => Promise +>handlers : ResolveRejectMap >new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : Promise >Promise : PromiseConstructor >(resolve, reject) => { handlers[++id] = [resolve, reject]} : (resolve: (value: any) => void, reject: (reason?: any) => void) => void @@ -28,7 +28,7 @@ const send = handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject] >handlers[++id] = [resolve, reject] : [(value: any) => void, (reason?: any) => void] >handlers[++id] : [Function, Function] ->handlers : { [id: string]: [Function, Function]; } +>handlers : ResolveRejectMap >++id : number >id : number >[resolve, reject] : [(value: any) => void, (reason?: any) => void] diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.types index 8594128d60..b3ed24d8fa 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.types @@ -29,16 +29,16 @@ class Foo { * @return {T} */ foo(x, y, alpha) { ->foo : (x: T, y: (t: T) => T, alpha: (t: T) => T) => T +>foo : (x: T, y: Id, alpha: (t: T) => T) => T >x : T ->y : (t: T) => T +>y : Id >alpha : (t: T) => T return alpha(y(x)) >alpha(y(x)) : T >alpha : (t: T) => T >y(x) : T ->y : (t: T) => T +>y : Id >x : T } } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt deleted file mode 100644 index 7dc6690cfb..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt +++ /dev/null @@ -1,112 +0,0 @@ -a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -a.js(14,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -a.js(26,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -a.js(37,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -a.js(48,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -a.js(59,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -a.js(68,18): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - - -==== a.js (7 errors) ==== - /** - * @template const T - ~~~~~ -!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - * @param {T} x - * @returns {T} - */ - function f1(x) { - return x; - } - const t1 = f1("a"); - const t2 = f1(["a", ["b", "c"]]); - const t3 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); - - /** - * @template const T, U - ~~~~~ -!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - * @param {T} x - * @returns {T} - */ - function f2(x) { - return x; - }; - const t4 = f2('a'); - const t5 = f2(['a', ['b', 'c']]); - const t6 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); - - /** - * @template const T - ~~~~~ -!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - * @param {T} x - * @returns {T[]} - */ - function f3(x) { - return [x]; - } - const t7 = f3("hello"); - const t8 = f3("hello"); - - /** - * @template const T - ~~~~~ -!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - * @param {[T, T]} x - * @returns {T} - */ - function f4(x) { - return x[0]; - } - const t9 = f4([[1, "x"], [2, "y"]]); - const t10 = f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]); - - /** - * @template const T - ~~~~~ -!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - * @param {{ x: T, y: T}} obj - * @returns {T} - */ - function f5(obj) { - return obj.x; - } - const t11 = f5({ x: [1, "x"], y: [2, "y"] }); - const t12 = f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }); - - /** - * @template const T - ~~~~~ -!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - */ - class C { - /** - * @param {T} x - */ - constructor(x) {} - - /** - * @template const U - ~~~~~ -!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - * @param {U} x - */ - foo(x) { - return x; - } - } - - const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); - const t14 = t13.foo(["a", ["b", "c"]]); - - /** - * @template {readonly unknown[]} const T - * @param {T} args - * @returns {T} - */ - function f6(...args) { - return args; - } - const t15 = f6(1, 'b', { a: 1, b: 'x' }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt index dcc4c36af3..6d5770242e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt @@ -1,9 +1,8 @@ a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -a.js(7,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter -==== a.js (3 errors) ==== +==== a.js (2 errors) ==== /** * @template const T ~~~~~ @@ -13,8 +12,6 @@ a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter /** * @template const T - ~~~~~ -!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class */ class C { } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types index 33c2ea62d1..352e96b960 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types @@ -8,25 +8,25 @@ /** @type {A} */ // ok, default for `T` in `A` is `string` const aDefault1 = [""]; ->aDefault1 : [string] +>aDefault1 : A >[""] : [string] >"" : "" /** @type {A} */ // error: `number` is not assignable to string` const aDefault2 = [0]; ->aDefault2 : [string] +>aDefault2 : A >[0] : [number] >0 : 0 /** @type {A} */ // ok, `T` is provided for `A` const aString = [""]; ->aString : [string] +>aString : A >[""] : [string] >"" : "" /** @type {A} */ // ok, `T` is provided for `A` const aNumber = [0]; ->aNumber : [number] +>aNumber : A >[0] : [number] >0 : 0 diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAlias.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportAlias.symbols index db9cea396e..2bba22ef22 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAlias.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAlias.symbols @@ -75,6 +75,7 @@ exportsAlias.func1 = function () { }; exports.func2 = function () { }; >exports : Symbol("b", Decl(b.js, 0, 0)) +>func2 : Symbol(func2, Decl(b.js, 1, 37)) var moduleExportsAlias = module.exports; >moduleExportsAlias : Symbol(moduleExportsAlias, Decl(b.js, 4, 3)) @@ -89,6 +90,7 @@ module.exports.func4 = function () { }; >module.exports : Symbol(export=, Decl(b.js, 41, 40)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(b.js, 41, 40)) +>func4 : Symbol(func4, Decl(b.js, 5, 43)) var multipleDeclarationAlias1 = exports = module.exports; >multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) @@ -160,11 +162,13 @@ exports = module.exports = someOtherVariable = {}; exports.func11 = function () { }; >exports : Symbol("b", Decl(b.js, 0, 0)) +>func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) module.exports.func12 = function () { }; >module.exports : Symbol(export=, Decl(b.js, 41, 40)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(b.js, 41, 40)) +>func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) exports = module.exports = someOtherVariable = {}; >exports : Symbol("b", Decl(b.js, 0, 0)) @@ -175,11 +179,13 @@ exports = module.exports = someOtherVariable = {}; exports.func11 = function () { }; >exports : Symbol("b", Decl(b.js, 0, 0)) +>func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) module.exports.func12 = function () { }; >module.exports : Symbol(export=, Decl(b.js, 41, 40)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(b.js, 41, 40)) +>func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) exports = module.exports = {}; >exports : Symbol("b", Decl(b.js, 0, 0)) @@ -189,11 +195,13 @@ exports = module.exports = {}; exports.func13 = function () { }; >exports : Symbol("b", Decl(b.js, 0, 0)) +>func13 : Symbol(func13, Decl(b.js, 35, 30)) module.exports.func14 = function () { }; >module.exports : Symbol(export=, Decl(b.js, 41, 40)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(b.js, 41, 40)) +>func14 : Symbol(func14, Decl(b.js, 36, 33)) exports = module.exports = {}; >exports : Symbol("b", Decl(b.js, 0, 0)) @@ -203,11 +211,13 @@ exports = module.exports = {}; exports.func15 = function () { }; >exports : Symbol("b", Decl(b.js, 0, 0)) +>func15 : Symbol(func15, Decl(b.js, 39, 30)) module.exports.func16 = function () { }; >module.exports : Symbol(export=, Decl(b.js, 41, 40)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(b.js, 41, 40)) +>func16 : Symbol(func16, Decl(b.js, 40, 33)) module.exports = exports = {}; >module.exports : Symbol(export=, Decl(b.js, 41, 40)) @@ -217,11 +227,13 @@ module.exports = exports = {}; exports.func17 = function () { }; >exports : Symbol("b", Decl(b.js, 0, 0)) +>func17 : Symbol(func17, Decl(b.js, 43, 30)) module.exports.func18 = function () { }; >module.exports : Symbol(export=, Decl(b.js, 41, 40)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(b.js, 41, 40)) +>func18 : Symbol(func18, Decl(b.js, 44, 33)) module.exports = {}; >module.exports : Symbol(export=, Decl(b.js, 41, 40)) @@ -230,10 +242,12 @@ module.exports = {}; exports.func19 = function () { }; >exports : Symbol("b", Decl(b.js, 0, 0)) +>func19 : Symbol(func19, Decl(b.js, 47, 20)) module.exports.func20 = function () { }; >module.exports : Symbol(export=, Decl(b.js, 41, 40)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(b.js, 41, 40)) +>func20 : Symbol(func20, Decl(b.js, 48, 33)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAlias.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAlias.symbols.diff index 7c68f5c1af..997672a24d 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAlias.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAlias.symbols.diff @@ -116,8 +116,8 @@ exports.func2 = function () { }; ->exports.func2 : Symbol(func2, Decl(b.js, 1, 37)) ->exports : Symbol(func2, Decl(b.js, 1, 37)) -->func2 : Symbol(func2, Decl(b.js, 1, 37)) +>exports : Symbol("b", Decl(b.js, 0, 0)) + >func2 : Symbol(func2, Decl(b.js, 1, 37)) var moduleExportsAlias = module.exports; >moduleExportsAlias : Symbol(moduleExportsAlias, Decl(b.js, 4, 3)) @@ -138,10 +138,10 @@ ->module.exports : Symbol(func4, Decl(b.js, 5, 43)) ->module : Symbol(module, Decl(b.js, 4, 24)) ->exports : Symbol(module.exports, Decl(b.js, 0, 0)) -->func4 : Symbol(func4, Decl(b.js, 5, 43)) +>module.exports : Symbol(export=, Decl(b.js, 41, 40)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(b.js, 41, 40)) + >func4 : Symbol(func4, Decl(b.js, 5, 43)) var multipleDeclarationAlias1 = exports = module.exports; >multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) @@ -175,7 +175,7 @@ var someOtherVariable; >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) -@@= skipped -60, +48 lines =@@ +@@= skipped -60, +50 lines =@@ >exports : Symbol("b", Decl(b.js, 0, 0)) multipleDeclarationAlias3.func7 = function () { }; @@ -227,74 +227,58 @@ ->multipleDeclarationAlias6.func10 : Symbol(func10, Decl(b.js, 24, 62)) >multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) ->func10 : Symbol(func10, Decl(b.js, 24, 62)) -- --exports = module.exports = someOtherVariable = {}; -->exports : Symbol("b", Decl(b.js, 0, 0)) + + exports = module.exports = someOtherVariable = {}; + >exports : Symbol("b", Decl(b.js, 0, 0)) ->module.exports : Symbol(module.exports, Decl(b.js, 0, 0)) ->module : Symbol(module, Decl(b.js, 4, 24)) ->exports : Symbol(module.exports, Decl(b.js, 0, 0)) -->someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) -- --exports.func11 = function () { }; ++>module.exports : Symbol(export=, Decl(b.js, 41, 40)) ++>module : Symbol(module.exports) ++>exports : Symbol(export=, Decl(b.js, 41, 40)) + >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + + exports.func11 = function () { }; ->exports.func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) ->exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) -->func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) -- --module.exports.func12 = function () { }; ++>exports : Symbol("b", Decl(b.js, 0, 0)) + >func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) + + module.exports.func12 = function () { }; ->module.exports.func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) ->module.exports : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) ->module : Symbol(module, Decl(b.js, 4, 24)) ->exports : Symbol(module.exports, Decl(b.js, 0, 0)) -->func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) -- --exports = module.exports = someOtherVariable = {}; -->exports : Symbol("b", Decl(b.js, 0, 0)) ++>module.exports : Symbol(export=, Decl(b.js, 41, 40)) ++>module : Symbol(module.exports) ++>exports : Symbol(export=, Decl(b.js, 41, 40)) + >func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) + + exports = module.exports = someOtherVariable = {}; + >exports : Symbol("b", Decl(b.js, 0, 0)) ->module.exports : Symbol(module.exports, Decl(b.js, 0, 0)) ->module : Symbol(module, Decl(b.js, 4, 24)) ->exports : Symbol(module.exports, Decl(b.js, 0, 0)) -->someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) -- --exports.func11 = function () { }; ++>module.exports : Symbol(export=, Decl(b.js, 41, 40)) ++>module : Symbol(module.exports) ++>exports : Symbol(export=, Decl(b.js, 41, 40)) + >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) + + exports.func11 = function () { }; ->exports.func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) ->exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) -->func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) -- --module.exports.func12 = function () { }; ++>exports : Symbol("b", Decl(b.js, 0, 0)) + >func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) + + module.exports.func12 = function () { }; ->module.exports.func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) ->module.exports : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) ->module : Symbol(module, Decl(b.js, 4, 24)) ->exports : Symbol(module.exports, Decl(b.js, 0, 0)) -->func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) -+ -+exports = module.exports = someOtherVariable = {}; -+>exports : Symbol("b", Decl(b.js, 0, 0)) -+>module.exports : Symbol(export=, Decl(b.js, 41, 40)) -+>module : Symbol(module.exports) -+>exports : Symbol(export=, Decl(b.js, 41, 40)) -+>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) -+ -+exports.func11 = function () { }; -+>exports : Symbol("b", Decl(b.js, 0, 0)) -+ -+module.exports.func12 = function () { }; -+>module.exports : Symbol(export=, Decl(b.js, 41, 40)) -+>module : Symbol(module.exports) -+>exports : Symbol(export=, Decl(b.js, 41, 40)) -+ -+exports = module.exports = someOtherVariable = {}; -+>exports : Symbol("b", Decl(b.js, 0, 0)) -+>module.exports : Symbol(export=, Decl(b.js, 41, 40)) -+>module : Symbol(module.exports) -+>exports : Symbol(export=, Decl(b.js, 41, 40)) -+>someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) -+ -+exports.func11 = function () { }; -+>exports : Symbol("b", Decl(b.js, 0, 0)) -+ -+module.exports.func12 = function () { }; +>module.exports : Symbol(export=, Decl(b.js, 41, 40)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(b.js, 41, 40)) + >func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) exports = module.exports = {}; >exports : Symbol("b", Decl(b.js, 0, 0)) @@ -308,18 +292,18 @@ exports.func13 = function () { }; ->exports.func13 : Symbol(func13, Decl(b.js, 35, 30)) ->exports : Symbol(func13, Decl(b.js, 35, 30)) -->func13 : Symbol(func13, Decl(b.js, 35, 30)) +>exports : Symbol("b", Decl(b.js, 0, 0)) + >func13 : Symbol(func13, Decl(b.js, 35, 30)) module.exports.func14 = function () { }; ->module.exports.func14 : Symbol(func14, Decl(b.js, 36, 33)) ->module.exports : Symbol(func14, Decl(b.js, 36, 33)) ->module : Symbol(module, Decl(b.js, 4, 24)) ->exports : Symbol(module.exports, Decl(b.js, 0, 0)) -->func14 : Symbol(func14, Decl(b.js, 36, 33)) +>module.exports : Symbol(export=, Decl(b.js, 41, 40)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(b.js, 41, 40)) + >func14 : Symbol(func14, Decl(b.js, 36, 33)) exports = module.exports = {}; >exports : Symbol("b", Decl(b.js, 0, 0)) @@ -333,18 +317,18 @@ exports.func15 = function () { }; ->exports.func15 : Symbol(func15, Decl(b.js, 39, 30)) ->exports : Symbol(func15, Decl(b.js, 39, 30)) -->func15 : Symbol(func15, Decl(b.js, 39, 30)) +>exports : Symbol("b", Decl(b.js, 0, 0)) + >func15 : Symbol(func15, Decl(b.js, 39, 30)) module.exports.func16 = function () { }; ->module.exports.func16 : Symbol(func16, Decl(b.js, 40, 33)) ->module.exports : Symbol(func16, Decl(b.js, 40, 33)) ->module : Symbol(module, Decl(b.js, 4, 24)) ->exports : Symbol(module.exports, Decl(b.js, 0, 0)) -->func16 : Symbol(func16, Decl(b.js, 40, 33)) +>module.exports : Symbol(export=, Decl(b.js, 41, 40)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(b.js, 41, 40)) + >func16 : Symbol(func16, Decl(b.js, 40, 33)) module.exports = exports = {}; ->module.exports : Symbol(module.exports, Decl(b.js, 0, 0)) @@ -358,18 +342,18 @@ exports.func17 = function () { }; ->exports.func17 : Symbol(func17, Decl(b.js, 43, 30)) ->exports : Symbol(func17, Decl(b.js, 43, 30)) -->func17 : Symbol(func17, Decl(b.js, 43, 30)) +>exports : Symbol("b", Decl(b.js, 0, 0)) + >func17 : Symbol(func17, Decl(b.js, 43, 30)) module.exports.func18 = function () { }; ->module.exports.func18 : Symbol(func18, Decl(b.js, 44, 33)) ->module.exports : Symbol(func18, Decl(b.js, 44, 33)) ->module : Symbol(module, Decl(b.js, 4, 24)) ->exports : Symbol(module.exports, Decl(b.js, 0, 0)) -->func18 : Symbol(func18, Decl(b.js, 44, 33)) +>module.exports : Symbol(export=, Decl(b.js, 41, 40)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(b.js, 41, 40)) + >func18 : Symbol(func18, Decl(b.js, 44, 33)) module.exports = {}; ->module.exports : Symbol(module.exports, Decl(b.js, 0, 0)) @@ -382,16 +366,16 @@ exports.func19 = function () { }; ->exports.func19 : Symbol(func19, Decl(b.js, 47, 20)) ->exports : Symbol(func19, Decl(b.js, 47, 20)) -->func19 : Symbol(func19, Decl(b.js, 47, 20)) +>exports : Symbol("b", Decl(b.js, 0, 0)) + >func19 : Symbol(func19, Decl(b.js, 47, 20)) module.exports.func20 = function () { }; ->module.exports.func20 : Symbol(func20, Decl(b.js, 48, 33)) ->module.exports : Symbol(func20, Decl(b.js, 48, 33)) ->module : Symbol(module, Decl(b.js, 4, 24)) ->exports : Symbol(module.exports, Decl(b.js, 0, 0)) -->func20 : Symbol(func20, Decl(b.js, 48, 33)) +>module.exports : Symbol(export=, Decl(b.js, 41, 40)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(b.js, 41, 40)) + >func20 : Symbol(func20, Decl(b.js, 48, 33)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAlias.types b/testdata/baselines/reference/submodule/conformance/moduleExportAlias.types index c1a0b90c39..fbeca727fe 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAlias.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAlias.types @@ -121,7 +121,7 @@ exports.func2 = function () { }; >exports.func2 = function () { } : () => void >exports.func2 : any >exports : typeof import("./b") ->func2 : any +>func2 : () => void >function () { } : () => void var moduleExportsAlias = module.exports; @@ -143,7 +143,7 @@ module.exports.func4 = function () { }; >module.exports : {} >module : { "export=": {}; } >exports : {} ->func4 : any +>func4 : () => void >function () { } : () => void var multipleDeclarationAlias1 = exports = module.exports; @@ -256,7 +256,7 @@ exports.func11 = function () { }; >exports.func11 = function () { } : () => void >exports.func11 : any >exports : typeof import("./b") ->func11 : any +>func11 : () => void >function () { } : () => void module.exports.func12 = function () { }; @@ -265,7 +265,7 @@ module.exports.func12 = function () { }; >module.exports : {} >module : { "export=": {}; } >exports : {} ->func12 : any +>func12 : () => void >function () { } : () => void exports = module.exports = someOtherVariable = {}; @@ -283,7 +283,7 @@ exports.func11 = function () { }; >exports.func11 = function () { } : () => void >exports.func11 : any >exports : typeof import("./b") ->func11 : any +>func11 : () => void >function () { } : () => void module.exports.func12 = function () { }; @@ -292,7 +292,7 @@ module.exports.func12 = function () { }; >module.exports : {} >module : { "export=": {}; } >exports : {} ->func12 : any +>func12 : () => void >function () { } : () => void exports = module.exports = {}; @@ -308,7 +308,7 @@ exports.func13 = function () { }; >exports.func13 = function () { } : () => void >exports.func13 : any >exports : typeof import("./b") ->func13 : any +>func13 : () => void >function () { } : () => void module.exports.func14 = function () { }; @@ -317,7 +317,7 @@ module.exports.func14 = function () { }; >module.exports : {} >module : { "export=": {}; } >exports : {} ->func14 : any +>func14 : () => void >function () { } : () => void exports = module.exports = {}; @@ -333,7 +333,7 @@ exports.func15 = function () { }; >exports.func15 = function () { } : () => void >exports.func15 : any >exports : typeof import("./b") ->func15 : any +>func15 : () => void >function () { } : () => void module.exports.func16 = function () { }; @@ -342,7 +342,7 @@ module.exports.func16 = function () { }; >module.exports : {} >module : { "export=": {}; } >exports : {} ->func16 : any +>func16 : () => void >function () { } : () => void module.exports = exports = {}; @@ -358,7 +358,7 @@ exports.func17 = function () { }; >exports.func17 = function () { } : () => void >exports.func17 : any >exports : typeof import("./b") ->func17 : any +>func17 : () => void >function () { } : () => void module.exports.func18 = function () { }; @@ -367,7 +367,7 @@ module.exports.func18 = function () { }; >module.exports : {} >module : { "export=": {}; } >exports : {} ->func18 : any +>func18 : () => void >function () { } : () => void module.exports = {}; @@ -381,7 +381,7 @@ exports.func19 = function () { }; >exports.func19 = function () { } : () => void >exports.func19 : any >exports : typeof import("./b") ->func19 : any +>func19 : () => void >function () { } : () => void module.exports.func20 = function () { }; @@ -390,7 +390,7 @@ module.exports.func20 = function () { }; >module.exports : {} >module : { "export=": {}; } >exports : {} ->func20 : any +>func20 : () => void >function () { } : () => void diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.symbols index b87494dc53..707190491a 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.symbols @@ -17,5 +17,6 @@ module.exports.D = class D { } >module.exports : Symbol(C, Decl(bug24024.js, 2, 16)) >module : Symbol(module.exports) >exports : Symbol(C, Decl(bug24024.js, 2, 16)) +>D : Symbol(D, Decl(bug24024.js, 2, 27)) >D : Symbol(D, Decl(bug24024.js, 3, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.symbols.diff index eb88743e90..043c63a645 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.symbols.diff @@ -23,4 +23,5 @@ +>module.exports : Symbol(C, Decl(bug24024.js, 2, 16)) +>module : Symbol(module.exports) +>exports : Symbol(C, Decl(bug24024.js, 2, 16)) ++>D : Symbol(D, Decl(bug24024.js, 2, 27)) +>D : Symbol(D, Decl(bug24024.js, 3, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.types b/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.types index 5bdcdbf1b4..0a70bddce0 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAlias4.types @@ -22,7 +22,7 @@ module.exports.D = class D { } >module.exports : typeof wat >module : { C: typeof wat; } >exports : typeof wat ->D : any +>D : typeof D >class D { } : typeof D >D : typeof D diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.types b/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.types index e8e3ae4cbe..7b52d06f08 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.types @@ -8,7 +8,7 @@ exports["D"] = D; >exports["D"] = D : () => void >exports["D"] : () => void >exports : typeof import("./moduleExportAliasElementAccessExpression") ->"D" : "D" +>"D" : () => void >D : () => void // (the only package I could find that uses spaces in identifiers is webidl-conversions) @@ -16,6 +16,6 @@ exports["Does not work yet"] = D; >exports["Does not work yet"] = D : () => void >exports["Does not work yet"] : () => void >exports : typeof import("./moduleExportAliasElementAccessExpression") ->"Does not work yet" : "Does not work yet" +>"Does not work yet" : () => void >D : () => void diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.symbols index 7f1206e1a5..6f8bcd86e4 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.symbols @@ -3,6 +3,7 @@ === bug28014.js === exports.version = 1 >exports : Symbol("bug28014", Decl(bug28014.js, 0, 0)) +>version : Symbol(version, Decl(bug28014.js, 0, 0)) function alias() { } >alias : Symbol(alias, Decl(bug28014.js, 0, 19)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.symbols.diff index 3de71be421..052bd5f1ab 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.symbols.diff @@ -6,8 +6,8 @@ exports.version = 1 ->exports.version : Symbol(version, Decl(bug28014.js, 0, 0)) ->exports : Symbol(version, Decl(bug28014.js, 0, 0)) -->version : Symbol(version, Decl(bug28014.js, 0, 0)) +>exports : Symbol("bug28014", Decl(bug28014.js, 0, 0)) + >version : Symbol(version, Decl(bug28014.js, 0, 0)) function alias() { } >alias : Symbol(alias, Decl(bug28014.js, 0, 19)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types index 8aae436c98..853d3adb4c 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types @@ -5,7 +5,7 @@ exports.version = 1 >exports.version = 1 : 1 >exports.version : any >exports : typeof import("./bug28014") ->version : any +>version : 1 >1 : 1 function alias() { } diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasUnknown.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportAliasUnknown.symbols index 33e6b8ac42..354fc497a9 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasUnknown.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasUnknown.symbols @@ -9,4 +9,5 @@ module.exports = window.nonprop; exports.foo = bar; >exports : Symbol("bug27025", Decl(bug27025.js, 0, 0)) +>foo : Symbol(foo, Decl(bug27025.js, 0, 32)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasUnknown.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAliasUnknown.symbols.diff index 179701bcbd..930775c079 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasUnknown.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasUnknown.symbols.diff @@ -14,5 +14,5 @@ exports.foo = bar; ->exports : Symbol(foo, Decl(bug27025.js, 0, 32)) -->foo : Symbol(foo, Decl(bug27025.js, 0, 32)) +>exports : Symbol("bug27025", Decl(bug27025.js, 0, 0)) + >foo : Symbol(foo, Decl(bug27025.js, 0, 32)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.symbols index 723e4e6100..77637d117b 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.symbols @@ -3,6 +3,7 @@ === async.js === exports.default = { m: 1, a: 1 } >exports : Symbol("async", Decl(async.js, 0, 0)) +>default : Symbol(default, Decl(async.js, 0, 0)) >m : Symbol(m, Decl(async.js, 0, 19)) >a : Symbol(a, Decl(async.js, 0, 25)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.symbols.diff index 2ea079bfe5..b1450f31be 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.symbols.diff @@ -5,8 +5,8 @@ === async.js === exports.default = { m: 1, a: 1 } ->exports : Symbol(default, Decl(async.js, 0, 0)) -->default : Symbol(default, Decl(async.js, 0, 0)) +>exports : Symbol("async", Decl(async.js, 0, 0)) + >default : Symbol(default, Decl(async.js, 0, 0)) >m : Symbol(m, Decl(async.js, 0, 19)) >a : Symbol(a, Decl(async.js, 0, 25)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.types b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.types index 155e39e2e2..2030ce4503 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment4.types @@ -5,7 +5,7 @@ exports.default = { m: 1, a: 1 } >exports.default = { m: 1, a: 1 } : { m: number; a: number; } >exports.default : any >exports : typeof import("./async") ->default : any +>default : { m: number; a: number; } >{ m: 1, a: 1 } : { m: number; a: number; } >m : number >1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.symbols index e1144e754b..73fbdc5ef8 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.symbols @@ -29,5 +29,6 @@ module.exports.default = axios; >module.exports : Symbol(axios, Decl(axios.js, 5, 3)) >module : Symbol(module.exports) >exports : Symbol(axios, Decl(axios.js, 5, 3)) +>default : Symbol(default, Decl(axios.js, 8, 23)) >axios : Symbol(axios, Decl(axios.js, 5, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.symbols.diff index 8bddad8825..3a6d0a5407 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.symbols.diff @@ -33,8 +33,8 @@ ->module.exports : Symbol(default, Decl(axios.js, 8, 23)) ->module : Symbol(module, Decl(axios.js, 7, 9)) ->exports : Symbol(module.exports, Decl(axios.js, 0, 0)) -->default : Symbol(default, Decl(axios.js, 8, 23)) +>module.exports : Symbol(axios, Decl(axios.js, 5, 3)) +>module : Symbol(module.exports) +>exports : Symbol(axios, Decl(axios.js, 5, 3)) + >default : Symbol(default, Decl(axios.js, 8, 23)) >axios : Symbol(axios, Decl(axios.js, 5, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.types b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.types index 68d421dd4e..012970f595 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment5.types @@ -34,6 +34,6 @@ module.exports.default = axios; >module.exports : Axios >module : { axios: Axios; } >exports : Axios ->default : any +>default : Axios >axios : Axios diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.symbols index 49ff0d0d69..bc9feb80c2 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.symbols @@ -14,5 +14,6 @@ module.exports.default = axios >module.exports : Symbol(axios, Decl(axios.js, 0, 3)) >module : Symbol(module.exports) >exports : Symbol(axios, Decl(axios.js, 0, 3)) +>default : Symbol(default, Decl(axios.js, 1, 22)) >axios : Symbol(axios, Decl(axios.js, 0, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.symbols.diff index d12f7626db..0fdd48e9aa 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.symbols.diff @@ -17,8 +17,8 @@ ->module.exports : Symbol(default, Decl(axios.js, 1, 22)) ->module : Symbol(module, Decl(axios.js, 0, 14)) ->exports : Symbol(module.exports, Decl(axios.js, 0, 0)) -->default : Symbol(default, Decl(axios.js, 1, 22)) +>module.exports : Symbol(axios, Decl(axios.js, 0, 3)) +>module : Symbol(module.exports) +>exports : Symbol(axios, Decl(axios.js, 0, 3)) + >default : Symbol(default, Decl(axios.js, 1, 22)) >axios : Symbol(axios, Decl(axios.js, 0, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.types b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.types index 722a2dd211..4d8af48105 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.types @@ -18,6 +18,6 @@ module.exports.default = axios >module.exports : {} >module : { axios: {}; } >exports : {} ->default : any +>default : {} >axios : {} diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.symbols index 72949ef09f..24841a0c3b 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.symbols @@ -34,5 +34,6 @@ module.exports.f = function (a) { } >module.exports : Symbol(export=, Decl(mod1.js, 0, 0)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(mod1.js, 0, 0)) +>f : Symbol(f, Decl(mod1.js, 1, 32)) >a : Symbol(a, Decl(mod1.js, 3, 29)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.symbols.diff index 1f47a437b4..39f31df60d 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.symbols.diff @@ -26,8 +26,8 @@ ->module.exports : Symbol(f, Decl(mod1.js, 1, 32)) ->module : Symbol(module, Decl(mod1.js, 0, 0)) ->exports : Symbol(module.exports, Decl(mod1.js, 0, 0)) -->f : Symbol(f, Decl(mod1.js, 1, 32)) +>module.exports : Symbol(export=, Decl(mod1.js, 0, 0)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(mod1.js, 0, 0)) + >f : Symbol(f, Decl(mod1.js, 1, 32)) >a : Symbol(a, Decl(mod1.js, 3, 29)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.types b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.types index ee42485873..aa185d0bff 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment.types @@ -43,7 +43,7 @@ module.exports.f = function (a) { } >module.exports : () => void >module : { "export=": () => void; } >exports : () => void ->f : any +>f : (a: any) => void >function (a) { } : (a: any) => void >a : any diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.symbols index ab4d96a505..d503b48b98 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.symbols @@ -35,4 +35,5 @@ module.exports.f = function () { } >module.exports : Symbol(export=, Decl(mod1.js, 0, 0)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(mod1.js, 0, 0)) +>f : Symbol(f, Decl(mod1.js, 1, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.symbols.diff index 3f7dac72aa..f57088913f 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.symbols.diff @@ -26,7 +26,7 @@ ->module.exports : Symbol(f, Decl(mod1.js, 1, 18)) ->module : Symbol(module, Decl(mod1.js, 0, 0)) ->exports : Symbol(module.exports, Decl(mod1.js, 0, 0)) -->f : Symbol(f, Decl(mod1.js, 1, 18)) +>module.exports : Symbol(export=, Decl(mod1.js, 0, 0)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(mod1.js, 0, 0)) + >f : Symbol(f, Decl(mod1.js, 1, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.types b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.types index 8c1b21c209..99ade937ce 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment2.types @@ -45,6 +45,6 @@ module.exports.f = function () { } >module.exports : 1 >module : { "export=": 1; } >exports : 1 ->f : any +>f : () => void >function () { } : () => void diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.symbols index 98651fb010..c64bb0e83f 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.symbols @@ -47,7 +47,7 @@ module.exports.bothBefore = 'string' >module.exports : Symbol(export=, Decl(mod1.js, 1, 36)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(mod1.js, 1, 36)) ->bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18)) +>bothBefore : Symbol(bothBefore, Decl(mod1.js, 0, 0)) module.exports = { >module.exports : Symbol(export=, Decl(mod1.js, 1, 36)) @@ -68,10 +68,11 @@ module.exports.bothAfter = 'string' >module.exports : Symbol(export=, Decl(mod1.js, 1, 36)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(mod1.js, 1, 36)) ->bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18)) +>bothAfter : Symbol(bothAfter, Decl(mod1.js, 6, 1)) module.exports.justProperty = 'string' >module.exports : Symbol(export=, Decl(mod1.js, 1, 36)) >module : Symbol(module.exports) >exports : Symbol(export=, Decl(mod1.js, 1, 36)) +>justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.symbols.diff index 197654e3e3..2274077249 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.symbols.diff @@ -47,12 +47,11 @@ ->module.exports : Symbol(bothBefore, Decl(mod1.js, 0, 0)) ->module : Symbol(module, Decl(mod1.js, 0, 0)) ->exports : Symbol(module.exports, Decl(mod1.js, 0, 0)) -->bothBefore : Symbol(bothBefore, Decl(mod1.js, 0, 0)) +>module.exports.bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18)) +>module.exports : Symbol(export=, Decl(mod1.js, 1, 36)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(mod1.js, 1, 36)) -+>bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18)) + >bothBefore : Symbol(bothBefore, Decl(mod1.js, 0, 0)) module.exports = { ->module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0)) @@ -70,19 +69,18 @@ ->module.exports : Symbol(bothAfter, Decl(mod1.js, 6, 1)) ->module : Symbol(module, Decl(mod1.js, 0, 0)) ->exports : Symbol(module.exports, Decl(mod1.js, 0, 0)) -->bothAfter : Symbol(bothAfter, Decl(mod1.js, 6, 1)) +>module.exports.bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18)) +>module.exports : Symbol(export=, Decl(mod1.js, 1, 36)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(mod1.js, 1, 36)) -+>bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18)) + >bothAfter : Symbol(bothAfter, Decl(mod1.js, 6, 1)) module.exports.justProperty = 'string' ->module.exports.justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35)) ->module.exports : Symbol(justProperty, Decl(mod1.js, 7, 35)) ->module : Symbol(module, Decl(mod1.js, 0, 0)) ->exports : Symbol(module.exports, Decl(mod1.js, 0, 0)) -->justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35)) +>module.exports : Symbol(export=, Decl(mod1.js, 1, 36)) +>module : Symbol(module.exports) +>exports : Symbol(export=, Decl(mod1.js, 1, 36)) + >justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.types b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.types index f3b476d806..837b8ef76b 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.types @@ -56,7 +56,7 @@ module.exports.bothBefore = 'string' >module.exports : { justExport: number; bothBefore: number; bothAfter: number; } >module : { "export=": { justExport: number; bothBefore: number; bothAfter: number; }; } >exports : { justExport: number; bothBefore: number; bothAfter: number; } ->bothBefore : number +>bothBefore : "string" >'string' : "string" module.exports = { @@ -84,7 +84,7 @@ module.exports.bothAfter = 'string' >module.exports : { justExport: number; bothBefore: number; bothAfter: number; } >module : { "export=": { justExport: number; bothBefore: number; bothAfter: number; }; } >exports : { justExport: number; bothBefore: number; bothAfter: number; } ->bothAfter : number +>bothAfter : "string" >'string' : "string" module.exports.justProperty = 'string' @@ -93,6 +93,6 @@ module.exports.justProperty = 'string' >module.exports : { justExport: number; bothBefore: number; bothAfter: number; } >module : { "export=": { justExport: number; bothBefore: number; bothAfter: number; }; } >exports : { justExport: number; bothBefore: number; bothAfter: number; } ->justProperty : any +>justProperty : "string" >'string' : "string" diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.symbols index b236c055da..996bd6e42d 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.symbols @@ -47,7 +47,7 @@ module.exports.bothBefore = 'string' >module.exports : Symbol(A, Decl(mod1.js, 5, 18)) >module : Symbol(module.exports) >exports : Symbol(A, Decl(mod1.js, 5, 18)) ->bothBefore : Symbol(bothBefore, Decl(mod1.js, 2, 16)) +>bothBefore : Symbol(bothBefore, Decl(mod1.js, 0, 0)) A.justExport = 4 >A.justExport : Symbol(justExport, Decl(mod1.js, 1, 36)) @@ -80,10 +80,11 @@ module.exports.bothAfter = 'string' >module.exports : Symbol(A, Decl(mod1.js, 5, 18)) >module : Symbol(module.exports) >exports : Symbol(A, Decl(mod1.js, 5, 18)) ->bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16)) +>bothAfter : Symbol(bothAfter, Decl(mod1.js, 8, 1)) module.exports.justProperty = 'string' >module.exports : Symbol(A, Decl(mod1.js, 5, 18)) >module : Symbol(module.exports) >exports : Symbol(A, Decl(mod1.js, 5, 18)) +>justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.symbols.diff index 1c0d1c740e..b077f732f4 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.symbols.diff @@ -54,7 +54,7 @@ +>module.exports : Symbol(A, Decl(mod1.js, 5, 18)) +>module : Symbol(module.exports) +>exports : Symbol(A, Decl(mod1.js, 5, 18)) -+>bothBefore : Symbol(bothBefore, Decl(mod1.js, 2, 16)) ++>bothBefore : Symbol(bothBefore, Decl(mod1.js, 0, 0)) A.justExport = 4 ->A.justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36)) @@ -109,14 +109,14 @@ +>module.exports : Symbol(A, Decl(mod1.js, 5, 18)) +>module : Symbol(module.exports) +>exports : Symbol(A, Decl(mod1.js, 5, 18)) -+>bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16)) ++>bothAfter : Symbol(bothAfter, Decl(mod1.js, 8, 1)) module.exports.justProperty = 'string' ->module.exports.justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35)) ->module.exports : Symbol(justProperty, Decl(mod1.js, 9, 35)) ->module : Symbol(module, Decl(mod1.js, 0, 0)) ->exports : Symbol(module.exports, Decl(mod1.js, 0, 0)) -->justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35)) +>module.exports : Symbol(A, Decl(mod1.js, 5, 18)) +>module : Symbol(module.exports) +>exports : Symbol(A, Decl(mod1.js, 5, 18)) + >justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.types b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.types index 48e342babc..f39707c789 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment4.types @@ -56,7 +56,7 @@ module.exports.bothBefore = 'string' >module.exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } >module : { A: { (): void; justExport: number; bothBefore: number; bothAfter: number; }; } >exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } ->bothBefore : number +>bothBefore : "string" >'string' : "string" A.justExport = 4 @@ -103,7 +103,7 @@ module.exports.bothAfter = 'string' >module.exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } >module : { A: { (): void; justExport: number; bothBefore: number; bothAfter: number; }; } >exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } ->bothAfter : number +>bothAfter : "string" >'string' : "string" module.exports.justProperty = 'string' @@ -112,6 +112,6 @@ module.exports.justProperty = 'string' >module.exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } >module : { A: { (): void; justExport: number; bothBefore: number; bothAfter: number; }; } >exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } ->justProperty : any +>justProperty : "string" >'string' : "string" diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.types b/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.types index c84643db7c..861ad3cd3e 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.types @@ -53,7 +53,7 @@ exports["b"] = { x: "x" }; >exports["b"] = { x: "x" } : { x: string; } >exports["b"] : { x: string; } >exports : typeof import("./mod1") ->"b" : "b" +>"b" : { x: string; } >{ x: "x" } : { x: string; } >x : string >"x" : "x" @@ -62,7 +62,7 @@ exports["default"] = { x: "x" }; >exports["default"] = { x: "x" } : { x: string; } >exports["default"] : { x: string; } >exports : typeof import("./mod1") ->"default" : "default" +>"default" : { x: string; } >{ x: "x" } : { x: string; } >x : string >"x" : "x" @@ -73,7 +73,7 @@ module.exports["c"] = { x: "x" }; >module.exports : typeof import("./mod1") >module : { "\"mod1\"": typeof import("./mod1"); } >exports : typeof import("./mod1") ->"c" : "c" +>"c" : { x: string; } >{ x: "x" } : { x: string; } >x : string >"x" : "x" @@ -84,7 +84,7 @@ module["exports"]["d"] = {}; >module["exports"] : typeof import("./mod1") >module : { "\"mod1\"": typeof import("./mod1"); } >"exports" : "exports" ->"d" : "d" +>"d" : {} >{} : {} module["exports"]["d"].e = 0; diff --git a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt index 3fcc55219f..9c2df0fa3e 100644 --- a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt @@ -1,17 +1,11 @@ -bug39372.js(1,36): error TS2456: Type alias 'JsonArray' circularly references itself. -bug39372.js(3,88): error TS2456: Type alias 'Json' circularly references itself. -bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; }'. - Type '{}' is missing the following properties from type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O +bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. + Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -==== bug39372.js (3 errors) ==== +==== bug39372.js (1 errors) ==== /** @typedef {ReadonlyArray} JsonArray */ - ~~~~~~~~~ -!!! error TS2456: Type alias 'JsonArray' circularly references itself. /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ - ~~~~ -!!! error TS2456: Type alias 'Json' circularly references itself. /** * @template T @@ -35,6 +29,6 @@ bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { fo /** @type {XMLObject<{foo:string}>} */ const p = {}; ~ -!!! error TS2322: Type '{}' is not assignable to type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; }'. -!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O +!!! error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. +!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types index 13e0bb4968..e4f14be2e0 100644 --- a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types +++ b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types @@ -26,6 +26,6 @@ /** @type {XMLObject<{foo:string}>} */ const p = {}; ->p : { $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; } +>p : XMLObject<{ foo: string; }> >{} : {} diff --git a/testdata/baselines/reference/submodule/conformance/thisTag3.types b/testdata/baselines/reference/submodule/conformance/thisTag3.types index b62ff516aa..08334eacae 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag3.types +++ b/testdata/baselines/reference/submodule/conformance/thisTag3.types @@ -13,8 +13,8 @@ class C { * @param {string} a */ p = (a) => this.fn("" + a); ->p : (this: { fn(a: string): void; }, a: string) => any ->(a) => this.fn("" + a) : (this: { fn(a: string): void; }, a: string) => any +>p : (this: T, a: string) => any +>(a) => this.fn("" + a) : (this: T, a: string) => any >a : string >this.fn("" + a) : any >this.fn : any diff --git a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols index f4dc35d0c9..815a9d7522 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols +++ b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols @@ -10,7 +10,7 @@ const o1 = { this.b = n => n; >this.b : Symbol(b, Decl(bug25926.js, 0, 23)) ->this : Symbol(__type, Decl(bug25926.js, 0, 11)) +>this : Symbol(o1, Decl(bug25926.js, 0, 11)) >b : Symbol(b, Decl(bug25926.js, 0, 23)) >n : Symbol(n, Decl(bug25926.js, 3, 16)) >n : Symbol(n, Decl(bug25926.js, 3, 16)) @@ -26,14 +26,14 @@ const o2 = { this.e = this.f = m => this.g || m; >this.e : Symbol(e, Decl(bug25926.js, 7, 23)) ->this : Symbol(__type, Decl(bug25926.js, 7, 11)) +>this : Symbol(o2, Decl(bug25926.js, 7, 11)) >e : Symbol(e, Decl(bug25926.js, 7, 23)) >this.f : Symbol(f, Decl(bug25926.js, 7, 46)) ->this : Symbol(__type, Decl(bug25926.js, 7, 11)) +>this : Symbol(o2, Decl(bug25926.js, 7, 11)) >f : Symbol(f, Decl(bug25926.js, 7, 46)) >m : Symbol(m, Decl(bug25926.js, 10, 25)) >this.g : Symbol(g, Decl(bug25926.js, 7, 69)) ->this : Symbol(__type, Decl(bug25926.js, 7, 11)) +>this : Symbol(o2, Decl(bug25926.js, 7, 11)) >g : Symbol(g, Decl(bug25926.js, 7, 69)) >m : Symbol(m, Decl(bug25926.js, 10, 25)) } diff --git a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols.diff b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols.diff index 4d74104c94..09e86615e3 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols.diff @@ -1,24 +1,33 @@ --- old.typeFromContextualThisType.symbols +++ new.typeFromContextualThisType.symbols -@@= skipped -10, +10 lines =@@ +@@= skipped -9, +9 lines =@@ + this.b = n => n; >this.b : Symbol(b, Decl(bug25926.js, 0, 23)) - >this : Symbol(__type, Decl(bug25926.js, 0, 11)) +->this : Symbol(__type, Decl(bug25926.js, 0, 11)) ->b : Symbol(b, Decl(bug25926.js, 2, 9)) ++>this : Symbol(o1, Decl(bug25926.js, 0, 11)) +>b : Symbol(b, Decl(bug25926.js, 0, 23)) >n : Symbol(n, Decl(bug25926.js, 3, 16)) >n : Symbol(n, Decl(bug25926.js, 3, 16)) } @@= skipped -16, +16 lines =@@ + this.e = this.f = m => this.g || m; >this.e : Symbol(e, Decl(bug25926.js, 7, 23)) - >this : Symbol(__type, Decl(bug25926.js, 7, 11)) +->this : Symbol(__type, Decl(bug25926.js, 7, 11)) ->e : Symbol(e, Decl(bug25926.js, 9, 9)) ++>this : Symbol(o2, Decl(bug25926.js, 7, 11)) +>e : Symbol(e, Decl(bug25926.js, 7, 23)) >this.f : Symbol(f, Decl(bug25926.js, 7, 46)) - >this : Symbol(__type, Decl(bug25926.js, 7, 11)) +->this : Symbol(__type, Decl(bug25926.js, 7, 11)) ->f : Symbol(f, Decl(bug25926.js, 10, 16)) ++>this : Symbol(o2, Decl(bug25926.js, 7, 11)) +>f : Symbol(f, Decl(bug25926.js, 7, 46)) >m : Symbol(m, Decl(bug25926.js, 10, 25)) >this.g : Symbol(g, Decl(bug25926.js, 7, 69)) - >this : Symbol(__type, Decl(bug25926.js, 7, 11)) \ No newline at end of file +->this : Symbol(__type, Decl(bug25926.js, 7, 11)) ++>this : Symbol(o2, Decl(bug25926.js, 7, 11)) + >g : Symbol(g, Decl(bug25926.js, 7, 69)) + >m : Symbol(m, Decl(bug25926.js, 10, 25)) + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types index 4ed98d54bc..db5ac9e24e 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types +++ b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types @@ -5,18 +5,18 @@ /** @type {Test} */ const test = dibbity => dibbity ->test : (data: T1) => T1 +>test : Test >dibbity => dibbity : (dibbity: T1) => T1 >dibbity : T1 >dibbity : T1 test(1) // ok, T=1 >test(1) : 1 ->test : (data: T1) => T1 +>test : Test >1 : 1 test('hi') // error, T=number >test('hi') : number ->test : (data: T1) => T1 +>test : Test >'hi' : "hi" diff --git a/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.types b/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.types index 14cfb6a773..4b523d5efb 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.types +++ b/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.types @@ -20,7 +20,7 @@ inJs(1); // lints error. Why? /**@type {IFn}*/ const inJsArrow = (j) => { ->inJsArrow : (m: T) => T +>inJsArrow : IFn >(j) => { return j;} : (j: T) => T >j : T @@ -29,6 +29,6 @@ const inJsArrow = (j) => { } inJsArrow(2); // no error gets linted as expected >inJsArrow(2) : 2 ->inJsArrow : (m: T) => T +>inJsArrow : IFn >2 : 2 diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types index 6a7b83f6db..a66cb912fb 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types @@ -78,13 +78,13 @@ var both1 = { type: 'a', x: 1 }; /** @type {import('./mod2').Both} */ var both2 = both1; ->both2 : { type: "a"; x: 1; } | { type: "b"; y: 1; } +>both2 : import("./mod2").Both >both1 : any /** @type {import('./mod3').Both} */ var both3 = both2; ->both3 : { type: "a"; x: 1; } | { type: "b"; y: 1; } ->both2 : { type: "a"; x: 1; } | { type: "b"; y: 1; } +>both3 : import("./mod3").Both +>both2 : import("./mod2").Both diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols index 2104a285c8..859b7d29e7 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols @@ -30,6 +30,7 @@ class Foo { } // should error /** @typedef {number} Bar */ exports.Bar = class { } >exports : Symbol("mod1", Decl(mod1.js, 0, 0)) +>Bar : Symbol(Bar, Decl(mod1.js, 5, 4), Decl(mod1.js, 3, 13)) /** @typedef {number} Baz */ module.exports = { @@ -50,6 +51,7 @@ var Qux = 2; /** @typedef {number} Quid */ exports.Quid = 2; >exports : Symbol("mod1", Decl(mod1.js, 0, 0)) +>Quid : Symbol(Quid, Decl(mod1.js, 18, 4), Decl(mod1.js, 16, 12)) /** @typedef {number} Quack */ module.exports = { diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff index b01cc9dce5..ad7f9a063e 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff @@ -24,6 +24,7 @@ ->exports : Symbol(Bar, Decl(mod1.js, 3, 13), Decl(mod1.js, 5, 4)) ->Bar : Symbol(Bar, Decl(mod1.js, 3, 13), Decl(mod1.js, 5, 4)) +>exports : Symbol("mod1", Decl(mod1.js, 0, 0)) ++>Bar : Symbol(Bar, Decl(mod1.js, 5, 4), Decl(mod1.js, 3, 13)) /** @typedef {number} Baz */ module.exports = { @@ -36,7 +37,7 @@ Baz: class { } >Baz : Symbol(Baz, Decl(mod1.js, 9, 18)) -@@= skipped -31, +29 lines =@@ +@@= skipped -31, +30 lines =@@ /** @typedef {number} Qux */ var Qux = 2; @@ -49,6 +50,7 @@ ->exports : Symbol(Quid, Decl(mod1.js, 16, 12), Decl(mod1.js, 18, 4)) ->Quid : Symbol(Quid, Decl(mod1.js, 16, 12), Decl(mod1.js, 18, 4)) +>exports : Symbol("mod1", Decl(mod1.js, 0, 0)) ++>Quid : Symbol(Quid, Decl(mod1.js, 18, 4), Decl(mod1.js, 16, 12)) /** @typedef {number} Quack */ module.exports = { diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types index e597356b31..ccb1bf27ab 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types @@ -34,7 +34,7 @@ exports.Bar = class { } >exports.Bar = class { } : typeof Bar >exports.Bar : any >exports : typeof import("./mod1") ->Bar : any +>Bar : typeof Bar >class { } : typeof Bar /** @typedef {number} Baz */ @@ -62,7 +62,7 @@ exports.Quid = 2; >exports.Quid = 2 : 2 >exports.Quid : any >exports : typeof import("./mod1") ->Quid : any +>Quid : 2 >2 : 2 /** @typedef {number} Quack */ diff --git a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types index 4da165b585..1839da2652 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types +++ b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types @@ -11,11 +11,11 @@ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ var tuvwx; ->tuvwx : { t: { a: number; b: "hi"; c: never; }; u: undefined; v: { c: true; d: 1; }; w: number; x: string; } +>tuvwx : Everything<{ a: number; b: "hi"; c: never; }, undefined, { c: true; d: 1; }, number, string> /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ var wrong; ->wrong : { t: { a: number; }; u: undefined; v: { c: 1; d: 1; }; w: number; x: string; } +>wrong : Everything<{ a: number; }, undefined, { c: 1; d: 1; }, number, string> /** @type {Everything<{ a: number }>} */ var insufficient; diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.types b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.types index bc0ab0707e..d8d2377cb8 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.types +++ b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.types @@ -93,24 +93,24 @@ catch (e) { * @param {Q} q */ function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) { ->proof : (a: { a: string; }, b: { b: string; }, c: { c: string; }, d: { d: string; }, e: { e: string; }, f: { f: string; }, g: { g: string; }, h: { h: string; }, i: { i: string; }, j: { j: string; }, k: { k: string; }, l: { l: string; }, m: { m: string; }, n: { n: string; }, o: { o: string; }, p: { p: string; }, q: { q: string; }) => void ->a : { a: string; } ->b : { b: string; } ->c : { c: string; } ->d : { d: string; } ->e : { e: string; } ->f : { f: string; } ->g : { g: string; } ->h : { h: string; } ->i : { i: string; } ->j : { j: string; } ->k : { k: string; } ->l : { l: string; } ->m : { m: string; } ->n : { n: string; } ->o : { o: string; } ->p : { p: string; } ->q : { q: string; } +>proof : (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q) => void +>a : A +>b : B +>c : C +>d : D +>e : E +>f : F +>g : G +>h : H +>i : I +>j : J +>k : K +>l : L +>m : M +>n : N +>o : O +>p : P +>q : Q console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) >console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) : void @@ -118,55 +118,55 @@ function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) { >console : Console >log : (...data: any[]) => void >a.a : string ->a : { a: string; } +>a : A >a : string >b.b : string ->b : { b: string; } +>b : B >b : string >c.c : string ->c : { c: string; } +>c : C >c : string >d.d : string ->d : { d: string; } +>d : D >d : string >e.e : string ->e : { e: string; } +>e : E >e : string >f.f : string ->f : { f: string; } +>f : F >f : string >g.g : string ->g : { g: string; } +>g : G >g : string >h.h : string ->h : { h: string; } +>h : H >h : string >i.i : string ->i : { i: string; } +>i : I >i : string >j.j : string ->j : { j: string; } +>j : J >j : string >k.k : string ->k : { k: string; } +>k : K >k : string >l.l : string ->l : { l: string; } +>l : L >l : string >m.m : string ->m : { m: string; } +>m : M >m : string >n.n : string ->n : { n: string; } +>n : N >n : string >o.o : string ->o : { o: string; } +>o : O >o : string >p.p : string ->p : { p: string; } +>p : P >p : string >q.q : string ->q : { q: string; } +>q : Q >q : string /** @type {Alpha} */ diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.types b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.types index 83e0ce3072..ebd2541cad 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.types +++ b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.types @@ -39,19 +39,19 @@ function callIt(func, arg) { * @returns {string|number} The return. */ function check(obj) { ->check : (obj: { num: number; str: string; boo: boolean; }) => string | number ->obj : { num: number; str: string; boo: boolean; } +>check : (obj: Type2) => string | number +>obj : Type2 return obj.boo ? obj.num : obj.str; >obj.boo ? obj.num : obj.str : string | number >obj.boo : boolean ->obj : { num: number; str: string; boo: boolean; } +>obj : Type2 >boo : boolean >obj.num : number ->obj : { num: number; str: string; boo: boolean; } +>obj : Type2 >num : number >obj.str : string ->obj : { num: number; str: string; boo: boolean; } +>obj : Type2 >str : string } @@ -136,19 +136,19 @@ function use2(func, bool, str, num) { * @returns {string|number} The return. */ function check5(obj) { ->check5 : (obj: { num: number; str: string; boo: boolean; }) => string | number ->obj : { num: number; str: string; boo: boolean; } +>check5 : (obj: Type5) => string | number +>obj : Type5 return obj.boo ? obj.num : obj.str; >obj.boo ? obj.num : obj.str : string | number >obj.boo : boolean ->obj : { num: number; str: string; boo: boolean; } +>obj : Type5 >boo : boolean >obj.num : number ->obj : { num: number; str: string; boo: boolean; } +>obj : Type5 >num : number >obj.str : string ->obj : { num: number; str: string; boo: boolean; } +>obj : Type5 >str : string } @@ -168,12 +168,12 @@ function check5(obj) { * @returns {*} The return. */ function check6(obj) { ->check6 : (obj: { foo: any; bar: any; }) => any ->obj : { foo: any; bar: any; } +>check6 : (obj: Type6) => any +>obj : Type6 return obj.foo; >obj.foo : any ->obj : { foo: any; bar: any; } +>obj : Type6 >foo : any } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff index 0e87eff864..43940c7c28 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff @@ -8,11 +8,10 @@ ->module.exports : (foo: Foo) => string ->module : { exports: (foo: Foo) => string; } ->exports : (foo: Foo) => string -->(void 0) : FooFun -+>module.exports = /** @type {FooFun} */(void 0) : (foo: typeof import("./file")) => string -+>module.exports : (foo: typeof import("./file")) => string -+>module : { "export=": (foo: typeof import("./file")) => string; } -+>exports : (foo: typeof import("./file")) => string -+>(void 0) : (foo: typeof import("./file")) => string ++>module.exports = /** @type {FooFun} */(void 0) : FooFun ++>module.exports : FooFun ++>module : { "export=": FooFun; } ++>exports : FooFun + >(void 0) : FooFun >void 0 : undefined - >0 : 0 + >0 : 0 \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff index dae231da9a..2bb9e8b929 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff @@ -1,22 +1,6 @@ --- old.contextuallyTypedParametersOptionalInJSDoc.types +++ new.contextuallyTypedParametersOptionalInJSDoc.types -@@= skipped -14, +14 lines =@@ - - /** @type {Fn} */ - const fn1 = -->fn1 : Fn -+>fn1 : (a: string, b: number) => void - - /** - * @param [b] -@@= skipped -31, +31 lines =@@ - - /** @type {Fn} */ - const fn2 = -->fn2 : Fn -+>fn2 : (a: string, b: number) => void - - /** +@@= skipped -51, +51 lines =@@ * @param {number} [b] */ function self(a, b) { @@ -27,7 +11,7 @@ >a : string >b : number | undefined -@@= skipped -18, +18 lines =@@ +@@= skipped -12, +12 lines =@@ self(""); >self("") : void diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff index bf6224e8ee..3b89fc52aa 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff @@ -1,67 +1,16 @@ --- old.expandoFunctionContextualTypesJs.types +++ new.expandoFunctionContextualTypesJs.types -@@= skipped -10, +10 lines =@@ - * @type {StatelessComponent} +@@= skipped -11, +11 lines =@@ */ const MyComponent = () => /* @type {any} */(null); -->MyComponent : StatelessComponent + >MyComponent : StatelessComponent ->() => /* @type {any} */(null) : { (): any; defaultProps: Partial; } -+>MyComponent : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } +>() => /* @type {any} */(null) : { (): any; defaultProps: { color: "red"; }; } >(null) : null MyComponent.defaultProps = { - >MyComponent.defaultProps = { color: "red"} : { color: "red"; } -->MyComponent.defaultProps : Partial -->MyComponent : StatelessComponent -->defaultProps : Partial -+>MyComponent.defaultProps : Partial<{ color: "blue" | "red"; }> -+>MyComponent : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } -+>defaultProps : Partial<{ color: "blue" | "red"; }> - >{ color: "red"} : { color: "red"; } - - color: "red" -@@= skipped -18, +18 lines =@@ - }; - - const MyComponent2 = () => null; -->MyComponent2 : { (): any; defaultProps: MyComponentProps; } -->() => null : { (): any; defaultProps: MyComponentProps; } -+>MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } -+>() => null : { (): any; defaultProps: { color: "blue" | "red"; }; } - - /** - * @type {MyComponentProps} - */ - MyComponent2.defaultProps = { - >MyComponent2.defaultProps = { color: "red"} : { color: "red"; } -->MyComponent2.defaultProps : MyComponentProps -->MyComponent2 : { (): any; defaultProps: MyComponentProps; } -->defaultProps : MyComponentProps -+>MyComponent2.defaultProps : { color: "blue" | "red"; } -+>MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } -+>defaultProps : { color: "blue" | "red"; } - >{ color: "red"} : { color: "red"; } - - color: "red" -@@= skipped -22, +22 lines =@@ - * @type {StatelessComponent} - */ - const check = MyComponent2; -->check : StatelessComponent -->MyComponent2 : { (): any; defaultProps: MyComponentProps; } -+>check : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } -+>MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } - - /** - * - * @param {{ props: MyComponentProps }} p - */ - function expectLiteral(p) {} -->expectLiteral : (p: { props: MyComponentProps; }) => void -->p : { props: MyComponentProps; } -+>expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void -+>p : { props: { color: "blue" | "red"; }; } +@@= skipped -51, +51 lines =@@ + >p : { props: MyComponentProps; } function foo() { ->foo : typeof foo @@ -81,12 +30,11 @@ >{ color: "red" } : { color: "red"; } >color : "red" >"red" : "red" - +@@= skipped -17, +17 lines =@@ expectLiteral(this); >expectLiteral(this) : void -->expectLiteral : (p: { props: MyComponentProps; }) => void + >expectLiteral : (p: { props: MyComponentProps; }) => void ->this : this -+>expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void +>this : any } @@ -95,29 +43,17 @@ */ module.exports = { ->module.exports = { color: "red"} : MyComponentProps -->module.exports : MyComponentProps -->module : { exports: MyComponentProps; } -->exports : MyComponentProps +>module.exports = { color: "red"} : { color: "red"; } -+>module.exports : { color: "blue" | "red"; } -+>module : { "export=": { color: "blue" | "red"; }; } -+>exports : { color: "blue" | "red"; } + >module.exports : MyComponentProps +->module : { exports: MyComponentProps; } ++>module : { "export=": MyComponentProps; } + >exports : MyComponentProps >{ color: "red"} : { color: "red"; } - color: "red" -@@= skipped -49, +49 lines =@@ - - expectLiteral({ props: module.exports }); - >expectLiteral({ props: module.exports }) : void -->expectLiteral : (p: { props: MyComponentProps; }) => void -->{ props: module.exports } : { props: MyComponentProps; } -->props : MyComponentProps -->module.exports : MyComponentProps +@@= skipped -24, +24 lines =@@ + >{ props: module.exports } : { props: MyComponentProps; } + >props : MyComponentProps + >module.exports : MyComponentProps ->module : { exports: MyComponentProps; } -->exports : MyComponentProps -+>expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void -+>{ props: module.exports } : { props: { color: "blue" | "red"; }; } -+>props : { color: "blue" | "red"; } -+>module.exports : { color: "blue" | "red"; } -+>module : { "export=": { color: "blue" | "red"; }; } -+>exports : { color: "blue" | "red"; } ++>module : { "export=": MyComponentProps; } + >exports : MyComponentProps diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff index bcc2a35f63..3f86798074 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff @@ -11,11 +11,11 @@ === b.ts === import A from './a' ->A : import("a").NumberLike[] -+>A : (string | number)[] ++>A : import("./a").NumberLike[] A[0] ->A[0] : import("a").NumberLike ->A : import("a").NumberLike[] -+>A[0] : string | number -+>A : (string | number)[] ++>A[0] : import("./a").NumberLike ++>A : import("./a").NumberLike[] >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff index c6a8e0dac4..4de4140638 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff @@ -1,21 +1,15 @@ --- old.exportDefaultWithJSDoc2.types +++ new.exportDefaultWithJSDoc2.types -@@= skipped -6, +6 lines =@@ - */ - - export default /** @type {NumberLike[]} */([ ]); -->([ ]) : NumberLike[] -+>([ ]) : (string | number)[] - >[ ] : undefined[] +@@= skipped -11, +11 lines =@@ === b.ts === import A from './a' ->A : import("a").NumberLike[] -+>A : (string | number)[] ++>A : import("./a").NumberLike[] A[0] ->A[0] : import("a").NumberLike ->A : import("a").NumberLike[] -+>A[0] : string | number -+>A : (string | number)[] ++>A[0] : import("./a").NumberLike ++>A : import("./a").NumberLike[] >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportAssignmentNonMutableLocation.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportAssignmentNonMutableLocation.types.diff index 9cf27815e6..848456ac7f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportAssignmentNonMutableLocation.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportAssignmentNonMutableLocation.types.diff @@ -27,7 +27,7 @@ +>exports.customSymbol2 = Symbol("custom") : symbol +>exports.customSymbol2 : any +>exports : typeof import("./file") -+>customSymbol2 : any ++>customSymbol2 : symbol +>Symbol("custom") : symbol >Symbol : SymbolConstructor >"custom" : "custom" diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation3.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation3.types.diff index 0d098f61be..43753a1571 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation3.types.diff @@ -8,12 +8,11 @@ ->module.exports : typeof import("/y") ->module : { exports: typeof import("/y"); } ->exports : typeof import("/y") -->x : 1 +>module.exports.x : any +>module.exports : typeof import("./y.js") +>module : { "export=": typeof import("./y.js"); } +>exports : typeof import("./y.js") -+>x : any + >x : 1 >1 : 1 module.exports = require("./y.js"); diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff index 08ec916107..0c494dddc4 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff @@ -4,17 +4,12 @@ -a.js(7,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'A' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. - Types of property 'value' are incompatible. - Type 'undefined' is not assignable to type 'number'. --a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. -- Types of property 'value' are incompatible. -- Type 'undefined' is not assignable to type 'number'. -- -- + a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. + Types of property 'value' are incompatible. + Type 'undefined' is not assignable to type 'number'. + + -==== a.js (2 errors) ==== -+a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. -+ Types of property 'value' are incompatible. -+ Type 'undefined' is not assignable to type 'number'. -+ -+ +==== a.js (1 errors) ==== /** * @typedef {object} A @@ -29,13 +24,4 @@ -!!! error TS2375: Type 'undefined' is not assignable to type 'number'. /** - * @typedef {{ value?: number }} B -@@= skipped -12, +8 lines =@@ - /** @type {B} */ - const b = { value: undefined }; // error - ~ --!!! error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. -+!!! error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. - !!! error TS2375: Types of property 'value' are incompatible. - !!! error TS2375: Type 'undefined' is not assignable to type 'number'. - \ No newline at end of file + * @typedef {{ value?: number }} B \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.types.diff deleted file mode 100644 index 52a087eaf4..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.strictOptionalProperties3.types -+++ new.strictOptionalProperties3.types -@@= skipped -18, +18 lines =@@ - - /** @type {B} */ - const b = { value: undefined }; // error -->b : B -+>b : { value?: number; } - >{ value: undefined } : { value: undefined; } - >value : undefined - >undefined : undefined \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff deleted file mode 100644 index d46ad406b3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.assertionTypePredicates2.types -+++ new.assertionTypePredicates2.types -@@= skipped -13, +13 lines =@@ - * @returns { asserts a is B } - */ - const foo = (a) => { -->foo : (a: A) => asserts a is B -->(a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); return undefined;} : (a: A) => asserts a is B -->a : A -+>foo : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } -+>(a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); return undefined;} : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } -+>a : { x: number; } - - if (/** @type { B } */ (a).y !== 0) throw TypeError(); - >(a).y !== 0 : boolean - >(a).y : number -->(a) : B -->a : A -+>(a) : { x: number; } & { y: number; } -+>a : { x: number; } - >y : number - >0 : 0 - >TypeError() : TypeError -@@= skipped -25, +25 lines =@@ - - /** @type { A } */ - const a = { x: 1 }; -->a : A -+>a : { x: number; } - >{ x: 1 } : { x: number; } - >x : number - >1 : 1 - - foo(a); - >foo(a) : void -->foo : (a: A) => asserts a is B -->a : A -+>foo : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } -+>a : { x: number; } - - }; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.types.diff index 9499e17903..b4d7a603e3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.types.diff @@ -1,17 +1,15 @@ --- old.assertionsAndNonReturningFunctions.types +++ new.assertionsAndNonReturningFunctions.types -@@= skipped -4, +4 lines =@@ - +@@= skipped -5, +5 lines =@@ /** @type {AssertFunc} */ const assert = check => { -->assert : AssertFunc + >assert : AssertFunc ->check => { if (!check) throw new Error();} : (check: boolean) => asserts check -+>assert : (check: boolean) => asserts check +>check => { if (!check) throw new Error();} : (check: boolean) => void >check : boolean if (!check) throw new Error(); -@@= skipped -13, +13 lines =@@ +@@= skipped -12, +12 lines =@@ /** @type {(x: unknown) => asserts x is string } */ function assertIsString(x) { @@ -30,16 +28,7 @@ >"string" : "string" >new Error() : Error >Error : ErrorConstructor -@@= skipped -54, +54 lines =@@ - - assert(typeof x === "string"); - >assert(typeof x === "string") : void -->assert : AssertFunc -+>assert : (check: boolean) => asserts check - >typeof x === "string" : boolean - >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" - >x : any -@@= skipped -36, +36 lines =@@ +@@= skipped -90, +90 lines =@@ assertIsString(x); >assertIsString(x) : void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff deleted file mode 100644 index 26a2207f38..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.checkJsdocSatisfiesTag10.errors.txt -+++ new.checkJsdocSatisfiesTag10.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. -+/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. - /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. - - -@@= skipped -9, +9 lines =@@ - b: "hello", - x: 8 // Should error, 'x' isn't in 'Keys' - ~ --!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. -+!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. - }); - - // Should be OK -- retain info that a is number and b is string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff deleted file mode 100644 index aa1be201c2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.checkJsdocSatisfiesTag7.errors.txt -+++ new.checkJsdocSatisfiesTag7.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. -+/a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record<"a" | "b" | "c" | "d", unknown>'. - /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. - - -@@= skipped -9, +9 lines =@@ - b: "hello", - x: 8 // Should error, 'x' isn't in 'Keys' - ~ --!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. -+!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record<"a" | "b" | "c" | "d", unknown>'. - }) - - // Should be OK -- retain info that a is number and b is string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff deleted file mode 100644 index 1df5adda50..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.checkJsdocTypeTag4.types -+++ new.checkJsdocTypeTag4.types -@@= skipped -15, +15 lines =@@ - - /** @type {B} */ - var b; -->b : B -+>b : { b: number; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.types.diff index 77a534523c..cb7ae9e15e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.types.diff @@ -40,10 +40,9 @@ ->module.exports : { (ast: any): any; funky: (declaration: any) => boolean; } ->module : { exports: { (ast: any): any; funky: (declaration: any) => boolean; }; } ->exports : { (ast: any): any; funky: (declaration: any) => boolean; } -->funky : (declaration: any) => boolean +>module.exports.funky : any +>module.exports : (ast: any) => any +>module : { readonly donkey: (ast: any) => any; } +>exports : (ast: any) => any -+>funky : any + >funky : (declaration: any) => boolean >funky : (declaration: any) => boolean diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff index 3f71a0e559..8ba6639782 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff @@ -26,7 +26,7 @@ + status: 'done', + ~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type '"done"'. -+!!! related TS6500 test.js:2:5: The expected type comes from property 'status' which is declared here on type '{ status: "done"; m(n: number): void; }' ++!!! related TS6500 test.js:2:5: The expected type comes from property 'status' which is declared here on type 'DoneStatus' + m(n) { } + ~ +!!! error TS7006: Parameter 'n' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.types.diff index fca04eca50..a0a13f1a42 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.types.diff @@ -6,34 +6,29 @@ var ns = {} ->ns : typeof ns ->{} : {} -+>ns : { x: { status: "done"; m(n: number): void; }; } -+>{} : { x: { status: "done"; m(n: number): void; }; } ++>ns : { x: DoneStatus; } ++>{} : { x: DoneStatus; } /** @type {DoneStatus} */ ns.x = { >ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } -->ns.x : DoneStatus + >ns.x : DoneStatus ->ns : typeof ns -->x : DoneStatus -+>ns.x : { status: "done"; m(n: number): void; } -+>ns : { x: { status: "done"; m(n: number): void; }; } -+>x : { status: "done"; m(n: number): void; } ++>ns : { x: DoneStatus; } + >x : DoneStatus >{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } - status: 'done', @@= skipped -21, +21 lines =@@ } ns.x = { ->ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } -->ns.x : DoneStatus ++>ns.x = { status: 'done', m(n) { }} : { status: string; m(n: any): void; } + >ns.x : DoneStatus ->ns : typeof ns -->x : DoneStatus ++>ns : { x: DoneStatus; } + >x : DoneStatus ->{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } -+>ns.x = { status: 'done', m(n) { }} : { status: string; m(n: any): void; } -+>ns.x : { status: "done"; m(n: number): void; } -+>ns : { x: { status: "done"; m(n: number): void; }; } -+>x : { status: "done"; m(n: number): void; } +>{ status: 'done', m(n) { }} : { status: string; m(n: any): void; } status: 'done', @@ -48,40 +43,13 @@ +>n : any } ns.x -->ns.x : DoneStatus + >ns.x : DoneStatus ->ns : typeof ns -->x : DoneStatus -+>ns.x : { status: "done"; m(n: number): void; } -+>ns : { x: { status: "done"; m(n: number): void; }; } -+>x : { status: "done"; m(n: number): void; } - - - // this-property assignment -@@= skipped -28, +28 lines =@@ - /** @type {DoneStatus} */ - this.s = { - >this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } -->this.s : DoneStatus -+>this.s : { status: "done"; m(n: number): void; } - >this : this -->s : DoneStatus -+>s : { status: "done"; m(n: number): void; } - >{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } ++>ns : { x: DoneStatus; } + >x : DoneStatus - status: 'done', -@@= skipped -20, +20 lines =@@ - this.s = { - >this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } -->this.s : DoneStatus -+>this.s : { status: "done"; m(n: number): void; } - >this : this -->s : DoneStatus -+>s : { status: "done"; m(n: number): void; } - >{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } - - status: 'done', -@@= skipped -21, +21 lines =@@ +@@= skipped -69, +69 lines =@@ /** @type {DoneStatus} */ exports.x = { >exports.x = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } @@ -165,20 +133,17 @@ // prototype assignment function F() { ->F : typeof F -+>F : { (): void; prototype: { status: "done"; m(n: number): void; }; } ++>F : { (): void; prototype: DoneStatus; } } /** @type {DoneStatus} */ F.prototype = { >F.prototype = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } -->F.prototype : DoneStatus + >F.prototype : DoneStatus ->F : typeof F -->prototype : DoneStatus -+>F.prototype : { status: "done"; m(n: number): void; } -+>F : { (): void; prototype: { status: "done"; m(n: number): void; }; } -+>prototype : { status: "done"; m(n: number): void; } ++>F : { (): void; prototype: DoneStatus; } + >prototype : DoneStatus >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } - status: "done", @@= skipped -33, +33 lines =@@ module.exports = { >module.exports = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff deleted file mode 100644 index 120ca7a587..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.extendsTag5.errors.txt -+++ new.extendsTag5.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(29,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. -+/a.js(29,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint '{ a: string | number; b: boolean | string[]; }'. - Types of property 'b' are incompatible. - Type 'string' is not assignable to type 'boolean | string[]'. --/a.js(42,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. -+/a.js(42,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint '{ a: string | number; b: boolean | string[]; }'. - Types of property 'b' are incompatible. - Type 'string' is not assignable to type 'boolean | string[]'. - -@@= skipped -42, +42 lines =@@ - ~~~~~~~~~~~~~~~~ - * }>} - ~~~~ --!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. -+!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint '{ a: string | number; b: boolean | string[]; }'. - !!! error TS2344: Types of property 'b' are incompatible. - !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. - */ -@@= skipped -14, +14 lines =@@ - /** - * @extends {A<{a: string, b: string}>} - ~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. -+!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint '{ a: string | number; b: boolean | string[]; }'. - !!! error TS2344: Types of property 'b' are incompatible. - !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. - */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff deleted file mode 100644 index cf12acd1a3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.importTag23.errors.txt -+++ new.importTag23.errors.txt -@@= skipped -0, +0 lines =@@ -+/b.js(5,18): error TS1361: 'NS' cannot be used as a value because it was imported using 'import type'. - /b.js(6,14): error TS2420: Class 'C' incorrectly implements interface 'I'. - Property 'foo' is missing in type 'C' but required in type 'I'. - -@@= skipped -6, +7 lines =@@ - foo(): void; - } - --==== /b.js (1 errors) ==== -+==== /b.js (2 errors) ==== - /** - * @import * as NS from './a' - */ - - /** @implements {NS.I} */ -+ ~~ -+!!! error TS1361: 'NS' cannot be used as a value because it was imported using 'import type'. -+!!! related TS1376 /b.js:2:17: 'NS' was imported here. - export class C {} - ~ - !!! error TS2420: Class 'C' incorrectly implements interface 'I'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.types.diff index 90fb3fbf2c..3131e07864 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.types.diff @@ -17,11 +17,8 @@ ->module : { exports: typeof Foo; } +>module : { Foo: typeof Foo; } >exports : typeof Foo -->Strings : { a: string; b: string; } -+>Strings : any >Strings : { a: string; b: string; } - - === bar.js === + >Strings : { a: string; b: string; } @@= skipped -20, +20 lines =@@ module.exports = Bar; >module.exports = Bar : typeof Bar diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic.types.diff index 2366108956..25e8e64f18 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic.types.diff @@ -17,8 +17,5 @@ ->module : { exports: typeof Handler; } +>module : { Handler: typeof Handler; } >exports : typeof Handler -->Strings : { a: string; b: string; } -+>Strings : any >Strings : { a: string; b: string; } - - /** \ No newline at end of file + >Strings : { a: string; b: string; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsCrossfileMerge.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsCrossfileMerge.types.diff index 72e62b10b6..13a3d346f8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsCrossfileMerge.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsCrossfileMerge.types.diff @@ -24,12 +24,11 @@ ->module.exports : typeof m.default ->module : { exports: typeof m.default; } ->exports : typeof m.default -->memberName : "thing" +>module.exports.memberName : any +>module.exports : () => void +>module : { validate(): void; } +>exports : () => void -+>memberName : any + >memberName : "thing" >"thing" : "thing" === exporter.js === diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types.diff index f6ed465161..c325c55012 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types.diff @@ -37,12 +37,11 @@ ->module.exports : typeof import("index") ->module : { exports: typeof import("index"); } ->exports : typeof import("index") -->Sub : typeof Sub +>module.exports.Sub : any +>module.exports : typeof import(".") +>module : { "\uFFFDclass": typeof import("."); } +>exports : typeof import(".") -+>Sub : any + >Sub : typeof Sub >class { constructor() { this.instance = new module.exports(10); }} : typeof Sub constructor() { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.types.diff index aff43a9cf2..e3d1c5685d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.types.diff @@ -35,10 +35,9 @@ ->module.exports : typeof import("index") ->module : { exports: typeof import("index"); } ->exports : typeof import("index") -->Another : typeof Q +>module.exports.Another : any +>module.exports : typeof import(".") +>module : { Q: typeof import("."); } +>exports : typeof import(".") -+>Another : any + >Another : typeof Q >Q : typeof Q diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassInstance3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassInstance3.types.diff index a8e58d7687..145c4adaaf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassInstance3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassInstance3.types.diff @@ -21,10 +21,9 @@ ->module.exports : { member: number; additional: 20; } ->module : { exports: { member: number; additional: 20; }; } ->exports : { member: number; additional: 20; } -->additional : 20 +>module.exports.additional : any +>module.exports : Foo +>module : { "export=": Foo; } +>exports : Foo -+>additional : any + >additional : 20 >20 : 20 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.types.diff index 61fe270fcd..2cc9e8cb17 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.types.diff @@ -43,7 +43,7 @@ +>module.exports : (p: any) => void +>module : { "export=": (p: any) => void; } +>exports : (p: any) => void -+>Sub : any ++>Sub : () => void +>function() { this.instance = new module.exports(10);} : () => void this.instance = new module.exports(10); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.types.diff index 96c4f08cc2..70bcd2d5e4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.types.diff @@ -23,10 +23,9 @@ ->module.exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; } ->module : { exports: { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; }; } ->exports : { thing: string; also: string; desc: { item: string; }; Strings: { a: string; b: string; }; } -->Strings : { a: string; b: string; } +>module.exports.Strings : any +>module.exports : { thing: string; also: string; desc: { item: string; }; } +>module : { "export=": { thing: string; also: string; desc: { item: string; }; }; } +>exports : { thing: string; also: string; desc: { item: string; }; } -+>Strings : any + >Strings : { a: string; b: string; } >Strings : { a: string; b: string; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDoubleAssignmentInClosure.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDoubleAssignmentInClosure.types.diff index ffb4c2c0cf..9a119ca258 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDoubleAssignmentInClosure.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDoubleAssignmentInClosure.types.diff @@ -46,7 +46,8 @@ >exports.methods = m : () => void >exports.methods : any ->exports : any +->methods : any +>exports : typeof import(".") - >methods : any ++>methods : () => void >m : () => void - } \ No newline at end of file + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportSubAssignments.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportSubAssignments.types.diff index b518598bbc..7544619a0d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportSubAssignments.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportSubAssignments.types.diff @@ -17,6 +17,5 @@ ->module : { exports: typeof Foo; } +>module : { Foo: typeof Foo; } >exports : typeof Foo -->Strings : { a: string; b: string; } -+>Strings : any >Strings : { a: string; b: string; } + >Strings : { a: string; b: string; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff index f1f24d4676..0158bec3cb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff @@ -35,19 +35,16 @@ */ function Hook(handle) { ->Hook : typeof Hook -->handle : HookHandler -+>Hook : (handle: (arg: any) => void) => void -+>handle : (arg: any) => void ++>Hook : (handle: HookHandler) => void + >handle : HookHandler this.handle = handle; -->this.handle = handle : HookHandler -+>this.handle = handle : (arg: any) => void + >this.handle = handle : HookHandler >this.handle : any ->this : this +>this : any >handle : any -->handle : HookHandler -+>handle : (arg: any) => void + >handle : HookHandler } module.exports = Hook; ->module.exports = Hook : typeof Hook @@ -55,11 +52,11 @@ ->module : { exports: typeof Hook; } ->exports : typeof Hook ->Hook : typeof Hook -+>module.exports = Hook : (handle: (arg: any) => void) => void -+>module.exports : (handle: (arg: any) => void) => void -+>module : { Hook(handle: (arg: any) => void): void; } -+>exports : (handle: (arg: any) => void) => void -+>Hook : (handle: (arg: any) => void) => void ++>module.exports = Hook : (handle: HookHandler) => void ++>module.exports : (handle: HookHandler) => void ++>module : { Hook(handle: HookHandler): void; } ++>exports : (handle: HookHandler) => void ++>Hook : (handle: HookHandler) => void === context.js === /** diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.types.diff index a6e0c911c7..33b4d582f0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.types.diff @@ -1,29 +1,24 @@ --- old.jsDeclarationsImportTypeBundled.types +++ new.jsDeclarationsImportTypeBundled.types -@@= skipped -7, +7 lines =@@ - * @type {Item}; - */ - const x = {x: 12}; -->x : Item -+>x : { x: number; } - >{x: 12} : { x: number; } - >x : number +@@= skipped -13, +13 lines =@@ >12 : 12 -@@= skipped -8, +8 lines =@@ + module.exports = x; - >module.exports = x : { x: number; } - >module.exports : { x: number; } +->module.exports = x : { x: number; } +->module.exports : { x: number; } ->module : { exports: { x: number; }; } -+>module : { readonly x: { x: number; }; } - >exports : { x: number; } -->x : Item -+>x : { x: number; } +->exports : { x: number; } ++>module.exports = x : Item ++>module.exports : Item ++>module : { readonly x: Item; } ++>exports : Item + >x : Item === index.js === /** @type {(typeof import("./folder/mod1"))[]} */ const items = [{x: 12}]; ->items : import("folder/mod1").Item[] -+>items : { x: number; }[] ++>items : import("./folder/mod1").Item[] >[{x: 12}] : { x: number; }[] >{x: 12} : { x: number; } >x : number @@ -35,8 +30,8 @@ ->module : { exports: import("folder/mod1").Item[]; } ->exports : import("folder/mod1").Item[] ->items : import("folder/mod1").Item[] -+>module.exports = items : { x: number; }[] -+>module.exports : { x: number; }[] -+>module : { readonly items: { x: number; }[]; } -+>exports : { x: number; }[] -+>items : { x: number; }[] ++>module.exports = items : import("./folder/mod1").Item[] ++>module.exports : import("./folder/mod1").Item[] ++>module : { readonly items: import("./folder/mod1").Item[]; } ++>exports : import("./folder/mod1").Item[] ++>items : import("./folder/mod1").Item[] diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.types.diff index a80151c396..add66d18ea 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.types.diff @@ -1,15 +1,6 @@ --- old.jsDeclarationsTypeAliases.types +++ new.jsDeclarationsTypeAliases.types -@@= skipped -37, +37 lines =@@ - * @returns {SomeType} - */ - function doTheThing(x) { -->doTheThing : (x: number) => SomeType -+>doTheThing : (x: number) => number | ExportedThing | LocalThing | { x: string; } - >x : number - - return {x: ""+x}; -@@= skipped -18, +18 lines =@@ +@@= skipped -55, +55 lines =@@ >"ok" : "ok" } module.exports = { @@ -17,16 +8,10 @@ ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->{ doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } -+>module.exports = { doTheThing, ExportedThing,} : { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; } -+>module.exports : { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; } -+>module : { "export=": { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; }; } -+>exports : { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; } -+>{ doTheThing, ExportedThing,} : { doTheThing: (x: number) => number | ExportedThing | LocalThing | { x: string; }; ExportedThing: typeof ExportedThing; } - - doTheThing, -->doTheThing : (x: number) => SomeType -+>doTheThing : (x: number) => number | ExportedThing | LocalThing | { x: string; } ++>module.exports = { doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } ++>module.exports : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } ++>module : { "export=": { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; }; } ++>exports : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } + >{ doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } - ExportedThing, - >ExportedThing : typeof ExportedThing \ No newline at end of file + doTheThing, \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.types.diff deleted file mode 100644 index a1323e0ed9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.types.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.jsDeclarationsTypedefFunction.types -+++ new.jsDeclarationsTypedefFunction.types -@@= skipped -15, +15 lines =@@ - * @returns {Promise} - */ - const send = handlers => new Promise((resolve, reject) => { -->send : (handlers: ResolveRejectMap) => Promise -->handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : (handlers: ResolveRejectMap) => Promise -->handlers : ResolveRejectMap -+>send : (handlers: { [id: string]: [Function, Function]; }) => Promise -+>handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : (handlers: { [id: string]: [Function, Function]; }) => Promise -+>handlers : { [id: string]: [Function, Function]; } - >new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : Promise - >Promise : PromiseConstructor - >(resolve, reject) => { handlers[++id] = [resolve, reject]} : (resolve: (value: any) => void, reject: (reason?: any) => void) => void -@@= skipped -12, +12 lines =@@ - handlers[++id] = [resolve, reject] - >handlers[++id] = [resolve, reject] : [(value: any) => void, (reason?: any) => void] - >handlers[++id] : [Function, Function] -->handlers : ResolveRejectMap -+>handlers : { [id: string]: [Function, Function]; } - >++id : number - >id : number - >[resolve, reject] : [(value: any) => void, (reason?: any) => void] \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.types.diff index 7a5308d35f..da8668f6a0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.types.diff @@ -11,24 +11,4 @@ +>a : T >x : T } - /** -@@= skipped -13, +13 lines =@@ - * @return {T} - */ - foo(x, y, alpha) { -->foo : (x: T, y: Id, alpha: (t: T) => T) => T -+>foo : (x: T, y: (t: T) => T, alpha: (t: T) => T) => T - >x : T -->y : Id -+>y : (t: T) => T - >alpha : (t: T) => T - - return alpha(y(x)) - >alpha(y(x)) : T - >alpha : (t: T) => T - >y(x) : T -->y : Id -+>y : (t: T) => T - >x : T - } - } \ No newline at end of file + /** \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff deleted file mode 100644 index ad27c1d2fb..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff +++ /dev/null @@ -1,116 +0,0 @@ ---- old.jsdocTemplateTag6.errors.txt -+++ new.jsdocTemplateTag6.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+a.js(14,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+a.js(26,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+a.js(37,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+a.js(48,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+a.js(59,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+a.js(68,18): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+ -+ -+==== a.js (7 errors) ==== -+ /** -+ * @template const T -+ ~~~~~ -+!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+ * @param {T} x -+ * @returns {T} -+ */ -+ function f1(x) { -+ return x; -+ } -+ const t1 = f1("a"); -+ const t2 = f1(["a", ["b", "c"]]); -+ const t3 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -+ -+ /** -+ * @template const T, U -+ ~~~~~ -+!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+ * @param {T} x -+ * @returns {T} -+ */ -+ function f2(x) { -+ return x; -+ }; -+ const t4 = f2('a'); -+ const t5 = f2(['a', ['b', 'c']]); -+ const t6 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -+ -+ /** -+ * @template const T -+ ~~~~~ -+!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+ * @param {T} x -+ * @returns {T[]} -+ */ -+ function f3(x) { -+ return [x]; -+ } -+ const t7 = f3("hello"); -+ const t8 = f3("hello"); -+ -+ /** -+ * @template const T -+ ~~~~~ -+!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+ * @param {[T, T]} x -+ * @returns {T} -+ */ -+ function f4(x) { -+ return x[0]; -+ } -+ const t9 = f4([[1, "x"], [2, "y"]]); -+ const t10 = f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]); -+ -+ /** -+ * @template const T -+ ~~~~~ -+!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+ * @param {{ x: T, y: T}} obj -+ * @returns {T} -+ */ -+ function f5(obj) { -+ return obj.x; -+ } -+ const t11 = f5({ x: [1, "x"], y: [2, "y"] }); -+ const t12 = f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }); -+ -+ /** -+ * @template const T -+ ~~~~~ -+!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+ */ -+ class C { -+ /** -+ * @param {T} x -+ */ -+ constructor(x) {} -+ -+ /** -+ * @template const U -+ ~~~~~ -+!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+ * @param {U} x -+ */ -+ foo(x) { -+ return x; -+ } -+ } -+ -+ const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -+ const t14 = t13.foo(["a", ["b", "c"]]); -+ -+ /** -+ * @template {readonly unknown[]} const T -+ * @param {T} args -+ * @returns {T} -+ */ -+ function f6(...args) { -+ return args; -+ } -+ const t15 = f6(1, 'b', { a: 1, b: 'x' }); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff deleted file mode 100644 index c7e3efdbb8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.jsdocTemplateTag7.errors.txt -+++ new.jsdocTemplateTag7.errors.txt -@@= skipped -0, +0 lines =@@ - a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+a.js(7,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter - - --==== a.js (2 errors) ==== -+==== a.js (3 errors) ==== - /** - * @template const T - ~~~~~ -@@= skipped -11, +12 lines =@@ - - /** - * @template const T -+ ~~~~~ -+!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - */ - class C { } - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff deleted file mode 100644 index b8f6c5d302..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.jsdocTemplateTagDefault.types -+++ new.jsdocTemplateTagDefault.types -@@= skipped -7, +7 lines =@@ - - /** @type {A} */ // ok, default for `T` in `A` is `string` - const aDefault1 = [""]; -->aDefault1 : A -+>aDefault1 : [string] - >[""] : [string] - >"" : "" - - /** @type {A} */ // error: `number` is not assignable to string` - const aDefault2 = [0]; -->aDefault2 : A -+>aDefault2 : [string] - >[0] : [number] - >0 : 0 - - /** @type {A} */ // ok, `T` is provided for `A` - const aString = [""]; -->aString : A -+>aString : [string] - >[""] : [string] - >"" : "" - - /** @type {A} */ // ok, `T` is provided for `A` - const aNumber = [0]; -->aNumber : A -+>aNumber : [number] - >[0] : [number] - >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias.types.diff index 91276e3db0..7280e45e16 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias.types.diff @@ -189,10 +189,9 @@ >exports.func2 = function () { } : () => void ->exports.func2 : () => void ->exports : typeof import("b") -->func2 : () => void +>exports.func2 : any +>exports : typeof import("./b") -+>func2 : any + >func2 : () => void >function () { } : () => void var moduleExportsAlias = module.exports; @@ -221,12 +220,11 @@ ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->func4 : () => void +>module.exports.func4 : any +>module.exports : {} +>module : { "export=": {}; } +>exports : {} -+>func4 : any + >func4 : () => void >function () { } : () => void var multipleDeclarationAlias1 = exports = module.exports; @@ -370,117 +368,87 @@ ->multipleDeclarationAlias6.func10 : () => void ->multipleDeclarationAlias6 : typeof module.exports ->func10 : () => void -->function () { } : () => void -- --exports = module.exports = someOtherVariable = {}; -->exports = module.exports = someOtherVariable = {} : typeof module.exports -->exports : typeof import("b") -->module.exports = someOtherVariable = {} : typeof module.exports -->module.exports : typeof module.exports -->module : { exports: typeof module.exports; } -->exports : typeof module.exports -->someOtherVariable = {} : {} -->someOtherVariable : any -->{} : {} -- --exports.func11 = function () { }; -->exports.func11 = function () { } : () => void -->exports.func11 : () => void -->exports : typeof import("b") -->func11 : () => void -->function () { } : () => void -- --module.exports.func12 = function () { }; -->module.exports.func12 = function () { } : () => void -->module.exports.func12 : () => void -->module.exports : typeof module.exports -->module : { exports: typeof module.exports; } -->exports : typeof module.exports -->func12 : () => void -->function () { } : () => void -- --exports = module.exports = someOtherVariable = {}; ++>multipleDeclarationAlias6.func10 : any ++>multipleDeclarationAlias6 : {} ++>func10 : any + >function () { } : () => void + + exports = module.exports = someOtherVariable = {}; ->exports = module.exports = someOtherVariable = {} : typeof module.exports ->exports : typeof import("b") ->module.exports = someOtherVariable = {} : typeof module.exports ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->someOtherVariable = {} : {} -->someOtherVariable : any -->{} : {} -- --exports.func11 = function () { }; -->exports.func11 = function () { } : () => void -->exports.func11 : () => void -->exports : typeof import("b") -->func11 : () => void -->function () { } : () => void -- --module.exports.func12 = function () { }; -->module.exports.func12 = function () { } : () => void -->module.exports.func12 : () => void -->module.exports : typeof module.exports -->module : { exports: typeof module.exports; } -->exports : typeof module.exports -->func12 : () => void -+>multipleDeclarationAlias6.func10 : any -+>multipleDeclarationAlias6 : {} -+>func10 : any -+>function () { } : () => void -+ -+exports = module.exports = someOtherVariable = {}; +>exports = module.exports = someOtherVariable = {} : {} +>exports : any +>module.exports = someOtherVariable = {} : {} +>module.exports : {} +>module : { "export=": {}; } +>exports : {} -+>someOtherVariable = {} : {} -+>someOtherVariable : any -+>{} : {} -+ -+exports.func11 = function () { }; -+>exports.func11 = function () { } : () => void + >someOtherVariable = {} : {} + >someOtherVariable : any + >{} : {} + + exports.func11 = function () { }; + >exports.func11 = function () { } : () => void +->exports.func11 : () => void +->exports : typeof import("b") +>exports.func11 : any +>exports : typeof import("./b") -+>func11 : any -+>function () { } : () => void -+ -+module.exports.func12 = function () { }; -+>module.exports.func12 = function () { } : () => void + >func11 : () => void + >function () { } : () => void + + module.exports.func12 = function () { }; + >module.exports.func12 = function () { } : () => void +->module.exports.func12 : () => void +->module.exports : typeof module.exports +->module : { exports: typeof module.exports; } +->exports : typeof module.exports +>module.exports.func12 : any +>module.exports : {} +>module : { "export=": {}; } +>exports : {} -+>func12 : any -+>function () { } : () => void -+ -+exports = module.exports = someOtherVariable = {}; + >func12 : () => void + >function () { } : () => void + + exports = module.exports = someOtherVariable = {}; +->exports = module.exports = someOtherVariable = {} : typeof module.exports +->exports : typeof import("b") +->module.exports = someOtherVariable = {} : typeof module.exports +->module.exports : typeof module.exports +->module : { exports: typeof module.exports; } +->exports : typeof module.exports +>exports = module.exports = someOtherVariable = {} : {} +>exports : any +>module.exports = someOtherVariable = {} : {} +>module.exports : {} +>module : { "export=": {}; } +>exports : {} -+>someOtherVariable = {} : {} -+>someOtherVariable : any -+>{} : {} -+ -+exports.func11 = function () { }; -+>exports.func11 = function () { } : () => void + >someOtherVariable = {} : {} + >someOtherVariable : any + >{} : {} + + exports.func11 = function () { }; + >exports.func11 = function () { } : () => void +->exports.func11 : () => void +->exports : typeof import("b") +>exports.func11 : any +>exports : typeof import("./b") -+>func11 : any -+>function () { } : () => void -+ -+module.exports.func12 = function () { }; -+>module.exports.func12 = function () { } : () => void + >func11 : () => void + >function () { } : () => void + + module.exports.func12 = function () { }; + >module.exports.func12 = function () { } : () => void +->module.exports.func12 : () => void +->module.exports : typeof module.exports +->module : { exports: typeof module.exports; } +->exports : typeof module.exports +>module.exports.func12 : any +>module.exports : {} +>module : { "export=": {}; } +>exports : {} -+>func12 : any + >func12 : () => void >function () { } : () => void exports = module.exports = {}; @@ -502,10 +470,9 @@ >exports.func13 = function () { } : () => void ->exports.func13 : () => void ->exports : typeof import("b") -->func13 : () => void +>exports.func13 : any +>exports : typeof import("./b") -+>func13 : any + >func13 : () => void >function () { } : () => void module.exports.func14 = function () { }; @@ -514,12 +481,11 @@ ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->func14 : () => void +>module.exports.func14 : any +>module.exports : {} +>module : { "export=": {}; } +>exports : {} -+>func14 : any + >func14 : () => void >function () { } : () => void exports = module.exports = {}; @@ -541,10 +507,9 @@ >exports.func15 = function () { } : () => void ->exports.func15 : () => void ->exports : typeof import("b") -->func15 : () => void +>exports.func15 : any +>exports : typeof import("./b") -+>func15 : any + >func15 : () => void >function () { } : () => void module.exports.func16 = function () { }; @@ -553,12 +518,11 @@ ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->func16 : () => void +>module.exports.func16 : any +>module.exports : {} +>module : { "export=": {}; } +>exports : {} -+>func16 : any + >func16 : () => void >function () { } : () => void module.exports = exports = {}; @@ -579,10 +543,9 @@ >exports.func17 = function () { } : () => void ->exports.func17 : () => void ->exports : typeof import("b") -->func17 : () => void +>exports.func17 : any +>exports : typeof import("./b") -+>func17 : any + >func17 : () => void >function () { } : () => void module.exports.func18 = function () { }; @@ -591,12 +554,11 @@ ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->func18 : () => void +>module.exports.func18 : any +>module.exports : {} +>module : { "export=": {}; } +>exports : {} -+>func18 : any + >func18 : () => void >function () { } : () => void module.exports = {}; @@ -614,10 +576,9 @@ >exports.func19 = function () { } : () => void ->exports.func19 : () => void ->exports : typeof import("b") -->func19 : () => void +>exports.func19 : any +>exports : typeof import("./b") -+>func19 : any + >func19 : () => void >function () { } : () => void module.exports.func20 = function () { }; @@ -626,11 +587,9 @@ ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->func20 : () => void +>module.exports.func20 : any +>module.exports : {} +>module : { "export=": {}; } +>exports : {} -+>func20 : any + >func20 : () => void >function () { } : () => void - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias4.types.diff index 57ca50b7d5..68d1637176 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias4.types.diff @@ -22,6 +22,6 @@ ->D : typeof wat.D ->class D { } : typeof wat.D ->D : typeof wat.D -+>D : any ++>D : typeof D +>class D { } : typeof D +>D : typeof D diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAliasElementAccessExpression.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAliasElementAccessExpression.types.diff index 4b590a05fe..7ed1b2bc40 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAliasElementAccessExpression.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAliasElementAccessExpression.types.diff @@ -5,15 +5,17 @@ >exports["D"] = D : () => void >exports["D"] : () => void ->exports : typeof import("moduleExportAliasElementAccessExpression") +->"D" : "D" +>exports : typeof import("./moduleExportAliasElementAccessExpression") - >"D" : "D" ++>"D" : () => void >D : () => void -@@= skipped -8, +8 lines =@@ + // (the only package I could find that uses spaces in identifiers is webidl-conversions) exports["Does not work yet"] = D; >exports["Does not work yet"] = D : () => void >exports["Does not work yet"] : () => void ->exports : typeof import("moduleExportAliasElementAccessExpression") +->"Does not work yet" : "Does not work yet" +>exports : typeof import("./moduleExportAliasElementAccessExpression") - >"Does not work yet" : "Does not work yet" ++>"Does not work yet" : () => void >D : () => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAliasImported.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAliasImported.types.diff index c2ddbdd552..24d661c0ab 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAliasImported.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAliasImported.types.diff @@ -6,10 +6,9 @@ >exports.version = 1 : 1 ->exports.version : 1 ->exports : typeof alias -->version : 1 +>exports.version : any +>exports : typeof import("./bug28014") -+>version : any + >version : 1 >1 : 1 function alias() { } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment4.types.diff index 343c89c389..12049554e2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment4.types.diff @@ -5,10 +5,12 @@ >exports.default = { m: 1, a: 1 } : { m: number; a: number; } >exports.default : any ->exports : any +->default : any +>exports : typeof import("./async") - >default : any ++>default : { m: number; a: number; } >{ m: 1, a: 1 } : { m: number; a: number; } >m : number + >1 : 1 @@= skipped -9, +9 lines =@@ >1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment5.types.diff index a9346d39e9..8aad28b2dd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment5.types.diff @@ -20,10 +20,9 @@ ->module.exports : { m(): void; default: Axios; } ->module : { exports: { m(): void; default: Axios; }; } ->exports : { m(): void; default: Axios; } -->default : Axios +>module.exports.default : any +>module.exports : Axios +>module : { axios: Axios; } +>exports : Axios -+>default : any + >default : Axios >axios : Axios diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportPropertyAssignmentDefault.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportPropertyAssignmentDefault.types.diff index ed40ccdb9e..3c08ff6172 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportPropertyAssignmentDefault.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportPropertyAssignmentDefault.types.diff @@ -33,5 +33,5 @@ +>module.exports : {} +>module : { axios: {}; } +>exports : {} -+>default : any ++>default : {} +>axios : {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment.types.diff index 7179afaef8..731b08cc0d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment.types.diff @@ -57,6 +57,6 @@ +>module.exports : () => void +>module : { "export=": () => void; } +>exports : () => void -+>f : any ++>f : (a: any) => void +>function (a) { } : (a: any) => void +>a : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment2.types.diff index 9bbc38b930..671dd77965 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment2.types.diff @@ -47,8 +47,9 @@ ->module.exports : number ->module : { exports: number; } ->exports : number +->f : any +>module.exports : 1 +>module : { "export=": 1; } +>exports : 1 - >f : any ++>f : () => void >function () { } : () => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment3.types.diff index 2db4d6cc09..157aa7624a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment3.types.diff @@ -75,7 +75,7 @@ +>module.exports : { justExport: number; bothBefore: number; bothAfter: number; } +>module : { "export=": { justExport: number; bothBefore: number; bothAfter: number; }; } +>exports : { justExport: number; bothBefore: number; bothAfter: number; } -+>bothBefore : number ++>bothBefore : "string" >'string' : "string" module.exports = { @@ -103,7 +103,7 @@ +>module.exports : { justExport: number; bothBefore: number; bothAfter: number; } +>module : { "export=": { justExport: number; bothBefore: number; bothAfter: number; }; } +>exports : { justExport: number; bothBefore: number; bothAfter: number; } -+>bothAfter : number ++>bothAfter : "string" >'string' : "string" module.exports.justProperty = 'string' @@ -112,10 +112,9 @@ ->module.exports : { justExport: number; bothBefore: number | "string"; bothAfter: number | "string"; justProperty: "string"; } ->module : { exports: { justExport: number; bothBefore: number | "string"; bothAfter: number | "string"; justProperty: "string"; }; } ->exports : { justExport: number; bothBefore: number | "string"; bothAfter: number | "string"; justProperty: "string"; } -->justProperty : "string" +>module.exports.justProperty : any +>module.exports : { justExport: number; bothBefore: number; bothAfter: number; } +>module : { "export=": { justExport: number; bothBefore: number; bothAfter: number; }; } +>exports : { justExport: number; bothBefore: number; bothAfter: number; } -+>justProperty : any + >justProperty : "string" >'string' : "string" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment4.types.diff index ad7a4d3685..18cabe3453 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportWithExportPropertyAssignment4.types.diff @@ -75,7 +75,7 @@ +>module.exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } +>module : { A: { (): void; justExport: number; bothBefore: number; bothAfter: number; }; } +>exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } -+>bothBefore : number ++>bothBefore : "string" >'string' : "string" A.justExport = 4 @@ -141,7 +141,7 @@ +>module.exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } +>module : { A: { (): void; justExport: number; bothBefore: number; bothAfter: number; }; } +>exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } -+>bothAfter : number ++>bothAfter : "string" >'string' : "string" module.exports.justProperty = 'string' @@ -150,10 +150,9 @@ ->module.exports : typeof A ->module : { exports: typeof A; } ->exports : typeof A -->justProperty : "string" +>module.exports.justProperty : any +>module.exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } +>module : { A: { (): void; justExport: number; bothBefore: number; bothAfter: number; }; } +>exports : { (): void; justExport: number; bothBefore: number; bothAfter: number; } -+>justProperty : any + >justProperty : "string" >'string' : "string" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.types.diff index af3ced87ac..315180f865 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.types.diff @@ -37,19 +37,23 @@ >exports["b"] = { x: "x" } : { x: string; } >exports["b"] : { x: string; } ->exports : typeof import("mod1") +->"b" : "b" +>exports : typeof import("./mod1") - >"b" : "b" ++>"b" : { x: string; } >{ x: "x" } : { x: string; } >x : string + >"x" : "x" @@= skipped -9, +9 lines =@@ exports["default"] = { x: "x" }; >exports["default"] = { x: "x" } : { x: string; } >exports["default"] : { x: string; } ->exports : typeof import("mod1") +->"default" : "default" +>exports : typeof import("./mod1") - >"default" : "default" ++>"default" : { x: string; } >{ x: "x" } : { x: string; } >x : string + >"x" : "x" @@= skipped -9, +9 lines =@@ module.exports["c"] = { x: "x" }; >module.exports["c"] = { x: "x" } : { x: string; } @@ -57,10 +61,11 @@ ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports +->"c" : "c" +>module.exports : typeof import("./mod1") +>module : { "\"mod1\"": typeof import("./mod1"); } +>exports : typeof import("./mod1") - >"c" : "c" ++>"c" : { x: string; } >{ x: "x" } : { x: string; } >x : string >"x" : "x" @@ -75,7 +80,8 @@ +>module["exports"] : typeof import("./mod1") +>module : { "\"mod1\"": typeof import("./mod1"); } >"exports" : "exports" - >"d" : "d" +->"d" : "d" ++>"d" : {} >{} : {} module["exports"]["d"].e = 0; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff deleted file mode 100644 index 1953446aba..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.recursiveTypeReferences2.errors.txt -+++ new.recursiveTypeReferences2.errors.txt -@@= skipped -0, +0 lines =@@ --bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. -- Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -- -- --==== bug39372.js (1 errors) ==== -+bug39372.js(1,36): error TS2456: Type alias 'JsonArray' circularly references itself. -+bug39372.js(3,88): error TS2456: Type alias 'Json' circularly references itself. -+bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; }'. -+ Type '{}' is missing the following properties from type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -+ -+ -+==== bug39372.js (3 errors) ==== - /** @typedef {ReadonlyArray} JsonArray */ -+ ~~~~~~~~~ -+!!! error TS2456: Type alias 'JsonArray' circularly references itself. - /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ - /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ -+ ~~~~ -+!!! error TS2456: Type alias 'Json' circularly references itself. - - /** - * @template T -@@= skipped -28, +34 lines =@@ - /** @type {XMLObject<{foo:string}>} */ - const p = {}; - ~ --!!! error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. --!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -+!!! error TS2322: Type '{}' is not assignable to type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; }'. -+!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff deleted file mode 100644 index 60d6c6455a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.recursiveTypeReferences2.types -+++ new.recursiveTypeReferences2.types -@@= skipped -25, +25 lines =@@ - - /** @type {XMLObject<{foo:string}>} */ - const p = {}; -->p : XMLObject<{ foo: string; }> -+>p : { $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; } - >{} : {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff deleted file mode 100644 index 4e89799208..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.thisTag3.types -+++ new.thisTag3.types -@@= skipped -12, +12 lines =@@ - * @param {string} a - */ - p = (a) => this.fn("" + a); -->p : (this: T, a: string) => any -->(a) => this.fn("" + a) : (this: T, a: string) => any -+>p : (this: { fn(a: string): void; }, a: string) => any -+>(a) => this.fn("" + a) : (this: { fn(a: string): void; }, a: string) => any - >a : string - >this.fn("" + a) : any - >this.fn : any \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff deleted file mode 100644 index c008b3849f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.typeTagNoErasure.types -+++ new.typeTagNoErasure.types -@@= skipped -4, +4 lines =@@ - - /** @type {Test} */ - const test = dibbity => dibbity -->test : Test -+>test : (data: T1) => T1 - >dibbity => dibbity : (dibbity: T1) => T1 - >dibbity : T1 - >dibbity : T1 - - test(1) // ok, T=1 - >test(1) : 1 -->test : Test -+>test : (data: T1) => T1 - >1 : 1 - - test('hi') // error, T=number - >test('hi') : number -->test : Test -+>test : (data: T1) => T1 - >'hi' : "hi" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.types.diff index 86695b08b1..ed888b6474 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.types.diff @@ -20,17 +20,4 @@ +>inJs : (l: any) => any >1 : 1 - /**@type {IFn}*/ - const inJsArrow = (j) => { -->inJsArrow : IFn -+>inJsArrow : (m: T) => T - >(j) => { return j;} : (j: T) => T - >j : T - -@@= skipped -22, +22 lines =@@ - } - inJsArrow(2); // no error gets linted as expected - >inJsArrow(2) : 2 -->inJsArrow : IFn -+>inJsArrow : (m: T) => T - >2 : 2 + /**@type {IFn}*/ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff index 9a21090cfa..eab0e74fa6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff @@ -84,14 +84,14 @@ var both2 = both1; ->both2 : import("mod2").Both ->both1 : import("mod1").A -+>both2 : { type: "a"; x: 1; } | { type: "b"; y: 1; } ++>both2 : import("./mod2").Both +>both1 : any /** @type {import('./mod3').Both} */ var both3 = both2; ->both3 : import("mod3").Both ->both2 : import("mod2").A -+>both3 : { type: "a"; x: 1; } | { type: "b"; y: 1; } -+>both2 : { type: "a"; x: 1; } | { type: "b"; y: 1; } ++>both3 : import("./mod3").Both ++>both2 : import("./mod2").Both diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff index f33a595b97..957890343f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff @@ -36,10 +36,9 @@ >exports.Bar = class { } : typeof Bar ->exports.Bar : typeof Bar ->exports : { Bar: typeof Bar; Baz: typeof Baz; Quid: 2; Quack?: undefined; } | { Bar: typeof Bar; Baz?: undefined; Quid: 2; Quack: number; } -->Bar : typeof Bar +>exports.Bar : any +>exports : typeof import("./mod1") -+>Bar : any + >Bar : typeof Bar >class { } : typeof Bar /** @typedef {number} Baz */ @@ -61,10 +60,9 @@ >exports.Quid = 2 : 2 ->exports.Quid : 2 ->exports : { Bar: typeof Bar; Baz: typeof Baz; Quid: 2; Quack?: undefined; } | { Bar: typeof Bar; Baz?: undefined; Quid: 2; Quack: number; } -->Quid : 2 +>exports.Quid : any +>exports : typeof import("./mod1") -+>Quid : any + >Quid : 2 >2 : 2 /** @typedef {number} Quack */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff deleted file mode 100644 index feb6000a0b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.typedefMultipleTypeParameters.types -+++ new.typedefMultipleTypeParameters.types -@@= skipped -10, +10 lines =@@ - - /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ - var tuvwx; -->tuvwx : Everything<{ a: number; b: "hi"; c: never; }, undefined, { c: true; d: 1; }, number, string> -+>tuvwx : { t: { a: number; b: "hi"; c: never; }; u: undefined; v: { c: true; d: 1; }; w: number; x: string; } - - /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ - var wrong; -->wrong : Everything<{ a: number; }, undefined, { c: 1; d: 1; }, number, string> -+>wrong : { t: { a: number; }; u: undefined; v: { c: 1; d: 1; }; w: number; x: string; } - - /** @type {Everything<{ a: number }>} */ - var insufficient; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.types.diff deleted file mode 100644 index 30a5f3c400..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.types.diff +++ /dev/null @@ -1,118 +0,0 @@ ---- old.typedefOnStatements.types -+++ new.typedefOnStatements.types -@@= skipped -92, +92 lines =@@ - * @param {Q} q - */ - function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) { -->proof : (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q) => void -->a : A -->b : B -->c : C -->d : D -->e : E -->f : F -->g : G -->h : H -->i : I -->j : J -->k : K -->l : L -->m : M -->n : N -->o : O -->p : P -->q : Q -+>proof : (a: { a: string; }, b: { b: string; }, c: { c: string; }, d: { d: string; }, e: { e: string; }, f: { f: string; }, g: { g: string; }, h: { h: string; }, i: { i: string; }, j: { j: string; }, k: { k: string; }, l: { l: string; }, m: { m: string; }, n: { n: string; }, o: { o: string; }, p: { p: string; }, q: { q: string; }) => void -+>a : { a: string; } -+>b : { b: string; } -+>c : { c: string; } -+>d : { d: string; } -+>e : { e: string; } -+>f : { f: string; } -+>g : { g: string; } -+>h : { h: string; } -+>i : { i: string; } -+>j : { j: string; } -+>k : { k: string; } -+>l : { l: string; } -+>m : { m: string; } -+>n : { n: string; } -+>o : { o: string; } -+>p : { p: string; } -+>q : { q: string; } - - console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) - >console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) : void -@@= skipped -25, +25 lines =@@ - >console : Console - >log : (...data: any[]) => void - >a.a : string -->a : A -+>a : { a: string; } - >a : string - >b.b : string -->b : B -+>b : { b: string; } - >b : string - >c.c : string -->c : C -+>c : { c: string; } - >c : string - >d.d : string -->d : D -+>d : { d: string; } - >d : string - >e.e : string -->e : E -+>e : { e: string; } - >e : string - >f.f : string -->f : F -+>f : { f: string; } - >f : string - >g.g : string -->g : G -+>g : { g: string; } - >g : string - >h.h : string -->h : H -+>h : { h: string; } - >h : string - >i.i : string -->i : I -+>i : { i: string; } - >i : string - >j.j : string -->j : J -+>j : { j: string; } - >j : string - >k.k : string -->k : K -+>k : { k: string; } - >k : string - >l.l : string -->l : L -+>l : { l: string; } - >l : string - >m.m : string -->m : M -+>m : { m: string; } - >m : string - >n.n : string -->n : N -+>n : { n: string; } - >n : string - >o.o : string -->o : O -+>o : { o: string; } - >o : string - >p.p : string -->p : P -+>p : { p: string; } - >p : string - >q.q : string -->q : Q -+>q : { q: string; } - >q : string - - /** @type {Alpha} */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.types.diff index 6d39738624..d060dcf35a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.types.diff @@ -9,32 +9,7 @@ >func : Type1 >arg : string } -@@= skipped -20, +20 lines =@@ - * @returns {string|number} The return. - */ - function check(obj) { -->check : (obj: Type2) => string | number -->obj : Type2 -+>check : (obj: { num: number; str: string; boo: boolean; }) => string | number -+>obj : { num: number; str: string; boo: boolean; } - - return obj.boo ? obj.num : obj.str; - >obj.boo ? obj.num : obj.str : string | number - >obj.boo : boolean -->obj : Type2 -+>obj : { num: number; str: string; boo: boolean; } - >boo : boolean - >obj.num : number -->obj : Type2 -+>obj : { num: number; str: string; boo: boolean; } - >num : number - >obj.str : string -->obj : Type2 -+>obj : { num: number; str: string; boo: boolean; } - >str : string - } - -@@= skipped -40, +40 lines =@@ +@@= skipped -60, +60 lines =@@ >num : number return func(bool, str, num) @@ -51,44 +26,4 @@ +>func(bool, str, num) : any >func : StringOrNumber2 >bool : boolean - >str : string -@@= skipped -25, +25 lines =@@ - * @returns {string|number} The return. - */ - function check5(obj) { -->check5 : (obj: Type5) => string | number -->obj : Type5 -+>check5 : (obj: { num: number; str: string; boo: boolean; }) => string | number -+>obj : { num: number; str: string; boo: boolean; } - - return obj.boo ? obj.num : obj.str; - >obj.boo ? obj.num : obj.str : string | number - >obj.boo : boolean -->obj : Type5 -+>obj : { num: number; str: string; boo: boolean; } - >boo : boolean - >obj.num : number -->obj : Type5 -+>obj : { num: number; str: string; boo: boolean; } - >num : number - >obj.str : string -->obj : Type5 -+>obj : { num: number; str: string; boo: boolean; } - >str : string - } - -@@= skipped -32, +32 lines =@@ - * @returns {*} The return. - */ - function check6(obj) { -->check6 : (obj: Type6) => any -->obj : Type6 -+>check6 : (obj: { foo: any; bar: any; }) => any -+>obj : { foo: any; bar: any; } - - return obj.foo; - >obj.foo : any -->obj : Type6 -+>obj : { foo: any; bar: any; } - >foo : any - } + >str : string \ No newline at end of file From 246790da737b5caa803e7e33c71396dbe4c21b5e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 25 Jun 2025 14:47:00 -0700 Subject: [PATCH 09/10] Initialized closures! --- internal/ast/utilities.go | 70 ------------------------------------- internal/parser/parser.go | 27 ++++++++++++-- internal/parser/reparser.go | 2 +- 3 files changed, 26 insertions(+), 73 deletions(-) diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index e4b6686733..5c5fd2314d 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -923,76 +923,6 @@ func SetParentInChildren(node *Node) { fn(node) } -var setParentInImmediateChildrenPool = sync.Pool{ - New: func() any { - return newParentInImmediateChildrenSetter() - }, -} - -func newParentInImmediateChildrenSetter() func(node *Node) bool { - // Consolidate state into one allocation. - // Similar to https://go.dev/cl/552375. - var state struct { - parent *Node - visit func(*Node) bool - } - - state.visit = func(node *Node) bool { - if state.parent != nil && node.Parent == nil { - node.Parent = state.parent - } - // TODO: panic if attempt to overwrite .Parent with new, different .Parent when jsdoc reparser is fixed to not reuse the same nodes in many places - if state.parent == nil { - state.parent = node - node.ForEachChild(state.visit) - state.parent = nil - } - return false - } - - return state.visit -} - -func SetParentInImmediateChildren(node *Node) { - fn := setParentInImmediateChildrenPool.Get().(func(node *Node) bool) - defer setParentInImmediateChildrenPool.Put(fn) - fn(node) -} - -var overrideParentInImmediateChildrenPool = sync.Pool{ - New: func() any { - return newOverrideParentInImmediateChildrenSetter() - }, -} - -func newOverrideParentInImmediateChildrenSetter() func(node *Node) bool { - // Consolidate state into one allocation. - // Similar to https://go.dev/cl/552375. - var state struct { - parent *Node - visit func(*Node) bool - } - - state.visit = func(node *Node) bool { - if state.parent != nil { - node.Parent = state.parent - } else { - state.parent = node - node.ForEachChild(state.visit) - state.parent = nil - } - return false - } - - return state.visit -} - -func OverrideParentInImmediateChildren(node *Node) { - fn := overrideParentInImmediateChildrenPool.Get().(func(node *Node) bool) - defer overrideParentInImmediateChildrenPool.Put(fn) - fn(node) -} - // This should never be called outside the parser func SetImportsOfSourceFile(node *SourceFile, imports []*LiteralLikeNode) { node.imports = imports diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 2aed470750..b683e4b12c 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -78,13 +78,22 @@ type Parser struct { jsdocTagCommentsSpace []string reparseList []*ast.Node commonJSModuleIndicator *ast.Node + + currentParent *ast.Node + setParentFromContext ast.Visitor +} + +func newParser() *Parser { + res := &Parser{} + res.initializeClosures() + return res } var viableKeywordSuggestions = scanner.GetViableKeywordSuggestions() var parserPool = sync.Pool{ New: func() any { - return &Parser{} + return newParser() }, } @@ -94,6 +103,7 @@ func getParser() *Parser { func putParser(p *Parser) { *p = Parser{scanner: p.scanner} + p.initializeClosures() parserPool.Put(p) } @@ -108,6 +118,13 @@ func ParseSourceFile(opts ast.SourceFileParseOptions, sourceText string, scriptK return p.parseSourceFileWorker() } +func (p *Parser) initializeClosures() { + p.setParentFromContext = func(n *ast.Node) bool { + n.Parent = p.currentParent + return false + } +} + func (p *Parser) parseJSONText() *ast.SourceFile { pos := p.nodePos() var statements *ast.NodeList @@ -5914,7 +5931,13 @@ func (p *Parser) finishNodeWithEnd(node *ast.Node, pos int, end int) { node.Flags |= ast.NodeFlagsThisNodeHasError p.hasParseError = false } - ast.OverrideParentInImmediateChildren(node) + p.overrideParentInImmediateChildren(node) +} + +func (p *Parser) overrideParentInImmediateChildren(node *ast.Node) { + p.currentParent = node + node.ForEachChild(p.setParentFromContext) + p.currentParent = nil } func (p *Parser) nextTokenIsSlash() bool { diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index 838f5cd533..557d672bc2 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -6,7 +6,7 @@ import ( ) func (p *Parser) finishReparsedNode(node *ast.Node) { - ast.OverrideParentInImmediateChildren(node) + p.overrideParentInImmediateChildren(node) } func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { From a40df1e1797007e52167ee651f717dc38fc6b33c Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 25 Jun 2025 15:16:13 -0700 Subject: [PATCH 10/10] close once --- internal/parser/parser.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index b683e4b12c..ad749bf52a 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -102,8 +102,7 @@ func getParser() *Parser { } func putParser(p *Parser) { - *p = Parser{scanner: p.scanner} - p.initializeClosures() + *p = Parser{scanner: p.scanner, setParentFromContext: p.setParentFromContext} parserPool.Put(p) }