diff --git a/internal/ast/ast.go b/internal/ast/ast.go index bab4b495e4..b1434697f7 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -366,7 +366,7 @@ func (n *Node) Expression() *Node { case KindJsxSpreadAttribute: return n.AsJsxSpreadAttribute().Expression } - panic("Unhandled case in Node.Expression") + panic("Unhandled case in Node.Expression: " + n.Kind.String()) } func (n *Node) ArgumentList() *NodeList { @@ -376,7 +376,7 @@ func (n *Node) ArgumentList() *NodeList { case KindNewExpression: return n.AsNewExpression().Arguments } - panic("Unhandled case in Node.Arguments") + panic("Unhandled case in Node.Arguments: " + n.Kind.String()) } func (n *Node) Arguments() []*Node { @@ -518,6 +518,10 @@ func (n *Node) Type() *Node { return n.AsPropertySignatureDeclaration().Type case KindPropertyDeclaration: return n.AsPropertyDeclaration().Type + case KindPropertyAssignment: + return n.AsPropertyAssignment().Type + case KindShorthandPropertyAssignment: + return n.AsShorthandPropertyAssignment().Type case KindTypePredicate: return n.AsTypePredicateNode().Type case KindParenthesizedType: @@ -552,7 +556,13 @@ func (n *Node) Type() *Node { return n.AsJSDocNonNullableType().Type case KindJSDocOptionalType: return n.AsJSDocOptionalType().Type - case KindEnumMember, KindBindingElement, KindExportAssignment, KindJSExportAssignment, KindBinaryExpression, KindCommonJSExport: + case KindExportAssignment, KindJSExportAssignment: + return n.AsExportAssignment().Type + case KindCommonJSExport: + return n.AsCommonJSExport().Type + case KindBinaryExpression: + return n.AsBinaryExpression().Type + case KindEnumMember, KindBindingElement: return nil default: funcLike := n.FunctionLikeData() @@ -4434,46 +4444,48 @@ type ExportAssignment struct { ModifiersBase compositeNodeBase IsExportEquals bool + Type *TypeNode // TypeNode. Only set by JSDoc @type tags. Expression *Expression // Expression } -func (f *NodeFactory) newExportOrJSExportAssignment(kind Kind, modifiers *ModifierList, isExportEquals bool, expression *Expression) *Node { +func (f *NodeFactory) newExportOrJSExportAssignment(kind Kind, modifiers *ModifierList, isExportEquals bool, typeNode *TypeNode, expression *Expression) *Node { data := &ExportAssignment{} data.modifiers = modifiers data.IsExportEquals = isExportEquals + data.Type = typeNode data.Expression = expression return f.newNode(kind, data) } -func (f *NodeFactory) NewExportAssignment(modifiers *ModifierList, isExportEquals bool, expression *Expression) *Node { - return f.newExportOrJSExportAssignment(KindExportAssignment, modifiers, isExportEquals, expression) +func (f *NodeFactory) NewExportAssignment(modifiers *ModifierList, isExportEquals bool, typeNode *TypeNode, expression *Expression) *Node { + return f.newExportOrJSExportAssignment(KindExportAssignment, modifiers, isExportEquals, typeNode, expression) } -func (f *NodeFactory) NewJSExportAssignment(expression *Expression) *Node { - return f.newExportOrJSExportAssignment(KindJSExportAssignment, nil /*modifiers*/, true, expression) +func (f *NodeFactory) NewJSExportAssignment(t *TypeNode, expression *Expression) *Node { + return f.newExportOrJSExportAssignment(KindJSExportAssignment, nil /*modifiers*/, true, t, expression) } -func (f *NodeFactory) UpdateExportAssignment(node *ExportAssignment, modifiers *ModifierList, expression *Expression) *Node { - if modifiers != node.modifiers || expression != node.Expression { - return updateNode(f.newExportOrJSExportAssignment(node.Kind, modifiers, node.IsExportEquals, expression), node.AsNode(), f.hooks) +func (f *NodeFactory) UpdateExportAssignment(node *ExportAssignment, modifiers *ModifierList, typeNode *TypeNode, expression *Expression) *Node { + if modifiers != node.modifiers || typeNode != node.Type || expression != node.Expression { + return updateNode(f.newExportOrJSExportAssignment(node.Kind, modifiers, node.IsExportEquals, typeNode, expression), node.AsNode(), f.hooks) } return node.AsNode() } func (node *ExportAssignment) ForEachChild(v Visitor) bool { - return visitModifiers(v, node.modifiers) || visit(v, node.Expression) + return visitModifiers(v, node.modifiers) || visit(v, node.Type) || visit(v, node.Expression) } func (node *ExportAssignment) VisitEachChild(v *NodeVisitor) *Node { - return v.Factory.UpdateExportAssignment(node, v.visitModifiers(node.modifiers), v.visitNode(node.Expression)) + return v.Factory.UpdateExportAssignment(node, v.visitModifiers(node.modifiers), v.visitNode(node.Type), v.visitNode(node.Expression)) } func (node *ExportAssignment) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().newExportOrJSExportAssignment(node.Kind, node.Modifiers(), node.IsExportEquals, node.Expression), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().newExportOrJSExportAssignment(node.Kind, node.Modifiers(), node.IsExportEquals, node.Type, node.Expression), node.AsNode(), f.AsNodeFactory().hooks) } func (node *ExportAssignment) computeSubtreeFacts() SubtreeFacts { - return propagateModifierListSubtreeFacts(node.modifiers) | propagateSubtreeFacts(node.Expression) + return propagateModifierListSubtreeFacts(node.modifiers) | propagateSubtreeFacts(node.Type) | propagateSubtreeFacts(node.Expression) } func IsExportAssignment(node *Node) bool { @@ -4496,34 +4508,36 @@ type CommonJSExport struct { ExportableBase ModifiersBase name *IdentifierNode + Type *TypeNode Initializer *Expression } -func (f *NodeFactory) NewCommonJSExport(modifiers *ModifierList, name *IdentifierNode, initializer *Expression) *Node { +func (f *NodeFactory) NewCommonJSExport(modifiers *ModifierList, name *IdentifierNode, typeNode *TypeNode, initializer *Expression) *Node { data := &CommonJSExport{} data.modifiers = modifiers data.name = name + data.Type = typeNode data.Initializer = initializer return newNode(KindCommonJSExport, data, f.hooks) } -func (f *NodeFactory) UpdateCommonJSExport(node *CommonJSExport, modifiers *ModifierList, name *IdentifierNode, initializer *Expression) *Node { - if modifiers != node.modifiers || initializer != node.Initializer || name != node.name { - return updateNode(f.NewCommonJSExport(node.modifiers, name, initializer), node.AsNode(), f.hooks) +func (f *NodeFactory) UpdateCommonJSExport(node *CommonJSExport, modifiers *ModifierList, name *IdentifierNode, typeNode *TypeNode, initializer *Expression) *Node { + if modifiers != node.modifiers || initializer != node.Initializer || name != node.name || typeNode != node.Type { + return updateNode(f.NewCommonJSExport(node.modifiers, name, typeNode, initializer), node.AsNode(), f.hooks) } return node.AsNode() } func (node *CommonJSExport) ForEachChild(v Visitor) bool { - return visitModifiers(v, node.modifiers) || visit(v, node.name) || visit(v, node.Initializer) + return visitModifiers(v, node.modifiers) || visit(v, node.name) || visit(v, node.Type) || visit(v, node.Initializer) } func (node *CommonJSExport) VisitEachChild(v *NodeVisitor) *Node { - return v.Factory.UpdateCommonJSExport(node, v.visitModifiers(node.modifiers), v.visitNode(node.name), v.visitNode(node.Initializer)) + return v.Factory.UpdateCommonJSExport(node, v.visitModifiers(node.modifiers), v.visitNode(node.name), v.visitNode(node.Type), v.visitNode(node.Initializer)) } func (node *CommonJSExport) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewCommonJSExport(node.Modifiers(), node.name, node.Initializer), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewCommonJSExport(node.Modifiers(), node.name, node.Type, node.Initializer), node.AsNode(), f.AsNodeFactory().hooks) } func IsCommonJSExport(node *Node) bool { @@ -5548,44 +5562,50 @@ func (node *NoSubstitutionTemplateLiteral) Clone(f NodeFactoryCoercible) *Node { type BinaryExpression struct { ExpressionBase DeclarationBase + ModifiersBase compositeNodeBase Left *Expression // Expression + Type *TypeNode // TypeNode. Only set by JSDoc @type tags. OperatorToken *TokenNode // TokenNode Right *Expression // Expression } -func (f *NodeFactory) NewBinaryExpression(left *Expression, operatorToken *TokenNode, right *Expression) *Node { +func (f *NodeFactory) NewBinaryExpression(modifiers *ModifierList, left *Expression, typeNode *TypeNode, operatorToken *TokenNode, right *Expression) *Node { if operatorToken == nil { panic("operatorToken is required") } data := f.binaryExpressionPool.New() + data.modifiers = modifiers data.Left = left + data.Type = typeNode data.OperatorToken = operatorToken data.Right = right return f.newNode(KindBinaryExpression, data) } -func (f *NodeFactory) UpdateBinaryExpression(node *BinaryExpression, left *Expression, operatorToken *TokenNode, right *Expression) *Node { - if left != node.Left || operatorToken != node.OperatorToken || right != node.Right { - return updateNode(f.NewBinaryExpression(left, operatorToken, right), node.AsNode(), f.hooks) +func (f *NodeFactory) UpdateBinaryExpression(node *BinaryExpression, modifiers *ModifierList, left *Expression, typeNode *TypeNode, operatorToken *TokenNode, right *Expression) *Node { + if left != node.Left || typeNode != node.Type || operatorToken != node.OperatorToken || right != node.Right { + return updateNode(f.NewBinaryExpression(modifiers, left, typeNode, operatorToken, right), node.AsNode(), f.hooks) } return node.AsNode() } func (node *BinaryExpression) ForEachChild(v Visitor) bool { - return visit(v, node.Left) || visit(v, node.OperatorToken) || visit(v, node.Right) + return visitModifiers(v, node.modifiers) || visit(v, node.Left) || visit(v, node.Type) || visit(v, node.OperatorToken) || visit(v, node.Right) } func (node *BinaryExpression) VisitEachChild(v *NodeVisitor) *Node { - return v.Factory.UpdateBinaryExpression(node, v.visitNode(node.Left), v.visitToken(node.OperatorToken), v.visitNode(node.Right)) + return v.Factory.UpdateBinaryExpression(node, v.visitModifiers(node.modifiers), v.visitNode(node.Left), v.visitNode(node.Type), v.visitToken(node.OperatorToken), v.visitNode(node.Right)) } func (node *BinaryExpression) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewBinaryExpression(node.Left, node.OperatorToken, node.Right), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewBinaryExpression(node.modifiers, node.Left, node.Type, node.OperatorToken, node.Right), node.AsNode(), f.AsNodeFactory().hooks) } func (node *BinaryExpression) computeSubtreeFacts() SubtreeFacts { - return propagateSubtreeFacts(node.Left) | + return propagateModifierListSubtreeFacts(node.modifiers) | + propagateSubtreeFacts(node.Left) | + propagateSubtreeFacts(node.Type) | propagateSubtreeFacts(node.OperatorToken) | propagateSubtreeFacts(node.Right) | core.IfElse(node.OperatorToken.Kind == KindInKeyword && IsPrivateIdentifier(node.Left), SubtreeContainsClassFields, SubtreeFactsNone) @@ -6662,39 +6682,42 @@ type PropertyAssignment struct { NamedMemberBase ObjectLiteralElementBase compositeNodeBase + Type *TypeNode // TypeNode. Only set by JSDoc @type tags. Initializer *Expression // Expression } -func (f *NodeFactory) NewPropertyAssignment(modifiers *ModifierList, name *PropertyName, postfixToken *TokenNode, initializer *Expression) *Node { +func (f *NodeFactory) NewPropertyAssignment(modifiers *ModifierList, name *PropertyName, postfixToken *TokenNode, typeNode *TypeNode, initializer *Expression) *Node { data := f.propertyAssignmentPool.New() data.modifiers = modifiers data.name = name data.PostfixToken = postfixToken + data.Type = typeNode data.Initializer = initializer return f.newNode(KindPropertyAssignment, data) } -func (f *NodeFactory) UpdatePropertyAssignment(node *PropertyAssignment, modifiers *ModifierList, name *PropertyName, postfixToken *TokenNode, initializer *Expression) *Node { - if modifiers != node.modifiers || name != node.name || postfixToken != node.PostfixToken || initializer != node.Initializer { - return updateNode(f.NewPropertyAssignment(modifiers, name, postfixToken, initializer), node.AsNode(), f.hooks) +func (f *NodeFactory) UpdatePropertyAssignment(node *PropertyAssignment, modifiers *ModifierList, name *PropertyName, postfixToken *TokenNode, typeNode *TypeNode, initializer *Expression) *Node { + if modifiers != node.modifiers || name != node.name || postfixToken != node.PostfixToken || typeNode != node.Type || initializer != node.Initializer { + return updateNode(f.NewPropertyAssignment(modifiers, name, postfixToken, typeNode, initializer), node.AsNode(), f.hooks) } return node.AsNode() } func (node *PropertyAssignment) ForEachChild(v Visitor) bool { - return visitModifiers(v, node.modifiers) || visit(v, node.name) || visit(v, node.PostfixToken) || visit(v, node.Initializer) + return visitModifiers(v, node.modifiers) || visit(v, node.name) || visit(v, node.PostfixToken) || visit(v, node.Type) || visit(v, node.Initializer) } func (node *PropertyAssignment) VisitEachChild(v *NodeVisitor) *Node { - return v.Factory.UpdatePropertyAssignment(node, v.visitModifiers(node.modifiers), v.visitNode(node.name), v.visitToken(node.PostfixToken), v.visitNode(node.Initializer)) + return v.Factory.UpdatePropertyAssignment(node, v.visitModifiers(node.modifiers), v.visitNode(node.name), v.visitToken(node.PostfixToken), v.visitNode(node.Type), v.visitNode(node.Initializer)) } func (node *PropertyAssignment) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewPropertyAssignment(node.Modifiers(), node.Name(), node.PostfixToken, node.Initializer), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewPropertyAssignment(node.Modifiers(), node.Name(), node.PostfixToken, node.Type, node.Initializer), node.AsNode(), f.AsNodeFactory().hooks) } func (node *PropertyAssignment) computeSubtreeFacts() SubtreeFacts { return propagateSubtreeFacts(node.name) | + propagateSubtreeFacts(node.Type) | propagateSubtreeFacts(node.Initializer) } @@ -6709,41 +6732,44 @@ type ShorthandPropertyAssignment struct { NamedMemberBase ObjectLiteralElementBase compositeNodeBase + Type *TypeNode // TypeNode. Only set by JSDoc @type tags. EqualsToken *TokenNode ObjectAssignmentInitializer *Expression // Optional } -func (f *NodeFactory) NewShorthandPropertyAssignment(modifiers *ModifierList, name *PropertyName, postfixToken *TokenNode, equalsToken *TokenNode, objectAssignmentInitializer *Expression) *Node { +func (f *NodeFactory) NewShorthandPropertyAssignment(modifiers *ModifierList, name *PropertyName, postfixToken *TokenNode, typeNode *TypeNode, equalsToken *TokenNode, objectAssignmentInitializer *Expression) *Node { data := &ShorthandPropertyAssignment{} data.modifiers = modifiers data.name = name data.PostfixToken = postfixToken + data.Type = typeNode data.EqualsToken = equalsToken data.ObjectAssignmentInitializer = objectAssignmentInitializer return f.newNode(KindShorthandPropertyAssignment, data) } -func (f *NodeFactory) UpdateShorthandPropertyAssignment(node *ShorthandPropertyAssignment, modifiers *ModifierList, name *PropertyName, postfixToken *TokenNode, equalsToken *TokenNode, objectAssignmentInitializer *Expression) *Node { - if modifiers != node.modifiers || name != node.name || postfixToken != node.PostfixToken || objectAssignmentInitializer != node.ObjectAssignmentInitializer { - return updateNode(f.NewShorthandPropertyAssignment(modifiers, name, postfixToken, equalsToken, objectAssignmentInitializer), node.AsNode(), f.hooks) +func (f *NodeFactory) UpdateShorthandPropertyAssignment(node *ShorthandPropertyAssignment, modifiers *ModifierList, name *PropertyName, postfixToken *TokenNode, typeNode *TypeNode, equalsToken *TokenNode, objectAssignmentInitializer *Expression) *Node { + if modifiers != node.modifiers || name != node.name || typeNode != node.Type || postfixToken != node.PostfixToken || objectAssignmentInitializer != node.ObjectAssignmentInitializer { + return updateNode(f.NewShorthandPropertyAssignment(modifiers, name, postfixToken, typeNode, equalsToken, objectAssignmentInitializer), node.AsNode(), f.hooks) } return node.AsNode() } func (node *ShorthandPropertyAssignment) ForEachChild(v Visitor) bool { - return visitModifiers(v, node.modifiers) || visit(v, node.name) || visit(v, node.PostfixToken) || visit(v, node.EqualsToken) || visit(v, node.ObjectAssignmentInitializer) + return visitModifiers(v, node.modifiers) || visit(v, node.name) || visit(v, node.Type) || visit(v, node.PostfixToken) || visit(v, node.EqualsToken) || visit(v, node.ObjectAssignmentInitializer) } func (node *ShorthandPropertyAssignment) VisitEachChild(v *NodeVisitor) *Node { - return v.Factory.UpdateShorthandPropertyAssignment(node, v.visitModifiers(node.modifiers), v.visitNode(node.name), v.visitToken(node.PostfixToken), v.visitToken(node.EqualsToken), v.visitNode(node.ObjectAssignmentInitializer)) + return v.Factory.UpdateShorthandPropertyAssignment(node, v.visitModifiers(node.modifiers), v.visitNode(node.name), v.visitToken(node.PostfixToken), v.visitNode(node.Type), v.visitToken(node.EqualsToken), v.visitNode(node.ObjectAssignmentInitializer)) } func (node *ShorthandPropertyAssignment) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewShorthandPropertyAssignment(node.Modifiers(), node.Name(), node.PostfixToken, node.EqualsToken, node.ObjectAssignmentInitializer), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewShorthandPropertyAssignment(node.Modifiers(), node.Name(), node.PostfixToken, node.Type, node.EqualsToken, node.ObjectAssignmentInitializer), node.AsNode(), f.AsNodeFactory().hooks) } func (node *ShorthandPropertyAssignment) computeSubtreeFacts() SubtreeFacts { return propagateSubtreeFacts(node.name) | // we do not use propagateSubtreeFacts here because this is an IdentifierReference + propagateSubtreeFacts(node.Type) | propagateSubtreeFacts(node.ObjectAssignmentInitializer) | SubtreeContainsTypeScript // may require rewriting in a TypeScript namespace } diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index c2bf229968..8885bc0ced 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -652,6 +652,7 @@ func isDeclarationStatementKind(kind Kind) bool { KindExportDeclaration, KindExportAssignment, KindJSExportAssignment, + KindCommonJSExport, KindNamespaceExportDeclaration: return true } @@ -859,6 +860,15 @@ func WalkUpParenthesizedTypes(node *TypeNode) *Node { return node } +func GetEffectiveTypeParent(parent *Node) *Node { + if IsInJSFile(parent) && parent.Kind == KindJSDocTypeExpression { + if host := parent.AsJSDocTypeExpression().Host; host != nil { + parent = host + } + } + return parent +} + // Walks up the parents of a node to find the containing SourceFile func GetSourceFileOfNode(node *Node) *SourceFile { for node != nil { @@ -3300,6 +3310,7 @@ func ReplaceModifiers(factory *NodeFactory, node *Node, modifierArray *ModifierL return factory.UpdateExportAssignment( node.AsExportAssignment(), modifierArray, + node.Type(), node.Expression(), ) case KindExportDeclaration: diff --git a/internal/binder/binder.go b/internal/binder/binder.go index 8828bf5617..8dca2f0166 100644 --- a/internal/binder/binder.go +++ b/internal/binder/binder.go @@ -1649,7 +1649,7 @@ func (b *Binder) bindChildren(node *ast.Node) { b.inAssignmentPattern = saveInAssignmentPattern b.bindEachChild(node) case ast.KindJSExportAssignment, ast.KindCommonJSExport: - return // Reparsed nodes do not double-bind children, which are not reparsed + // Reparsed nodes do not double-bind children, which are not reparsed default: b.bindEachChild(node) } @@ -2208,9 +2208,11 @@ func (b *Binder) bindDestructuringAssignmentFlow(node *ast.Node) { b.bind(expr.Right) b.inAssignmentPattern = true b.bind(expr.Left) + b.bind(expr.Type) } else { b.inAssignmentPattern = true b.bind(expr.Left) + b.bind(expr.Type) b.inAssignmentPattern = false b.bind(expr.OperatorToken) b.bind(expr.Right) @@ -2239,6 +2241,7 @@ func (b *Binder) bindBinaryExpressionFlow(node *ast.Node) { } } else { b.bind(expr.Left) + b.bind(expr.Type) if operator == ast.KindCommaToken { b.maybeBindExpressionFlowIfCall(node) } diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 59ed4274e8..a78ceb1980 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -2887,11 +2887,12 @@ func (c *Checker) checkTypePredicate(node *ast.Node) { } func (c *Checker) getTypePredicateParent(node *ast.Node) *ast.SignatureDeclaration { - switch node.Parent.Kind { + parent := ast.GetEffectiveTypeParent(node.Parent) + switch parent.Kind { case ast.KindArrowFunction, ast.KindCallSignature, ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindFunctionType, ast.KindMethodDeclaration, ast.KindMethodSignature: - if node == node.Parent.Type() { - return node.Parent + if node == parent.Type() { + return parent } } return nil @@ -5322,6 +5323,11 @@ func (c *Checker) checkExportAssignment(node *ast.Node) { c.error(node, diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled) } c.checkExternalModuleExports(container) + if typeNode := node.Type(); typeNode != nil && node.Kind == ast.KindExportAssignment { + t := c.getTypeFromTypeNode(typeNode) + initializerType := c.checkExpressionCached(node.Expression()) + c.checkTypeAssignableToAndOptionallyElaborate(initializerType, t, node.Expression(), node.Expression(), nil /*headMessage*/, nil) + } if (node.Flags&ast.NodeFlagsAmbient != 0) && !ast.IsEntityNameExpression(node.Expression()) { c.grammarErrorOnNode(node.Expression(), diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context) } @@ -12500,18 +12506,11 @@ func (c *Checker) checkObjectLiteral(node *ast.Node, checkMode CheckMode) *Type } if ast.IsPropertyAssignment(memberDecl) || ast.IsShorthandPropertyAssignment(memberDecl) || ast.IsObjectLiteralMethod(memberDecl) { var t *Type - switch { - case memberDecl.Kind == ast.KindPropertyAssignment: + switch memberDecl.Kind { + case ast.KindPropertyAssignment: t = c.checkPropertyAssignment(memberDecl, checkMode) - case memberDecl.Kind == ast.KindShorthandPropertyAssignment: - var expr *ast.Node - if !inDestructuringPattern { - expr = memberDecl.AsShorthandPropertyAssignment().ObjectAssignmentInitializer - } - if expr == nil { - expr = memberDecl.Name() - } - t = c.checkExpressionForMutableLocation(expr, checkMode) + case ast.KindShorthandPropertyAssignment: + t = c.checkShorthandPropertyAssignment(memberDecl, inDestructuringPattern, checkMode) default: t = c.checkObjectLiteralMethod(memberDecl, checkMode) } @@ -12946,7 +12945,30 @@ func (c *Checker) checkPropertyAssignment(node *ast.Node, checkMode CheckMode) * if ast.IsComputedPropertyName(node.Name()) { c.checkComputedPropertyName(node.Name()) } - return c.checkExpressionForMutableLocation(node.Initializer(), checkMode) + initializerType := c.checkExpressionForMutableLocation(node.Initializer(), checkMode) + if node.Type() != nil { + t := c.getTypeFromTypeNode(node.Type()) + c.checkTypeAssignableToAndOptionallyElaborate(initializerType, t, node, node.Initializer(), nil /*headMessage*/, nil) + return t + } + return initializerType +} + +func (c *Checker) checkShorthandPropertyAssignment(node *ast.Node, inDestructuringPattern bool, checkMode CheckMode) *Type { + var expr *ast.Node + if !inDestructuringPattern { + expr = node.AsShorthandPropertyAssignment().ObjectAssignmentInitializer + } + if expr == nil { + expr = node.Name() + } + expressionType := c.checkExpressionForMutableLocation(expr, checkMode) + if node.Type() != nil { + t := c.getTypeFromTypeNode(node.Type()) + c.checkTypeAssignableToAndOptionallyElaborate(expressionType, t, node, expr, nil /*headMessage*/, nil) + return t + } + return expressionType } func (c *Checker) isInPropertyInitializerOrClassStaticBlock(node *ast.Node) bool { @@ -15605,11 +15627,15 @@ func (c *Checker) getTypeOfVariableOrParameterOrPropertyWorker(symbol *ast.Symbo case ast.KindPropertyAssignment: result = c.checkPropertyAssignment(declaration, CheckModeNormal) case ast.KindShorthandPropertyAssignment: - result = c.checkExpressionForMutableLocation(declaration.Name(), CheckModeNormal) + result = c.checkShorthandPropertyAssignment(declaration, true /*inDestructuringPattern*/, CheckModeNormal) case ast.KindMethodDeclaration: result = c.checkObjectLiteralMethod(declaration, CheckModeNormal) case ast.KindExportAssignment, ast.KindJSExportAssignment: - result = c.widenTypeForVariableLikeDeclaration(c.checkExpressionCached(declaration.AsExportAssignment().Expression), declaration, false /*reportErrors*/) + if declaration.Type() != nil { + result = c.getTypeFromTypeNode(declaration.Type()) + } else { + result = c.widenTypeForVariableLikeDeclaration(c.checkExpressionCached(declaration.AsExportAssignment().Expression), declaration, false /*reportErrors*/) + } case ast.KindBinaryExpression: result = c.getWidenedTypeForAssignmentDeclaration(symbol) case ast.KindJsxAttribute: @@ -17036,23 +17062,28 @@ const ( func (c *Checker) getWidenedTypeForAssignmentDeclaration(symbol *ast.Symbol) *Type { var t *Type kind, location := c.isConstructorDeclaredThisProperty(symbol) - if kind == thisAssignmentDeclarationTyped { + switch kind { + case thisAssignmentDeclarationTyped: if location == nil { panic("location should not be nil when this assignment has a type.") } t = c.getTypeFromTypeNode(location) - } else if kind == thisAssignmentDeclarationConstructor { + case thisAssignmentDeclarationConstructor: if location == nil { panic("constructor should not be nil when this assignment is in a constructor.") } t = c.getFlowTypeInConstructor(symbol, location) - } else if kind == thisAssignmentDeclarationMethod { + case thisAssignmentDeclarationMethod: t = c.getTypeOfPropertyInBaseClass(symbol) } if t == nil { var types []*Type for _, declaration := range symbol.Declarations { if ast.IsBinaryExpression(declaration) { + if declaration.Type() != nil { + t = c.getTypeFromTypeNode(declaration.Type()) + break + } types = core.AppendIfUnique(types, c.checkExpressionForMutableLocation(declaration.AsBinaryExpression().Right, CheckModeNormal)) } } @@ -17061,7 +17092,9 @@ func (c *Checker) getWidenedTypeForAssignmentDeclaration(symbol *ast.Symbol) *Ty types = core.AppendIfUnique(types, c.undefinedOrMissingType) } } - t = c.getWidenedType(c.getUnionType(types)) + if t == nil { + t = c.getWidenedType(c.getUnionType(types)) + } } // report an all-nullable or empty union as an implicit any in JS files if symbol.ValueDeclaration != nil && ast.IsInJSFile(symbol.ValueDeclaration) && @@ -17082,7 +17115,7 @@ func (c *Checker) isConstructorDeclaredThisProperty(symbol *ast.Symbol) (thisAss if kind, ok := c.thisExpandoKinds[symbol]; ok { location, ok2 := c.thisExpandoLocations[symbol] if !ok2 { - panic("ctor should be cached whenever this expando location is cached") + panic("location should be cached whenever this expando symbol is cached") } return kind, location } @@ -17096,9 +17129,8 @@ func (c *Checker) isConstructorDeclaredThisProperty(symbol *ast.Symbol) (thisAss bin := declaration.AsBinaryExpression() if ast.GetAssignmentDeclarationKind(bin) == ast.JSDeclarationKindThisProperty && (bin.Left.Kind != ast.KindElementAccessExpression || ast.IsStringOrNumericLiteralLike(bin.Left.AsElementAccessExpression().ArgumentExpression)) { - // TODO: if bin.Type() != nil, use bin.Type() - if bin.Right.Kind == ast.KindTypeAssertionExpression { - typeAnnotation = bin.Right.AsTypeAssertion().Type + if bin.Type != nil { + typeAnnotation = bin.Type } } else { allThis = false @@ -21714,6 +21746,7 @@ func (c *Checker) getTypeFromTypeOperatorNode(node *ast.Node) *Type { } func (c *Checker) getESSymbolLikeTypeForNode(node *ast.Node) *Type { + node = ast.GetEffectiveTypeParent(node) if isValidESSymbolDeclaration(node) { symbol := c.getSymbolOfNode(node) if symbol != nil { @@ -27585,7 +27618,7 @@ func (c *Checker) getContextualType(node *ast.Node, contextFlags ContextFlags) * return c.getContextualType(parent, contextFlags) case ast.KindSatisfiesExpression: return c.getTypeFromTypeNode(parent.AsSatisfiesExpression().Type) - case ast.KindExportAssignment: + case ast.KindExportAssignment, ast.KindJSExportAssignment, ast.KindCommonJSExport: return c.tryGetTypeFromTypeNode(parent) case ast.KindJsxExpression: return c.getContextualTypeForJsxExpression(parent, contextFlags) @@ -27995,11 +28028,15 @@ func (c *Checker) getContextualTypeForDecorator(decorator *ast.Node) *Type { func (c *Checker) getContextualTypeForBinaryOperand(node *ast.Node, contextFlags ContextFlags) *Type { binary := node.Parent.AsBinaryExpression() + if t := binary.Type; t != nil { + return c.getTypeFromTypeNode(t) + } switch binary.OperatorToken.Kind { case ast.KindEqualsToken, ast.KindAmpersandAmpersandEqualsToken, ast.KindBarBarEqualsToken, ast.KindQuestionQuestionEqualsToken: // In an assignment expression, the right operand is contextually typed by the type of the left operand // unless it's an assignment declaration. - if node == binary.Right { + kind := ast.GetAssignmentDeclarationKind(binary) + if node == binary.Right && kind != ast.JSDeclarationKindModuleExports && kind != ast.JSDeclarationKindExportsProperty { return c.getContextualTypeForAssignmentExpression(binary) } case ast.KindBarBarToken, ast.KindQuestionQuestionToken: @@ -28091,6 +28128,9 @@ func (c *Checker) getContextualTypeForAssignmentExpression(binary *ast.BinaryExp } func (c *Checker) getContextualTypeForObjectLiteralElement(element *ast.Node, contextFlags ContextFlags) *Type { + if t := element.Type(); t != nil && !ast.IsObjectLiteralMethod(element) { + return c.getTypeFromTypeNode(t) + } objectLiteral := element.Parent t := c.getApparentTypeOfContextualType(objectLiteral, contextFlags) if t != nil { diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index da139ed53b..63c55b3827 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -1377,14 +1377,7 @@ func (c *Checker) checkGrammarTypeOperatorNode(node *ast.TypeOperatorNode) bool if innerType.Kind != ast.KindSymbolKeyword { return c.grammarErrorOnNode(innerType, diagnostics.X_0_expected, scanner.TokenToString(ast.KindSymbolKeyword)) } - parent := ast.WalkUpParenthesizedTypes(node.Parent) - // !!! - // if ast.IsInJSFile(parent) && isJSDocTypeExpression(parent) { - // host := getJSDocHost(parent) - // if host != nil { - // parent = getSingleVariableOfVariableStatement(host) || host - // } - // } + parent := ast.GetEffectiveTypeParent(ast.WalkUpParenthesizedTypes(node.Parent)) switch parent.Kind { case ast.KindVariableDeclaration: decl := parent.AsVariableDeclaration() diff --git a/internal/parser/jsdoc.go b/internal/parser/jsdoc.go index c70ed2a99f..de1ecf9eb0 100644 --- a/internal/parser/jsdoc.go +++ b/internal/parser/jsdoc.go @@ -26,9 +26,9 @@ const ( propertyLikeParseCallbackParameter ) -func (p *Parser) withJSDoc(node *ast.Node, hasJSDoc bool) { +func (p *Parser) withJSDoc(node *ast.Node, hasJSDoc bool) []*ast.Node { if !hasJSDoc { - return + return nil } if p.jsdocCache == nil { @@ -60,7 +60,9 @@ func (p *Parser) withJSDoc(node *ast.Node, hasJSDoc bool) { p.reparseTags(node, jsdoc) } p.jsdocCache[node] = jsdoc + return jsdoc } + return nil } func (p *Parser) parseJSDocTypeExpression(mayOmitBraces bool) *ast.Node { diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 76ac865373..dd6f962a29 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -1396,8 +1396,8 @@ func (p *Parser) parseExpressionOrLabeledStatement() *ast.Statement { } result := p.factory.NewExpressionStatement(expression) p.finishNode(result, pos) - p.withJSDoc(result, hasJSDoc && !hasParen) - p.reparseCommonJS(result) + jsdoc := p.withJSDoc(result, hasJSDoc && !hasParen) + p.reparseCommonJS(result, jsdoc) return result } @@ -2378,7 +2378,7 @@ func (p *Parser) parseExportAssignment(pos int, hasJSDoc bool, modifiers *ast.Mo p.parseSemicolon() p.contextFlags = saveContextFlags p.statementHasAwaitIdentifier = saveHasAwaitIdentifier - result := p.factory.NewExportAssignment(modifiers, isExportEquals, expression) + result := p.factory.NewExportAssignment(modifiers, isExportEquals, nil /*typeNode*/, expression) p.finishNode(result, pos) p.withJSDoc(result, hasJSDoc) return result @@ -4585,7 +4585,7 @@ func (p *Parser) makeAsExpression(left *ast.Expression, right *ast.TypeNode) *as } func (p *Parser) makeBinaryExpression(left *ast.Expression, operatorToken *ast.Node, right *ast.Expression, pos int) *ast.Node { - result := p.factory.NewBinaryExpression(left, operatorToken, right) + result := p.factory.NewBinaryExpression(nil /*modifiers*/, left, nil /*typeNode*/, operatorToken, right) p.finishNode(result, pos) return result } @@ -4727,7 +4727,7 @@ func (p *Parser) parseJsxElementOrSelfClosingElementOrFragment(inExpressionConte operatorToken := p.factory.NewToken(ast.KindCommaToken) operatorToken.Loc = core.NewTextRange(invalidElement.Pos(), invalidElement.Pos()) p.parseErrorAt(scanner.SkipTrivia(p.sourceText, topBadPos), invalidElement.End(), diagnostics.JSX_expressions_must_have_one_parent_element) - result = p.factory.NewBinaryExpression(result, operatorToken, invalidElement) + result = p.factory.NewBinaryExpression(nil /*modifiers*/, result, nil /*typeNode*/, operatorToken, invalidElement) p.finishNode(result, pos) } return result @@ -5637,11 +5637,11 @@ func (p *Parser) parseObjectLiteralElement() *ast.Node { if equalsToken != nil { initializer = doInContext(p, ast.NodeFlagsDisallowInContext, false, (*Parser).parseAssignmentExpressionOrHigher) } - node = p.factory.NewShorthandPropertyAssignment(modifiers, name, postfixToken, equalsToken, initializer) + node = p.factory.NewShorthandPropertyAssignment(modifiers, name, postfixToken, nil /*typeNode*/, equalsToken, initializer) } else { p.parseExpected(ast.KindColonToken) initializer := doInContext(p, ast.NodeFlagsDisallowInContext, false, (*Parser).parseAssignmentExpressionOrHigher) - node = p.factory.NewPropertyAssignment(modifiers, name, postfixToken, initializer) + node = p.factory.NewPropertyAssignment(modifiers, name, postfixToken, nil /*typeNode*/, initializer) } p.finishNode(node, pos) p.withJSDoc(node, hasJSDoc) diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index f6e32ec8e9..d6fb4f8e08 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" ) -func (p *Parser) reparseCommonJS(node *ast.Node) { +func (p *Parser) reparseCommonJS(node *ast.Node, jsdoc []*ast.Node) { if p.scriptKind != core.ScriptKindJS && p.scriptKind != core.ScriptKindJSX { return } @@ -17,20 +17,21 @@ func (p *Parser) reparseCommonJS(node *ast.Node) { var export *ast.Node switch kind { case ast.JSDeclarationKindModuleExports: - export = p.factory.NewJSExportAssignment(bin.Right) + export = p.factory.NewJSExportAssignment(nil, bin.Right) case ast.JSDeclarationKindExportsProperty: nodes := p.nodeSlicePool.NewSlice(1) nodes[0] = p.factory.NewModifier(ast.KindExportKeyword) nodes[0].Flags = ast.NodeFlagsReparsed nodes[0].Loc = bin.Loc // TODO: Name can sometimes be a string literal, so downstream code needs to handle this - export = p.factory.NewCommonJSExport(p.newModifierList(bin.Loc, nodes), ast.GetElementOrPropertyAccessName(bin.Left), bin.Right) + export = p.factory.NewCommonJSExport(p.newModifierList(bin.Loc, nodes), ast.GetElementOrPropertyAccessName(bin.Left), nil /*typeNode*/, bin.Right) } if export != nil { export.Flags = ast.NodeFlagsReparsed export.Loc = bin.Loc p.reparseList = append(p.reparseList, export) p.commonJSModuleIndicator = export + p.reparseTags(export, jsdoc) } } @@ -44,154 +45,74 @@ func (p *Parser) reparseTags(parent *ast.Node, jsDoc []*ast.Node) { continue } for _, tag := range tags.Nodes { - switch tag.Kind { - case ast.KindJSDocTypedefTag: - // !!! Don't mark typedefs as exported if they are not in a module - typeExpression := tag.AsJSDocTypedefTag().TypeExpression - if typeExpression == nil { - break - } - export := p.factory.NewModifier(ast.KindExportKeyword) - export.Loc = tag.Loc - export.Flags = p.contextFlags | ast.NodeFlagsReparsed - nodes := p.nodeSlicePool.NewSlice(1) - nodes[0] = export - modifiers := p.newModifierList(export.Loc, nodes) - - typeParameters := p.gatherTypeParameters(j) - - var t *ast.Node - switch typeExpression.Kind { - case ast.KindJSDocTypeExpression: - t = typeExpression.Type() - case ast.KindJSDocTypeLiteral: - members := p.nodeSlicePool.NewSlice(0) - for _, member := range typeExpression.AsJSDocTypeLiteral().JSDocPropertyTags { - var questionToken *ast.TokenNode - if member.AsJSDocPropertyTag().IsBracketed || - member.AsJSDocPropertyTag().TypeExpression != nil && member.AsJSDocPropertyTag().TypeExpression.Type().Kind == ast.KindJSDocOptionalType { - questionToken = p.factory.NewToken(ast.KindQuestionToken) - questionToken.Loc = core.NewTextRange(member.Pos(), member.End()) - questionToken.Flags = p.contextFlags | ast.NodeFlagsReparsed - } - prop := p.factory.NewPropertySignatureDeclaration(nil, member.Name(), questionToken, member.Type(), nil /*initializer*/) - prop.Loc = member.Loc - prop.Flags = p.contextFlags | ast.NodeFlagsReparsed - members = append(members, prop) - } - t = p.factory.NewTypeLiteralNode(p.newNodeList(typeExpression.Loc, members)) - t.Loc = typeExpression.Loc - t.Flags = p.contextFlags | ast.NodeFlagsReparsed - default: - panic("typedef tag type expression should be a name reference or a type expression" + typeExpression.Kind.String()) - } - typeAlias := p.factory.NewJSTypeAliasDeclaration(modifiers, tag.AsJSDocTypedefTag().Name(), typeParameters, t) - typeAlias.Loc = core.NewTextRange(tag.Pos(), tag.End()) - typeAlias.Flags = p.contextFlags | ast.NodeFlagsReparsed - p.reparseList = append(p.reparseList, typeAlias) - case ast.KindJSDocImportTag: - importTag := tag.AsJSDocImportTag() - importClause := importTag.ImportClause.Clone(&p.factory) - importClause.Flags |= ast.NodeFlagsReparsed - importClause.AsImportClause().IsTypeOnly = true - importDeclaration := p.factory.NewJSImportDeclaration(importTag.Modifiers(), importClause, importTag.ModuleSpecifier, importTag.Attributes) - importDeclaration.Loc = core.NewTextRange(tag.Pos(), tag.End()) - importDeclaration.Flags = p.contextFlags | ast.NodeFlagsReparsed - p.reparseList = append(p.reparseList, importDeclaration) - importTag.JSImportDeclaration = importDeclaration.AsImportDeclaration() - // !!! @overload and other unattached tags (@callback et al) support goes here - } - if !isLast { - continue + if parent.Kind != ast.KindCommonJSExport && parent.Kind != ast.KindJSExportAssignment { + p.reparseUnhosted(tag, j) } - switch tag.Kind { - case ast.KindJSDocTypeTag: - if parent.Kind == ast.KindVariableStatement && parent.AsVariableStatement().DeclarationList != nil { - for _, declaration := range parent.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes { - if declaration.AsVariableDeclaration().Type == nil { - declaration.AsVariableDeclaration().Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, declaration) - break - } - } - } else if parent.Kind == ast.KindVariableDeclaration { - if parent.AsVariableDeclaration().Type == nil { - parent.AsVariableDeclaration().Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) - } - } else if parent.Kind == ast.KindPropertyDeclaration { - declaration := parent.AsPropertyDeclaration() - if declaration.Type == nil { - declaration.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) - } - } else if parent.Kind == ast.KindPropertyAssignment { - prop := parent.AsPropertyAssignment() - prop.Initializer = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), prop.Initializer) - } else if parent.Kind == ast.KindExportAssignment { - export := parent.AsExportAssignment() - export.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), export.Expression) - } else if parent.Kind == ast.KindReturnStatement { - ret := parent.AsReturnStatement() - ret.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), ret.Expression) - } else if parent.Kind == ast.KindParenthesizedExpression { - paren := parent.AsParenthesizedExpression() - paren.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), paren.Expression) - } else if parent.Kind == ast.KindExpressionStatement && - parent.AsExpressionStatement().Expression.Kind == ast.KindBinaryExpression { - bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() - if ast.GetAssignmentDeclarationKind(bin) != ast.JSDeclarationKindNone { - bin.Right = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), bin.Right) - } - } - case ast.KindJSDocTemplateTag: - if fun, ok := getFunctionLikeHost(parent); ok { - if fun.TypeParameters() == nil { - fun.FunctionLikeData().TypeParameters = p.gatherTypeParameters(j) - } - } else if parent.Kind == ast.KindClassDeclaration { - class := parent.AsClassDeclaration() - if class.TypeParameters == nil { - class.TypeParameters = p.gatherTypeParameters(j) - } - } else if parent.Kind == ast.KindClassExpression { - class := parent.AsClassExpression() - if class.TypeParameters == nil { - class.TypeParameters = p.gatherTypeParameters(j) - } - } - case ast.KindJSDocParameterTag: - if fun, ok := getFunctionLikeHost(parent); ok { - jsparam := tag.AsJSDocParameterTag() - if param, ok := findMatchingParameter(fun, jsparam); ok { - if param.Type() == nil { - param.AsParameterDeclaration().Type = p.makeNewType(jsparam.TypeExpression, param) - if param.AsParameterDeclaration().QuestionToken == nil && - param.AsParameterDeclaration().Initializer == nil && - (jsparam.IsBracketed || jsparam.TypeExpression != nil && jsparam.TypeExpression.Type().Kind == ast.KindJSDocOptionalType) { - param.AsParameterDeclaration().QuestionToken = p.factory.NewToken(ast.KindQuestionToken) - param.AsParameterDeclaration().QuestionToken.Loc = core.NewTextRange(param.End(), param.End()) - param.AsParameterDeclaration().QuestionToken.Flags = p.contextFlags | ast.NodeFlagsReparsed - } - } - } - } - case ast.KindJSDocReturnTag: - if fun, ok := getFunctionLikeHost(parent); ok { - if fun.Type() == nil { - fun.FunctionLikeData().Type = p.makeNewType(tag.AsJSDocReturnTag().TypeExpression, fun) - } - } + if isLast { + p.reparseHosted(tag, parent, j) } } } } -func findMatchingParameter(fun *ast.Node, tag *ast.JSDocParameterTag) (*ast.Node, bool) { - for _, parameter := range fun.Parameters() { - if parameter.Name().Kind == ast.KindIdentifier && tag.Name().Kind == ast.KindIdentifier && - parameter.Name().Text() == tag.Name().Text() { - return parameter, true +func (p *Parser) reparseUnhosted(tag *ast.Node, jsDoc *ast.Node) { + switch tag.Kind { + case ast.KindJSDocTypedefTag: + // !!! Don't mark typedefs as exported if they are not in a module + typeExpression := tag.AsJSDocTypedefTag().TypeExpression + if typeExpression == nil { + break } + export := p.factory.NewModifier(ast.KindExportKeyword) + export.Loc = tag.Loc + export.Flags = p.contextFlags | ast.NodeFlagsReparsed + nodes := p.nodeSlicePool.NewSlice(1) + nodes[0] = export + modifiers := p.newModifierList(export.Loc, nodes) + + typeParameters := p.gatherTypeParameters(jsDoc) + + var t *ast.Node + switch typeExpression.Kind { + case ast.KindJSDocTypeExpression: + t = typeExpression.Type() + case ast.KindJSDocTypeLiteral: + members := p.nodeSlicePool.NewSlice(0) + for _, member := range typeExpression.AsJSDocTypeLiteral().JSDocPropertyTags { + var questionToken *ast.TokenNode + if member.AsJSDocPropertyTag().IsBracketed || + member.AsJSDocPropertyTag().TypeExpression != nil && member.AsJSDocPropertyTag().TypeExpression.Type().Kind == ast.KindJSDocOptionalType { + questionToken = p.factory.NewToken(ast.KindQuestionToken) + questionToken.Loc = core.NewTextRange(member.Pos(), member.End()) + questionToken.Flags = p.contextFlags | ast.NodeFlagsReparsed + } + prop := p.factory.NewPropertySignatureDeclaration(nil, member.Name(), questionToken, member.Type(), nil /*initializer*/) + prop.Loc = member.Loc + prop.Flags = p.contextFlags | ast.NodeFlagsReparsed + members = append(members, prop) + } + t = p.factory.NewTypeLiteralNode(p.newNodeList(typeExpression.Loc, members)) + t.Loc = typeExpression.Loc + t.Flags = p.contextFlags | ast.NodeFlagsReparsed + default: + panic("typedef tag type expression should be a name reference or a type expression" + typeExpression.Kind.String()) + } + typeAlias := p.factory.NewJSTypeAliasDeclaration(modifiers, tag.AsJSDocTypedefTag().Name(), typeParameters, t) + typeAlias.Loc = core.NewTextRange(tag.Pos(), tag.End()) + typeAlias.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.reparseList = append(p.reparseList, typeAlias) + case ast.KindJSDocImportTag: + importTag := tag.AsJSDocImportTag() + importClause := importTag.ImportClause.Clone(&p.factory) + importClause.Flags |= ast.NodeFlagsReparsed + importClause.AsImportClause().IsTypeOnly = true + importDeclaration := p.factory.NewJSImportDeclaration(importTag.Modifiers(), importClause, importTag.ModuleSpecifier, importTag.Attributes) + importDeclaration.Loc = core.NewTextRange(tag.Pos(), tag.End()) + importDeclaration.Flags = p.contextFlags | ast.NodeFlagsReparsed + importTag.JSImportDeclaration = importDeclaration.AsImportDeclaration() + p.reparseList = append(p.reparseList, importDeclaration) + // !!! @overload and other unattached tags (@callback et al) support goes here } - return nil, false } func (p *Parser) gatherTypeParameters(j *ast.Node) *ast.NodeList { @@ -231,6 +152,109 @@ func (p *Parser) gatherTypeParameters(j *ast.Node) *ast.NodeList { } } +func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) { + switch tag.Kind { + case ast.KindJSDocTypeTag: + if parent.Kind == ast.KindVariableStatement && parent.AsVariableStatement().DeclarationList != nil { + for _, declaration := range parent.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes { + if declaration.AsVariableDeclaration().Type == nil { + declaration.AsVariableDeclaration().Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, declaration) + break + } + } + } else if parent.Kind == ast.KindVariableDeclaration { + if parent.AsVariableDeclaration().Type == nil { + parent.AsVariableDeclaration().Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + } + } else if parent.Kind == ast.KindCommonJSExport { + export := parent.AsCommonJSExport() + if export.Type == nil { + export.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + } + } else if parent.Kind == ast.KindPropertyDeclaration { + declaration := parent.AsPropertyDeclaration() + if declaration.Type == nil { + declaration.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + } + } else if parent.Kind == ast.KindPropertyAssignment { + prop := parent.AsPropertyAssignment() + if prop.Type == nil { + prop.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + } + } else if parent.Kind == ast.KindShorthandPropertyAssignment { + prop := parent.AsShorthandPropertyAssignment() + if prop.Type == nil { + prop.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + } + } else if parent.Kind == ast.KindExportAssignment || parent.Kind == ast.KindJSExportAssignment { + export := parent.AsExportAssignment() + if export.Type == nil { + export.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + } + } else if parent.Kind == ast.KindReturnStatement { + ret := parent.AsReturnStatement() + ret.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), ret.Expression) + } else if parent.Kind == ast.KindParenthesizedExpression { + paren := parent.AsParenthesizedExpression() + paren.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), paren.Expression) + } else if parent.Kind == ast.KindExpressionStatement && + parent.AsExpressionStatement().Expression.Kind == ast.KindBinaryExpression { + bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() + if kind := ast.GetAssignmentDeclarationKind(bin); kind != ast.JSDeclarationKindNone { + bin.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent.AsExpressionStatement().Expression) + } + } + case ast.KindJSDocTemplateTag: + if fun, ok := getFunctionLikeHost(parent); ok { + if fun.TypeParameters() == nil { + fun.FunctionLikeData().TypeParameters = p.gatherTypeParameters(jsDoc) + } + } else if parent.Kind == ast.KindClassDeclaration { + class := parent.AsClassDeclaration() + if class.TypeParameters == nil { + class.TypeParameters = p.gatherTypeParameters(jsDoc) + } + } else if parent.Kind == ast.KindClassExpression { + class := parent.AsClassExpression() + if class.TypeParameters == nil { + class.TypeParameters = p.gatherTypeParameters(jsDoc) + } + } + case ast.KindJSDocParameterTag: + if fun, ok := getFunctionLikeHost(parent); ok { + jsparam := tag.AsJSDocParameterTag() + if param, ok := findMatchingParameter(fun, jsparam); ok { + if param.Type() == nil { + param.AsParameterDeclaration().Type = p.makeNewType(jsparam.TypeExpression, param) + if param.AsParameterDeclaration().QuestionToken == nil && + param.AsParameterDeclaration().Initializer == nil && + (jsparam.IsBracketed || jsparam.TypeExpression != nil && jsparam.TypeExpression.Type().Kind == ast.KindJSDocOptionalType) { + param.AsParameterDeclaration().QuestionToken = p.factory.NewToken(ast.KindQuestionToken) + param.AsParameterDeclaration().QuestionToken.Loc = core.NewTextRange(param.End(), param.End()) + param.AsParameterDeclaration().QuestionToken.Flags = p.contextFlags | ast.NodeFlagsReparsed + } + } + } + } + case ast.KindJSDocReturnTag: + if fun, ok := getFunctionLikeHost(parent); ok { + if fun.Type() == nil { + fun.FunctionLikeData().Type = p.makeNewType(tag.AsJSDocReturnTag().TypeExpression, fun) + } + } + } +} + +func findMatchingParameter(fun *ast.Node, tag *ast.JSDocParameterTag) (*ast.Node, bool) { + for _, parameter := range fun.Parameters() { + if parameter.Name().Kind == ast.KindIdentifier && tag.Name().Kind == ast.KindIdentifier && + parameter.Name().Text() == tag.Name().Text() { + return parameter, true + } + } + return nil, false +} + func getFunctionLikeHost(host *ast.Node) (*ast.Node, bool) { fun := host if host.Kind == ast.KindVariableStatement && host.AsVariableStatement().DeclarationList != nil { @@ -268,13 +292,10 @@ func (p *Parser) makeNewType(typeExpression *ast.TypeNode, host *ast.Node) *ast. } if typeExpression.AsJSDocTypeExpression().Host == nil { typeExpression.AsJSDocTypeExpression().Host = host - } else { + } else if host.Kind != ast.KindJSExportAssignment && host.Kind != ast.KindCommonJSExport { panic("JSDoc type expression already has a host: " + typeExpression.AsJSDocTypeExpression().Host.Kind.String()) } - t := typeExpression.Type().Clone(&p.factory) + t := typeExpression.Type() t.Flags |= ast.NodeFlagsReparsed - if host != nil { - t.Parent = host - } return t } diff --git a/internal/printer/factory.go b/internal/printer/factory.go index 99343b1f16..30316454f5 100644 --- a/internal/printer/factory.go +++ b/internal/printer/factory.go @@ -204,15 +204,15 @@ func (f *NodeFactory) NewFalseExpression() *ast.Expression { // func (f *NodeFactory) NewCommaExpression(left *ast.Expression, right *ast.Expression) *ast.Expression { - return f.NewBinaryExpression(left, f.NewToken(ast.KindCommaToken), right) + return f.NewBinaryExpression(nil /*modifiers*/, left, nil /*typeNode*/, f.NewToken(ast.KindCommaToken), right) } func (f *NodeFactory) NewAssignmentExpression(left *ast.Expression, right *ast.Expression) *ast.Expression { - return f.NewBinaryExpression(left, f.NewToken(ast.KindEqualsToken), right) + return f.NewBinaryExpression(nil /*modifiers*/, left, nil /*typeNode*/, f.NewToken(ast.KindEqualsToken), right) } func (f *NodeFactory) NewLogicalORExpression(left *ast.Expression, right *ast.Expression) *ast.Expression { - return f.NewBinaryExpression(left, f.NewToken(ast.KindBarBarToken), right) + return f.NewBinaryExpression(nil /*modifiers*/, left, nil /*typeNode*/, f.NewToken(ast.KindBarBarToken), right) } // func (f *NodeFactory) NewLogicalANDExpression(left *ast.Expression, right *ast.Expression) *ast.Expression @@ -222,7 +222,7 @@ func (f *NodeFactory) NewLogicalORExpression(left *ast.Expression, right *ast.Ex // func (f *NodeFactory) NewStrictEqualityExpression(left *ast.Expression, right *ast.Expression) *ast.Expression func (f *NodeFactory) NewStrictInequalityExpression(left *ast.Expression, right *ast.Expression) *ast.Expression { - return f.NewBinaryExpression(left, f.NewToken(ast.KindExclamationEqualsEqualsToken), right) + return f.NewBinaryExpression(nil /*modifiers*/, left, nil /*typeNode*/, f.NewToken(ast.KindExclamationEqualsEqualsToken), right) } // diff --git a/internal/printer/printer_test.go b/internal/printer/printer_test.go index 9af9d079d8..1bd17cc6c6 100644 --- a/internal/printer/printer_test.go +++ b/internal/printer/printer_test.go @@ -595,7 +595,9 @@ func TestParenthesizeDecorator(t *testing.T) { []*ast.Node{ factory.NewDecorator( factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindPlusToken), factory.NewIdentifier("b"), ), @@ -632,7 +634,9 @@ func TestParenthesizeComputedPropertyName(t *testing.T) { factory.NewComputedPropertyName( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -662,7 +666,9 @@ func TestParenthesizeArrayLiteral(t *testing.T) { []*ast.Node{ // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -688,7 +694,9 @@ func TestParenthesizePropertyAccess1(t *testing.T) { factory.NewPropertyAccessExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -767,7 +775,9 @@ func TestParenthesizeElementAccess1(t *testing.T) { factory.NewElementAccessExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -846,7 +856,9 @@ func TestParenthesizeCall1(t *testing.T) { factory.NewCallExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -931,7 +943,9 @@ func TestParenthesizeCall4(t *testing.T) { nil, /*typeArguments*/ factory.NewNodeList([]*ast.Node{ factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("b"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("c"), ), @@ -956,7 +970,9 @@ func TestParenthesizeNew1(t *testing.T) { factory.NewNewExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1010,7 +1026,9 @@ func TestParenthesizeNew3(t *testing.T) { nil, /*typeArguments*/ factory.NewNodeList([]*ast.Node{ factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1034,7 +1052,9 @@ func TestParenthesizeTaggedTemplate1(t *testing.T) { factory.NewTaggedTemplateExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1093,7 +1113,9 @@ func TestParenthesizeTypeAssertion1(t *testing.T) { ), // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindPlusToken), factory.NewIdentifier("b"), ), @@ -1175,7 +1197,9 @@ func TestParenthesizeDelete(t *testing.T) { factory.NewDeleteExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindPlusToken), factory.NewIdentifier("b"), ), @@ -1198,7 +1222,9 @@ func TestParenthesizeVoid(t *testing.T) { factory.NewVoidExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindPlusToken), factory.NewIdentifier("b"), ), @@ -1221,7 +1247,9 @@ func TestParenthesizeTypeOf(t *testing.T) { factory.NewTypeOfExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindPlusToken), factory.NewIdentifier("b"), ), @@ -1244,7 +1272,9 @@ func TestParenthesizeAwait(t *testing.T) { factory.NewAwaitExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindPlusToken), factory.NewIdentifier("b"), ), @@ -1321,7 +1351,9 @@ func makeSide(label string, kind ast.Kind, factory *ast.NodeFactory) *ast.Node { ) case isBinaryOperator(kind): return factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier(label+"l"), + nil, /*typeNode*/ factory.NewToken(kind), factory.NewIdentifier(label+"r"), ) @@ -1364,7 +1396,9 @@ func TestParenthesizeBinary(t *testing.T) { []*ast.Node{ factory.NewExpressionStatement( factory.NewBinaryExpression( + nil, /*modifiers*/ makeSide("l", rec.left, &factory), + nil, /*typeNode*/ factory.NewToken(rec.operator), makeSide("r", rec.right, &factory), ), @@ -1388,7 +1422,9 @@ func TestParenthesizeConditional1(t *testing.T) { factory.NewConditionalExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1415,7 +1451,9 @@ func TestParenthesizeConditional2(t *testing.T) { factory.NewConditionalExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindEqualsToken), factory.NewIdentifier("b"), ), @@ -1500,7 +1538,9 @@ func TestParenthesizeConditional5(t *testing.T) { factory.NewToken(ast.KindQuestionToken), // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("b"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("c"), ), @@ -1529,7 +1569,9 @@ func TestParenthesizeConditional6(t *testing.T) { factory.NewToken(ast.KindColonToken), // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("c"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("d"), ), @@ -1553,7 +1595,9 @@ func TestParenthesizeYield1(t *testing.T) { nil, /*asteriskToken*/ // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1583,7 +1627,9 @@ func TestParenthesizeSpreadElement1(t *testing.T) { factory.NewSpreadElement( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1616,7 +1662,9 @@ func TestParenthesizeSpreadElement2(t *testing.T) { factory.NewSpreadElement( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("b"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("c"), ), @@ -1648,7 +1696,9 @@ func TestParenthesizeSpreadElement3(t *testing.T) { factory.NewSpreadElement( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("b"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("c"), ), @@ -1674,7 +1724,9 @@ func TestParenthesizeExpressionWithTypeArguments(t *testing.T) { factory.NewExpressionWithTypeArguments( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1705,7 +1757,9 @@ func TestParenthesizeAsExpression(t *testing.T) { factory.NewAsExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1732,7 +1786,9 @@ func TestParenthesizeSatisfiesExpression(t *testing.T) { factory.NewSatisfiesExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1759,7 +1815,9 @@ func TestParenthesizeNonNullExpression(t *testing.T) { factory.NewNonNullExpression( // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), @@ -1856,6 +1914,7 @@ func TestParenthesizeExpressionDefault1(t *testing.T) { factory.NewExportAssignment( nil, /*modifiers*/ false, /*isExportEquals*/ + nil, /*typeNode*/ // will be parenthesized on emit: factory.NewClassExpression( nil, /*modifiers*/ @@ -1883,6 +1942,7 @@ func TestParenthesizeExpressionDefault2(t *testing.T) { factory.NewExportAssignment( nil, /*modifiers*/ false, /*isExportEquals*/ + nil, /*typeNode*/ // will be parenthesized on emit: factory.NewFunctionExpression( nil, /*modifiers*/ @@ -1917,9 +1977,12 @@ func TestParenthesizeExpressionDefault3(t *testing.T) { factory.NewExportAssignment( nil, /*modifiers*/ false, /*isExportEquals*/ + nil, /*typeNode*/ // will be parenthesized on emit: factory.NewBinaryExpression( + nil, /*modifiers*/ factory.NewIdentifier("a"), + nil, /*typeNode*/ factory.NewToken(ast.KindCommaToken), factory.NewIdentifier("b"), ), diff --git a/internal/transformers/commonjsmodule.go b/internal/transformers/commonjsmodule.go index a13ebd1448..1687c30574 100644 --- a/internal/transformers/commonjsmodule.go +++ b/internal/transformers/commonjsmodule.go @@ -272,6 +272,7 @@ func (tx *CommonJSModuleTransformer) createUnderscoreUnderscoreESModule() *ast.S nil, /*modifiers*/ tx.factory.NewIdentifier("value"), nil, /*postfixToken*/ + nil, /*typeNode*/ tx.factory.NewTrueExpression(), ), }), @@ -609,12 +610,14 @@ func (tx *CommonJSModuleTransformer) createExportExpression(name *ast.ModuleExpo nil, /*modifiers*/ tx.factory.NewIdentifier("enumerable"), nil, /*postfixToken*/ + nil, /*typeNode*/ tx.factory.NewTrueExpression(), ), tx.factory.NewPropertyAssignment( nil, /*modifiers*/ tx.factory.NewIdentifier("get"), nil, /*postfixToken*/ + nil, /*typeNode*/ tx.factory.NewFunctionExpression( nil, /*modifiers*/ nil, /*asteriskToken*/ @@ -1367,7 +1370,9 @@ func (tx *CommonJSModuleTransformer) visitAssignmentExpression(node *ast.BinaryE func (tx *CommonJSModuleTransformer) visitDestructuringAssignment(node *ast.BinaryExpression) *ast.Node { return tx.factory.UpdateBinaryExpression( node, + nil, /*modifiers*/ tx.assignmentPatternVisitor.VisitNode(node.Left), + nil, /*typeNode*/ node.OperatorToken, tx.visitor.VisitNode(node.Right), ) @@ -1379,6 +1384,7 @@ func (tx *CommonJSModuleTransformer) visitAssignmentProperty(node *ast.PropertyA nil, /*modifiers*/ tx.visitor.VisitNode(node.Name()), nil, /*postfixToken*/ + nil, /*typeNode*/ tx.assignmentPatternVisitor.VisitNode(node.Initializer), ) } @@ -1391,6 +1397,7 @@ func (tx *CommonJSModuleTransformer) visitShorthandAssignmentProperty(node *ast. nil, /*modifiers*/ target, nil, /*postfixToken*/ + nil, /*typeNode*/ node.EqualsToken, tx.visitor.VisitNode(node.ObjectAssignmentInitializer), ) @@ -1401,7 +1408,9 @@ func (tx *CommonJSModuleTransformer) visitShorthandAssignmentProperty(node *ast. equalsToken = tx.factory.NewToken(ast.KindEqualsToken) } target = tx.factory.NewBinaryExpression( + nil, /*modifiers*/ target, + nil, /*typeNode*/ equalsToken, tx.visitor.VisitNode(node.ObjectAssignmentInitializer), ) @@ -1410,6 +1419,7 @@ func (tx *CommonJSModuleTransformer) visitShorthandAssignmentProperty(node *ast. nil, /*modifiers*/ node.Name(), nil, /*postfixToken*/ + nil, /*typeNode*/ target, ) tx.emitContext.SetOriginal(updated, node.AsNode()) @@ -1437,7 +1447,9 @@ func (tx *CommonJSModuleTransformer) visitAssignmentElement(node *ast.Node) *ast if n.OperatorToken.Kind == ast.KindEqualsToken { return tx.factory.UpdateBinaryExpression( n, + nil, /*modifiers*/ tx.visitDestructuringAssignmentTarget(n.Left), + nil, /*typeNode*/ n.OperatorToken, tx.visitor.VisitNode(n.Right), ) @@ -1515,7 +1527,7 @@ func (tx *CommonJSModuleTransformer) visitDestructuringAssignmentTargetNoStack(n func (tx *CommonJSModuleTransformer) visitCommaExpression(node *ast.BinaryExpression, resultIsDiscarded bool) *ast.Node { left := tx.discardedValueVisitor.VisitNode(node.Left) right := core.IfElse(resultIsDiscarded, tx.discardedValueVisitor, tx.visitor).VisitNode(node.Right) - return tx.factory.UpdateBinaryExpression(node, left, node.OperatorToken, right) + return tx.factory.UpdateBinaryExpression(node, nil /*modifiers*/, left, nil /*typeNode*/, node.OperatorToken, right) } // Visits a prefix unary expression that might modify an exported identifier. @@ -1866,7 +1878,7 @@ func (tx *CommonJSModuleTransformer) visitShorthandPropertyAssignment(node *ast. tx.visitor.VisitNode(node.ObjectAssignmentInitializer), ) } - assignment := tx.factory.NewPropertyAssignment(nil /*modifiers*/, name, nil /*postfixToken*/, expression) + assignment := tx.factory.NewPropertyAssignment(nil /*modifiers*/, name, nil /*postfixToken*/, nil /*typeNode*/, expression) assignment.Loc = node.Loc tx.emitContext.AssignCommentAndSourceMapRanges(assignment, node.AsNode()) return assignment @@ -1875,6 +1887,7 @@ func (tx *CommonJSModuleTransformer) visitShorthandPropertyAssignment(node *ast. nil, /*modifiers*/ exportedOrImportedName, nil, /*postfixToken*/ + nil, /*typeNode*/ node.EqualsToken, tx.visitor.VisitNode(node.ObjectAssignmentInitializer), ) diff --git a/internal/transformers/declarations/transform.go b/internal/transformers/declarations/transform.go index a8aa849ce4..ea9b2a4197 100644 --- a/internal/transformers/declarations/transform.go +++ b/internal/transformers/declarations/transform.go @@ -931,7 +931,7 @@ func (tx *DeclarationTransformer) visitDeclarationStatements(input *ast.Node) *a } statement := tx.Factory().NewVariableStatement(modList, tx.Factory().NewVariableDeclarationList(ast.NodeFlagsConst, tx.Factory().NewNodeList([]*ast.Node{varDecl}))) - assignment := tx.Factory().UpdateExportAssignment(input.AsExportAssignment(), input.Modifiers(), newId) + assignment := tx.Factory().UpdateExportAssignment(input.AsExportAssignment(), input.Modifiers(), input.Type(), newId) // Remove coments from the export declaration and copy them onto the synthetic _default declaration tx.preserveJsDoc(statement, input) tx.removeAllComments(assignment) diff --git a/internal/transformers/esmodule.go b/internal/transformers/esmodule.go index c7d85b6064..a8d8293f2c 100644 --- a/internal/transformers/esmodule.go +++ b/internal/transformers/esmodule.go @@ -223,7 +223,7 @@ func (tx *ESModuleTransformer) visitExportDeclaration(node *ast.ExportDeclaratio var exportDecl *ast.Node if ast.IsExportNamespaceAsDefaultDeclaration(node.AsNode()) { - exportDecl = tx.factory.NewExportAssignment(nil /*modifiers*/, false /*isExportEquals*/, synthName) + exportDecl = tx.factory.NewExportAssignment(nil /*modifiers*/, false /*isExportEquals*/, nil /*typeNode*/, synthName) } else { exportDecl = tx.factory.NewExportDeclaration( nil, /*modifiers*/ diff --git a/internal/transformers/esnext.go b/internal/transformers/esnext.go index 408aaf95da..8d084fa3bc 100644 --- a/internal/transformers/esnext.go +++ b/internal/transformers/esnext.go @@ -167,6 +167,7 @@ func (tx *ESNextTransformer) visitSourceFile(node *ast.SourceFile) *ast.Node { topLevelStatements = append(topLevelStatements, tx.factory.NewExportAssignment( nil, /*modifiers*/ true, /*isExportEquals*/ + nil, /*typeNode*/ tx.exportEqualsBinding, )) } @@ -715,9 +716,9 @@ func (tx *ESNextTransformer) createDownlevelUsingStatements(bodyStatements []*as // const env_1 = { stack: [], error: void 0, hasError: false }; // envObject := tx.factory.NewObjectLiteralExpression(tx.factory.NewNodeList([]*ast.Expression{ - tx.factory.NewPropertyAssignment(nil /*modifiers*/, tx.factory.NewIdentifier("stack"), nil /*postfixToken*/, tx.factory.NewArrayLiteralExpression(nil, false /*multiLine*/)), - tx.factory.NewPropertyAssignment(nil /*modifiers*/, tx.factory.NewIdentifier("error"), nil /*postfixToken*/, tx.factory.NewVoidZeroExpression()), - tx.factory.NewPropertyAssignment(nil /*modifiers*/, tx.factory.NewIdentifier("hasError"), nil /*postfixToken*/, tx.factory.NewFalseExpression()), + tx.factory.NewPropertyAssignment(nil /*modifiers*/, tx.factory.NewIdentifier("stack"), nil /*postfixToken*/, nil /*typeNode*/, tx.factory.NewArrayLiteralExpression(nil, false /*multiLine*/)), + tx.factory.NewPropertyAssignment(nil /*modifiers*/, tx.factory.NewIdentifier("error"), nil /*postfixToken*/, nil /*typeNode*/, tx.factory.NewVoidZeroExpression()), + tx.factory.NewPropertyAssignment(nil /*modifiers*/, tx.factory.NewIdentifier("hasError"), nil /*postfixToken*/, nil /*typeNode*/, tx.factory.NewFalseExpression()), }), false /*multiLine*/) envVar := tx.factory.NewVariableDeclaration(envBinding, nil /*exclamationToken*/, nil /*typeNode*/, envObject) envVarList := tx.factory.NewVariableDeclarationList(ast.NodeFlagsConst, tx.factory.NewNodeList([]*ast.VariableDeclarationNode{envVar})) diff --git a/internal/transformers/namedevaluation.go b/internal/transformers/namedevaluation.go index d934b3e86d..dddd5c535d 100644 --- a/internal/transformers/namedevaluation.go +++ b/internal/transformers/namedevaluation.go @@ -310,7 +310,7 @@ func transformNamedEvaluationOfPropertyAssignment(context *printer.EmitContext, factory := context.Factory assignedName, name := getAssignedNameOfPropertyName(context, node.Name(), assignedNameText) initializer := finishTransformNamedEvaluation(context, node.Initializer, assignedName, ignoreEmptyStringLiteral) - return factory.UpdatePropertyAssignment(node, nil /*modifiers*/, name, nil /*postfixToken*/, initializer) + return factory.UpdatePropertyAssignment(node, nil /*modifiers*/, name, nil /*postfixToken*/, nil /*typeNode*/, initializer) } func transformNamedEvaluationOfShorthandAssignmentProperty(emitContext *printer.EmitContext, node *ast.ShorthandPropertyAssignment /*NamedEvaluation & ShorthandPropertyAssignment*/, ignoreEmptyStringLiteral bool, assignedNameText string) *ast.Expression { @@ -335,6 +335,7 @@ func transformNamedEvaluationOfShorthandAssignmentProperty(emitContext *printer. nil, /*modifiers*/ node.Name(), nil, /*postfixToken*/ + nil, /*typeNode*/ node.EqualsToken, objectAssignmentInitializer, ) @@ -500,7 +501,9 @@ func transformNamedEvaluationOfAssignmentExpression(emitContext *printer.EmitCon right := finishTransformNamedEvaluation(emitContext, node.Right, assignedName, ignoreEmptyStringLiteral) return factory.UpdateBinaryExpression( node, + nil, /*modifiers*/ node.Left, + nil, /*typeNode*/ node.OperatorToken, right, ) @@ -527,6 +530,7 @@ func transformNamedEvaluationOfExportAssignment(emitContext *printer.EmitContext return factory.UpdateExportAssignment( node, nil, /*modifiers*/ + nil, /*typeNode*/ expression, ) } diff --git a/internal/transformers/runtimesyntax.go b/internal/transformers/runtimesyntax.go index 27e18517ed..caa3eed6c9 100644 --- a/internal/transformers/runtimesyntax.go +++ b/internal/transformers/runtimesyntax.go @@ -998,13 +998,15 @@ func (tx *RuntimeSyntaxTransformer) visitShorthandPropertyAssignment(node *ast.S equalsToken = tx.factory.NewToken(ast.KindEqualsToken) } expression = tx.factory.NewBinaryExpression( + nil, /*modifiers*/ expression, + nil, /*typeNode*/ equalsToken, tx.visitor.VisitNode(node.ObjectAssignmentInitializer), ) } - updated := tx.factory.NewPropertyAssignment(nil /*modifiers*/, node.Name(), nil /*postfixToken*/, expression) + updated := tx.factory.NewPropertyAssignment(nil /*modifiers*/, node.Name(), nil /*postfixToken*/, nil /*typeNode*/, expression) updated.Loc = node.Loc tx.emitContext.SetOriginal(updated, node.AsNode()) tx.emitContext.AssignCommentAndSourceMapRanges(updated, node.AsNode()) @@ -1014,6 +1016,7 @@ func (tx *RuntimeSyntaxTransformer) visitShorthandPropertyAssignment(node *ast.S nil, /*modifiers*/ exportedOrImportedName, nil, /*postfixToken*/ + nil, /*typeNode*/ node.EqualsToken, tx.visitor.VisitNode(node.ObjectAssignmentInitializer), ) diff --git a/internal/transformers/utilities.go b/internal/transformers/utilities.go index fd1ff7f2fd..84bee466e4 100644 --- a/internal/transformers/utilities.go +++ b/internal/transformers/utilities.go @@ -181,7 +181,7 @@ func convertBindingElementToObjectAssignmentElement(emitContext *printer.EmitCon if element.Initializer != nil { expression = emitContext.Factory.NewAssignmentExpression(expression, element.Initializer) } - assignment := emitContext.Factory.NewPropertyAssignment(nil /*modifiers*/, element.PropertyName, nil /*postfixToken*/, expression) + assignment := emitContext.Factory.NewPropertyAssignment(nil /*modifiers*/, element.PropertyName, nil /*postfixToken*/, nil /*typeNode*/, expression) emitContext.SetOriginal(assignment, element.AsNode()) emitContext.AssignCommentAndSourceMapRanges(assignment, element.AsNode()) return assignment @@ -194,6 +194,7 @@ func convertBindingElementToObjectAssignmentElement(emitContext *printer.EmitCon nil, /*modifiers*/ element.Name(), nil, /*postfixToken*/ + nil, /*typeNode*/ equalsToken, element.Initializer, ) diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types index 475e6a90d6..b081eadf8c 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types @@ -21,7 +21,6 @@ class A { >this.arguments : object >this : this >arguments : object ->foo : object >foo : object } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types index 9a03bc3a9d..7dd8e53d55 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types @@ -21,7 +21,6 @@ class A { >this["arguments"] : object >this : this >"arguments" : "arguments" ->foo : object >foo : object } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types index 082c68c644..13e197938e 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types @@ -39,18 +39,16 @@ class B extends A { >this.foo : object >this : this >foo : object ->foo : object >foo : object /** * @type object */ this.bar = super.arguments.foo; ->this.bar = super.arguments.foo : object +>this.bar = super.arguments.foo : any >this.bar : object >this : this >bar : object ->super.arguments.foo : object >super.arguments.foo : any >super.arguments : { bar: {}; } >super : A diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types index edb1100ba3..cb216389aa 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types @@ -25,7 +25,6 @@ class A { >this.foo : object >this : this >foo : object ->foo : object >foo : object /** @@ -41,11 +40,10 @@ class A { * @type object */ this.bar = arguments.bar; ->this.bar = arguments.bar : object +>this.bar = arguments.bar : any >this.bar : object >this : this >bar : object ->arguments.bar : object >arguments.bar : any >arguments : object >bar : any @@ -54,11 +52,10 @@ class A { * @type object */ this.baz = arguments[key]; ->this.baz = arguments[key] : object +>this.baz = arguments[key] : any >this.baz : object >this : this >baz : object ->arguments[key] : object >arguments[key] : any >arguments : object >key : "bar" @@ -71,7 +68,6 @@ class A { >this.options : object >this : this >options : object ->arguments : object >arguments : object } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types index dfa301b550..8a2ea459fa 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types @@ -30,18 +30,16 @@ class A { >this.foo : object >this : this >foo : object ->foo : object >foo : object /** * @type object */ this.bar = bar.arguments; ->this.bar = bar.arguments : object +>this.bar = bar.arguments : {} >this.bar : object >this : this >bar : object ->bar.arguments : object >bar.arguments : {} >bar : { arguments: {}; } >arguments : {} diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor6_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor6_Js.types index ba59cbd896..f40a31737d 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor6_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor6_Js.types @@ -9,11 +9,10 @@ class A { * @type object */ this.foo = arguments; ->this.foo = arguments : object +>this.foo = arguments : IArguments >this.foo : object >this : this >foo : object ->arguments : object >arguments : IArguments } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor7_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor7_Js.types index 047e4449f9..25f345353d 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor7_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor7_Js.types @@ -14,7 +14,6 @@ class A { >this : this >callee : Function >arguments.callee : Function ->arguments.callee : Function >arguments : IArguments >callee : Function } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types index ca8c602763..fe819f951d 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types @@ -20,7 +20,6 @@ class A { >this.arguments : object >this : this >arguments : object ->foo : object >foo : object } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types index 5613bd8ad6..e4750d6b42 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types @@ -20,7 +20,6 @@ class A { >this["arguments"] : object >this : this >"arguments" : "arguments" ->foo : object >foo : object } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types index 8748baadda..1b0a4702ae 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types @@ -34,18 +34,16 @@ class B extends A { >this.x : object >this : this >x : object ->foo : object >foo : object /** * @type object */ this.y = super.arguments.bar; ->this.y = super.arguments.bar : object +>this.y = super.arguments.bar : {} >this.y : object >this : this >y : object ->super.arguments.bar : object >super.arguments.bar : {} >super.arguments : { bar: {}; } >super : A diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types index 65a0768939..0f3c0570e6 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types @@ -24,7 +24,6 @@ class A { >this.foo : object >this : this >foo : object ->foo : object >foo : object /** @@ -40,11 +39,10 @@ class A { * @type object */ this.bar = arguments.bar; ->this.bar = arguments.bar : object +>this.bar = arguments.bar : any >this.bar : object >this : this >bar : object ->arguments.bar : object >arguments.bar : any >arguments : object >bar : any @@ -53,11 +51,10 @@ class A { * @type object */ this.baz = arguments[key]; ->this.baz = arguments[key] : object +>this.baz = arguments[key] : any >this.baz : object >this : this >baz : object ->arguments[key] : object >arguments[key] : any >arguments : object >key : "bar" @@ -70,7 +67,6 @@ class A { >this.options : object >this : this >options : object ->arguments : object >arguments : object } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types index 33f2305316..efbab8d1bc 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types @@ -29,18 +29,16 @@ class A { >this.foo : object >this : this >foo : object ->foo : object >foo : object /** * @type object */ this.bar = bar.arguments; ->this.bar = bar.arguments : object +>this.bar = bar.arguments : {} >this.bar : object >this : this >bar : object ->bar.arguments : object >bar.arguments : {} >bar : { arguments: {}; } >arguments : {} diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod6_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod6_Js.types index 80ae866adb..aff03ae803 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod6_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod6_Js.types @@ -11,11 +11,10 @@ class A { * @type object */ this.foo = arguments; ->this.foo = arguments : object +>this.foo = arguments : IArguments >this.foo : object >this : this >foo : object ->arguments : object >arguments : IArguments } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod7_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod7_Js.types index 58a1f7ab1e..afae4e22ad 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod7_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod7_Js.types @@ -16,7 +16,6 @@ class A { >this : this >callee : Function >arguments.callee : Function ->arguments.callee : Function >arguments : IArguments >callee : Function } diff --git a/testdata/baselines/reference/submodule/compiler/checkJsFiles7.types b/testdata/baselines/reference/submodule/compiler/checkJsFiles7.types index 7d08242804..c4335e1467 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsFiles7.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsFiles7.types @@ -7,11 +7,10 @@ class C { constructor() { /** @type {boolean} */ this.a = true; ->this.a = true : boolean +>this.a = true : true >this.a : boolean >this : this >a : boolean ->true : boolean >true : true this.a = !!this.a; @@ -21,8 +20,8 @@ class C { >a : boolean >!!this.a : boolean >!this.a : boolean ->this.a : boolean +>this.a : true >this : this ->a : boolean +>a : true } } diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt index 6a1dc47beb..80bf4e5488 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt @@ -1,4 +1,4 @@ -a.js(8,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b +a.js(8,18): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. ==== checkJsdocTypeTagOnExportAssignment1.js (0 errors) ==== @@ -12,8 +12,8 @@ a.js(8,16): error TS2739: Type '{ c: boolean; }' is missing the following proper /** @type {Foo} */ export default { c: false }; - ~~~~~~~~~~~~ -!!! error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b + ~ +!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. ==== b.js (0 errors) ==== import a from "./a"; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.types index 7d9e67d3fc..4d3b353fe7 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.types @@ -11,7 +11,6 @@ /** @type {Foo} */ export default { c: false }; ->{ c: false } : Foo >{ c: false } : { c: boolean; } >c : boolean >false : false diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt index e72324e834..7ad65b7a41 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt @@ -1,4 +1,4 @@ -b.js(2,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b +b.js(2,18): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. ==== checkJsdocTypeTagOnExportAssignment2.js (0 errors) ==== @@ -12,8 +12,8 @@ b.js(2,16): error TS2739: Type '{ c: boolean; }' is missing the following proper ==== b.js (1 errors) ==== /** @type {import("./a").Foo} */ export default { c: false }; - ~~~~~~~~~~~~ -!!! error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b + ~ +!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. ==== c.js (0 errors) ==== import b from "./b"; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.types index d0c7ca1865..016818ad79 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.types @@ -14,7 +14,6 @@ export interface Foo { === b.js === /** @type {import("./a").Foo} */ export default { c: false }; ->{ c: false } : import("./a").Foo >{ c: false } : { c: boolean; } >c : boolean >false : false diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types index e2583c0124..d74c8372b9 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types @@ -17,13 +17,12 @@ const bar = { c: 1 }; /** @type {Foo} */ export default bar; ->bar : Foo >bar : { c: number; } === b.js === import a from "./a"; ->a : import("./a").Foo +>a : { c: number; } a; ->a : import("./a").Foo +>a : { c: number; } diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt index 68770ff145..b9fbe6d353 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt @@ -1,4 +1,4 @@ -a.js(6,16): error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +a.js(6,16): error TS2322: Type 'string' is not assignable to type 'number'. ==== checkJsdocTypeTagOnExportAssignment4.js (0 errors) ==== @@ -11,6 +11,6 @@ a.js(6,16): error TS2352: Conversion of type 'string' to type 'number' may be a /** @type {Foo} */ export default ""; ~~ -!!! error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.types index 1917332358..0a31928944 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.types @@ -3,13 +3,12 @@ === checkJsdocTypeTagOnExportAssignment4.js === === a.js === + /** * @typedef {number} Foo */ /** @type {Foo} */ export default ""; ->"" : number ->"" : "" diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.types index eb3734b6f6..da77e34bf9 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.types @@ -11,7 +11,6 @@ /** @type {Foo} */ export default { a: 1, b: 1 }; ->{ a: 1, b: 1 } : Foo >{ a: 1, b: 1 } : { a: number; b: number; } >a : number >1 : 1 diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.errors.txt new file mode 100644 index 0000000000..319b9dc4fc --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.errors.txt @@ -0,0 +1,21 @@ +a.js(8,30): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. + + +==== checkJsdocTypeTagOnExportAssignment6.js (0 errors) ==== + +==== a.js (1 errors) ==== + /** + * @typedef {Object} Foo + * @property {number} a + * @property {number} b + */ + + /** @type {Foo} */ + export default { a: 1, b: 1, c: 1 }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. + +==== b.js (0 errors) ==== + import a from "./a"; + a; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.types index 146185e2ff..9e0e0fdcc0 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.types @@ -11,7 +11,6 @@ /** @type {Foo} */ export default { a: 1, b: 1, c: 1 }; ->{ a: 1, b: 1, c: 1 } : Foo >{ a: 1, b: 1, c: 1 } : { a: number; b: number; c: number; } >a : number >1 : 1 diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types index 273ea39275..b7766d4109 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types @@ -21,13 +21,12 @@ const abc = { a: 1, b: 1, c: 1 }; /** @type {Foo} */ export default abc; ->abc : Foo >abc : { a: number; b: number; c: number; } === b.js === import a from "./a"; ->a : import("./a").Foo +>a : { a: number; b: number; c: number; } a; ->a : import("./a").Foo +>a : { a: number; b: number; c: number; } diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types index 7b4ec2e042..b8c62e6b5f 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types @@ -11,7 +11,6 @@ /** @type {Foo} */ export default { ->{ a: 'a', b: 'b'} : Foo >{ a: 'a', b: 'b'} : { a: string; b: string; } a: 'a', diff --git a/testdata/baselines/reference/submodule/compiler/commonjsAccessExports.types b/testdata/baselines/reference/submodule/compiler/commonjsAccessExports.types index b08ef54bdf..ce2c025987 100644 --- a/testdata/baselines/reference/submodule/compiler/commonjsAccessExports.types +++ b/testdata/baselines/reference/submodule/compiler/commonjsAccessExports.types @@ -18,9 +18,9 @@ exports.x; // 'exports' does not provide a contextual type to a function-class exports.Cls = function() { >exports.Cls = function() { this.x = 0; } : () => void ->exports.Cls : any +>exports.Cls : () => void >exports : typeof import("./a") ->Cls : any +>Cls : () => void >function() { this.x = 0; } : () => void this.x = 0; @@ -35,7 +35,7 @@ exports.x; const instance = new exports.Cls(); >instance : any >new exports.Cls() : any ->exports.Cls : any +>exports.Cls : () => void >exports : typeof import("./a") ->Cls : any +>Cls : () => void diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types index 8cc1fbdb5a..8c306d3ccd 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types @@ -36,11 +36,10 @@ const MyComponent2 = () => null; * @type {MyComponentProps} */ MyComponent2.defaultProps = { ->MyComponent2.defaultProps = { color: "red"} : { color: "blue" | "red"; } +>MyComponent2.defaultProps = { color: "red"} : { color: "red"; } >MyComponent2.defaultProps : { color: "blue" | "red"; } >MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } >defaultProps : { color: "blue" | "red"; } ->{ color: "red"} : { color: "blue" | "red"; } >{ color: "red"} : { color: "red"; } color: "red" @@ -70,11 +69,10 @@ function foo() { * @type {MyComponentProps} */ this.props = { color: "red" }; ->this.props = { color: "red" } : { color: "blue" | "red"; } +>this.props = { color: "red" } : { color: "red"; } >this.props : any >this : any >props : any ->{ color: "red" } : { color: "blue" | "red"; } >{ color: "red" } : { color: "red"; } >color : "red" >"red" : "red" @@ -89,11 +87,10 @@ function foo() { * @type {MyComponentProps} */ module.exports = { ->module.exports = { color: "red"} : { color: "blue" | "red"; } +>module.exports = { color: "red"} : { color: "red"; } >module.exports : { color: "blue" | "red"; } >module : { "export=": { color: "blue" | "red"; }; } >exports : { color: "blue" | "red"; } ->{ color: "red"} : { color: "blue" | "red"; } >{ color: "red"} : { color: "red"; } color: "red" diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types index 03b13b004b..4b4791a5e4 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types @@ -7,7 +7,6 @@ */ /** @type {NumberLike[]} */export default ([ ]); ->([ ]) : (string | number)[] >([ ]) : undefined[] >[ ] : undefined[] diff --git a/testdata/baselines/reference/submodule/compiler/functionExpressionNames.types b/testdata/baselines/reference/submodule/compiler/functionExpressionNames.types index e965d5e5a4..0a5b4ed29d 100644 --- a/testdata/baselines/reference/submodule/compiler/functionExpressionNames.types +++ b/testdata/baselines/reference/submodule/compiler/functionExpressionNames.types @@ -3,9 +3,9 @@ === b.js === exports.E = function() { >exports.E = function() { this.e = 'exported'} : () => void ->exports.E : any +>exports.E : () => void >exports : typeof import("./b") ->E : any +>E : () => void >function() { this.e = 'exported'} : () => void this.e = 'exported' @@ -18,9 +18,9 @@ exports.E = function() { var e = new exports.E(); >e : any >new exports.E() : any ->exports.E : any +>exports.E : () => void >exports : typeof import("./b") ->E : any +>E : () => void var o = { >o : { C: () => void; } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyType2.types b/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyType2.types index 0c92826509..ad5b19f5c9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyType2.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileClassPropertyType2.types @@ -7,11 +7,10 @@ class C { constructor() { /** @type {number[]}*/ this.p = []; ->this.p = [] : number[] +>this.p = [] : undefined[] >this.p : number[] >this : this >p : number[] ->[] : number[] >[] : undefined[] } } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt index 2bb4e07c0e..095a8b3c6b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt @@ -1,105 +1,84 @@ index.js(2,19): error TS2315: Type 'Boolean' is not generic. -index.js(2,27): error TS2304: Cannot find name 'T'. index2.js(2,19): error TS2304: Cannot find name 'Void'. -index2.js(2,24): error TS2304: Cannot find name 'T'. index3.js(2,19): error TS2304: Cannot find name 'Undefined'. -index3.js(2,29): error TS2304: Cannot find name 'T'. index4.js(2,19): error TS2315: Type 'Function' is not generic. -index4.js(2,28): error TS2304: Cannot find name 'T'. index5.js(2,19): error TS2315: Type 'String' is not generic. -index5.js(2,26): error TS2304: Cannot find name 'T'. index6.js(2,19): error TS2315: Type 'Number' is not generic. -index6.js(2,26): error TS2304: Cannot find name 'T'. index7.js(2,19): error TS2315: Type 'Object' is not generic. -index7.js(2,26): error TS2304: Cannot find name 'T'. index8.js(4,12): error TS2749: 'fn' refers to a value, but is being used as a type here. Did you mean 'typeof fn'? index8.js(4,15): error TS2304: Cannot find name 'T'. -==== index.js (2 errors) ==== +==== index.js (1 errors) ==== /** * @param {(m: Boolean) => string} somebody ~~~~~~~~~~ !!! error TS2315: Type 'Boolean' is not generic. - ~ -!!! error TS2304: Cannot find name 'T'. */ function sayHello(somebody) { return 'Hello ' + somebody; } -==== index2.js (2 errors) ==== +==== index2.js (1 errors) ==== /** * @param {(m: Void) => string} somebody ~~~~ !!! error TS2304: Cannot find name 'Void'. - ~ -!!! error TS2304: Cannot find name 'T'. */ function sayHello2(somebody) { return 'Hello ' + somebody; } -==== index3.js (2 errors) ==== +==== index3.js (1 errors) ==== /** * @param {(m: Undefined) => string} somebody ~~~~~~~~~ !!! error TS2304: Cannot find name 'Undefined'. - ~ -!!! error TS2304: Cannot find name 'T'. */ function sayHello3(somebody) { return 'Hello ' + somebody; } -==== index4.js (2 errors) ==== +==== index4.js (1 errors) ==== /** * @param {(m: Function) => string} somebody ~~~~~~~~~~~ !!! error TS2315: Type 'Function' is not generic. - ~ -!!! error TS2304: Cannot find name 'T'. */ function sayHello4(somebody) { return 'Hello ' + somebody; } -==== index5.js (2 errors) ==== +==== index5.js (1 errors) ==== /** * @param {(m: String) => string} somebody ~~~~~~~~~ !!! error TS2315: Type 'String' is not generic. - ~ -!!! error TS2304: Cannot find name 'T'. */ function sayHello5(somebody) { return 'Hello ' + somebody; } -==== index6.js (2 errors) ==== +==== index6.js (1 errors) ==== /** * @param {(m: Number) => string} somebody ~~~~~~~~~ !!! error TS2315: Type 'Number' is not generic. - ~ -!!! error TS2304: Cannot find name 'T'. */ function sayHello6(somebody) { return 'Hello ' + somebody; } -==== index7.js (2 errors) ==== +==== index7.js (1 errors) ==== /** * @param {(m: Object) => string} somebody ~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~ -!!! error TS2304: Cannot find name 'T'. */ function sayHello7(somebody) { return 'Hello ' + somebody; diff --git a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.types b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.types index b43a25561e..aa86beabe2 100644 --- a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.types +++ b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.types @@ -12,7 +12,6 @@ class Test { >this : this >data : number[] >[1, 2, 3] : number[] ->[1, 2, 3] : number[] >1 : 1 >2 : 2 >3 : 3 diff --git a/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.types b/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.types index 5bd2284cdc..f257b2b453 100644 --- a/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.types +++ b/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.types @@ -13,11 +13,10 @@ export class C { constructor() { /** @type {{ [assetName: string]: number}} */ this.assets = {}; ->this.assets = {} : { [assetName: string]: number; } +>this.assets = {} : {} >this.assets : { [assetName: string]: number; } >this : this >assets : { [assetName: string]: number; } ->{} : { [assetName: string]: number; } >{} : {} } m() { diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.types index 39cbcd771f..ecc22b7fa0 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.types @@ -13,13 +13,11 @@ const obj = { /** @type {string|undefined} */ foo: undefined, >foo : string | undefined ->undefined : string | undefined >undefined : undefined /** @type {string|undefined} */ bar: "42", >bar : string | undefined ->"42" : string | undefined >"42" : "42" /** @type {function(number): number} */ @@ -43,13 +41,11 @@ const obj = { >'b' + 'ar1' : string >'b' : "b" >'ar1' : "ar1" ->42 : number >42 : 42 /** @type {function(number): number} */ arrowFunc: (num) => num + 42 >arrowFunc : function ->(num) => num + 42 : function >(num) => num + 42 : (num: any) => any >num : any >num + 42 : any diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt index 579a296c34..0eb1d13321 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt @@ -1,4 +1,4 @@ -0.js(5,8): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string'. 0.js(10,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? 0.js(12,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? @@ -9,8 +9,8 @@ const obj = { /** @type {string|undefined} */ bar: 42, - ~~ -!!! error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + ~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. /** @type {function(number): number} */ method1(n1) { return "42"; diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.types index e9c3b299d1..cd0598e4db 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.types @@ -6,13 +6,12 @@ var lol; >lol : any const obj = { ->obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: any; } ->{ /** @type {string|undefined} */ bar: 42, /** @type {function(number): number} */ method1(n1) { return "42"; }, /** @type {function(number): number} */ method2: (n1) => "lol", /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, /** @type {string} */ lol} : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: any; } +>obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: string; } +>{ /** @type {string|undefined} */ bar: 42, /** @type {function(number): number} */ method1(n1) { return "42"; }, /** @type {function(number): number} */ method2: (n1) => "lol", /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, /** @type {string} */ lol} : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: string; } /** @type {string|undefined} */ bar: 42, >bar : string | undefined ->42 : string | undefined >42 : 42 /** @type {function(number): number} */ @@ -27,7 +26,6 @@ const obj = { /** @type {function(number): number} */ method2: (n1) => "lol", >method2 : function ->(n1) => "lol" : function >(n1) => "lol" : (n1: any) => string >n1 : any >"lol" : "lol" @@ -35,7 +33,6 @@ const obj = { /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, >arrowFunc : function ->(num="0") => num + 42 : function >(num="0") => num + 42 : (num?: string) => string >num : string >"0" : "0" @@ -45,7 +42,7 @@ const obj = { /** @type {string} */ lol ->lol : any +>lol : string } lol = "string" >lol = "string" : "string" @@ -57,7 +54,7 @@ var s = obj.method1(0); >s : string >obj.method1(0) : string >obj.method1 : (n1: any) => string ->obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: any; } +>obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: string; } >method1 : (n1: any) => string >0 : 0 @@ -66,7 +63,7 @@ var s1 = obj.method2("0"); >s1 : string >obj.method2("0") : any >obj.method2 : function ->obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: any; } +>obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: string; } >method2 : function >"0" : "0" diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctions3.types b/testdata/baselines/reference/submodule/conformance/constructorFunctions3.types index 55d4befb1b..62fe215033 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctions3.types +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctions3.types @@ -68,7 +68,6 @@ function A () { >this : any >second : any >1 : 1 ->1 : 1 } /** @param {number} n */ A.prototype.z = function f(n) { diff --git a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt index 34df0c9b04..9c910956e3 100644 --- a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt @@ -2,14 +2,12 @@ test.js(9,4): error TS2339: Property 'x' does not exist on type '{}'. test.js(14,4): error TS2339: Property 'x' does not exist on type '{}'. test.js(16,7): error TS7006: Parameter 'n' implicitly has an 'any' type. test.js(18,4): error TS2339: Property 'x' does not exist on type '{}'. -test.js(33,13): error TS2322: Type 'string' is not assignable to type '"done"'. -test.js(34,15): error TS7006: Parameter 'n' implicitly has an 'any' type. test.js(57,17): error TS2339: Property 'x' does not exist on type 'Thing'. test.js(59,7): error TS7006: Parameter 'n' implicitly has an 'any' type. test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. -==== test.js (9 errors) ==== +==== test.js (7 errors) ==== /** @typedef {{ status: 'done' m(n: number): void @@ -51,12 +49,7 @@ test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. fail() { this.s = { 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; }' 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 f04c928353..fae631cf33 100644 --- a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.types @@ -17,7 +17,6 @@ ns.x = { >ns.x : any >ns : {} >x : any ->{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } >{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } status: 'done', @@ -61,7 +60,6 @@ class Thing { >this.s : { status: "done"; m(n: number): void; } >this : this >s : { status: "done"; m(n: number): void; } ->{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } >{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } status: 'done', @@ -78,19 +76,19 @@ class Thing { >fail : () => void this.s = { ->this.s = { status: 'done', m(n) { } } : { status: string; m(n: any): void; } +>this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } >this.s : { status: "done"; m(n: number): void; } >this : this >s : { status: "done"; m(n: number): void; } ->{ status: 'done', m(n) { } } : { status: string; m(n: any): void; } +>{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } status: 'done', ->status : string +>status : "done" >'done' : "done" m(n) { } ->m : (n: any) => void ->n : any +>m : (n: number) => void +>n : number } } } @@ -103,7 +101,6 @@ exports.x = { >exports.x : { status: "done"; m(n: number): void; } >exports : typeof import("./test") >x : { status: "done"; m(n: number): void; } ->{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } status: "done", @@ -127,7 +124,6 @@ module.exports.y = { >module : { "\"test\"": typeof import("./test"); } >exports : typeof import("./test") >y : { status: "done"; m(n: number): void; } ->{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } status: "done", @@ -181,7 +177,6 @@ F.prototype = { >F.prototype : { status: "done"; m(n: number): void; } >F : { (): void; prototype: { status: "done"; m(n: number): void; }; } >prototype : { status: "done"; m(n: number): void; } ->{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } status: "done", @@ -201,7 +196,6 @@ module.exports = { >module.exports : { status: "done"; m(n: number): void; } >module : { "export=": { status: "done"; m(n: number): void; }; } >exports : { status: "done"; m(n: number): void; } ->{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } status: "done", diff --git a/testdata/baselines/reference/submodule/conformance/enumTag.types b/testdata/baselines/reference/submodule/conformance/enumTag.types index e8fa8e9905..03c5f941bd 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTag.types +++ b/testdata/baselines/reference/submodule/conformance/enumTag.types @@ -25,7 +25,6 @@ const Target = { /** @type {number} */ OK_I_GUESS: 2 >OK_I_GUESS : number ->2 : number >2 : 2 } /** @enum number */ @@ -44,7 +43,6 @@ const Second = { /** @type {number} */ FINE: 2, >FINE : number ->2 : number >2 : 2 } /** @enum {function(number): number} */ diff --git a/testdata/baselines/reference/submodule/conformance/enumTagOnExports.types b/testdata/baselines/reference/submodule/conformance/enumTagOnExports.types index f61f7a59c4..2a041435f5 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTagOnExports.types +++ b/testdata/baselines/reference/submodule/conformance/enumTagOnExports.types @@ -4,18 +4,18 @@ /** @enum {number} */ exports.a = {}; >exports.a = {} : {} ->exports.a : any +>exports.a : {} >exports : typeof import("./enumTagOnExports") ->a : any +>a : {} >{} : {} /** @enum {string} */ module.exports.b = {}; >module.exports.b = {} : {} ->module.exports.b : any +>module.exports.b : {} >module.exports : typeof import("./enumTagOnExports") >module : { "\"enumTagOnExports\"": typeof import("./enumTagOnExports"); } >exports : typeof import("./enumTagOnExports") ->b : any +>b : {} >{} : {} diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt index a02025e400..de19b01701 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt @@ -1,10 +1,14 @@ +mod.js(2,11): error TS2339: Property 'K' does not exist on type '{}'. +use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -==== mod.js (0 errors) ==== +==== mod.js (1 errors) ==== exports.n = {}; exports.n.K = function () { + ~ +!!! error TS2339: Property 'K' does not exist on type '{}'. this.x = 10; } exports.Classic = class { @@ -13,10 +17,12 @@ use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as } } -==== use.js (2 errors) ==== +==== use.js (3 errors) ==== import * as s from './mod' var k = new s.n.K() + ~ +!!! error TS2339: Property 'K' does not exist on type '{}'. k.x var classic = new s.Classic() diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.types b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.types index bc441f5d72..a7f74b14dd 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.types +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.types @@ -3,17 +3,17 @@ === mod.js === exports.n = {}; >exports.n = {} : {} ->exports.n : any +>exports.n : {} >exports : typeof import("./mod") ->n : any +>n : {} >{} : {} exports.n.K = function () { >exports.n.K = function () { this.x = 10;} : () => void >exports.n.K : any ->exports.n : any +>exports.n : {} >exports : typeof import("./mod") ->n : any +>n : {} >K : any >function () { this.x = 10;} : () => void @@ -49,9 +49,9 @@ var k = new s.n.K() >k : any >new s.n.K() : any >s.n.K : any ->s.n : any +>s.n : {} >s : typeof s ->n : any +>n : {} >K : any k.x diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt index 67b03a3c01..267c1730e9 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt @@ -4,6 +4,8 @@ first.js(2,1): error TS2304: Cannot find name 'exports'. second.js(1,1): error TS2304: Cannot find name 'exports'. second.js(1,11): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. second.js(2,1): error TS2304: Cannot find name 'exports'. +use.js(3,18): error TS2339: Property 'j' does not exist on type '{}'. +use.js(4,28): error TS2339: Property 'o' does not exist on type '{}'. ==== mod.js (0 errors) ==== @@ -32,9 +34,13 @@ second.js(2,1): error TS2304: Cannot find name 'exports'. return v } -==== use.js (0 errors) ==== +==== use.js (2 errors) ==== import * as debug from './mod' debug.formatters.j + ~ +!!! error TS2339: Property 'j' does not exist on type '{}'. var one = debug.formatters.o(1) + ~ +!!! error TS2339: Property 'o' does not exist on type '{}'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.types b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.types index 85bf302d0c..4cce3d6368 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.types +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.types @@ -4,9 +4,9 @@ // Based on a pattern from adonis exports.formatters = {} >exports.formatters = {} : {} ->exports.formatters : any +>exports.formatters : {} >exports : typeof import("./mod") ->formatters : any +>formatters : {} >{} : {} === first.js === @@ -58,18 +58,18 @@ import * as debug from './mod' debug.formatters.j >debug.formatters.j : any ->debug.formatters : any +>debug.formatters : {} >debug : typeof debug ->formatters : any +>formatters : {} >j : any var one = debug.formatters.o(1) >one : any >debug.formatters.o(1) : any >debug.formatters.o : any ->debug.formatters : any +>debug.formatters : {} >debug : typeof debug ->formatters : any +>formatters : {} >o : any >1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt new file mode 100644 index 0000000000..f346a8c3e3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt @@ -0,0 +1,25 @@ +instantiateTemplateTagTypeParameterOnVariableStatement.js(12,5): error TS2322: Type 'T' is not assignable to type 'string'. +instantiateTemplateTagTypeParameterOnVariableStatement.js(12,24): error TS2345: Argument of type 'string' is not assignable to parameter of type 'T'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. + + +==== instantiateTemplateTagTypeParameterOnVariableStatement.js (2 errors) ==== + /** + * @template T + * @param {T} a + * @returns {(b: T) => T} + */ + const seq = a => b => b; + + const text1 = "hello"; + const text2 = "world"; + + /** @type {string} */ + var text3 = seq(text1)(text2); + ~~~~~ +!!! error TS2322: Type 'T' is not assignable to type 'string'. +!!! related TS2208 instantiateTemplateTagTypeParameterOnVariableStatement.js:2:14: This type parameter might need an `extends string` constraint. + ~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'T'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types index 72bbe8f04d..3c17660135 100644 --- a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types +++ b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types @@ -25,8 +25,8 @@ const text2 = "world"; /** @type {string} */ var text3 = seq(text1)(text2); >text3 : string ->seq(text1)(text2) : string ->seq(text1) : (b: string) => string +>seq(text1)(text2) : T +>seq(text1) : (b: T) => T >seq : (a: T) => (b: T) => T >text1 : "hello" >text2 : "world" diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.types index 3bb4eed24e..440509b700 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.types @@ -21,7 +21,6 @@ export const Target = { /** @type {number} */ OK_I_GUESS: 2 >OK_I_GUESS : number ->2 : number >2 : 2 } /** @enum number */ @@ -36,7 +35,6 @@ export const Second = { /** @type {number} */ FINE: 2, >FINE : number ->2 : number >2 : 2 } /** @enum {function(number): number} */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.symbols index f0c785a0b4..b2905a3bdc 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.symbols @@ -12,11 +12,13 @@ module.exports.MyClass = function() { this.x = 1 } module.exports.MyClass.prototype = { +>module.exports.MyClass.prototype : Symbol(prototype, Decl(lib.es5.d.ts, --, --)) >module.exports.MyClass : Symbol(MyClass, Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0)) >module.exports : Symbol("jsDeclarationsExportAssignedConstructorFunction", Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0)) >module : Symbol(module.exports) >exports : Symbol("jsDeclarationsExportAssignedConstructorFunction", Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0)) >MyClass : Symbol(MyClass, Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0)) +>prototype : Symbol(prototype, Decl(lib.es5.d.ts, --, --)) a: function() { >a : Symbol(a, Decl(jsDeclarationsExportAssignedConstructorFunction.js, 4, 36)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.symbols.diff index 094da5d353..f0a08f6844 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.symbols.diff @@ -28,11 +28,13 @@ ->exports : Symbol(module.exports, Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0)) ->MyClass : Symbol(MyClass, Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0), Decl(jsDeclarationsExportAssignedConstructorFunction.js, 4, 15)) ->prototype : Symbol(MyClass.prototype, Decl(jsDeclarationsExportAssignedConstructorFunction.js, 3, 1)) ++>module.exports.MyClass.prototype : Symbol(prototype, Decl(lib.es5.d.ts, --, --)) +>module.exports.MyClass : Symbol(MyClass, Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0)) +>module.exports : Symbol("jsDeclarationsExportAssignedConstructorFunction", Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0)) +>module : Symbol(module.exports) +>exports : Symbol("jsDeclarationsExportAssignedConstructorFunction", Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0)) +>MyClass : Symbol(MyClass, Decl(jsDeclarationsExportAssignedConstructorFunction.js, 0, 0)) ++>prototype : Symbol(prototype, Decl(lib.es5.d.ts, --, --)) a: function() { >a : Symbol(a, Decl(jsDeclarationsExportAssignedConstructorFunction.js, 4, 36)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.types index 69ab036964..c9cb7b8192 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.types @@ -4,11 +4,11 @@ /** @constructor */ module.exports.MyClass = function() { >module.exports.MyClass = function() { this.x = 1} : () => void ->module.exports.MyClass : any +>module.exports.MyClass : () => void >module.exports : typeof import("./jsDeclarationsExportAssignedConstructorFunction") >module : { "\"jsDeclarationsExportAssignedConstructorFunction\"": typeof import("./jsDeclarationsExportAssignedConstructorFunction"); } >exports : typeof import("./jsDeclarationsExportAssignedConstructorFunction") ->MyClass : any +>MyClass : () => void >function() { this.x = 1} : () => void this.x = 1 @@ -21,11 +21,11 @@ module.exports.MyClass = function() { module.exports.MyClass.prototype = { >module.exports.MyClass.prototype = { a: function() { }} : { a: () => void; } >module.exports.MyClass.prototype : any ->module.exports.MyClass : any +>module.exports.MyClass : () => void >module.exports : typeof import("./jsDeclarationsExportAssignedConstructorFunction") >module : { "\"jsDeclarationsExportAssignedConstructorFunction\"": typeof import("./jsDeclarationsExportAssignedConstructorFunction"); } >exports : typeof import("./jsDeclarationsExportAssignedConstructorFunction") ->MyClass : any +>MyClass : () => void >prototype : any >{ a: function() { }} : { a: () => void; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.types index ee3576f332..50467cb084 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.types @@ -12,11 +12,10 @@ export function Vec(len) { * @type {number[]} */ this.storage = new Array(len); ->this.storage = new Array(len) : number[] +>this.storage = new Array(len) : any[] >this.storage : any >this : any >storage : any ->new Array(len) : number[] >new Array(len) : any[] >Array : ArrayConstructor >len : number diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt index a435838ea1..e4e224acd2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt @@ -1,15 +1,22 @@ +index.js(4,18): error TS2339: Property 'cat' does not exist on type '() => void'. +index.js(7,18): error TS2339: Property 'Cls' does not exist on type '() => void'. +index.js(31,18): error TS2339: Property 'self' does not exist on type '(a: any) => any'. index.js(35,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== index.js (2 errors) ==== +==== index.js (5 errors) ==== module.exports.a = function a() {} module.exports.b = function b() {} module.exports.b.cat = "cat"; + ~~~ +!!! error TS2339: Property 'cat' does not exist on type '() => void'. module.exports.c = function c() {} module.exports.c.Cls = class {} + ~~~ +!!! error TS2339: Property 'Cls' does not exist on type '() => void'. /** * @param {number} a @@ -34,6 +41,8 @@ index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install return a; } module.exports.f.self = module.exports.f; + ~~~~ +!!! error TS2339: Property 'self' does not exist on type '(a: any) => any'. /** * @param {{x: string}} a diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types index c4a24dda71..a178b06c90 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types @@ -3,53 +3,53 @@ === index.js === module.exports.a = function a() {} >module.exports.a = function a() {} : () => void ->module.exports.a : any +>module.exports.a : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->a : any +>a : () => void >function a() {} : () => void >a : () => void module.exports.b = function b() {} >module.exports.b = function b() {} : () => void ->module.exports.b : any +>module.exports.b : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->b : any +>b : () => void >function b() {} : () => void >b : () => void module.exports.b.cat = "cat"; >module.exports.b.cat = "cat" : "cat" >module.exports.b.cat : any ->module.exports.b : any +>module.exports.b : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->b : any +>b : () => void >cat : any >"cat" : "cat" module.exports.c = function c() {} >module.exports.c = function c() {} : () => void ->module.exports.c : any +>module.exports.c : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->c : any +>c : () => void >function c() {} : () => void >c : () => void module.exports.c.Cls = class {} >module.exports.c.Cls = class {} : typeof Cls >module.exports.c.Cls : any ->module.exports.c : any +>module.exports.c : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->c : any +>c : () => void >Cls : any >class {} : typeof Cls @@ -60,11 +60,11 @@ module.exports.c.Cls = class {} */ module.exports.d = function d(a, b) { return /** @type {*} */(null); } >module.exports.d = function d(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any ->module.exports.d : any +>module.exports.d : (a: any, b: any) => any >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->d : any +>d : (a: any, b: any) => any >function d(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any >d : (a: any, b: any) => any >a : any @@ -80,11 +80,11 @@ module.exports.d = function d(a, b) { return /** @type {*} */(null); } */ module.exports.e = function e(a, b) { return /** @type {*} */(null); } >module.exports.e = function e(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any ->module.exports.e : any +>module.exports.e : (a: any, b: any) => any >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->e : any +>e : (a: any, b: any) => any >function e(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any >e : (a: any, b: any) => any >a : any @@ -98,11 +98,11 @@ module.exports.e = function e(a, b) { return /** @type {*} */(null); } */ module.exports.f = function f(a) { >module.exports.f = function f(a) { return a;} : (a: any) => any ->module.exports.f : any +>module.exports.f : (a: any) => any >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->f : any +>f : (a: any) => any >function f(a) { return a;} : (a: any) => any >f : (a: any) => any >a : any @@ -111,19 +111,19 @@ module.exports.f = function f(a) { >a : any } module.exports.f.self = module.exports.f; ->module.exports.f.self = module.exports.f : any +>module.exports.f.self = module.exports.f : (a: any) => any >module.exports.f.self : any ->module.exports.f : any +>module.exports.f : (a: any) => any >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->f : any +>f : (a: any) => any >self : any ->module.exports.f : any +>module.exports.f : (a: any) => any >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->f : any +>f : (a: any) => any /** * @param {{x: string}} a @@ -185,48 +185,48 @@ module.exports.h = hh; module.exports.i = function i() {} >module.exports.i = function i() {} : () => void ->module.exports.i : any +>module.exports.i : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->i : any +>i : () => void >function i() {} : () => void >i : () => void module.exports.ii = module.exports.i; ->module.exports.ii = module.exports.i : any ->module.exports.ii : any +>module.exports.ii = module.exports.i : () => void +>module.exports.ii : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->ii : any ->module.exports.i : any +>ii : () => void +>module.exports.i : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->i : any +>i : () => void // note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings module.exports.jj = module.exports.j; ->module.exports.jj = module.exports.j : any ->module.exports.jj : any +>module.exports.jj = module.exports.j : () => void +>module.exports.jj : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->jj : any ->module.exports.j : any +>jj : () => void +>module.exports.j : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->j : any +>j : () => void module.exports.j = function j() {} >module.exports.j = function j() {} : () => void ->module.exports.j : any +>module.exports.j : () => void >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->j : any +>j : () => void >function j() {} : () => void >j : () => void diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.types index 187509ec26..f80120c9be 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.types @@ -66,11 +66,10 @@ class Render { * @type {Rectangle[]} */ this.objects = []; ->this.objects = [] : Rectangle[] +>this.objects = [] : undefined[] >this.objects : Rectangle[] >this : this >objects : Rectangle[] ->[] : Rectangle[] >[] : undefined[] } /** diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt index b54ec9236b..b8e52a3a33 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt @@ -1,7 +1,8 @@ index.js(3,19): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +index.js(5,18): error TS2339: Property 'B' does not exist on type '{}'. -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== /// const Something = require("fs").Something; @@ -9,6 +10,8 @@ index.js(3,19): error TS2580: Cannot find name 'require'. Do you need to install !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. module.exports.A = {} module.exports.A.B = { + ~ +!!! error TS2339: Property 'B' does not exist on type '{}'. thing: new Something() } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.types index 71b6c1c34e..aab876a0d7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.types @@ -13,21 +13,21 @@ const Something = require("fs").Something; module.exports.A = {} >module.exports.A = {} : {} ->module.exports.A : any +>module.exports.A : {} >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->A : any +>A : {} >{} : {} module.exports.A.B = { >module.exports.A.B = { thing: new Something()} : { thing: any; } >module.exports.A.B : any ->module.exports.A : any +>module.exports.A : {} >module.exports : typeof import(".") >module : { "\"index\"": typeof import("."); } >exports : typeof import(".") ->A : any +>A : {} >B : any >{ thing: new Something()} : { thing: any; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types index e9a7f29208..e7ab5d1732 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types @@ -49,11 +49,10 @@ class Wrap { /** @type {import("./conn").Whatever} */ this.another = ""; ->this.another = "" : any +>this.another = "" : "" >this.another : any >this : this >another : any ->"" : any >"" : "" } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt index 9159bcdbdb..0bb4eb949a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt @@ -1,6 +1,5 @@ index.js(3,37): error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. index.js(21,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -module.js(11,38): error TS2304: Cannot find name 'P'. module.js(24,12): error TS2315: Type 'Object' is not generic. module.js(27,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -31,7 +30,7 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w module.exports = MainThreadTasks; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== module.js (3 errors) ==== +==== module.js (2 errors) ==== /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ /** @@ -43,8 +42,6 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w /** * @type {{[P in TaskGroupIds]: {id: P, label: string}}} - ~ -!!! error TS2304: Cannot find name 'P'. */ const taskGroups = { parseHTML: { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types index a5046bde8a..02e415dd5a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types @@ -2,9 +2,9 @@ === index.js === const {taskGroups, taskNameToGroup} = require('./module.js'); ->taskGroups : { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; } +>taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } >taskNameToGroup : any ->require('./module.js') : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } +>require('./module.js') : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } >require : any >'./module.js' : "./module.js" @@ -51,15 +51,15 @@ module.exports = MainThreadTasks; * @type {{[P in TaskGroupIds]: {id: P, label: string}}} */ const taskGroups = { ->taskGroups : { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; } ->{ parseHTML: { id: 'parseHTML', label: 'Parse HTML & CSS' }, styleLayout: { id: 'styleLayout', label: 'Style & Layout' },} : { parseHTML: { id: string; label: string; }; styleLayout: { id: string; label: string; }; } +>taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } +>{ parseHTML: { id: 'parseHTML', label: 'Parse HTML & CSS' }, styleLayout: { id: 'styleLayout', label: 'Style & Layout' },} : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } parseHTML: { ->parseHTML : { id: string; label: string; } ->{ id: 'parseHTML', label: 'Parse HTML & CSS' } : { id: string; label: string; } +>parseHTML : { id: "parseHTML"; label: string; } +>{ id: 'parseHTML', label: 'Parse HTML & CSS' } : { id: "parseHTML"; label: string; } id: 'parseHTML', ->id : string +>id : "parseHTML" >'parseHTML' : "parseHTML" label: 'Parse HTML & CSS' @@ -68,11 +68,11 @@ const taskGroups = { }, styleLayout: { ->styleLayout : { id: string; label: string; } ->{ id: 'styleLayout', label: 'Style & Layout' } : { id: string; label: string; } +>styleLayout : { id: "styleLayout"; label: string; } +>{ id: 'styleLayout', label: 'Style & Layout' } : { id: "styleLayout"; label: string; } id: 'styleLayout', ->id : string +>id : "styleLayout" >'styleLayout' : "styleLayout" label: 'Style & Layout' @@ -88,14 +88,14 @@ const taskNameToGroup = {}; >{} : {} module.exports = { ->module.exports = { taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } ->module.exports : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } ->module : { "export=": { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; }; } ->exports : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } ->{ taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } +>module.exports = { taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } +>module.exports : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } +>module : { "export=": { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; }; } +>exports : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } +>{ taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } taskGroups, ->taskGroups : { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; } +>taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } taskNameToGroup, >taskNameToGroup : any diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.types b/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.types index f66781d6a4..54dac37ff9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.types @@ -25,11 +25,10 @@ class C { * @type {number} */ this.y = n ->this.y = n : number +>this.y = n : any >this.y : number >this : this >y : number ->n : number >n : any } } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt index b46ac506c2..36fe1f4292 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt @@ -6,13 +6,12 @@ a.js(28,5): error TS2683: 'this' implicitly has type 'any' because it does not h a.js(35,37): error TS7006: Parameter 'key' implicitly has an 'any' type. a.js(46,4): error TS2339: Property 'Multimap3' does not exist on type '{}'. a.js(47,16): error TS2315: Type 'Object' is not generic. -a.js(47,31): error TS2304: Cannot find name 'V'. a.js(48,10): error TS2339: Property '_map' does not exist on type '{}'. a.js(55,4): error TS2339: Property 'Multimap3' does not exist on type '{}'. a.js(55,40): error TS7006: Parameter 'key' implicitly has an 'any' type. -==== a.js (12 errors) ==== +==== a.js (11 errors) ==== /** * Should work for function declarations * @constructor @@ -76,8 +75,6 @@ a.js(55,40): error TS7006: Parameter 'key' implicitly has an 'any' type. /** @type {Object} TODO: Remove the prototype from the fresh object */ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~ -!!! error TS2304: Cannot find name 'V'. this._map = {}; ~~~~ !!! error TS2339: Property '_map' does not exist on type '{}'. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.types index 52f157ebd5..21efece73b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.types @@ -12,11 +12,10 @@ function Multimap() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; ->this._map = {} : any +>this._map = {} : {} >this._map : any >this : any >_map : any ->{} : any >{} : {} }; @@ -57,11 +56,10 @@ var Multimap2 = function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; ->this._map = {} : any +>this._map = {} : {} >this._map : any >this : any >_map : any ->{} : any >{} : {} }; @@ -109,11 +107,10 @@ Ns.Multimap3 = function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; ->this._map = {} : any +>this._map = {} : {} >this._map : any >this : {} >_map : any ->{} : any >{} : {} }; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt index 0a595a052e..5eaeb65fc4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt @@ -9,14 +9,13 @@ a.js(35,16): error TS2304: Cannot find name 'K'. a.js(36,18): error TS2304: Cannot find name 'V'. a.js(50,4): error TS2339: Property 'Multimap3' does not exist on type '{}'. a.js(51,16): error TS2315: Type 'Object' is not generic. -a.js(51,31): error TS2304: Cannot find name 'V'. a.js(52,10): error TS2339: Property '_map' does not exist on type '{}'. a.js(55,4): error TS2339: Property 'Multimap3' does not exist on type '{}'. a.js(57,16): error TS2304: Cannot find name 'K'. a.js(58,18): error TS2304: Cannot find name 'V'. -==== a.js (16 errors) ==== +==== a.js (15 errors) ==== /** * Should work for function declarations * @constructor @@ -90,8 +89,6 @@ a.js(58,18): error TS2304: Cannot find name 'V'. /** @type {Object} TODO: Remove the prototype from the fresh object */ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~ -!!! error TS2304: Cannot find name 'V'. this._map = {}; ~~~~ !!! error TS2339: Property '_map' does not exist on type '{}'. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.types index c7499a6723..6473ac109b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.types @@ -12,11 +12,10 @@ function Multimap() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; ->this._map = {} : any +>this._map = {} : {} >this._map : any >this : any >_map : any ->{} : any >{} : {} }; @@ -59,11 +58,10 @@ var Multimap2 = function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; ->this._map = {} : any +>this._map = {} : {} >this._map : any >this : any >_map : any ->{} : any >{} : {} }; @@ -114,11 +112,10 @@ Ns.Multimap3 = function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; ->this._map = {} : any +>this._map = {} : {} >this._map : any >this : {} >_map : any ->{} : any >{} : {} }; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeFromChainedAssignment.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeFromChainedAssignment.types index f6e91fd66e..8ab853edc0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeFromChainedAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeFromChainedAssignment.types @@ -18,7 +18,6 @@ function A () { >this : any >first : any >this.second = 1 : 1 ->this.second = 1 : 1 >this.second : any >this : any >second : any diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types index 0b92e77d84..868c12ce17 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types @@ -91,11 +91,10 @@ function SomeFakeClass() { /** @type {string|number} */ this.p = "bar"; ->this.p = "bar" : string | number +>this.p = "bar" : "bar" >this.p : any >this : any >p : any ->"bar" : string | number >"bar" : "bar" } diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAlias2.types b/testdata/baselines/reference/submodule/conformance/moduleExportAlias2.types index 7b1db9dddb..8ec634b4d0 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAlias2.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAlias2.types @@ -11,9 +11,9 @@ const C = require("./semver") var two = C.f(1) >two : any >C.f(1) : any ->C.f : any +>C.f : (n: any) => any >C : typeof C ->f : any +>f : (n: any) => any >1 : 1 var c = new C @@ -46,9 +46,9 @@ exports = module.exports = C exports.f = n => n + 1 >exports.f = n => n + 1 : (n: any) => any ->exports.f : any +>exports.f : (n: any) => any >exports : typeof import("./semver") ->f : any +>f : (n: any) => any >n => n + 1 : (n: any) => any >n : any >n + 1 : any diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment2.types b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment2.types index fec0c30d63..9f2732ca9a 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment2.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment2.types @@ -12,11 +12,11 @@ var npm = module.exports = function (tree) { } module.exports.asReadInstalled = function (tree) { >module.exports.asReadInstalled = function (tree) { npm(tree) // both references should be callable module.exports(tree)} : (tree: any) => void ->module.exports.asReadInstalled : any +>module.exports.asReadInstalled : (tree: any) => void >module.exports : typeof import("./npm") >module : { "\"npm\"": typeof import("./npm"); } >exports : typeof import("./npm") ->asReadInstalled : any +>asReadInstalled : (tree: any) => void >function (tree) { npm(tree) // both references should be callable module.exports(tree)} : (tree: any) => void >tree : any diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt index a23b0530f1..b3f788da0c 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt @@ -1,10 +1,14 @@ +mod.js(2,18): error TS2339: Property 'K' does not exist on type '{}'. +use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -==== mod.js (0 errors) ==== +==== mod.js (1 errors) ==== module.exports.n = {}; module.exports.n.K = function C() { + ~ +!!! error TS2339: Property 'K' does not exist on type '{}'. this.x = 10; } module.exports.Classic = class { @@ -13,10 +17,12 @@ use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as } } -==== use.js (2 errors) ==== +==== use.js (3 errors) ==== import * as s from './mod' var k = new s.n.K() + ~ +!!! error TS2339: Property 'K' does not exist on type '{}'. k.x var classic = new s.Classic() diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.types b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.types index 651db88acb..e6ab8d75bb 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.types @@ -3,21 +3,21 @@ === mod.js === module.exports.n = {}; >module.exports.n = {} : {} ->module.exports.n : any +>module.exports.n : {} >module.exports : typeof import("./mod") >module : { "\"mod\"": typeof import("./mod"); } >exports : typeof import("./mod") ->n : any +>n : {} >{} : {} module.exports.n.K = function C() { >module.exports.n.K = function C() { this.x = 10;} : () => void >module.exports.n.K : any ->module.exports.n : any +>module.exports.n : {} >module.exports : typeof import("./mod") >module : { "\"mod\"": typeof import("./mod"); } >exports : typeof import("./mod") ->n : any +>n : {} >K : any >function C() { this.x = 10;} : () => void >C : () => void @@ -56,9 +56,9 @@ var k = new s.n.K() >k : any >new s.n.K() : any >s.n.K : any ->s.n : any +>s.n : {} >s : typeof s ->n : any +>n : {} >K : any k.x diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.errors.txt index 2927f2bc3c..da9dd12010 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.errors.txt @@ -1,33 +1,24 @@ -mod1.js(1,1): error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -mod1.js(2,1): error TS7022: '"b"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -mod1.js(3,1): error TS7022: '"default"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -mod1.js(4,1): error TS7022: '"c"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -mod1.js(5,1): error TS7022: '"d"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +mod1.js(6,24): error TS2339: Property 'e' does not exist on type '{}'. +mod2.js(6,8): error TS2339: Property 'e' does not exist on type '{}'. -==== mod2.js (0 errors) ==== +==== mod2.js (1 errors) ==== const mod1 = require("./mod1"); mod1.a; mod1.b; mod1.c; mod1.d; mod1.d.e; + ~ +!!! error TS2339: Property 'e' does not exist on type '{}'. mod1.default; -==== mod1.js (5 errors) ==== +==== mod1.js (1 errors) ==== exports.a = { x: "x" }; - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. exports["b"] = { x: "x" }; - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS7022: '"b"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. exports["default"] = { x: "x" }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS7022: '"default"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. module.exports["c"] = { x: "x" }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS7022: '"c"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. module["exports"]["d"] = {}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS7022: '"d"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. module["exports"]["d"].e = 0; + ~ +!!! error TS2339: Property 'e' does not exist on type '{}'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.types b/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.types index af040015d4..c84643db7c 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment.types @@ -8,50 +8,50 @@ const mod1 = require("./mod1"); >"./mod1" : "./mod1" mod1.a; ->mod1.a : any +>mod1.a : { x: string; } >mod1 : typeof mod1 ->a : any +>a : { x: string; } mod1.b; ->mod1.b : any +>mod1.b : { x: string; } >mod1 : typeof mod1 ->b : any +>b : { x: string; } mod1.c; ->mod1.c : any +>mod1.c : { x: string; } >mod1 : typeof mod1 ->c : any +>c : { x: string; } mod1.d; ->mod1.d : any +>mod1.d : {} >mod1 : typeof mod1 ->d : any +>d : {} mod1.d.e; >mod1.d.e : any ->mod1.d : any +>mod1.d : {} >mod1 : typeof mod1 ->d : any +>d : {} >e : any mod1.default; ->mod1.default : any +>mod1.default : { x: string; } >mod1 : typeof mod1 ->default : any +>default : { x: string; } === mod1.js === exports.a = { x: "x" }; >exports.a = { x: "x" } : { x: string; } ->exports.a : any +>exports.a : { x: string; } >exports : typeof import("./mod1") ->a : any +>a : { x: string; } >{ x: "x" } : { x: string; } >x : string >"x" : "x" exports["b"] = { x: "x" }; >exports["b"] = { x: "x" } : { x: string; } ->exports["b"] : any +>exports["b"] : { x: string; } >exports : typeof import("./mod1") >"b" : "b" >{ x: "x" } : { x: string; } @@ -60,7 +60,7 @@ exports["b"] = { x: "x" }; exports["default"] = { x: "x" }; >exports["default"] = { x: "x" } : { x: string; } ->exports["default"] : any +>exports["default"] : { x: string; } >exports : typeof import("./mod1") >"default" : "default" >{ x: "x" } : { x: string; } @@ -69,7 +69,7 @@ exports["default"] = { x: "x" }; module.exports["c"] = { x: "x" }; >module.exports["c"] = { x: "x" } : { x: string; } ->module.exports["c"] : any +>module.exports["c"] : { x: string; } >module.exports : typeof import("./mod1") >module : { "\"mod1\"": typeof import("./mod1"); } >exports : typeof import("./mod1") @@ -80,7 +80,7 @@ module.exports["c"] = { x: "x" }; module["exports"]["d"] = {}; >module["exports"]["d"] = {} : {} ->module["exports"]["d"] : any +>module["exports"]["d"] : {} >module["exports"] : typeof import("./mod1") >module : { "\"mod1\"": typeof import("./mod1"); } >"exports" : "exports" @@ -90,7 +90,7 @@ module["exports"]["d"] = {}; module["exports"]["d"].e = 0; >module["exports"]["d"].e = 0 : 0 >module["exports"]["d"].e : any ->module["exports"]["d"] : any +>module["exports"]["d"] : {} >module["exports"] : typeof import("./mod1") >module : { "\"mod1\"": typeof import("./mod1"); } >"exports" : "exports" diff --git a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt deleted file mode 100644 index 992effe5ec..0000000000 --- a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -38572.js(4,39): error TS2304: Cannot find name 'K'. - - -==== 38572.js (1 errors) ==== - /** - * @template T - * @param {T} a - * @param {{[K in keyof T]: (value: T[K]) => void }} b - ~ -!!! error TS2304: Cannot find name 'K'. - */ - function f(a, b) { - } - - f({ x: 42 }, { x(param) { param.toFixed() } }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.symbols b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.symbols index 78188b126c..eca5bba289 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.symbols +++ b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.symbols @@ -17,5 +17,7 @@ f({ x: 42 }, { x(param) { param.toFixed() } }); >x : Symbol(x, Decl(38572.js, 8, 3)) >x : Symbol(x, Decl(38572.js, 8, 14)) >param : Symbol(param, Decl(38572.js, 8, 17)) +>param.toFixed : Symbol(toFixed, Decl(lib.es5.d.ts, --, --)) >param : Symbol(param, Decl(38572.js, 8, 17)) +>toFixed : Symbol(toFixed, Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.symbols.diff b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.symbols.diff index c3b39999d8..14e4852680 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.symbols.diff @@ -5,5 +5,7 @@ >x : Symbol(x, Decl(38572.js, 8, 14)) >param : Symbol(param, Decl(38572.js, 8, 17)) ->param.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) ++>param.toFixed : Symbol(toFixed, Decl(lib.es5.d.ts, --, --)) >param : Symbol(param, Decl(38572.js, 8, 17)) ->toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) ++>toFixed : Symbol(toFixed, Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.types b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.types index 60cf72b48a..5470054ab2 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.types +++ b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.types @@ -18,11 +18,11 @@ f({ x: 42 }, { x(param) { param.toFixed() } }); >{ x: 42 } : { x: number; } >x : number >42 : 42 ->{ x(param) { param.toFixed() } } : { x(param: K): void; } ->x : (param: K) => void ->param : K ->param.toFixed() : any ->param.toFixed : any ->param : K ->toFixed : any +>{ x(param) { param.toFixed() } } : { x(param: number): void; } +>x : (param: number) => void +>param : number +>param.toFixed() : string +>param.toFixed : (fractionDigits?: number) => string +>param : number +>toFixed : (fractionDigits?: number) => string diff --git a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.types b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.types index 7c602d86b5..2f1a0d01e2 100644 --- a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.types +++ b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.types @@ -14,11 +14,10 @@ function Multimap(ik, iv) { /** @type {{ [s: string]: V }} */ this._map = {}; ->this._map = {} : { [s: string]: V; } +>this._map = {} : {} >this._map : any >this : any >_map : any ->{} : { [s: string]: V; } >{} : {} // without type annotation diff --git a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt index a53610938e..af718cddbf 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt @@ -1,10 +1,9 @@ propertyAssignmentUseParentType2.js(11,14): error TS2322: Type '{ (): true; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. Types of property 'nuo' are incompatible. Type '1000' is not assignable to type '789'. -propertyAssignmentUseParentType2.js(13,1): error TS2322: Type '1000' is not assignable to type '789'. -==== propertyAssignmentUseParentType2.js (2 errors) ==== +==== propertyAssignmentUseParentType2.js (1 errors) ==== /** @type {{ (): boolean; nuo: 789 }} */ export const inlined = () => true inlined.nuo = 789 @@ -22,6 +21,4 @@ propertyAssignmentUseParentType2.js(13,1): error TS2322: Type '1000' is not assi !!! error TS2322: Type '1000' is not assignable to type '789'. /** @type {1000} */ conflictingDuplicated.nuo = 789 - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '1000' is not assignable to type '789'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.types b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.types index f6c85114a5..0dd8cd70cb 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.types +++ b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.types @@ -27,7 +27,6 @@ duplicated.nuo = 789 >duplicated : { (): boolean; nuo: 789; } >nuo : 789 >789 : 789 ->789 : 789 /** @type {{ (): boolean; nuo: 789 }} */ export const conflictingDuplicated = () => true @@ -37,10 +36,9 @@ export const conflictingDuplicated = () => true /** @type {1000} */ conflictingDuplicated.nuo = 789 ->conflictingDuplicated.nuo = 789 : 1000 +>conflictingDuplicated.nuo = 789 : 789 >conflictingDuplicated.nuo : 789 >conflictingDuplicated : { (): boolean; nuo: 789; } >nuo : 789 ->789 : 1000 >789 : 789 diff --git a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt index a81db9088a..0961be452d 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt @@ -1,11 +1,10 @@ -thisTypeOfConstructorFunctions.js(7,16): error TS2526: A 'this' type is available only in a non-static member of a class or interface. thisTypeOfConstructorFunctions.js(15,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. thisTypeOfConstructorFunctions.js(38,12): error TS2749: 'Cpp' refers to a value, but is being used as a type here. Did you mean 'typeof Cpp'? thisTypeOfConstructorFunctions.js(41,12): error TS2749: 'Cp' refers to a value, but is being used as a type here. Did you mean 'typeof Cp'? thisTypeOfConstructorFunctions.js(43,12): error TS2749: 'Cp' refers to a value, but is being used as a type here. Did you mean 'typeof Cp'? -==== thisTypeOfConstructorFunctions.js (5 errors) ==== +==== thisTypeOfConstructorFunctions.js (4 errors) ==== /** * @class * @template T @@ -13,8 +12,6 @@ thisTypeOfConstructorFunctions.js(43,12): error TS2749: 'Cp' refers to a value, */ function Cp(t) { /** @type {this} */ - ~~~~ -!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. this.dit = this this.y = t /** @return {this} */ diff --git a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.types b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.types index 80766c115f..7e4ffba491 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.types +++ b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.types @@ -16,7 +16,6 @@ function Cp(t) { >this.dit : any >this : any >dit : any ->this : any >this : any this.y = t diff --git a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols index 815a9d7522..55fefc4095 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(o1, Decl(bug25926.js, 0, 11)) +>this : Symbol(þtype, 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(o2, Decl(bug25926.js, 7, 11)) +>this : Symbol(þtype, Decl(bug25926.js, 7, 11)) >e : Symbol(e, Decl(bug25926.js, 7, 23)) >this.f : Symbol(f, Decl(bug25926.js, 7, 46)) ->this : Symbol(o2, Decl(bug25926.js, 7, 11)) +>this : Symbol(þtype, 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(o2, Decl(bug25926.js, 7, 11)) +>this : Symbol(þtype, 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 09e86615e3..e07416038e 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols.diff @@ -6,7 +6,7 @@ >this.b : Symbol(b, Decl(bug25926.js, 0, 23)) ->this : Symbol(__type, Decl(bug25926.js, 0, 11)) ->b : Symbol(b, Decl(bug25926.js, 2, 9)) -+>this : Symbol(o1, Decl(bug25926.js, 0, 11)) ++>this : Symbol(þtype, 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)) @@ -17,17 +17,17 @@ >this.e : Symbol(e, Decl(bug25926.js, 7, 23)) ->this : Symbol(__type, Decl(bug25926.js, 7, 11)) ->e : Symbol(e, Decl(bug25926.js, 9, 9)) -+>this : Symbol(o2, Decl(bug25926.js, 7, 11)) ++>this : Symbol(þtype, 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)) ->f : Symbol(f, Decl(bug25926.js, 10, 16)) -+>this : Symbol(o2, Decl(bug25926.js, 7, 11)) ++>this : Symbol(þtype, 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)) ++>this : Symbol(þtype, 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/typeFromParamTagForFunction.types b/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.types index 27ac331b24..35644c1093 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.types @@ -12,9 +12,9 @@ declare var module: any, exports: any; === a-ext.js === exports.A = function () { >exports.A = function () { this.x = 1;} : () => void ->exports.A : any +>exports.A : () => void >exports : typeof import("./a-ext") ->A : any +>A : () => void >function () { this.x = 1;} : () => void this.x = 1; @@ -28,7 +28,7 @@ exports.A = function () { === a.js === const { A } = require("./a-ext"); ->A : any +>A : () => void >require("./a-ext") : typeof import("./a-ext") >require : (id: string) => any >"./a-ext" : "./a-ext" diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.types index b558b96f4b..cee63223df 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.types @@ -54,11 +54,10 @@ Outer.app.Inner = class { constructor() { /** @type {number} */ this.y = 12; ->this.y = 12 : number +>this.y = 12 : 12 >this.y : number >this : this >y : number ->12 : number >12 : 12 } } diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.types index fe291e6b17..7e43b29727 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.types @@ -54,11 +54,10 @@ Outer.app.Inner = class { constructor() { /** @type {number} */ this.y = 12; ->this.y = 12 : number +>this.y = 12 : 12 >this.y : number >this : this >y : number ->12 : number >12 : 12 } } diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.types index 539ab62eb3..a21e68c064 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.types @@ -16,11 +16,10 @@ Outer.Inner = class { constructor() { /** @type {number} */ this.y = 12 ->this.y = 12 : number +>this.y = 12 : 12 >this.y : number >this : this >y : number ->12 : number >12 : 12 } } diff --git a/testdata/baselines/reference/submodule/conformance/typeTagModuleExports.errors.txt b/testdata/baselines/reference/submodule/conformance/typeTagModuleExports.errors.txt index a43429364d..4e7ff446d9 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagModuleExports.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeTagModuleExports.errors.txt @@ -1,9 +1,9 @@ -bug27327.js(2,18): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +bug27327.js(2,1): error TS2322: Type 'number' is not assignable to type 'string'. ==== bug27327.js (1 errors) ==== /** @type {string} */ module.exports = 0; - ~ -!!! error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + ~~~~~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeTagModuleExports.types b/testdata/baselines/reference/submodule/conformance/typeTagModuleExports.types index 47ba2592f8..8c68639509 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagModuleExports.types +++ b/testdata/baselines/reference/submodule/conformance/typeTagModuleExports.types @@ -3,10 +3,9 @@ === bug27327.js === /** @type {string} */ module.exports = 0; ->module.exports = 0 : string +>module.exports = 0 : 0 >module.exports : string >module : { "export=": string; } >exports : string ->0 : string >0 : 0 diff --git a/testdata/baselines/reference/submodule/conformance/typeTagOnPropertyAssignment.types b/testdata/baselines/reference/submodule/conformance/typeTagOnPropertyAssignment.types index 7766f435ed..8bf9b35a16 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagOnPropertyAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/typeTagOnPropertyAssignment.types @@ -10,14 +10,12 @@ const o = { */ a: "a", >a : "a" ->"a" : "a" >"a" : "a" /** @type {() => 'b'} */ n: () => 'b' >n : () => "b" >() => 'b' : () => "b" ->() => 'b' : () => "b" >'b' : "b" }; diff --git a/testdata/baselines/reference/submodule/conformance/typeTagPrototypeAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/typeTagPrototypeAssignment.errors.txt index d2ef86570a..1e7d8b7db7 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagPrototypeAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeTagPrototypeAssignment.errors.txt @@ -1,4 +1,4 @@ -bug27327.js(4,15): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +bug27327.js(4,1): error TS2322: Type 'number' is not assignable to type 'string'. ==== bug27327.js (1 errors) ==== @@ -6,6 +6,6 @@ bug27327.js(4,15): error TS2352: Conversion of type 'number' to type 'string' ma } /** @type {string} */ C.prototype = 12 - ~~ -!!! error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. + ~~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeTagPrototypeAssignment.types b/testdata/baselines/reference/submodule/conformance/typeTagPrototypeAssignment.types index 497159aebf..0069035e1b 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagPrototypeAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/typeTagPrototypeAssignment.types @@ -6,10 +6,9 @@ function C() { } /** @type {string} */ C.prototype = 12 ->C.prototype = 12 : string +>C.prototype = 12 : 12 >C.prototype : string >C : { (): void; prototype: string; } >prototype : string ->12 : string >12 : 12 diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types index 6173bb4fd3..6a7b83f6db 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types @@ -53,9 +53,9 @@ export function C() { exports.C = function() { >exports.C = function() { this.p = 1} : () => void ->exports.C : any +>exports.C : () => void >exports : typeof import("./mod3") ->C : any +>C : () => void >function() { this.p = 1} : () => void this.p = 1 diff --git a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols index 99801b5b7e..6493017cb5 100644 --- a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols +++ b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols @@ -5,7 +5,9 @@ import foo from "foo"; >foo : Symbol(foo, Decl(a.ts, 0, 6)) foo.bar(); +>foo.bar : Symbol(bar, Decl(index.js, 0, 19)) >foo : Symbol(foo, Decl(a.ts, 0, 6)) +>bar : Symbol(bar, Decl(index.js, 0, 19)) === /node_modules/foo/index.js === exports.default = { bar() { return 0; } } diff --git a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols.diff b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols.diff index f96b0963c2..b8241f1ff0 100644 --- a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols.diff @@ -1,13 +1,6 @@ --- old.untypedModuleImport_allowJs.symbols +++ new.untypedModuleImport_allowJs.symbols -@@= skipped -4, +4 lines =@@ - >foo : Symbol(foo, Decl(a.ts, 0, 6)) - - foo.bar(); -->foo.bar : Symbol(bar, Decl(index.js, 0, 19)) - >foo : Symbol(foo, Decl(a.ts, 0, 6)) -->bar : Symbol(bar, Decl(index.js, 0, 19)) - +@@= skipped -11, +11 lines =@@ === /node_modules/foo/index.js === exports.default = { bar() { return 0; } } >exports.default : Symbol(default, Decl(index.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types index 77cd60bc2b..0dbb57e504 100644 --- a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types +++ b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types @@ -2,20 +2,20 @@ === /a.ts === import foo from "foo"; ->foo : any +>foo : { bar(): number; } foo.bar(); ->foo.bar() : any ->foo.bar : any ->foo : any ->bar : any +>foo.bar() : number +>foo.bar : () => number +>foo : { bar(): number; } +>bar : () => number === /node_modules/foo/index.js === exports.default = { bar() { return 0; } } >exports.default = { bar() { return 0; } } : { bar(): number; } ->exports.default : any +>exports.default : { bar(): number; } >exports : typeof import("foo") ->default : any +>default : { bar(): number; } >{ bar() { return 0; } } : { bar(): number; } >bar : () => number >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff index 6fd6076b2f..5389070825 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff @@ -20,7 +20,6 @@ ->arguments : any ->foo : any +>arguments : object -+>foo : object +>foo : object } } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.types.diff index 77654b0dee..7195e6fef4 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.types.diff @@ -19,7 +19,6 @@ >this : this >"arguments" : "arguments" ->foo : any -+>foo : object +>foo : object } } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.types.diff index 2cf96b6320..5d7c1b5042 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.types.diff @@ -21,7 +21,6 @@ ->foo : any ->foo : any +>foo : object -+>foo : object +>foo : object /** @@ -30,13 +29,12 @@ this.bar = super.arguments.foo; ->this.bar = super.arguments.foo : error ->this.bar : any -+>this.bar = super.arguments.foo : object ++>this.bar = super.arguments.foo : any +>this.bar : object >this : this ->bar : any ->super.arguments.foo : error +>bar : object -+>super.arguments.foo : object +>super.arguments.foo : any >super.arguments : { bar: {}; } >super : A diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff index 75642ca53e..9cbf9418c2 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff @@ -21,7 +21,6 @@ ->foo : any ->foo : any +>foo : object -+>foo : object +>foo : object /** @@ -33,35 +32,30 @@ >this.arguments : { bar: {}; } >this : this >arguments : { bar: {}; } -@@= skipped -19, +20 lines =@@ - * @type object +@@= skipped -20, +20 lines =@@ */ this.bar = arguments.bar; -->this.bar = arguments.bar : any + >this.bar = arguments.bar : any ->this.bar : any -+>this.bar = arguments.bar : object +>this.bar : object >this : this ->bar : any +>bar : object -+>arguments.bar : object >arguments.bar : any ->arguments : any +>arguments : object >bar : any /** - * @type object +@@= skipped -12, +12 lines =@@ */ this.baz = arguments[key]; -->this.baz = arguments[key] : any + >this.baz = arguments[key] : any ->this.baz : any -+>this.baz = arguments[key] : object +>this.baz : object >this : this ->baz : any +>baz : object -+>arguments[key] : object >arguments[key] : any ->arguments : any +>arguments : object @@ -79,7 +73,6 @@ ->options : any ->arguments : any +>options : object -+>arguments : object +>arguments : object } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff index 3b1a1ba825..77d08976cc 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff @@ -20,21 +20,18 @@ ->foo : any ->foo : any +>foo : object -+>foo : object +>foo : object /** * @type object */ this.bar = bar.arguments; -->this.bar = bar.arguments : {} + >this.bar = bar.arguments : {} ->this.bar : any -+>this.bar = bar.arguments : object +>this.bar : object >this : this ->bar : any +>bar : object -+>bar.arguments : object >bar.arguments : {} >bar : { arguments: {}; } >arguments : {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor6_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor6_Js.types.diff index aeb5a088fd..49b3f8d202 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor6_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor6_Js.types.diff @@ -1,17 +1,14 @@ --- old.argumentsReferenceInConstructor6_Js.types +++ new.argumentsReferenceInConstructor6_Js.types -@@= skipped -8, +8 lines =@@ - * @type object +@@= skipped -9, +9 lines =@@ */ this.foo = arguments; -->this.foo = arguments : IArguments + >this.foo = arguments : IArguments ->this.foo : any -+>this.foo = arguments : object +>this.foo : object >this : this ->foo : any +>foo : object -+>arguments : object >arguments : IArguments } } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor7_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor7_Js.types.diff deleted file mode 100644 index fb347b8f61..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor7_Js.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.argumentsReferenceInConstructor7_Js.types -+++ new.argumentsReferenceInConstructor7_Js.types -@@= skipped -13, +13 lines =@@ - >this : this - >callee : Function - >arguments.callee : Function -+>arguments.callee : Function - >arguments : IArguments - >callee : Function - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff index 06a6e59d81..269be873b4 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff @@ -20,7 +20,6 @@ ->arguments : any ->foo : any +>arguments : object -+>foo : object +>foo : object } } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.types.diff index 53b7b2c8fa..d47332cf08 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.types.diff @@ -19,7 +19,6 @@ >this : this >"arguments" : "arguments" ->foo : any -+>foo : object +>foo : object } } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.types.diff index fa8bc33b4b..089cc0c393 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.types.diff @@ -20,21 +20,18 @@ ->x : any ->foo : any +>x : object -+>foo : object +>foo : object /** * @type object */ this.y = super.arguments.bar; -->this.y = super.arguments.bar : {} + >this.y = super.arguments.bar : {} ->this.y : any -+>this.y = super.arguments.bar : object +>this.y : object >this : this ->y : any +>y : object -+>super.arguments.bar : object >super.arguments.bar : {} >super.arguments : { bar: {}; } >super : A \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff index af8740bba6..bb44aca173 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff @@ -21,7 +21,6 @@ ->foo : any ->foo : any +>foo : object -+>foo : object +>foo : object /** @@ -33,35 +32,30 @@ >this.arguments : { bar: {}; } >this : this >arguments : { bar: {}; } -@@= skipped -19, +20 lines =@@ - * @type object +@@= skipped -20, +20 lines =@@ */ this.bar = arguments.bar; -->this.bar = arguments.bar : any + >this.bar = arguments.bar : any ->this.bar : any -+>this.bar = arguments.bar : object +>this.bar : object >this : this ->bar : any +>bar : object -+>arguments.bar : object >arguments.bar : any ->arguments : any +>arguments : object >bar : any /** - * @type object +@@= skipped -12, +12 lines =@@ */ this.baz = arguments[key]; -->this.baz = arguments[key] : any + >this.baz = arguments[key] : any ->this.baz : any -+>this.baz = arguments[key] : object +>this.baz : object >this : this ->baz : any +>baz : object -+>arguments[key] : object >arguments[key] : any ->arguments : any +>arguments : object @@ -79,7 +73,6 @@ ->options : any ->arguments : any +>options : object -+>arguments : object +>arguments : object } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff index cc8c31f7d0..92fec681f7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff @@ -20,21 +20,18 @@ ->foo : any ->foo : any +>foo : object -+>foo : object +>foo : object /** * @type object */ this.bar = bar.arguments; -->this.bar = bar.arguments : {} + >this.bar = bar.arguments : {} ->this.bar : any -+>this.bar = bar.arguments : object +>this.bar : object >this : this ->bar : any +>bar : object -+>bar.arguments : object >bar.arguments : {} >bar : { arguments: {}; } >arguments : {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod6_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod6_Js.types.diff index a0ffca742b..e93e782324 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod6_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod6_Js.types.diff @@ -11,14 +11,12 @@ * @type object */ this.foo = arguments; -->this.foo = arguments : IArguments + >this.foo = arguments : IArguments ->this.foo : any -+>this.foo = arguments : object +>this.foo : object >this : this ->foo : any +>foo : object -+>arguments : object >arguments : IArguments } } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod7_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod7_Js.types.diff index b7b45704fc..50607eb1ac 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod7_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod7_Js.types.diff @@ -8,12 +8,4 @@ +>m : () => void /** - * @type Function -@@= skipped -10, +10 lines =@@ - >this.callee : Function - >this : this - >callee : Function -+>arguments.callee : Function - >arguments.callee : Function - >arguments : IArguments - >callee : Function \ No newline at end of file + * @type Function \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles7.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles7.types.diff deleted file mode 100644 index 1914a49df5..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles7.types.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.checkJsFiles7.types -+++ new.checkJsFiles7.types -@@= skipped -6, +6 lines =@@ - constructor() { - /** @type {boolean} */ - this.a = true; -->this.a = true : true -+>this.a = true : boolean - >this.a : boolean - >this : this - >a : boolean -+>true : boolean - >true : true - - this.a = !!this.a; -@@= skipped -13, +14 lines =@@ - >a : boolean - >!!this.a : boolean - >!this.a : boolean -->this.a : true -+>this.a : boolean - >this : this -->a : true -+>a : boolean - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt.diff deleted file mode 100644 index 4255e957a2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment1.errors.txt -+++ new.checkJsdocTypeTagOnExportAssignment1.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(8,18): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. -+a.js(8,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b - - - ==== checkJsdocTypeTagOnExportAssignment1.js (0 errors) ==== -@@= skipped -11, +11 lines =@@ - - /** @type {Foo} */ - export default { c: false }; -- ~ --!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. -+ ~~~~~~~~~~~~ -+!!! error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b - - ==== b.js (0 errors) ==== - import a from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.types.diff index 7ae85f0b17..c32e5448fa 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.types.diff @@ -1,13 +1,6 @@ --- old.checkJsdocTypeTagOnExportAssignment1.types +++ new.checkJsdocTypeTagOnExportAssignment1.types -@@= skipped -10, +10 lines =@@ - - /** @type {Foo} */ - export default { c: false }; -+>{ c: false } : Foo - >{ c: false } : { c: boolean; } - >c : boolean - >false : false +@@= skipped -16, +16 lines =@@ === b.js === import a from "./a"; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt.diff deleted file mode 100644 index 7676de2776..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment2.errors.txt -+++ new.checkJsdocTypeTagOnExportAssignment2.errors.txt -@@= skipped -0, +0 lines =@@ --b.js(2,18): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. -+b.js(2,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b - - - ==== checkJsdocTypeTagOnExportAssignment2.js (0 errors) ==== -@@= skipped -11, +11 lines =@@ - ==== b.js (1 errors) ==== - /** @type {import("./a").Foo} */ - export default { c: false }; -- ~ --!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. -+ ~~~~~~~~~~~~ -+!!! error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b - - ==== c.js (0 errors) ==== - import b from "./b"; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.types.diff index 30be3893cf..354c3f18c8 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.types.diff @@ -1,13 +1,6 @@ --- old.checkJsdocTypeTagOnExportAssignment2.types +++ new.checkJsdocTypeTagOnExportAssignment2.types -@@= skipped -13, +13 lines =@@ - === b.js === - /** @type {import("./a").Foo} */ - export default { c: false }; -+>{ c: false } : import("./a").Foo - >{ c: false } : { c: boolean; } - >c : boolean - >false : false +@@= skipped -19, +19 lines =@@ === c.js === import b from "./b"; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff index 5a0725b28c..8b7d30e4ec 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff @@ -1,17 +1,12 @@ --- old.checkJsdocTypeTagOnExportAssignment3.types +++ new.checkJsdocTypeTagOnExportAssignment3.types -@@= skipped -16, +16 lines =@@ - - /** @type {Foo} */ - export default bar; -+>bar : Foo - >bar : { c: number; } +@@= skipped -20, +20 lines =@@ === b.js === import a from "./a"; ->a : import("a").Foo -+>a : import("./a").Foo ++>a : { c: number; } a; ->a : import("a").Foo -+>a : import("./a").Foo ++>a : { c: number; } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt.diff deleted file mode 100644 index 117a806158..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment4.errors.txt -+++ new.checkJsdocTypeTagOnExportAssignment4.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(6,16): error TS2322: Type 'string' is not assignable to type 'number'. -+a.js(6,16): error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - - - ==== checkJsdocTypeTagOnExportAssignment4.js (0 errors) ==== -@@= skipped -10, +10 lines =@@ - /** @type {Foo} */ - export default ""; - ~~ --!!! error TS2322: Type 'string' is not assignable to type 'number'. -+!!! error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.types.diff deleted file mode 100644 index e1ddb7ba53..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.types.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment4.types -+++ new.checkJsdocTypeTagOnExportAssignment4.types -@@= skipped -2, +2 lines =@@ - === checkJsdocTypeTagOnExportAssignment4.js === - - === a.js === -- - /** - * @typedef {number} Foo - */ - - /** @type {Foo} */ - export default ""; -+>"" : number -+>"" : "" - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment5.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment5.types.diff index 48bd6f0081..a18bfea751 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment5.types.diff @@ -1,14 +1,6 @@ --- old.checkJsdocTypeTagOnExportAssignment5.types +++ new.checkJsdocTypeTagOnExportAssignment5.types -@@= skipped -10, +10 lines =@@ - - /** @type {Foo} */ - export default { a: 1, b: 1 }; -+>{ a: 1, b: 1 } : Foo - >{ a: 1, b: 1 } : { a: number; b: number; } - >a : number - >1 : 1 -@@= skipped -8, +9 lines =@@ +@@= skipped -18, +18 lines =@@ === b.js === import a from "./a"; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.errors.txt.diff deleted file mode 100644 index f732e353ce..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment6.errors.txt -+++ new.checkJsdocTypeTagOnExportAssignment6.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(8,30): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. -- -- --==== checkJsdocTypeTagOnExportAssignment6.js (0 errors) ==== -- --==== a.js (1 errors) ==== -- /** -- * @typedef {Object} Foo -- * @property {number} a -- * @property {number} b -- */ -- -- /** @type {Foo} */ -- export default { a: 1, b: 1, c: 1 }; -- ~ --!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. -- --==== b.js (0 errors) ==== -- import a from "./a"; -- a; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.types.diff index 54af9382ea..9d1f6aeeae 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.types.diff @@ -1,14 +1,6 @@ --- old.checkJsdocTypeTagOnExportAssignment6.types +++ new.checkJsdocTypeTagOnExportAssignment6.types -@@= skipped -10, +10 lines =@@ - - /** @type {Foo} */ - export default { a: 1, b: 1, c: 1 }; -+>{ a: 1, b: 1, c: 1 } : Foo - >{ a: 1, b: 1, c: 1 } : { a: number; b: number; c: number; } - >a : number - >1 : 1 -@@= skipped -10, +11 lines =@@ +@@= skipped -20, +20 lines =@@ === b.js === import a from "./a"; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff index 8001a0d111..54dd5c1188 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff @@ -1,17 +1,12 @@ --- old.checkJsdocTypeTagOnExportAssignment7.types +++ new.checkJsdocTypeTagOnExportAssignment7.types -@@= skipped -20, +20 lines =@@ - - /** @type {Foo} */ - export default abc; -+>abc : Foo - >abc : { a: number; b: number; c: number; } +@@= skipped -24, +24 lines =@@ === b.js === import a from "./a"; ->a : import("a").Foo -+>a : import("./a").Foo ++>a : { a: number; b: number; c: number; } a; ->a : import("a").Foo -+>a : import("./a").Foo ++>a : { a: number; b: number; c: number; } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff index aede746b58..c3b3f96792 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff @@ -5,7 +5,6 @@ /** @type {Foo} */ export default { ->{ a: 'a', b: 'b'} : { a: string; b: "b"; } -+>{ a: 'a', b: 'b'} : Foo +>{ a: 'a', b: 'b'} : { a: string; b: string; } a: 'a', diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/commonjsAccessExports.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/commonjsAccessExports.types.diff index bc068dd79e..0c498ddeab 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/commonjsAccessExports.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/commonjsAccessExports.types.diff @@ -25,9 +25,9 @@ ->Cls : typeof Cls ->function() { this.x = 0; } : typeof Cls +>exports.Cls = function() { this.x = 0; } : () => void -+>exports.Cls : any ++>exports.Cls : () => void +>exports : typeof import("./a") -+>Cls : any ++>Cls : () => void +>function() { this.x = 0; } : () => void this.x = 0; @@ -48,6 +48,6 @@ ->Cls : typeof Cls +>instance : any +>new exports.Cls() : any -+>exports.Cls : any ++>exports.Cls : () => void +>exports : typeof import("./a") -+>Cls : any ++>Cls : () => void diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff index 99e452ae6d..3e5d73d956 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff @@ -39,19 +39,17 @@ * @type {MyComponentProps} */ MyComponent2.defaultProps = { -->MyComponent2.defaultProps = { color: "red"} : { color: "red"; } + >MyComponent2.defaultProps = { color: "red"} : { color: "red"; } ->MyComponent2.defaultProps : MyComponentProps ->MyComponent2 : { (): any; defaultProps: MyComponentProps; } ->defaultProps : MyComponentProps -+>MyComponent2.defaultProps = { color: "red"} : { color: "blue" | "red"; } +>MyComponent2.defaultProps : { color: "blue" | "red"; } +>MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } +>defaultProps : { color: "blue" | "red"; } -+>{ color: "red"} : { color: "blue" | "red"; } >{ color: "red"} : { color: "red"; } color: "red" -@@= skipped -40, +41 lines =@@ +@@= skipped -40, +40 lines =@@ * @type {StatelessComponent} */ const check = MyComponent2; @@ -78,15 +76,13 @@ * @type {MyComponentProps} */ this.props = { color: "red" }; -->this.props = { color: "red" } : { color: "red"; } + >this.props = { color: "red" } : { color: "red"; } ->this.props : MyComponentProps ->this : this ->props : MyComponentProps -+>this.props = { color: "red" } : { color: "blue" | "red"; } +>this.props : any +>this : any +>props : any -+>{ color: "red" } : { color: "blue" | "red"; } >{ color: "red" } : { color: "red"; } >color : "red" >"red" : "red" @@ -107,15 +103,14 @@ ->module.exports : MyComponentProps ->module : { exports: MyComponentProps; } ->exports : MyComponentProps -+>module.exports = { color: "red"} : { color: "blue" | "red"; } ++>module.exports = { color: "red"} : { color: "red"; } +>module.exports : { color: "blue" | "red"; } +>module : { "export=": { color: "blue" | "red"; }; } +>exports : { color: "blue" | "red"; } -+>{ color: "red"} : { color: "blue" | "red"; } >{ color: "red"} : { color: "red"; } color: "red" -@@= skipped -49, +51 lines =@@ +@@= skipped -49, +49 lines =@@ expectLiteral({ props: module.exports }); >expectLiteral({ props: module.exports }) : void diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff index 35601938ba..bcc2a35f63 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff @@ -5,7 +5,6 @@ /** @type {NumberLike[]} */export default ([ ]); ->([ ]) : NumberLike[] -+>([ ]) : (string | number)[] +>([ ]) : undefined[] >[ ] : undefined[] diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/functionExpressionNames.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/functionExpressionNames.types.diff index a2b4cafb50..4594a2b99b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/functionExpressionNames.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/functionExpressionNames.types.diff @@ -10,9 +10,9 @@ ->E : typeof E ->function() { this.e = 'exported'} : typeof E +>exports.E = function() { this.e = 'exported'} : () => void -+>exports.E : any ++>exports.E : () => void +>exports : typeof import("./b") -+>E : any ++>E : () => void +>function() { this.e = 'exported'} : () => void this.e = 'exported' @@ -31,9 +31,9 @@ ->E : typeof E +>e : any +>new exports.E() : any -+>exports.E : any ++>exports.E : () => void +>exports : typeof import("./b") -+>E : any ++>E : () => void var o = { ->o : { C: typeof C; } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileClassPropertyType2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileClassPropertyType2.types.diff deleted file mode 100644 index 6fc9a0c731..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileClassPropertyType2.types.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileClassPropertyType2.types -+++ new.jsFileClassPropertyType2.types -@@= skipped -6, +6 lines =@@ - constructor() { - /** @type {number[]}*/ - this.p = []; -->this.p = [] : undefined[] -+>this.p = [] : number[] - >this.p : number[] - >this : this - >p : number[] -+>[] : number[] - >[] : undefined[] - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff index 72cf35b686..2122f5ce56 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff @@ -4,120 +4,39 @@ index.js(2,19): error TS2315: Type 'Boolean' is not generic. -index2.js(2,19): error TS2315: Type 'Void' is not generic. -index3.js(2,19): error TS2315: Type 'Undefined' is not generic. -+index.js(2,27): error TS2304: Cannot find name 'T'. +index2.js(2,19): error TS2304: Cannot find name 'Void'. -+index2.js(2,24): error TS2304: Cannot find name 'T'. +index3.js(2,19): error TS2304: Cannot find name 'Undefined'. -+index3.js(2,29): error TS2304: Cannot find name 'T'. index4.js(2,19): error TS2315: Type 'Function' is not generic. -+index4.js(2,28): error TS2304: Cannot find name 'T'. index5.js(2,19): error TS2315: Type 'String' is not generic. -+index5.js(2,26): error TS2304: Cannot find name 'T'. index6.js(2,19): error TS2315: Type 'Number' is not generic. -+index6.js(2,26): error TS2304: Cannot find name 'T'. index7.js(2,19): error TS2315: Type 'Object' is not generic. -+index7.js(2,26): error TS2304: Cannot find name 'T'. +index8.js(4,12): error TS2749: 'fn' refers to a value, but is being used as a type here. Did you mean 'typeof fn'? index8.js(4,15): error TS2304: Cannot find name 'T'. --==== index.js (1 errors) ==== -+==== index.js (2 errors) ==== - /** - * @param {(m: Boolean) => string} somebody - ~~~~~~~~~~ - !!! error TS2315: Type 'Boolean' is not generic. -+ ~ -+!!! error TS2304: Cannot find name 'T'. - */ - function sayHello(somebody) { - return 'Hello ' + somebody; - } - --==== index2.js (1 errors) ==== -+==== index2.js (2 errors) ==== +@@= skipped -20, +21 lines =@@ + ==== index2.js (1 errors) ==== /** * @param {(m: Void) => string} somebody - ~~~~~~~ -!!! error TS2315: Type 'Void' is not generic. + ~~~~ +!!! error TS2304: Cannot find name 'Void'. -+ ~ -+!!! error TS2304: Cannot find name 'T'. */ function sayHello2(somebody) { return 'Hello ' + somebody; - } - - --==== index3.js (1 errors) ==== -+==== index3.js (2 errors) ==== +@@= skipped -11, +11 lines =@@ + ==== index3.js (1 errors) ==== /** * @param {(m: Undefined) => string} somebody - ~~~~~~~~~~~~ -!!! error TS2315: Type 'Undefined' is not generic. + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'Undefined'. -+ ~ -+!!! error TS2304: Cannot find name 'T'. */ function sayHello3(somebody) { return 'Hello ' + somebody; - } - - --==== index4.js (1 errors) ==== -+==== index4.js (2 errors) ==== - /** - * @param {(m: Function) => string} somebody - ~~~~~~~~~~~ - !!! error TS2315: Type 'Function' is not generic. -+ ~ -+!!! error TS2304: Cannot find name 'T'. - */ - function sayHello4(somebody) { - return 'Hello ' + somebody; - } - - --==== index5.js (1 errors) ==== -+==== index5.js (2 errors) ==== - /** - * @param {(m: String) => string} somebody - ~~~~~~~~~ - !!! error TS2315: Type 'String' is not generic. -+ ~ -+!!! error TS2304: Cannot find name 'T'. - */ - function sayHello5(somebody) { - return 'Hello ' + somebody; - } - - --==== index6.js (1 errors) ==== -+==== index6.js (2 errors) ==== - /** - * @param {(m: Number) => string} somebody - ~~~~~~~~~ - !!! error TS2315: Type 'Number' is not generic. -+ ~ -+!!! error TS2304: Cannot find name 'T'. - */ - function sayHello6(somebody) { - return 'Hello ' + somebody; - } - - --==== index7.js (1 errors) ==== -+==== index7.js (2 errors) ==== - /** - * @param {(m: Object) => string} somebody - ~~~~~~~~~ - !!! error TS2315: Type 'Object' is not generic. -+ ~ -+!!! error TS2304: Cannot find name 'T'. - */ - function sayHello7(somebody) { +@@= skipped -51, +51 lines =@@ return 'Hello ' + somebody; } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.types.diff index 3970a70f63..e6d1ca987f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.types.diff @@ -1,14 +1,6 @@ --- old.thisInFunctionCallJs.types +++ new.thisInFunctionCallJs.types -@@= skipped -11, +11 lines =@@ - >this : this - >data : number[] - >[1, 2, 3] : number[] -+>[1, 2, 3] : number[] - >1 : 1 - >2 : 2 - >3 : 3 -@@= skipped -72, +73 lines =@@ +@@= skipped -83, +83 lines =@@ /** @this {Test} */ function (d) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.types.diff deleted file mode 100644 index 5a41aad4a2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.types.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.annotatedThisPropertyInitializerDoesntNarrow.types -+++ new.annotatedThisPropertyInitializerDoesntNarrow.types -@@= skipped -12, +12 lines =@@ - constructor() { - /** @type {{ [assetName: string]: number}} */ - this.assets = {}; -->this.assets = {} : {} -+>this.assets = {} : { [assetName: string]: number; } - >this.assets : { [assetName: string]: number; } - >this : this - >assets : { [assetName: string]: number; } -+>{} : { [assetName: string]: number; } - >{} : {} - } - m() { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.types.diff index 2041429d90..8715aafdd4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.types.diff @@ -11,15 +11,7 @@ /** @type {string|undefined} */ foo: undefined, - >foo : string | undefined -+>undefined : string | undefined - >undefined : undefined - - /** @type {string|undefined} */ - bar: "42", - >bar : string | undefined -+>"42" : string | undefined - >"42" : "42" +@@= skipped -15, +15 lines =@@ /** @type {function(number): number} */ method1(n1) { @@ -36,12 +28,7 @@ >42 : 42 }, -@@= skipped -34, +36 lines =@@ - >'b' + 'ar1' : string - >'b' : "b" - >'ar1' : "ar1" -+>42 : number - >42 : 42 +@@= skipped -23, +23 lines =@@ /** @type {function(number): number} */ arrowFunc: (num) => num + 42 @@ -51,7 +38,6 @@ ->num + 42 : number ->num : number +>arrowFunc : function -+>(num) => num + 42 : function +>(num) => num + 42 : (num: any) => any +>num : any +>num + 42 : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff index d2dc5ae4f8..b398e62b86 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff @@ -1,7 +1,7 @@ --- old.checkJsdocTypeTagOnObjectProperty2.errors.txt +++ new.checkJsdocTypeTagOnObjectProperty2.errors.txt @@= skipped -0, +0 lines =@@ --0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string'. + 0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string'. -0.js(8,7): error TS2322: Type 'string' is not assignable to type 'number'. -0.js(11,20): error TS2322: Type 'string' is not assignable to type 'number'. -0.js(13,15): error TS2322: Type 'string' is not assignable to type 'number'. @@ -12,7 +12,6 @@ - - -==== 0.js (8 errors) ==== -+0.js(5,8): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +0.js(10,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(12,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + @@ -21,12 +20,7 @@ // @ts-check var lol; const obj = { - /** @type {string|undefined} */ - bar: 42, -- ~~~~~~~ --!!! error TS2322: Type 'number' is not assignable to type 'string'. -+ ~~ -+!!! error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. +@@= skipped -18, +13 lines =@@ /** @type {function(number): number} */ method1(n1) { return "42"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.types.diff index ce03a66660..b68147adad 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.types.diff @@ -6,14 +6,12 @@ const obj = { ->obj : { bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } ->{ /** @type {string|undefined} */ bar: 42, /** @type {function(number): number} */ method1(n1) { return "42"; }, /** @type {function(number): number} */ method2: (n1) => "lol", /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, /** @type {string} */ lol} : { bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } -+>obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: any; } -+>{ /** @type {string|undefined} */ bar: 42, /** @type {function(number): number} */ method1(n1) { return "42"; }, /** @type {function(number): number} */ method2: (n1) => "lol", /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, /** @type {string} */ lol} : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: any; } ++>obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: string; } ++>{ /** @type {string|undefined} */ bar: 42, /** @type {function(number): number} */ method1(n1) { return "42"; }, /** @type {function(number): number} */ method2: (n1) => "lol", /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, /** @type {string} */ lol} : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: string; } /** @type {string|undefined} */ bar: 42, - >bar : string | undefined -+>42 : string | undefined - >42 : 42 +@@= skipped -10, +10 lines =@@ /** @type {function(number): number} */ method1(n1) { @@ -24,7 +22,7 @@ return "42"; >"42" : "42" -@@= skipped -19, +20 lines =@@ +@@= skipped -9, +9 lines =@@ }, /** @type {function(number): number} */ method2: (n1) => "lol", @@ -32,7 +30,6 @@ ->(n1) => "lol" : (n1: number) => number ->n1 : number +>method2 : function -+>(n1) => "lol" : function +>(n1) => "lol" : (n1: any) => string +>n1 : any >"lol" : "lol" @@ -43,7 +40,6 @@ ->(num="0") => num + 42 : (num?: number) => number ->num : number +>arrowFunc : function -+>(num="0") => num + 42 : function +>(num="0") => num + 42 : (num?: string) => string +>num : string >"0" : "0" @@ -54,13 +50,7 @@ >42 : 42 /** @type {string} */ - lol -->lol : string -+>lol : any - } - lol = "string" - >lol = "string" : "string" -@@= skipped -27, +29 lines =@@ +@@= skipped -27, +27 lines =@@ /** @type {string} */ var s = obj.method1(0); >s : string @@ -70,7 +60,7 @@ ->method1 : (arg0: number) => number +>obj.method1(0) : string +>obj.method1 : (n1: any) => string -+>obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: any; } ++>obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: string; } +>method1 : (n1: any) => string >0 : 0 @@ -83,6 +73,6 @@ ->method2 : (arg0: number) => number +>obj.method2("0") : any +>obj.method2 : function -+>obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: any; } ++>obj : { bar: string | undefined; method1(n1: any): string; method2: function; arrowFunc: function; lol: string; } +>method2 : function >"0" : "0" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions3.types.diff index 3ae663834f..595be4cec1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions3.types.diff @@ -89,7 +89,6 @@ +>this.second : any +>this : any +>second : any -+>1 : 1 >1 : 1 } /** @param {number} n */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff index e8e19459fd..800c1e807a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff @@ -6,14 +6,12 @@ +test.js(14,4): error TS2339: Property 'x' does not exist on type '{}'. +test.js(16,7): error TS7006: Parameter 'n' implicitly has an 'any' type. +test.js(18,4): error TS2339: Property 'x' does not exist on type '{}'. -+test.js(33,13): error TS2322: Type 'string' is not assignable to type '"done"'. -+test.js(34,15): error TS7006: Parameter 'n' implicitly has an 'any' type. +test.js(57,17): error TS2339: Property 'x' does not exist on type 'Thing'. +test.js(59,7): error TS7006: Parameter 'n' implicitly has an 'any' type. +test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. + + -+==== test.js (9 errors) ==== ++==== test.js (7 errors) ==== + /** @typedef {{ + status: 'done' + m(n: number): void @@ -55,12 +53,7 @@ + fail() { + this.s = { + 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; }' + 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 603be558a0..f549535fac 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.types.diff @@ -17,11 +17,10 @@ +>ns.x : any +>ns : {} +>x : any -+>{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } >{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } status: 'done', -@@= skipped -21, +22 lines =@@ +@@= skipped -21, +21 lines =@@ } ns.x = { @@ -66,38 +65,22 @@ >this : this ->s : DoneStatus +>s : { status: "done"; m(n: number): void; } -+>{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } >{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } status: 'done', -@@= skipped -19, +20 lines =@@ - >fail : () => void +@@= skipped -20, +20 lines =@@ this.s = { -->this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } + >this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } ->this.s : DoneStatus -+>this.s = { status: 'done', m(n) { } } : { status: string; m(n: any): void; } +>this.s : { status: "done"; m(n: number): void; } >this : this ->s : DoneStatus -->{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } +>s : { status: "done"; m(n: number): void; } -+>{ status: 'done', m(n) { } } : { status: string; m(n: any): void; } + >{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } status: 'done', -->status : "done" -+>status : string - >'done' : "done" - - m(n) { } -->m : (n: number) => void -->n : number -+>m : (n: any) => void -+>n : any - } - } - } -@@= skipped -22, +22 lines =@@ +@@= skipped -21, +21 lines =@@ /** @type {DoneStatus} */ exports.x = { >exports.x = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } @@ -107,11 +90,10 @@ +>exports.x : { status: "done"; m(n: number): void; } +>exports : typeof import("./test") +>x : { status: "done"; m(n: number): void; } -+>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } status: "done", -@@= skipped -14, +15 lines =@@ +@@= skipped -14, +14 lines =@@ >n : number } exports.x @@ -135,11 +117,10 @@ +>module : { "\"test\"": typeof import("./test"); } +>exports : typeof import("./test") +>y : { status: "done"; m(n: number): void; } -+>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } status: "done", -@@= skipped -23, +24 lines =@@ +@@= skipped -23, +23 lines =@@ >n : number } module.exports.y @@ -203,18 +184,14 @@ +>F.prototype : { status: "done"; m(n: number): void; } +>F : { (): void; prototype: { status: "done"; m(n: number): void; }; } +>prototype : { status: "done"; m(n: number): void; } -+>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } status: "done", -@@= skipped -59, +60 lines =@@ +@@= skipped -59, +59 lines =@@ module.exports = { >module.exports = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } >module.exports : { status: "done"; m(n: number): void; } ->module : { exports: { status: "done"; m(n: number): void; }; } +>module : { "export=": { status: "done"; m(n: number): void; }; } >exports : { status: "done"; m(n: number): void; } -+>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } >{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } - - status: "done", \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.types.diff index 53b71e18c3..c7592f15c8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.types.diff @@ -1,22 +1,6 @@ --- old.enumTag.types +++ new.enumTag.types -@@= skipped -24, +24 lines =@@ - /** @type {number} */ - OK_I_GUESS: 2 - >OK_I_GUESS : number -+>2 : number - >2 : 2 - } - /** @enum number */ -@@= skipped -18, +19 lines =@@ - /** @type {number} */ - FINE: 2, - >FINE : number -+>2 : number - >2 : 2 - } - /** @enum {function(number): number} */ -@@= skipped -36, +37 lines =@@ +@@= skipped -78, +78 lines =@@ */ function consume(t,s,f) { >consume : (t: Target, s: Second, f: Fs) => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagOnExports.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagOnExports.types.diff index b58a6459a0..06c305a9bc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagOnExports.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagOnExports.types.diff @@ -7,9 +7,9 @@ ->exports.a : typeof a ->exports : typeof import("enumTagOnExports") ->a : typeof a -+>exports.a : any ++>exports.a : {} +>exports : typeof import("./enumTagOnExports") -+>a : any ++>a : {} >{} : {} /** @enum {string} */ @@ -20,9 +20,9 @@ ->module : { exports: typeof module.exports; } ->exports : typeof module.exports ->b : typeof b -+>module.exports.b : any ++>module.exports.b : {} +>module.exports : typeof import("./enumTagOnExports") +>module : { "\"enumTagOnExports\"": typeof import("./enumTagOnExports"); } +>exports : typeof import("./enumTagOnExports") -+>b : any ++>b : {} >{} : {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff index c159897641..a86c615df7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff @@ -2,13 +2,17 @@ +++ new.exportNestedNamespaces.errors.txt @@= skipped -0, +0 lines =@@ - ++mod.js(2,11): error TS2339: Property 'K' does not exist on type '{}'. ++use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. +use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. +use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? + + -+==== mod.js (0 errors) ==== ++==== mod.js (1 errors) ==== + exports.n = {}; + exports.n.K = function () { ++ ~ ++!!! error TS2339: Property 'K' does not exist on type '{}'. + this.x = 10; + } + exports.Classic = class { @@ -17,10 +21,12 @@ + } + } + -+==== use.js (2 errors) ==== ++==== use.js (3 errors) ==== + import * as s from './mod' + + var k = new s.n.K() ++ ~ ++!!! error TS2339: Property 'K' does not exist on type '{}'. + k.x + var classic = new s.Classic() + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.types.diff index b4d5b2f3e8..9134f1a3d7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.types.diff @@ -9,9 +9,9 @@ ->exports : typeof import("mod") ->n : typeof n +>exports.n = {} : {} -+>exports.n : any ++>exports.n : {} +>exports : typeof import("./mod") -+>n : any ++>n : {} >{} : {} exports.n.K = function () { @@ -24,9 +24,9 @@ ->function () { this.x = 10;} : typeof K +>exports.n.K = function () { this.x = 10;} : () => void +>exports.n.K : any -+>exports.n : any ++>exports.n : {} +>exports : typeof import("./mod") -+>n : any ++>n : {} +>K : any +>function () { this.x = 10;} : () => void @@ -68,11 +68,11 @@ +>k : any +>new s.n.K() : any +>s.n.K : any -+>s.n : any ++>s.n : {} >s : typeof s ->n : typeof s.n ->K : typeof K -+>n : any ++>n : {} +>K : any k.x diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces2.errors.txt.diff index b4f6da3a73..9da350756f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces2.errors.txt.diff @@ -9,6 +9,8 @@ +second.js(1,1): error TS2304: Cannot find name 'exports'. +second.js(1,11): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +second.js(2,1): error TS2304: Cannot find name 'exports'. ++use.js(3,18): error TS2339: Property 'j' does not exist on type '{}'. ++use.js(4,28): error TS2339: Property 'o' does not exist on type '{}'. ==== mod.js (0 errors) ==== @@ -42,4 +44,15 @@ +!!! error TS2304: Cannot find name 'exports'. return v } + +-==== use.js (0 errors) ==== ++==== use.js (2 errors) ==== + import * as debug from './mod' + + debug.formatters.j ++ ~ ++!!! error TS2339: Property 'j' does not exist on type '{}'. + var one = debug.formatters.o(1) ++ ~ ++!!! error TS2339: Property 'o' does not exist on type '{}'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces2.types.diff index 257215ddbe..fcaaf75f04 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces2.types.diff @@ -1,15 +1,12 @@ --- old.exportNestedNamespaces2.types +++ new.exportNestedNamespaces2.types -@@= skipped -3, +3 lines =@@ - // Based on a pattern from adonis +@@= skipped -4, +4 lines =@@ exports.formatters = {} >exports.formatters = {} : {} -->exports.formatters : {} + >exports.formatters : {} ->exports : typeof import("mod") -->formatters : {} -+>exports.formatters : any +>exports : typeof import("./mod") -+>formatters : any + >formatters : {} >{} : {} === first.js === @@ -23,7 +20,7 @@ >require : any >'./mod' : "./mod" -@@= skipped -17, +17 lines =@@ +@@= skipped -16, +16 lines =@@ >exports.formatters.j = function (v) { return v} : (v: any) => any >exports.formatters.j : any >exports.formatters : any @@ -53,26 +50,4 @@ +>exports : any >formatters : any >o : any - >function (v) { return v} : (v: any) => any -@@= skipped -16, +16 lines =@@ - - debug.formatters.j - >debug.formatters.j : any -->debug.formatters : {} -+>debug.formatters : any - >debug : typeof debug -->formatters : {} -+>formatters : any - >j : any - - var one = debug.formatters.o(1) - >one : any - >debug.formatters.o(1) : any - >debug.formatters.o : any -->debug.formatters : {} -+>debug.formatters : any - >debug : typeof debug -->formatters : {} -+>formatters : any - >o : any - >1 : 1 + >function (v) { return v} : (v: any) => any \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff new file mode 100644 index 0000000000..a5e7999e31 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt ++++ new.instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt +@@= skipped -0, +0 lines =@@ +- ++instantiateTemplateTagTypeParameterOnVariableStatement.js(12,5): error TS2322: Type 'T' is not assignable to type 'string'. ++instantiateTemplateTagTypeParameterOnVariableStatement.js(12,24): error TS2345: Argument of type 'string' is not assignable to parameter of type 'T'. ++ 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. ++ ++ ++==== instantiateTemplateTagTypeParameterOnVariableStatement.js (2 errors) ==== ++ /** ++ * @template T ++ * @param {T} a ++ * @returns {(b: T) => T} ++ */ ++ const seq = a => b => b; ++ ++ const text1 = "hello"; ++ const text2 = "world"; ++ ++ /** @type {string} */ ++ var text3 = seq(text1)(text2); ++ ~~~~~ ++!!! error TS2322: Type 'T' is not assignable to type 'string'. ++!!! related TS2208 instantiateTemplateTagTypeParameterOnVariableStatement.js:2:14: This type parameter might need an `extends string` constraint. ++ ~~~~~ ++!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'T'. ++!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types.diff new file mode 100644 index 0000000000..8ea8637f9c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types.diff @@ -0,0 +1,13 @@ +--- old.instantiateTemplateTagTypeParameterOnVariableStatement.types ++++ new.instantiateTemplateTagTypeParameterOnVariableStatement.types +@@= skipped -24, +24 lines =@@ + /** @type {string} */ + var text3 = seq(text1)(text2); + >text3 : string +->seq(text1)(text2) : string +->seq(text1) : (b: string) => string ++>seq(text1)(text2) : T ++>seq(text1) : (b: T) => T + >seq : (a: T) => (b: T) => T + >text1 : "hello" + >text2 : "world" \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.types.diff index 1f74acb374..f360380bed 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.types.diff @@ -1,22 +1,6 @@ --- old.jsDeclarationsEnumTag.types +++ new.jsDeclarationsEnumTag.types -@@= skipped -20, +20 lines =@@ - /** @type {number} */ - OK_I_GUESS: 2 - >OK_I_GUESS : number -+>2 : number - >2 : 2 - } - /** @enum number */ -@@= skipped -14, +15 lines =@@ - /** @type {number} */ - FINE: 2, - >FINE : number -+>2 : number - >2 : 2 - } - /** @enum {function(number): number} */ -@@= skipped -37, +38 lines =@@ +@@= skipped -71, +71 lines =@@ */ export function consume(t,s,f) { >consume : (t: Target, s: Second, f: Fs) => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedConstructorFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedConstructorFunction.types.diff index bc03287455..c0ff01906a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedConstructorFunction.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedConstructorFunction.types.diff @@ -12,11 +12,11 @@ ->MyClass : typeof MyClass ->function() { this.x = 1} : typeof MyClass +>module.exports.MyClass = function() { this.x = 1} : () => void -+>module.exports.MyClass : any ++>module.exports.MyClass : () => void +>module.exports : typeof import("./jsDeclarationsExportAssignedConstructorFunction") +>module : { "\"jsDeclarationsExportAssignedConstructorFunction\"": typeof import("./jsDeclarationsExportAssignedConstructorFunction"); } +>exports : typeof import("./jsDeclarationsExportAssignedConstructorFunction") -+>MyClass : any ++>MyClass : () => void +>function() { this.x = 1} : () => void this.x = 1 @@ -37,11 +37,11 @@ ->MyClass : typeof MyClass ->prototype : { a: () => void; } +>module.exports.MyClass.prototype : any -+>module.exports.MyClass : any ++>module.exports.MyClass : () => void +>module.exports : typeof import("./jsDeclarationsExportAssignedConstructorFunction") +>module : { "\"jsDeclarationsExportAssignedConstructorFunction\"": typeof import("./jsDeclarationsExportAssignedConstructorFunction"); } +>exports : typeof import("./jsDeclarationsExportAssignedConstructorFunction") -+>MyClass : any ++>MyClass : () => void +>prototype : any >{ a: function() { }} : { a: () => void; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.types.diff index 444c094225..edc9df00b9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.types.diff @@ -9,22 +9,20 @@ >len : number /** - * @type {number[]} +@@= skipped -8, +8 lines =@@ */ this.storage = new Array(len); -->this.storage = new Array(len) : any[] + >this.storage = new Array(len) : any[] ->this.storage : number[] ->this : this ->storage : number[] -+>this.storage = new Array(len) : number[] +>this.storage : any +>this : any +>storage : any -+>new Array(len) : number[] >new Array(len) : any[] >Array : ArrayConstructor >len : number -@@= skipped -19, +20 lines =@@ +@@= skipped -11, +11 lines =@@ Vec.prototype = { >Vec.prototype = { /** * @param {Vec} other */ dot(other) { if (other.storage.length !== this.storage.length) { throw new Error(`Dot product only applicable for vectors of equal length`); } let sum = 0; for (let i = 0; i < this.storage.length; i++) { sum += (this.storage[i] * other.storage[i]); } return sum; }, magnitude() { let sum = 0; for (let i = 0; i < this.storage.length; i++) { sum += (this.storage[i] ** 2); } return Math.sqrt(sum); }} : { dot(other: Vec): number; magnitude(): number; } >Vec.prototype : { dot(other: Vec): number; magnitude(): number; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff index 7e33df980a..4d291444a9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff @@ -2,18 +2,25 @@ +++ new.jsDeclarationsFunctionsCjs.errors.txt @@= skipped -0, +0 lines =@@ - ++index.js(4,18): error TS2339: Property 'cat' does not exist on type '() => void'. ++index.js(7,18): error TS2339: Property 'Cls' does not exist on type '() => void'. ++index.js(31,18): error TS2339: Property 'self' does not exist on type '(a: any) => any'. +index.js(35,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + -+==== index.js (2 errors) ==== ++==== index.js (5 errors) ==== + module.exports.a = function a() {} + + module.exports.b = function b() {} + module.exports.b.cat = "cat"; ++ ~~~ ++!!! error TS2339: Property 'cat' does not exist on type '() => void'. + + module.exports.c = function c() {} + module.exports.c.Cls = class {} ++ ~~~ ++!!! error TS2339: Property 'Cls' does not exist on type '() => void'. + + /** + * @param {number} a @@ -38,6 +45,8 @@ + return a; + } + module.exports.f.self = module.exports.f; ++ ~~~~ ++!!! error TS2339: Property 'self' does not exist on type '(a: any) => any'. + + /** + * @param {{x: string}} a diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff index 7390b91776..a5dbd352ca 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff @@ -1,19 +1,16 @@ --- old.jsDeclarationsFunctionsCjs.types +++ new.jsDeclarationsFunctionsCjs.types -@@= skipped -2, +2 lines =@@ - === index.js === +@@= skipped -3, +3 lines =@@ module.exports.a = function a() {} >module.exports.a = function a() {} : () => void -->module.exports.a : () => void + >module.exports.a : () => void ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->a : () => void -+>module.exports.a : any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>a : any + >a : () => void >function a() {} : () => void >a : () => void @@ -27,11 +24,11 @@ ->function b() {} : { (): void; cat: string; } ->b : { (): void; cat: string; } +>module.exports.b = function b() {} : () => void -+>module.exports.b : any ++>module.exports.b : () => void +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>b : any ++>b : () => void +>function b() {} : () => void +>b : () => void @@ -45,11 +42,11 @@ ->b : { (): void; cat: string; } ->cat : string +>module.exports.b.cat : any -+>module.exports.b : any ++>module.exports.b : () => void +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>b : any ++>b : () => void +>cat : any >"cat" : "cat" @@ -63,11 +60,11 @@ ->function c() {} : { (): void; Cls: typeof Cls; } ->c : { (): void; Cls: typeof Cls; } +>module.exports.c = function c() {} : () => void -+>module.exports.c : any ++>module.exports.c : () => void +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>c : any ++>c : () => void +>function c() {} : () => void +>c : () => void @@ -81,16 +78,16 @@ ->c : { (): void; Cls: typeof Cls; } ->Cls : typeof Cls +>module.exports.c.Cls : any -+>module.exports.c : any ++>module.exports.c : () => void +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>c : any ++>c : () => void +>Cls : any >class {} : typeof Cls /** -@@= skipped -56, +56 lines =@@ +@@= skipped -55, +55 lines =@@ * @return {string} */ module.exports.d = function d(a, b) { return /** @type {*} */(null); } @@ -105,11 +102,11 @@ ->a : number ->b : number +>module.exports.d = function d(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any -+>module.exports.d : any ++>module.exports.d : (a: any, b: any) => any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>d : any ++>d : (a: any, b: any) => any +>function d(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any +>d : (a: any, b: any) => any +>a : any @@ -134,11 +131,11 @@ ->a : T ->b : U +>module.exports.e = function e(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any -+>module.exports.e : any ++>module.exports.e : (a: any, b: any) => any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>e : any ++>e : (a: any, b: any) => any +>function e(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any +>e : (a: any, b: any) => any +>a : any @@ -161,11 +158,11 @@ ->f : { (a: T): T; self: any; } ->a : T +>module.exports.f = function f(a) { return a;} : (a: any) => any -+>module.exports.f : any ++>module.exports.f : (a: any) => any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>f : any ++>f : (a: any) => any +>function f(a) { return a;} : (a: any) => any +>f : (a: any) => any +>a : any @@ -188,19 +185,19 @@ ->module : { exports: typeof module.exports; } ->exports : typeof module.exports ->f : { (a: T): T; self: any; } -+>module.exports.f.self = module.exports.f : any ++>module.exports.f.self = module.exports.f : (a: any) => any +>module.exports.f.self : any -+>module.exports.f : any ++>module.exports.f : (a: any) => any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>f : any ++>f : (a: any) => any +>self : any -+>module.exports.f : any ++>module.exports.f : (a: any) => any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>f : any ++>f : (a: any) => any /** * @param {{x: string}} a @@ -290,79 +287,65 @@ module.exports.i = function i() {} >module.exports.i = function i() {} : () => void -->module.exports.i : () => void + >module.exports.i : () => void ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->i : () => void -+>module.exports.i : any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>i : any + >i : () => void >function i() {} : () => void >i : () => void - +@@= skipped -116, +117 lines =@@ module.exports.ii = module.exports.i; -->module.exports.ii = module.exports.i : () => void -->module.exports.ii : () => void + >module.exports.ii = module.exports.i : () => void + >module.exports.ii : () => void ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->ii : () => void -->module.exports.i : () => void -->module.exports : typeof module.exports -->module : { exports: typeof module.exports; } -->exports : typeof module.exports -->i : () => void -+>module.exports.ii = module.exports.i : any -+>module.exports.ii : any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>ii : any -+>module.exports.i : any + >ii : () => void + >module.exports.i : () => void +->module.exports : typeof module.exports +->module : { exports: typeof module.exports; } +->exports : typeof module.exports +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>i : any + >i : () => void // note that this last one doesn't make much sense in cjs, since exports aren't hoisted bindings module.exports.jj = module.exports.j; -->module.exports.jj = module.exports.j : () => void -->module.exports.jj : () => void + >module.exports.jj = module.exports.j : () => void + >module.exports.jj : () => void ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->jj : () => void -->module.exports.j : () => void -->module.exports : typeof module.exports -->module : { exports: typeof module.exports; } -->exports : typeof module.exports -->j : () => void -+>module.exports.jj = module.exports.j : any -+>module.exports.jj : any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>jj : any -+>module.exports.j : any + >jj : () => void + >module.exports.j : () => void +->module.exports : typeof module.exports +->module : { exports: typeof module.exports; } +->exports : typeof module.exports +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>j : any + >j : () => void module.exports.j = function j() {} >module.exports.j = function j() {} : () => void -->module.exports.j : () => void + >module.exports.j : () => void ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->j : () => void -+>module.exports.j : any +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>j : any - >function j() {} : () => void >j : () => void + >function j() {} : () => void + >j : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.types.diff index f8ddbf801c..a7a6a40dcd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.types.diff @@ -58,20 +58,7 @@ >require : any >'./rectangle' : "./rectangle" -@@= skipped -23, +23 lines =@@ - * @type {Rectangle[]} - */ - this.objects = []; -->this.objects = [] : undefined[] -+>this.objects = [] : Rectangle[] - >this.objects : Rectangle[] - >this : this - >objects : Rectangle[] -+>[] : Rectangle[] - >[] : undefined[] - } - /** -@@= skipped -34, +35 lines =@@ +@@= skipped -57, +57 lines =@@ } module.exports = { Render }; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences3.errors.txt.diff index 472a6041c7..6f157d663f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences3.errors.txt.diff @@ -3,9 +3,10 @@ @@= skipped -0, +0 lines =@@ - +index.js(3,19): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++index.js(5,18): error TS2339: Property 'B' does not exist on type '{}'. + + -+==== index.js (1 errors) ==== ++==== index.js (2 errors) ==== + /// + + const Something = require("fs").Something; @@ -13,6 +14,8 @@ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + module.exports.A = {} + module.exports.A.B = { ++ ~ ++!!! error TS2339: Property 'B' does not exist on type '{}'. + thing: new Something() + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences3.types.diff index c0798fd56e..8abea689e9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences3.types.diff @@ -23,11 +23,11 @@ ->exports : typeof module.exports ->A : typeof A +>module.exports.A = {} : {} -+>module.exports.A : any ++>module.exports.A : {} +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>A : any ++>A : {} >{} : {} module.exports.A.B = { @@ -42,11 +42,11 @@ ->{ thing: new Something()} : { thing: Something; } +>module.exports.A.B = { thing: new Something()} : { thing: any; } +>module.exports.A.B : any -+>module.exports.A : any ++>module.exports.A : {} +>module.exports : typeof import(".") +>module : { "\"index\"": typeof import("."); } +>exports : typeof import(".") -+>A : any ++>A : {} +>B : any +>{ thing: new Something()} : { thing: any; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.types.diff index 3b3f454761..3fe51714b9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.types.diff @@ -30,14 +30,12 @@ /** @type {import("./conn").Whatever} */ this.another = ""; -->this.another = "" : "" + >this.another = "" : "" ->this.another : import("conn").Whatever -+>this.another = "" : any +>this.another : any >this : this ->another : import("conn").Whatever +>another : any -+>"" : any >"" : "" } } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff index 3062e47e9b..a95ad05e93 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff @@ -4,7 +4,6 @@ - +index.js(3,37): error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. +index.js(21,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+module.js(11,38): error TS2304: Cannot find name 'P'. +module.js(24,12): error TS2315: Type 'Object' is not generic. +module.js(27,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + @@ -35,7 +34,7 @@ + module.exports = MainThreadTasks; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== module.js (3 errors) ==== ++==== module.js (2 errors) ==== + /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ + + /** @@ -47,8 +46,6 @@ + + /** + * @type {{[P in TaskGroupIds]: {id: P, label: string}}} -+ ~ -+!!! error TS2304: Cannot find name 'P'. + */ + const taskGroups = { + parseHTML: { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff index 400a02d05b..811f187d26 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff @@ -1,19 +1,17 @@ --- old.jsDeclarationsTypedefPropertyAndExportAssignment.types +++ new.jsDeclarationsTypedefPropertyAndExportAssignment.types -@@= skipped -1, +1 lines =@@ - +@@= skipped -2, +2 lines =@@ === index.js === const {taskGroups, taskNameToGroup} = require('./module.js'); -->taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } + >taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } ->taskNameToGroup : { [x: string]: import("module").TaskGroup; } ->require('./module.js') : typeof import("module") -+>taskGroups : { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; } +>taskNameToGroup : any -+>require('./module.js') : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } ++>require('./module.js') : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } >require : any >'./module.js' : "./module.js" -@@= skipped -24, +24 lines =@@ +@@= skipped -23, +23 lines =@@ * @param {TaskNode} y */ constructor(x, y){} @@ -30,43 +28,7 @@ >exports : typeof MainThreadTasks >MainThreadTasks : typeof MainThreadTasks -@@= skipped -25, +25 lines =@@ - * @type {{[P in TaskGroupIds]: {id: P, label: string}}} - */ - const taskGroups = { -->taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } -->{ parseHTML: { id: 'parseHTML', label: 'Parse HTML & CSS' }, styleLayout: { id: 'styleLayout', label: 'Style & Layout' },} : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } -+>taskGroups : { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; } -+>{ parseHTML: { id: 'parseHTML', label: 'Parse HTML & CSS' }, styleLayout: { id: 'styleLayout', label: 'Style & Layout' },} : { parseHTML: { id: string; label: string; }; styleLayout: { id: string; label: string; }; } - - parseHTML: { -->parseHTML : { id: "parseHTML"; label: string; } -->{ id: 'parseHTML', label: 'Parse HTML & CSS' } : { id: "parseHTML"; label: string; } -+>parseHTML : { id: string; label: string; } -+>{ id: 'parseHTML', label: 'Parse HTML & CSS' } : { id: string; label: string; } - - id: 'parseHTML', -->id : "parseHTML" -+>id : string - >'parseHTML' : "parseHTML" - - label: 'Parse HTML & CSS' -@@= skipped -17, +17 lines =@@ - - }, - styleLayout: { -->styleLayout : { id: "styleLayout"; label: string; } -->{ id: 'styleLayout', label: 'Style & Layout' } : { id: "styleLayout"; label: string; } -+>styleLayout : { id: string; label: string; } -+>{ id: 'styleLayout', label: 'Style & Layout' } : { id: string; label: string; } - - id: 'styleLayout', -->id : "styleLayout" -+>id : string - >'styleLayout' : "styleLayout" - - label: 'Style & Layout' -@@= skipped -16, +16 lines =@@ +@@= skipped -58, +58 lines =@@ /** @type {Object} */ const taskNameToGroup = {}; @@ -80,15 +42,14 @@ ->module : { exports: typeof module.exports; } ->exports : typeof module.exports ->{ taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: { [x: string]: TaskGroup; }; } -+>module.exports = { taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } -+>module.exports : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } -+>module : { "export=": { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; }; } -+>exports : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } -+>{ taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; }; taskNameToGroup: any; } ++>module.exports = { taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } ++>module.exports : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } ++>module : { "export=": { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; }; } ++>exports : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } ++>{ taskGroups, taskNameToGroup,} : { taskGroups: { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; }; taskNameToGroup: any; } taskGroups, -->taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } -+>taskGroups : { parseHTML: { id: P; label: string; }; styleLayout: { id: P; label: string; }; } + >taskGroups : { parseHTML: { id: "parseHTML"; label: string; }; styleLayout: { id: "styleLayout"; label: string; }; } taskNameToGroup, ->taskNameToGroup : { [x: string]: TaskGroup; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.types.diff index 2d7ff5aeb8..ddddffee2e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.types.diff @@ -21,17 +21,7 @@ >n : any /** -@@= skipped -10, +10 lines =@@ - * @type {number} - */ - this.y = n -->this.y = n : any -+>this.y = n : number - >this.y : number - >this : this - >y : number -+>n : number - >n : any +@@= skipped -18, +18 lines =@@ } } new C().x diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff index 6a7de887d0..2b1a668517 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff @@ -10,13 +10,12 @@ +a.js(35,37): error TS7006: Parameter 'key' implicitly has an 'any' type. +a.js(46,4): error TS2339: Property 'Multimap3' does not exist on type '{}'. +a.js(47,16): error TS2315: Type 'Object' is not generic. -+a.js(47,31): error TS2304: Cannot find name 'V'. +a.js(48,10): error TS2339: Property '_map' does not exist on type '{}'. +a.js(55,4): error TS2339: Property 'Multimap3' does not exist on type '{}'. +a.js(55,40): error TS7006: Parameter 'key' implicitly has an 'any' type. + + -+==== a.js (12 errors) ==== ++==== a.js (11 errors) ==== + /** + * Should work for function declarations + * @constructor @@ -80,8 +79,6 @@ + /** @type {Object} TODO: Remove the prototype from the fresh object */ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~ -+!!! error TS2304: Cannot find name 'V'. + this._map = {}; + ~~~~ +!!! error TS2339: Property '_map' does not exist on type '{}'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.types.diff index 6eef0b3a48..0544c9f295 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.types.diff @@ -9,19 +9,17 @@ /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; -->this._map = {} : {} + >this._map = {} : {} ->this._map : { [x: string]: V; } ->this : this ->_map : { [x: string]: V; } -+>this._map = {} : any +>this._map : any +>this : any +>_map : any -+>{} : any >{} : {} }; -@@= skipped -17, +18 lines =@@ +@@= skipped -17, +17 lines =@@ * @returns {V} the value ok */ Multimap.prototype.get = function (key) { @@ -64,19 +62,17 @@ /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; -->this._map = {} : {} + >this._map = {} : {} ->this._map : { [x: string]: V; } ->this : this ->_map : { [x: string]: V; } -+>this._map = {} : any +>this._map : any +>this : any +>_map : any -+>{} : any >{} : {} }; -@@= skipped -18, +19 lines =@@ +@@= skipped -18, +18 lines =@@ * @returns {V} the value ok */ Multimap2.prototype.get = function (key) { @@ -131,19 +127,17 @@ /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; -->this._map = {} : {} + >this._map = {} : {} ->this._map : { [x: string]: V; } ->this : this ->_map : { [x: string]: V; } -+>this._map = {} : any +>this._map : any +>this : {} +>_map : any -+>{} : any >{} : {} }; -@@= skipped -21, +22 lines =@@ +@@= skipped -21, +21 lines =@@ * @returns {V} the value ok */ Ns.Multimap3.prototype.get = function (key) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff index cabb8620c5..f04ebb0ee3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff @@ -13,14 +13,13 @@ +a.js(36,18): error TS2304: Cannot find name 'V'. +a.js(50,4): error TS2339: Property 'Multimap3' does not exist on type '{}'. +a.js(51,16): error TS2315: Type 'Object' is not generic. -+a.js(51,31): error TS2304: Cannot find name 'V'. +a.js(52,10): error TS2339: Property '_map' does not exist on type '{}'. +a.js(55,4): error TS2339: Property 'Multimap3' does not exist on type '{}'. +a.js(57,16): error TS2304: Cannot find name 'K'. +a.js(58,18): error TS2304: Cannot find name 'V'. + + -+==== a.js (16 errors) ==== ++==== a.js (15 errors) ==== + /** + * Should work for function declarations + * @constructor @@ -94,8 +93,6 @@ + /** @type {Object} TODO: Remove the prototype from the fresh object */ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~ -+!!! error TS2304: Cannot find name 'V'. + this._map = {}; + ~~~~ +!!! error TS2339: Property '_map' does not exist on type '{}'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.types.diff index 7101b8188d..96a9a58819 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.types.diff @@ -9,19 +9,17 @@ /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; -->this._map = {} : {} + >this._map = {} : {} ->this._map : { [x: string]: V; } ->this : this ->_map : { [x: string]: V; } -+>this._map = {} : any +>this._map : any +>this : any +>_map : any -+>{} : any >{} : {} }; -@@= skipped -15, +16 lines =@@ +@@= skipped -15, +15 lines =@@ Multimap.prototype = { >Multimap.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: K): V; } >Multimap.prototype : { get(key: K): V; } @@ -56,15 +54,13 @@ /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; -->this._map = {} : {} + >this._map = {} : {} ->this._map : { [x: string]: V; } ->this : this ->_map : { [x: string]: V; } -+>this._map = {} : any +>this._map : any +>this : any +>_map : any -+>{} : any >{} : {} }; @@ -80,7 +76,7 @@ >{ /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: K) => V; } /** -@@= skipped -30, +31 lines =@@ +@@= skipped -30, +30 lines =@@ >key : K return this._map[key + '']; @@ -121,15 +117,13 @@ /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; -->this._map = {} : {} + >this._map = {} : {} ->this._map : { [x: string]: V; } ->this : this ->_map : { [x: string]: V; } -+>this._map = {} : any +>this._map : any +>this : {} +>_map : any -+>{} : any >{} : {} }; @@ -149,7 +143,7 @@ >{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: K): V; } /** -@@= skipped -34, +35 lines =@@ +@@= skipped -34, +34 lines =@@ >key : K return this._map[key + '']; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeFromChainedAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeFromChainedAssignment.types.diff index a43e097ca1..75a74bd8d5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeFromChainedAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeFromChainedAssignment.types.diff @@ -21,15 +21,13 @@ ->this.first : 1 ->this : this ->first : 1 -->this.second = 1 : 1 -->this.second : 1 -->this : this -->second : 1 +>this.first : any +>this : any +>first : any -+>this.second = 1 : 1 -+>this.second = 1 : 1 + >this.second = 1 : 1 +->this.second : 1 +->this : this +->second : 1 +>this.second : any +>this : any +>second : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff index 9641f98cdb..9160d47fcf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff @@ -75,19 +75,17 @@ /** @type {string|number} */ this.p = "bar"; -->this.p = "bar" : "bar" + >this.p = "bar" : "bar" ->this.p : string | number ->this : this ->p : string | number -+>this.p = "bar" : string | number +>this.p : any +>this : any +>p : any -+>"bar" : string | number >"bar" : "bar" } -@@= skipped -36, +37 lines =@@ +@@= skipped -36, +36 lines =@@ >SomeOther : typeof SomeOther var someFakeClass = new SomeFakeClass(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias2.types.diff index 0d6847aa42..4784001b51 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAlias2.types.diff @@ -1,14 +1,6 @@ --- old.moduleExportAlias2.types +++ new.moduleExportAlias2.types -@@= skipped -10, +10 lines =@@ - var two = C.f(1) - >two : any - >C.f(1) : any -->C.f : (n: any) => any -+>C.f : any - >C : typeof C -->f : (n: any) => any -+>f : any +@@= skipped -16, +16 lines =@@ >1 : 1 var c = new C @@ -19,7 +11,7 @@ >C : typeof C === node.d.ts === -@@= skipped -25, +25 lines =@@ +@@= skipped -19, +19 lines =@@ === semver.js === /// exports = module.exports = C @@ -40,15 +32,12 @@ exports.f = n => n + 1 >exports.f = n => n + 1 : (n: any) => any -->exports.f : (n: any) => any + >exports.f : (n: any) => any ->exports : typeof C -->f : (n: any) => any -+>exports.f : any +>exports : typeof import("./semver") -+>f : any + >f : (n: any) => any >n => n + 1 : (n: any) => any >n : any - >n + 1 : any @@= skipped -20, +20 lines =@@ >1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment2.types.diff index 65630e727a..c6e1364453 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment2.types.diff @@ -19,16 +19,14 @@ } module.exports.asReadInstalled = function (tree) { >module.exports.asReadInstalled = function (tree) { npm(tree) // both references should be callable module.exports(tree)} : (tree: any) => void -->module.exports.asReadInstalled : (tree: any) => void + >module.exports.asReadInstalled : (tree: any) => void ->module.exports : { (tree: any): void; asReadInstalled: (tree: any) => void; } ->module : { exports: { (tree: any): void; asReadInstalled: (tree: any) => void; }; } ->exports : { (tree: any): void; asReadInstalled: (tree: any) => void; } -->asReadInstalled : (tree: any) => void -+>module.exports.asReadInstalled : any +>module.exports : typeof import("./npm") +>module : { "\"npm\"": typeof import("./npm"); } +>exports : typeof import("./npm") -+>asReadInstalled : any + >asReadInstalled : (tree: any) => void >function (tree) { npm(tree) // both references should be callable module.exports(tree)} : (tree: any) => void >tree : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff index 048f3dc44a..de6a3161fb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff @@ -2,13 +2,17 @@ +++ new.moduleExportNestedNamespaces.errors.txt @@= skipped -0, +0 lines =@@ - ++mod.js(2,18): error TS2339: Property 'K' does not exist on type '{}'. ++use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. +use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. +use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? + + -+==== mod.js (0 errors) ==== ++==== mod.js (1 errors) ==== + module.exports.n = {}; + module.exports.n.K = function C() { ++ ~ ++!!! error TS2339: Property 'K' does not exist on type '{}'. + this.x = 10; + } + module.exports.Classic = class { @@ -17,10 +21,12 @@ + } + } + -+==== use.js (2 errors) ==== ++==== use.js (3 errors) ==== + import * as s from './mod' + + var k = new s.n.K() ++ ~ ++!!! error TS2339: Property 'K' does not exist on type '{}'. + k.x + var classic = new s.Classic() + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.types.diff index 5d3a9d9ca0..1e329bcef9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.types.diff @@ -11,11 +11,11 @@ ->exports : typeof module.exports ->n : typeof n +>module.exports.n = {} : {} -+>module.exports.n : any ++>module.exports.n : {} +>module.exports : typeof import("./mod") +>module : { "\"mod\"": typeof import("./mod"); } +>exports : typeof import("./mod") -+>n : any ++>n : {} >{} : {} module.exports.n.K = function C() { @@ -31,11 +31,11 @@ ->C : typeof C +>module.exports.n.K = function C() { this.x = 10;} : () => void +>module.exports.n.K : any -+>module.exports.n : any ++>module.exports.n : {} +>module.exports : typeof import("./mod") +>module : { "\"mod\"": typeof import("./mod"); } +>exports : typeof import("./mod") -+>n : any ++>n : {} +>K : any +>function C() { this.x = 10;} : () => void +>C : () => void @@ -82,11 +82,11 @@ +>k : any +>new s.n.K() : any +>s.n.K : any -+>s.n : any ++>s.n : {} >s : typeof s ->n : typeof s.n ->K : typeof C -+>n : any ++>n : {} +>K : any k.x diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.errors.txt.diff index f7e2b75b94..42b332e921 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.errors.txt.diff @@ -2,36 +2,27 @@ +++ new.moduleExportsElementAccessAssignment.errors.txt @@= skipped -0, +0 lines =@@ - -+mod1.js(1,1): error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -+mod1.js(2,1): error TS7022: '"b"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -+mod1.js(3,1): error TS7022: '"default"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -+mod1.js(4,1): error TS7022: '"c"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -+mod1.js(5,1): error TS7022: '"d"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. ++mod1.js(6,24): error TS2339: Property 'e' does not exist on type '{}'. ++mod2.js(6,8): error TS2339: Property 'e' does not exist on type '{}'. + + -+==== mod2.js (0 errors) ==== ++==== mod2.js (1 errors) ==== + const mod1 = require("./mod1"); + mod1.a; + mod1.b; + mod1.c; + mod1.d; + mod1.d.e; ++ ~ ++!!! error TS2339: Property 'e' does not exist on type '{}'. + mod1.default; -+==== mod1.js (5 errors) ==== ++==== mod1.js (1 errors) ==== + exports.a = { x: "x" }; -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + exports["b"] = { x: "x" }; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS7022: '"b"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + exports["default"] = { x: "x" }; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS7022: '"default"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + module.exports["c"] = { x: "x" }; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS7022: '"c"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + module["exports"]["d"] = {}; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS7022: '"d"' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + module["exports"]["d"].e = 0; ++ ~ ++!!! error TS2339: Property 'e' does not exist on type '{}'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.types.diff index 19f1669f93..af3ced87ac 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment.types.diff @@ -1,96 +1,62 @@ --- old.moduleExportsElementAccessAssignment.types +++ new.moduleExportsElementAccessAssignment.types -@@= skipped -7, +7 lines =@@ - >"./mod1" : "./mod1" - - mod1.a; -->mod1.a : { x: string; } -+>mod1.a : any - >mod1 : typeof mod1 -->a : { x: string; } -+>a : any - - mod1.b; -->mod1.b : { x: string; } -+>mod1.b : any - >mod1 : typeof mod1 -->b : { x: string; } -+>b : any - - mod1.c; -->mod1.c : { x: string; } -+>mod1.c : any - >mod1 : typeof mod1 -->c : { x: string; } -+>c : any +@@= skipped -22, +22 lines =@@ + >c : { x: string; } mod1.d; ->mod1.d : typeof mod1."d" -+>mod1.d : any ++>mod1.d : {} >mod1 : typeof mod1 ->d : typeof mod1."d" -+>d : any ++>d : {} mod1.d.e; ->mod1.d.e : number ->mod1.d : typeof mod1."d" +>mod1.d.e : any -+>mod1.d : any ++>mod1.d : {} >mod1 : typeof mod1 ->d : typeof mod1."d" ->e : number -+>d : any ++>d : {} +>e : any mod1.default; -->mod1.default : { x: string; } -+>mod1.default : any - >mod1 : typeof mod1 -->default : { x: string; } -+>default : any - - === mod1.js === + >mod1.default : { x: string; } +@@= skipped -20, +20 lines =@@ exports.a = { x: "x" }; >exports.a = { x: "x" } : { x: string; } -->exports.a : { x: string; } + >exports.a : { x: string; } ->exports : typeof import("mod1") -->a : { x: string; } -+>exports.a : any +>exports : typeof import("./mod1") -+>a : any + >a : { x: string; } >{ x: "x" } : { x: string; } >x : string - >"x" : "x" - +@@= skipped -9, +9 lines =@@ exports["b"] = { x: "x" }; >exports["b"] = { x: "x" } : { x: string; } -->exports["b"] : { x: string; } + >exports["b"] : { x: string; } ->exports : typeof import("mod1") -+>exports["b"] : any +>exports : typeof import("./mod1") >"b" : "b" >{ x: "x" } : { x: string; } >x : string -@@= skipped -52, +52 lines =@@ - +@@= skipped -9, +9 lines =@@ exports["default"] = { x: "x" }; >exports["default"] = { x: "x" } : { x: string; } -->exports["default"] : { x: string; } + >exports["default"] : { x: string; } ->exports : typeof import("mod1") -+>exports["default"] : any +>exports : typeof import("./mod1") >"default" : "default" >{ x: "x" } : { x: string; } >x : string @@= skipped -9, +9 lines =@@ - module.exports["c"] = { x: "x" }; >module.exports["c"] = { x: "x" } : { x: string; } -->module.exports["c"] : { x: string; } + >module.exports["c"] : { x: string; } ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -+>module.exports["c"] : any +>module.exports : typeof import("./mod1") +>module : { "\"mod1\"": typeof import("./mod1"); } +>exports : typeof import("./mod1") @@ -105,7 +71,7 @@ ->module["exports"] : typeof module.exports ->module : { exports: typeof module.exports; } +>module["exports"]["d"] = {} : {} -+>module["exports"]["d"] : any ++>module["exports"]["d"] : {} +>module["exports"] : typeof import("./mod1") +>module : { "\"mod1\"": typeof import("./mod1"); } >"exports" : "exports" @@ -119,7 +85,7 @@ ->module["exports"] : typeof module.exports ->module : { exports: typeof module.exports; } +>module["exports"]["d"].e : any -+>module["exports"]["d"] : any ++>module["exports"]["d"] : {} +>module["exports"] : typeof import("./mod1") +>module : { "\"mod1\"": typeof import("./mod1"); } >"exports" : "exports" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff deleted file mode 100644 index 14419ad4d7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.paramTagTypeResolution2.errors.txt -+++ new.paramTagTypeResolution2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+38572.js(4,39): error TS2304: Cannot find name 'K'. -+ -+ -+==== 38572.js (1 errors) ==== -+ /** -+ * @template T -+ * @param {T} a -+ * @param {{[K in keyof T]: (value: T[K]) => void }} b -+ ~ -+!!! error TS2304: Cannot find name 'K'. -+ */ -+ function f(a, b) { -+ } -+ -+ f({ x: 42 }, { x(param) { param.toFixed() } }); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.types.diff deleted file mode 100644 index 14191c78f7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.types.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.paramTagTypeResolution2.types -+++ new.paramTagTypeResolution2.types -@@= skipped -17, +17 lines =@@ - >{ x: 42 } : { x: number; } - >x : number - >42 : 42 -->{ x(param) { param.toFixed() } } : { x(param: number): void; } -->x : (param: number) => void -->param : number -->param.toFixed() : string -->param.toFixed : (fractionDigits?: number) => string -->param : number -->toFixed : (fractionDigits?: number) => string -+>{ x(param) { param.toFixed() } } : { x(param: K): void; } -+>x : (param: K) => void -+>param : K -+>param.toFixed() : any -+>param.toFixed : any -+>param : K -+>toFixed : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.types.diff index 44f7b824e5..c294ec58c7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.types.diff @@ -11,15 +11,13 @@ /** @type {{ [s: string]: V }} */ this._map = {}; -->this._map = {} : {} + >this._map = {} : {} ->this._map : { [s: string]: V; } ->this : this ->_map : { [s: string]: V; } -+>this._map = {} : { [s: string]: V; } +>this._map : any +>this : any +>_map : any -+>{} : { [s: string]: V; } >{} : {} // without type annotation @@ -31,7 +29,7 @@ >_map2 : any >{ [ik]: iv } : { [x: string]: V; } >[ik] : V -@@= skipped -28, +29 lines =@@ +@@= skipped -28, +28 lines =@@ /** @type {Multimap<"a" | "b", number>} with type annotation */ const map = new Multimap("a", 1); >map : Multimap<"a" | "b", number> diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff index 578e481916..4a3a8a2346 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff @@ -5,17 +5,8 @@ +propertyAssignmentUseParentType2.js(11,14): error TS2322: Type '{ (): true; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. Types of property 'nuo' are incompatible. Type '1000' is not assignable to type '789'. -- -- --==== propertyAssignmentUseParentType2.js (1 errors) ==== -+propertyAssignmentUseParentType2.js(13,1): error TS2322: Type '1000' is not assignable to type '789'. -+ -+ -+==== propertyAssignmentUseParentType2.js (2 errors) ==== - /** @type {{ (): boolean; nuo: 789 }} */ - export const inlined = () => true - inlined.nuo = 789 -@@= skipped -15, +16 lines =@@ + +@@= skipped -15, +15 lines =@@ /** @type {{ (): boolean; nuo: 789 }} */ export const conflictingDuplicated = () => true ~~~~~~~~~~~~~~~~~~~~~ @@ -23,8 +14,4 @@ +!!! error TS2322: Type '{ (): true; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. !!! error TS2322: Types of property 'nuo' are incompatible. !!! error TS2322: Type '1000' is not assignable to type '789'. - /** @type {1000} */ - conflictingDuplicated.nuo = 789 -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2322: Type '1000' is not assignable to type '789'. - \ No newline at end of file + /** @type {1000} */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.types.diff index c55985b8ed..96f3624e3c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.types.diff @@ -18,12 +18,7 @@ >true : true /** @type {789} */ -@@= skipped -10, +10 lines =@@ - >duplicated : { (): boolean; nuo: 789; } - >nuo : 789 - >789 : 789 -+>789 : 789 - +@@= skipped -14, +14 lines =@@ /** @type {{ (): boolean; nuo: 789 }} */ export const conflictingDuplicated = () => true >conflictingDuplicated : { (): boolean; nuo: 789; } @@ -31,12 +26,4 @@ +>() => true : { (): true; nuo: 1000; } >true : true - /** @type {1000} */ - conflictingDuplicated.nuo = 789 -->conflictingDuplicated.nuo = 789 : 789 -+>conflictingDuplicated.nuo = 789 : 1000 - >conflictingDuplicated.nuo : 789 - >conflictingDuplicated : { (): boolean; nuo: 789; } - >nuo : 789 -+>789 : 1000 - >789 : 789 + /** @type {1000} */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff index 7d713f72b4..0d0f4cee34 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff @@ -2,14 +2,13 @@ +++ new.thisTypeOfConstructorFunctions.errors.txt @@= skipped -0, +0 lines =@@ - -+thisTypeOfConstructorFunctions.js(7,16): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +thisTypeOfConstructorFunctions.js(15,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +thisTypeOfConstructorFunctions.js(38,12): error TS2749: 'Cpp' refers to a value, but is being used as a type here. Did you mean 'typeof Cpp'? +thisTypeOfConstructorFunctions.js(41,12): error TS2749: 'Cp' refers to a value, but is being used as a type here. Did you mean 'typeof Cp'? +thisTypeOfConstructorFunctions.js(43,12): error TS2749: 'Cp' refers to a value, but is being used as a type here. Did you mean 'typeof Cp'? + + -+==== thisTypeOfConstructorFunctions.js (5 errors) ==== ++==== thisTypeOfConstructorFunctions.js (4 errors) ==== + /** + * @class + * @template T @@ -17,8 +16,6 @@ + */ + function Cp(t) { + /** @type {this} */ -+ ~~~~ -+!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + this.dit = this + this.y = t + /** @return {this} */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.types.diff index c274c13ec7..3792cdf6ab 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.types.diff @@ -19,7 +19,6 @@ +>this.dit : any +>this : any +>dit : any -+>this : any +>this : any this.y = t @@ -81,7 +80,7 @@ } } -@@= skipped -57, +58 lines =@@ +@@= skipped -57, +57 lines =@@ * @param {T} t */ function Cpp(t) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.types.diff index c2726cba3d..6b980beefb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.types.diff @@ -10,9 +10,9 @@ ->A : typeof A ->function () { this.x = 1;} : typeof A +>exports.A = function () { this.x = 1;} : () => void -+>exports.A : any ++>exports.A : () => void +>exports : typeof import("./a-ext") -+>A : any ++>A : () => void +>function () { this.x = 1;} : () => void this.x = 1; @@ -29,7 +29,7 @@ const { A } = require("./a-ext"); ->A : typeof A ->require("./a-ext") : typeof import("a-ext") -+>A : any ++>A : () => void +>require("./a-ext") : typeof import("./a-ext") >require : (id: string) => any >"./a-ext" : "./a-ext" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.types.diff index 0b6b0c5435..429adcdbfa 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.types.diff @@ -64,15 +64,7 @@ >class { constructor() { /** @type {number} */ this.y = 12; }} : typeof Inner constructor() { - /** @type {number} */ - this.y = 12; -->this.y = 12 : 12 -+>this.y = 12 : number - >this.y : number - >this : this - >y : number -+>12 : number - >12 : 12 +@@= skipped -18, +18 lines =@@ } } var example = new Outer.app.Inner(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.types.diff index 1f662def80..3c1f08e0c8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.types.diff @@ -64,15 +64,7 @@ >class { constructor() { /** @type {number} */ this.y = 12; }} : typeof Inner constructor() { - /** @type {number} */ - this.y = 12; -->this.y = 12 : 12 -+>this.y = 12 : number - >this.y : number - >this : this - >y : number -+>12 : number - >12 : 12 +@@= skipped -18, +18 lines =@@ } } var example = new Outer.app.Inner(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.types.diff index d7daa342ec..60ecd20cba 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.types.diff @@ -20,17 +20,7 @@ >class { constructor() { /** @type {number} */ this.y = 12 }} : typeof Inner constructor() { - /** @type {number} */ - this.y = 12 -->this.y = 12 : 12 -+>this.y = 12 : number - >this.y : number - >this : this - >y : number -+>12 : number - >12 : 12 - } - } +@@= skipped -24, +24 lines =@@ /** @type {Outer.Inner} */ var local diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagModuleExports.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagModuleExports.errors.txt.diff deleted file mode 100644 index afd81e7ee0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagModuleExports.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.typeTagModuleExports.errors.txt -+++ new.typeTagModuleExports.errors.txt -@@= skipped -0, +0 lines =@@ --bug27327.js(2,1): error TS2322: Type 'number' is not assignable to type 'string'. -+bug27327.js(2,18): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - - - ==== bug27327.js (1 errors) ==== - /** @type {string} */ - module.exports = 0; -- ~~~~~~~~~~~~~~ --!!! error TS2322: Type 'number' is not assignable to type 'string'. -+ ~ -+!!! error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagModuleExports.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagModuleExports.types.diff index 37623d0216..802067005a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagModuleExports.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagModuleExports.types.diff @@ -1,11 +1,13 @@ --- old.typeTagModuleExports.types +++ new.typeTagModuleExports.types -@@= skipped -4, +4 lines =@@ +@@= skipped -2, +2 lines =@@ + === bug27327.js === + /** @type {string} */ module.exports = 0; - >module.exports = 0 : string +->module.exports = 0 : string ++>module.exports = 0 : 0 >module.exports : string ->module : { exports: string; } +>module : { "export=": string; } >exports : string -+>0 : string >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnPropertyAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnPropertyAssignment.types.diff deleted file mode 100644 index a16314a3fa..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnPropertyAssignment.types.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.typeTagOnPropertyAssignment.types -+++ new.typeTagOnPropertyAssignment.types -@@= skipped -10, +10 lines =@@ - a: "a", - >a : "a" - >"a" : "a" -+>"a" : "a" - - /** @type {() => 'b'} */ - n: () => 'b' - >n : () => "b" -+>() => 'b' : () => "b" - >() => 'b' : () => "b" - >'b' : "b" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagPrototypeAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagPrototypeAssignment.errors.txt.diff deleted file mode 100644 index e973d66271..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagPrototypeAssignment.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.typeTagPrototypeAssignment.errors.txt -+++ new.typeTagPrototypeAssignment.errors.txt -@@= skipped -0, +0 lines =@@ --bug27327.js(4,1): error TS2322: Type 'number' is not assignable to type 'string'. -+bug27327.js(4,15): error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - - - ==== bug27327.js (1 errors) ==== -@@= skipped -5, +5 lines =@@ - } - /** @type {string} */ - C.prototype = 12 -- ~~~~~~~~~~~ --!!! error TS2322: Type 'number' is not assignable to type 'string'. -+ ~~ -+!!! error TS2352: Conversion of type 'number' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagPrototypeAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagPrototypeAssignment.types.diff index 84b77c717f..5053a04cde 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagPrototypeAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagPrototypeAssignment.types.diff @@ -9,11 +9,9 @@ } /** @type {string} */ C.prototype = 12 -->C.prototype = 12 : 12 -+>C.prototype = 12 : string + >C.prototype = 12 : 12 >C.prototype : string ->C : typeof C +>C : { (): void; prototype: string; } >prototype : string -+>12 : string >12 : 12 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff index fdea4946cc..9a21090cfa 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff @@ -52,9 +52,9 @@ ->C : typeof C ->function() { this.p = 1} : typeof C +>exports.C = function() { this.p = 1} : () => void -+>exports.C : any ++>exports.C : () => void +>exports : typeof import("./mod3") -+>C : any ++>C : () => void +>function() { this.p = 1} : () => void this.p = 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/untypedModuleImport_allowJs.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/untypedModuleImport_allowJs.types.diff index c1428bf639..24172272bd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/untypedModuleImport_allowJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/untypedModuleImport_allowJs.types.diff @@ -1,31 +1,11 @@ --- old.untypedModuleImport_allowJs.types +++ new.untypedModuleImport_allowJs.types -@@= skipped -1, +1 lines =@@ - - === /a.ts === - import foo from "foo"; -->foo : { bar(): number; } -+>foo : any - - foo.bar(); -->foo.bar() : number -->foo.bar : () => number -->foo : { bar(): number; } -->bar : () => number -+>foo.bar() : any -+>foo.bar : any -+>foo : any -+>bar : any - - === /node_modules/foo/index.js === +@@= skipped -13, +13 lines =@@ exports.default = { bar() { return 0; } } >exports.default = { bar() { return 0; } } : { bar(): number; } -->exports.default : { bar(): number; } + >exports.default : { bar(): number; } ->exports : typeof import("/node_modules/foo/index") -->default : { bar(): number; } -+>exports.default : any +>exports : typeof import("foo") -+>default : any + >default : { bar(): number; } >{ bar() { return 0; } } : { bar(): number; } - >bar : () => number - >0 : 0 \ No newline at end of file + >bar : () => number \ No newline at end of file