diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 961cf2cd64..58e1daeb2b 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -402,7 +402,7 @@ func (n *Node) TypeParameterList() *NodeList { return n.AsClassExpression().TypeParameters case KindInterfaceDeclaration: return n.AsInterfaceDeclaration().TypeParameters - case KindTypeAliasDeclaration: + case KindTypeAliasDeclaration, KindJSTypeAliasDeclaration: return n.AsTypeAliasDeclaration().TypeParameters default: funcLike := n.FunctionLikeData() @@ -436,7 +436,7 @@ func (n *Node) MemberList() *NodeList { case KindMappedType: return n.AsMappedTypeNode().Members } - panic("Unhandled case in Node.MemberList") + panic("Unhandled case in Node.MemberList: " + n.Kind.String()) } func (n *Node) Members() []*Node { @@ -487,7 +487,7 @@ func (n *Node) Type() *Node { return n.AsAsExpression().Type case KindSatisfiesExpression: return n.AsSatisfiesExpression().Type - case KindTypeAliasDeclaration: + case KindTypeAliasDeclaration, KindJSTypeAliasDeclaration: return n.AsTypeAliasDeclaration().Type case KindNamedTupleMember: return n.AsNamedTupleMember().Type @@ -499,6 +499,8 @@ func (n *Node) Type() *Node { return n.AsTemplateLiteralTypeSpan().Type case KindJSDocTypeExpression: return n.AsJSDocTypeExpression().Type + case KindJSDocPropertyTag: + return n.AsJSDocPropertyTag().TypeExpression case KindJSDocNullableType: return n.AsJSDocNullableType().Type case KindJSDocNonNullableType: @@ -513,7 +515,7 @@ func (n *Node) Type() *Node { return funcLike.Type } } - panic("Unhandled case in Node.Type") + panic("Unhandled case in Node.Type: " + n.Kind.String()) } func (n *Node) Initializer() *Node { @@ -3380,6 +3382,7 @@ type ClassLikeBase struct { DeclarationBase ExportableBase ModifiersBase + LocalsContainerBase compositeNodeBase name *IdentifierNode // IdentifierNode TypeParameters *NodeList // NodeList[*TypeParameterDeclarationNode]. Optional @@ -3617,13 +3620,17 @@ type TypeAliasDeclaration struct { Type *TypeNode // TypeNode } -func (f *NodeFactory) NewTypeAliasDeclaration(modifiers *ModifierList, name *IdentifierNode, typeParameters *NodeList, typeNode *TypeNode) *Node { +func (f *NodeFactory) newTypeOrJSTypeAliasDeclaration(kind Kind, modifiers *ModifierList, name *IdentifierNode, typeParameters *NodeList, typeNode *TypeNode) *Node { data := &TypeAliasDeclaration{} data.modifiers = modifiers data.name = name data.TypeParameters = typeParameters data.Type = typeNode - return newNode(KindTypeAliasDeclaration, data, f.hooks) + return newNode(kind, data, f.hooks) +} + +func (f *NodeFactory) NewTypeAliasDeclaration(modifiers *ModifierList, name *IdentifierNode, typeParameters *NodeList, typeNode *TypeNode) *Node { + return f.newTypeOrJSTypeAliasDeclaration(KindTypeAliasDeclaration, modifiers, name, typeParameters, typeNode) } func (f *NodeFactory) UpdateTypeAliasDeclaration(node *TypeAliasDeclaration, modifiers *ModifierList, name *IdentifierNode, typeParameters *TypeParameterList, typeNode *TypeNode) *Node { @@ -3638,6 +3645,9 @@ func (node *TypeAliasDeclaration) ForEachChild(v Visitor) bool { } func (node *TypeAliasDeclaration) VisitEachChild(v *NodeVisitor) *Node { + if node.Kind == KindJSTypeAliasDeclaration { + return v.Factory.UpdateJSTypeAliasDeclaration(node, v.visitModifiers(node.modifiers), v.visitNode(node.name), v.visitNodes(node.TypeParameters), v.visitNode(node.Type)) + } return v.Factory.UpdateTypeAliasDeclaration(node, v.visitModifiers(node.modifiers), v.visitNode(node.name), v.visitNodes(node.TypeParameters), v.visitNode(node.Type)) } @@ -3651,6 +3661,25 @@ func IsTypeAliasDeclaration(node *Node) bool { return node.Kind == KindTypeAliasDeclaration } +func IsTypeOrJSTypeAliasDeclaration(node *Node) bool { + return node.Kind == KindTypeAliasDeclaration || node.Kind == KindJSTypeAliasDeclaration +} + +func (f *NodeFactory) NewJSTypeAliasDeclaration(modifiers *ModifierList, name *IdentifierNode, typeParameters *NodeList, typeNode *TypeNode) *Node { + return f.newTypeOrJSTypeAliasDeclaration(KindJSTypeAliasDeclaration, modifiers, name, typeParameters, typeNode) +} + +func (f *NodeFactory) UpdateJSTypeAliasDeclaration(node *TypeAliasDeclaration, modifiers *ModifierList, name *IdentifierNode, typeParameters *TypeParameterList, typeNode *TypeNode) *Node { + if modifiers != node.modifiers || name != node.name || typeParameters != node.TypeParameters || typeNode != node.Type { + return updateNode(f.NewJSTypeAliasDeclaration(modifiers, name, typeParameters, typeNode), node.AsNode(), f.hooks) + } + return node.AsNode() +} + +func IsJSTypeAliasDeclaration(node *Node) bool { + return node.Kind == KindJSTypeAliasDeclaration +} + // EnumMember type EnumMember struct { @@ -8584,6 +8613,7 @@ func (node *JSDocLinkCode) Name() *DeclarationName { type JSDocTypeExpression struct { TypeNodeBase + Host *Node Type *TypeNode } @@ -8865,8 +8895,7 @@ func (node *JSDocTemplateTag) Clone(f *NodeFactory) *Node { func (node *JSDocTemplateTag) TypeParameters() *TypeParameterList { return node.typeParameters } -// JSDocParameterTag - +// JSDocPropertyTag type JSDocPropertyTag struct { JSDocTagBase name *EntityName @@ -8918,6 +8947,7 @@ func (node *JSDocPropertyTag) Clone(f *NodeFactory) *Node { func (node *JSDocPropertyTag) Name() *EntityName { return node.name } +// JSDocParameterTag type JSDocParameterTag struct { JSDocTagBase name *EntityName @@ -9473,20 +9503,20 @@ func (node *JSDocOverloadTag) Clone(f *NodeFactory) *Node { type JSDocTypedefTag struct { JSDocTagBase TypeExpression *Node - FullName *Node + name *IdentifierNode } -func (f *NodeFactory) NewJSDocTypedefTag(tagName *IdentifierNode, typeExpression *Node, fullName *Node, comment *NodeList) *Node { +func (f *NodeFactory) NewJSDocTypedefTag(tagName *IdentifierNode, typeExpression *Node, name *IdentifierNode, comment *NodeList) *Node { data := &JSDocTypedefTag{} data.TagName = tagName data.TypeExpression = typeExpression - data.FullName = fullName + data.name = name data.Comment = comment return newNode(KindJSDocTypedefTag, data, f.hooks) } -func (f *NodeFactory) UpdateJSDocTypedefTag(node *JSDocTypedefTag, tagName *IdentifierNode, typeExpression *Node, fullName *Node, comment *NodeList) *Node { - if tagName != node.TagName || typeExpression != node.TypeExpression || fullName != node.FullName || comment != node.Comment { +func (f *NodeFactory) UpdateJSDocTypedefTag(node *JSDocTypedefTag, tagName *IdentifierNode, typeExpression *Node, fullName *IdentifierNode, comment *NodeList) *Node { + if tagName != node.TagName || typeExpression != node.TypeExpression || fullName != node.name || comment != node.Comment { return updateNode(f.NewJSDocTypedefTag(tagName, typeExpression, fullName, comment), node.AsNode(), f.hooks) } return node.AsNode() @@ -9494,19 +9524,21 @@ func (f *NodeFactory) UpdateJSDocTypedefTag(node *JSDocTypedefTag, tagName *Iden func (node *JSDocTypedefTag) ForEachChild(v Visitor) bool { if node.TypeExpression != nil && node.TypeExpression.Kind == KindJSDocTypeLiteral { - return visit(v, node.TagName) || visit(v, node.FullName) || visit(v, node.TypeExpression) || visitNodeList(v, node.Comment) + return visit(v, node.TagName) || visit(v, node.name) || visit(v, node.TypeExpression) || visitNodeList(v, node.Comment) } - return visit(v, node.TagName) || visit(v, node.TypeExpression) || visit(v, node.FullName) || visitNodeList(v, node.Comment) + return visit(v, node.TagName) || visit(v, node.TypeExpression) || visit(v, node.name) || visitNodeList(v, node.Comment) } func (node *JSDocTypedefTag) VisitEachChild(v *NodeVisitor) *Node { - return v.Factory.UpdateJSDocTypedefTag(node, v.visitNode(node.TagName), v.visitNode(node.TypeExpression), v.visitNode(node.FullName), v.visitNodes(node.Comment)) + return v.Factory.UpdateJSDocTypedefTag(node, v.visitNode(node.TagName), v.visitNode(node.TypeExpression), v.visitNode(node.name), v.visitNodes(node.Comment)) } func (node *JSDocTypedefTag) Clone(f *NodeFactory) *Node { - return cloneNode(f.NewJSDocTypedefTag(node.TagName, node.TypeExpression, node.FullName, node.Comment), node.AsNode(), f.hooks) + return cloneNode(f.NewJSDocTypedefTag(node.TagName, node.TypeExpression, node.name, node.Comment), node.AsNode(), f.hooks) } +func (node *JSDocTypedefTag) Name() *DeclarationName { return node.name } + // JSDocTypeLiteral type JSDocTypeLiteral struct { TypeNodeBase diff --git a/internal/ast/kind.go b/internal/ast/kind.go index cfcb41d291..228c440c58 100644 --- a/internal/ast/kind.go +++ b/internal/ast/kind.go @@ -377,6 +377,8 @@ const ( KindJSDocImportTag // Synthesized list KindSyntaxList + // Synthesized JS nodes + KindJSTypeAliasDeclaration // Transformation nodes KindNotEmittedStatement KindPartiallyEmittedExpression diff --git a/internal/ast/kind_stringer_generated.go b/internal/ast/kind_stringer_generated.go index b067e7f341..62972bad69 100644 --- a/internal/ast/kind_stringer_generated.go +++ b/internal/ast/kind_stringer_generated.go @@ -353,16 +353,17 @@ func _() { _ = x[KindJSDocSatisfiesTag-342] _ = x[KindJSDocImportTag-343] _ = x[KindSyntaxList-344] - _ = x[KindNotEmittedStatement-345] - _ = x[KindPartiallyEmittedExpression-346] - _ = x[KindCommaListExpression-347] - _ = x[KindSyntheticReferenceExpression-348] - _ = x[KindCount-349] + _ = x[KindJSTypeAliasDeclaration-345] + _ = x[KindNotEmittedStatement-346] + _ = x[KindPartiallyEmittedExpression-347] + _ = x[KindCommaListExpression-348] + _ = x[KindSyntheticReferenceExpression-349] + _ = x[KindCount-350] } -const _Kind_name = "KindUnknownKindEndOfFileKindSingleLineCommentTriviaKindMultiLineCommentTriviaKindNewLineTriviaKindWhitespaceTriviaKindConflictMarkerTriviaKindNonTextFileMarkerTriviaKindNumericLiteralKindBigIntLiteralKindStringLiteralKindJsxTextKindJsxTextAllWhiteSpacesKindRegularExpressionLiteralKindNoSubstitutionTemplateLiteralKindTemplateHeadKindTemplateMiddleKindTemplateTailKindOpenBraceTokenKindCloseBraceTokenKindOpenParenTokenKindCloseParenTokenKindOpenBracketTokenKindCloseBracketTokenKindDotTokenKindDotDotDotTokenKindSemicolonTokenKindCommaTokenKindQuestionDotTokenKindLessThanTokenKindLessThanSlashTokenKindGreaterThanTokenKindLessThanEqualsTokenKindGreaterThanEqualsTokenKindEqualsEqualsTokenKindExclamationEqualsTokenKindEqualsEqualsEqualsTokenKindExclamationEqualsEqualsTokenKindEqualsGreaterThanTokenKindPlusTokenKindMinusTokenKindAsteriskTokenKindAsteriskAsteriskTokenKindSlashTokenKindPercentTokenKindPlusPlusTokenKindMinusMinusTokenKindLessThanLessThanTokenKindGreaterThanGreaterThanTokenKindGreaterThanGreaterThanGreaterThanTokenKindAmpersandTokenKindBarTokenKindCaretTokenKindExclamationTokenKindTildeTokenKindAmpersandAmpersandTokenKindBarBarTokenKindQuestionTokenKindColonTokenKindAtTokenKindQuestionQuestionTokenKindBacktickTokenKindHashTokenKindEqualsTokenKindPlusEqualsTokenKindMinusEqualsTokenKindAsteriskEqualsTokenKindAsteriskAsteriskEqualsTokenKindSlashEqualsTokenKindPercentEqualsTokenKindLessThanLessThanEqualsTokenKindGreaterThanGreaterThanEqualsTokenKindGreaterThanGreaterThanGreaterThanEqualsTokenKindAmpersandEqualsTokenKindBarEqualsTokenKindBarBarEqualsTokenKindAmpersandAmpersandEqualsTokenKindQuestionQuestionEqualsTokenKindCaretEqualsTokenKindIdentifierKindPrivateIdentifierKindJSDocCommentTextTokenKindBreakKeywordKindCaseKeywordKindCatchKeywordKindClassKeywordKindConstKeywordKindContinueKeywordKindDebuggerKeywordKindDefaultKeywordKindDeleteKeywordKindDoKeywordKindElseKeywordKindEnumKeywordKindExportKeywordKindExtendsKeywordKindFalseKeywordKindFinallyKeywordKindForKeywordKindFunctionKeywordKindIfKeywordKindImportKeywordKindInKeywordKindInstanceOfKeywordKindNewKeywordKindNullKeywordKindReturnKeywordKindSuperKeywordKindSwitchKeywordKindThisKeywordKindThrowKeywordKindTrueKeywordKindTryKeywordKindTypeOfKeywordKindVarKeywordKindVoidKeywordKindWhileKeywordKindWithKeywordKindImplementsKeywordKindInterfaceKeywordKindLetKeywordKindPackageKeywordKindPrivateKeywordKindProtectedKeywordKindPublicKeywordKindStaticKeywordKindYieldKeywordKindAbstractKeywordKindAccessorKeywordKindAsKeywordKindAssertsKeywordKindAssertKeywordKindAnyKeywordKindAsyncKeywordKindAwaitKeywordKindBooleanKeywordKindConstructorKeywordKindDeclareKeywordKindGetKeywordKindImmediateKeywordKindInferKeywordKindIntrinsicKeywordKindIsKeywordKindKeyOfKeywordKindModuleKeywordKindNamespaceKeywordKindNeverKeywordKindOutKeywordKindReadonlyKeywordKindRequireKeywordKindNumberKeywordKindObjectKeywordKindSatisfiesKeywordKindSetKeywordKindStringKeywordKindSymbolKeywordKindTypeKeywordKindUndefinedKeywordKindUniqueKeywordKindUnknownKeywordKindUsingKeywordKindFromKeywordKindGlobalKeywordKindBigIntKeywordKindOverrideKeywordKindOfKeywordKindQualifiedNameKindComputedPropertyNameKindTypeParameterKindParameterKindDecoratorKindPropertySignatureKindPropertyDeclarationKindMethodSignatureKindMethodDeclarationKindClassStaticBlockDeclarationKindConstructorKindGetAccessorKindSetAccessorKindCallSignatureKindConstructSignatureKindIndexSignatureKindTypePredicateKindTypeReferenceKindFunctionTypeKindConstructorTypeKindTypeQueryKindTypeLiteralKindArrayTypeKindTupleTypeKindOptionalTypeKindRestTypeKindUnionTypeKindIntersectionTypeKindConditionalTypeKindInferTypeKindParenthesizedTypeKindThisTypeKindTypeOperatorKindIndexedAccessTypeKindMappedTypeKindLiteralTypeKindNamedTupleMemberKindTemplateLiteralTypeKindTemplateLiteralTypeSpanKindImportTypeKindObjectBindingPatternKindArrayBindingPatternKindBindingElementKindArrayLiteralExpressionKindObjectLiteralExpressionKindPropertyAccessExpressionKindElementAccessExpressionKindCallExpressionKindNewExpressionKindTaggedTemplateExpressionKindTypeAssertionExpressionKindParenthesizedExpressionKindFunctionExpressionKindArrowFunctionKindDeleteExpressionKindTypeOfExpressionKindVoidExpressionKindAwaitExpressionKindPrefixUnaryExpressionKindPostfixUnaryExpressionKindBinaryExpressionKindConditionalExpressionKindTemplateExpressionKindYieldExpressionKindSpreadElementKindClassExpressionKindOmittedExpressionKindExpressionWithTypeArgumentsKindAsExpressionKindNonNullExpressionKindMetaPropertyKindSyntheticExpressionKindSatisfiesExpressionKindTemplateSpanKindSemicolonClassElementKindBlockKindEmptyStatementKindVariableStatementKindExpressionStatementKindIfStatementKindDoStatementKindWhileStatementKindForStatementKindForInStatementKindForOfStatementKindContinueStatementKindBreakStatementKindReturnStatementKindWithStatementKindSwitchStatementKindLabeledStatementKindThrowStatementKindTryStatementKindDebuggerStatementKindVariableDeclarationKindVariableDeclarationListKindFunctionDeclarationKindClassDeclarationKindInterfaceDeclarationKindTypeAliasDeclarationKindEnumDeclarationKindModuleDeclarationKindModuleBlockKindCaseBlockKindNamespaceExportDeclarationKindImportEqualsDeclarationKindImportDeclarationKindImportClauseKindNamespaceImportKindNamedImportsKindImportSpecifierKindExportAssignmentKindExportDeclarationKindNamedExportsKindNamespaceExportKindExportSpecifierKindMissingDeclarationKindExternalModuleReferenceKindJsxElementKindJsxSelfClosingElementKindJsxOpeningElementKindJsxClosingElementKindJsxFragmentKindJsxOpeningFragmentKindJsxClosingFragmentKindJsxAttributeKindJsxAttributesKindJsxSpreadAttributeKindJsxExpressionKindJsxNamespacedNameKindCaseClauseKindDefaultClauseKindHeritageClauseKindCatchClauseKindImportAttributesKindImportAttributeKindPropertyAssignmentKindShorthandPropertyAssignmentKindSpreadAssignmentKindEnumMemberKindSourceFileKindBundleKindJSDocTypeExpressionKindJSDocNameReferenceKindJSDocMemberNameKindJSDocAllTypeKindJSDocNullableTypeKindJSDocNonNullableTypeKindJSDocOptionalTypeKindJSDocVariadicTypeKindJSDocKindJSDocTextKindJSDocTypeLiteralKindJSDocSignatureKindJSDocLinkKindJSDocLinkCodeKindJSDocLinkPlainKindJSDocTagKindJSDocAugmentsTagKindJSDocImplementsTagKindJSDocDeprecatedTagKindJSDocPublicTagKindJSDocPrivateTagKindJSDocProtectedTagKindJSDocReadonlyTagKindJSDocOverrideTagKindJSDocCallbackTagKindJSDocOverloadTagKindJSDocParameterTagKindJSDocReturnTagKindJSDocThisTagKindJSDocTypeTagKindJSDocTemplateTagKindJSDocTypedefTagKindJSDocSeeTagKindJSDocPropertyTagKindJSDocSatisfiesTagKindJSDocImportTagKindSyntaxListKindNotEmittedStatementKindPartiallyEmittedExpressionKindCommaListExpressionKindSyntheticReferenceExpressionKindCount" +const _Kind_name = "KindUnknownKindEndOfFileKindSingleLineCommentTriviaKindMultiLineCommentTriviaKindNewLineTriviaKindWhitespaceTriviaKindConflictMarkerTriviaKindNonTextFileMarkerTriviaKindNumericLiteralKindBigIntLiteralKindStringLiteralKindJsxTextKindJsxTextAllWhiteSpacesKindRegularExpressionLiteralKindNoSubstitutionTemplateLiteralKindTemplateHeadKindTemplateMiddleKindTemplateTailKindOpenBraceTokenKindCloseBraceTokenKindOpenParenTokenKindCloseParenTokenKindOpenBracketTokenKindCloseBracketTokenKindDotTokenKindDotDotDotTokenKindSemicolonTokenKindCommaTokenKindQuestionDotTokenKindLessThanTokenKindLessThanSlashTokenKindGreaterThanTokenKindLessThanEqualsTokenKindGreaterThanEqualsTokenKindEqualsEqualsTokenKindExclamationEqualsTokenKindEqualsEqualsEqualsTokenKindExclamationEqualsEqualsTokenKindEqualsGreaterThanTokenKindPlusTokenKindMinusTokenKindAsteriskTokenKindAsteriskAsteriskTokenKindSlashTokenKindPercentTokenKindPlusPlusTokenKindMinusMinusTokenKindLessThanLessThanTokenKindGreaterThanGreaterThanTokenKindGreaterThanGreaterThanGreaterThanTokenKindAmpersandTokenKindBarTokenKindCaretTokenKindExclamationTokenKindTildeTokenKindAmpersandAmpersandTokenKindBarBarTokenKindQuestionTokenKindColonTokenKindAtTokenKindQuestionQuestionTokenKindBacktickTokenKindHashTokenKindEqualsTokenKindPlusEqualsTokenKindMinusEqualsTokenKindAsteriskEqualsTokenKindAsteriskAsteriskEqualsTokenKindSlashEqualsTokenKindPercentEqualsTokenKindLessThanLessThanEqualsTokenKindGreaterThanGreaterThanEqualsTokenKindGreaterThanGreaterThanGreaterThanEqualsTokenKindAmpersandEqualsTokenKindBarEqualsTokenKindBarBarEqualsTokenKindAmpersandAmpersandEqualsTokenKindQuestionQuestionEqualsTokenKindCaretEqualsTokenKindIdentifierKindPrivateIdentifierKindJSDocCommentTextTokenKindBreakKeywordKindCaseKeywordKindCatchKeywordKindClassKeywordKindConstKeywordKindContinueKeywordKindDebuggerKeywordKindDefaultKeywordKindDeleteKeywordKindDoKeywordKindElseKeywordKindEnumKeywordKindExportKeywordKindExtendsKeywordKindFalseKeywordKindFinallyKeywordKindForKeywordKindFunctionKeywordKindIfKeywordKindImportKeywordKindInKeywordKindInstanceOfKeywordKindNewKeywordKindNullKeywordKindReturnKeywordKindSuperKeywordKindSwitchKeywordKindThisKeywordKindThrowKeywordKindTrueKeywordKindTryKeywordKindTypeOfKeywordKindVarKeywordKindVoidKeywordKindWhileKeywordKindWithKeywordKindImplementsKeywordKindInterfaceKeywordKindLetKeywordKindPackageKeywordKindPrivateKeywordKindProtectedKeywordKindPublicKeywordKindStaticKeywordKindYieldKeywordKindAbstractKeywordKindAccessorKeywordKindAsKeywordKindAssertsKeywordKindAssertKeywordKindAnyKeywordKindAsyncKeywordKindAwaitKeywordKindBooleanKeywordKindConstructorKeywordKindDeclareKeywordKindGetKeywordKindImmediateKeywordKindInferKeywordKindIntrinsicKeywordKindIsKeywordKindKeyOfKeywordKindModuleKeywordKindNamespaceKeywordKindNeverKeywordKindOutKeywordKindReadonlyKeywordKindRequireKeywordKindNumberKeywordKindObjectKeywordKindSatisfiesKeywordKindSetKeywordKindStringKeywordKindSymbolKeywordKindTypeKeywordKindUndefinedKeywordKindUniqueKeywordKindUnknownKeywordKindUsingKeywordKindFromKeywordKindGlobalKeywordKindBigIntKeywordKindOverrideKeywordKindOfKeywordKindQualifiedNameKindComputedPropertyNameKindTypeParameterKindParameterKindDecoratorKindPropertySignatureKindPropertyDeclarationKindMethodSignatureKindMethodDeclarationKindClassStaticBlockDeclarationKindConstructorKindGetAccessorKindSetAccessorKindCallSignatureKindConstructSignatureKindIndexSignatureKindTypePredicateKindTypeReferenceKindFunctionTypeKindConstructorTypeKindTypeQueryKindTypeLiteralKindArrayTypeKindTupleTypeKindOptionalTypeKindRestTypeKindUnionTypeKindIntersectionTypeKindConditionalTypeKindInferTypeKindParenthesizedTypeKindThisTypeKindTypeOperatorKindIndexedAccessTypeKindMappedTypeKindLiteralTypeKindNamedTupleMemberKindTemplateLiteralTypeKindTemplateLiteralTypeSpanKindImportTypeKindObjectBindingPatternKindArrayBindingPatternKindBindingElementKindArrayLiteralExpressionKindObjectLiteralExpressionKindPropertyAccessExpressionKindElementAccessExpressionKindCallExpressionKindNewExpressionKindTaggedTemplateExpressionKindTypeAssertionExpressionKindParenthesizedExpressionKindFunctionExpressionKindArrowFunctionKindDeleteExpressionKindTypeOfExpressionKindVoidExpressionKindAwaitExpressionKindPrefixUnaryExpressionKindPostfixUnaryExpressionKindBinaryExpressionKindConditionalExpressionKindTemplateExpressionKindYieldExpressionKindSpreadElementKindClassExpressionKindOmittedExpressionKindExpressionWithTypeArgumentsKindAsExpressionKindNonNullExpressionKindMetaPropertyKindSyntheticExpressionKindSatisfiesExpressionKindTemplateSpanKindSemicolonClassElementKindBlockKindEmptyStatementKindVariableStatementKindExpressionStatementKindIfStatementKindDoStatementKindWhileStatementKindForStatementKindForInStatementKindForOfStatementKindContinueStatementKindBreakStatementKindReturnStatementKindWithStatementKindSwitchStatementKindLabeledStatementKindThrowStatementKindTryStatementKindDebuggerStatementKindVariableDeclarationKindVariableDeclarationListKindFunctionDeclarationKindClassDeclarationKindInterfaceDeclarationKindTypeAliasDeclarationKindEnumDeclarationKindModuleDeclarationKindModuleBlockKindCaseBlockKindNamespaceExportDeclarationKindImportEqualsDeclarationKindImportDeclarationKindImportClauseKindNamespaceImportKindNamedImportsKindImportSpecifierKindExportAssignmentKindExportDeclarationKindNamedExportsKindNamespaceExportKindExportSpecifierKindMissingDeclarationKindExternalModuleReferenceKindJsxElementKindJsxSelfClosingElementKindJsxOpeningElementKindJsxClosingElementKindJsxFragmentKindJsxOpeningFragmentKindJsxClosingFragmentKindJsxAttributeKindJsxAttributesKindJsxSpreadAttributeKindJsxExpressionKindJsxNamespacedNameKindCaseClauseKindDefaultClauseKindHeritageClauseKindCatchClauseKindImportAttributesKindImportAttributeKindPropertyAssignmentKindShorthandPropertyAssignmentKindSpreadAssignmentKindEnumMemberKindSourceFileKindBundleKindJSDocTypeExpressionKindJSDocNameReferenceKindJSDocMemberNameKindJSDocAllTypeKindJSDocNullableTypeKindJSDocNonNullableTypeKindJSDocOptionalTypeKindJSDocVariadicTypeKindJSDocKindJSDocTextKindJSDocTypeLiteralKindJSDocSignatureKindJSDocLinkKindJSDocLinkCodeKindJSDocLinkPlainKindJSDocTagKindJSDocAugmentsTagKindJSDocImplementsTagKindJSDocDeprecatedTagKindJSDocPublicTagKindJSDocPrivateTagKindJSDocProtectedTagKindJSDocReadonlyTagKindJSDocOverrideTagKindJSDocCallbackTagKindJSDocOverloadTagKindJSDocParameterTagKindJSDocReturnTagKindJSDocThisTagKindJSDocTypeTagKindJSDocTemplateTagKindJSDocTypedefTagKindJSDocSeeTagKindJSDocPropertyTagKindJSDocSatisfiesTagKindJSDocImportTagKindSyntaxListKindJSTypeAliasDeclarationKindNotEmittedStatementKindPartiallyEmittedExpressionKindCommaListExpressionKindSyntheticReferenceExpressionKindCount" -var _Kind_index = [...]uint16{0, 11, 24, 51, 77, 94, 114, 138, 165, 183, 200, 217, 228, 253, 281, 314, 330, 348, 364, 382, 401, 419, 438, 458, 479, 491, 509, 527, 541, 561, 578, 600, 620, 643, 669, 690, 716, 743, 775, 801, 814, 828, 845, 870, 884, 900, 917, 936, 961, 992, 1034, 1052, 1064, 1078, 1098, 1112, 1139, 1154, 1171, 1185, 1196, 1221, 1238, 1251, 1266, 1285, 1305, 1328, 1359, 1379, 1401, 1432, 1469, 1517, 1541, 1559, 1580, 1613, 1644, 1664, 1678, 1699, 1724, 1740, 1755, 1771, 1787, 1803, 1822, 1841, 1859, 1876, 1889, 1904, 1919, 1936, 1954, 1970, 1988, 2002, 2021, 2034, 2051, 2064, 2085, 2099, 2114, 2131, 2147, 2164, 2179, 2195, 2210, 2224, 2241, 2255, 2270, 2286, 2301, 2322, 2342, 2356, 2374, 2392, 2412, 2429, 2446, 2462, 2481, 2500, 2513, 2531, 2548, 2562, 2578, 2594, 2612, 2634, 2652, 2666, 2686, 2702, 2722, 2735, 2751, 2768, 2788, 2804, 2818, 2837, 2855, 2872, 2889, 2909, 2923, 2940, 2957, 2972, 2992, 3009, 3027, 3043, 3058, 3075, 3092, 3111, 3124, 3141, 3165, 3182, 3195, 3208, 3229, 3252, 3271, 3292, 3323, 3338, 3353, 3368, 3385, 3407, 3425, 3442, 3459, 3475, 3494, 3507, 3522, 3535, 3548, 3564, 3576, 3589, 3609, 3628, 3641, 3662, 3674, 3690, 3711, 3725, 3740, 3760, 3783, 3810, 3824, 3848, 3871, 3889, 3915, 3942, 3970, 3997, 4015, 4032, 4060, 4087, 4114, 4136, 4153, 4173, 4193, 4211, 4230, 4255, 4281, 4301, 4326, 4348, 4367, 4384, 4403, 4424, 4455, 4471, 4492, 4508, 4531, 4554, 4570, 4595, 4604, 4622, 4643, 4666, 4681, 4696, 4714, 4730, 4748, 4766, 4787, 4805, 4824, 4841, 4860, 4880, 4898, 4914, 4935, 4958, 4985, 5008, 5028, 5052, 5076, 5095, 5116, 5131, 5144, 5174, 5201, 5222, 5238, 5257, 5273, 5292, 5312, 5333, 5349, 5368, 5387, 5409, 5436, 5450, 5475, 5496, 5517, 5532, 5554, 5576, 5592, 5609, 5631, 5648, 5669, 5683, 5700, 5718, 5733, 5753, 5772, 5794, 5825, 5845, 5859, 5873, 5883, 5906, 5928, 5947, 5963, 5984, 6008, 6029, 6050, 6059, 6072, 6092, 6110, 6123, 6140, 6158, 6170, 6190, 6212, 6234, 6252, 6271, 6292, 6312, 6332, 6352, 6372, 6393, 6411, 6427, 6443, 6463, 6482, 6497, 6517, 6538, 6556, 6570, 6593, 6623, 6646, 6678, 6687} +var _Kind_index = [...]uint16{0, 11, 24, 51, 77, 94, 114, 138, 165, 183, 200, 217, 228, 253, 281, 314, 330, 348, 364, 382, 401, 419, 438, 458, 479, 491, 509, 527, 541, 561, 578, 600, 620, 643, 669, 690, 716, 743, 775, 801, 814, 828, 845, 870, 884, 900, 917, 936, 961, 992, 1034, 1052, 1064, 1078, 1098, 1112, 1139, 1154, 1171, 1185, 1196, 1221, 1238, 1251, 1266, 1285, 1305, 1328, 1359, 1379, 1401, 1432, 1469, 1517, 1541, 1559, 1580, 1613, 1644, 1664, 1678, 1699, 1724, 1740, 1755, 1771, 1787, 1803, 1822, 1841, 1859, 1876, 1889, 1904, 1919, 1936, 1954, 1970, 1988, 2002, 2021, 2034, 2051, 2064, 2085, 2099, 2114, 2131, 2147, 2164, 2179, 2195, 2210, 2224, 2241, 2255, 2270, 2286, 2301, 2322, 2342, 2356, 2374, 2392, 2412, 2429, 2446, 2462, 2481, 2500, 2513, 2531, 2548, 2562, 2578, 2594, 2612, 2634, 2652, 2666, 2686, 2702, 2722, 2735, 2751, 2768, 2788, 2804, 2818, 2837, 2855, 2872, 2889, 2909, 2923, 2940, 2957, 2972, 2992, 3009, 3027, 3043, 3058, 3075, 3092, 3111, 3124, 3141, 3165, 3182, 3195, 3208, 3229, 3252, 3271, 3292, 3323, 3338, 3353, 3368, 3385, 3407, 3425, 3442, 3459, 3475, 3494, 3507, 3522, 3535, 3548, 3564, 3576, 3589, 3609, 3628, 3641, 3662, 3674, 3690, 3711, 3725, 3740, 3760, 3783, 3810, 3824, 3848, 3871, 3889, 3915, 3942, 3970, 3997, 4015, 4032, 4060, 4087, 4114, 4136, 4153, 4173, 4193, 4211, 4230, 4255, 4281, 4301, 4326, 4348, 4367, 4384, 4403, 4424, 4455, 4471, 4492, 4508, 4531, 4554, 4570, 4595, 4604, 4622, 4643, 4666, 4681, 4696, 4714, 4730, 4748, 4766, 4787, 4805, 4824, 4841, 4860, 4880, 4898, 4914, 4935, 4958, 4985, 5008, 5028, 5052, 5076, 5095, 5116, 5131, 5144, 5174, 5201, 5222, 5238, 5257, 5273, 5292, 5312, 5333, 5349, 5368, 5387, 5409, 5436, 5450, 5475, 5496, 5517, 5532, 5554, 5576, 5592, 5609, 5631, 5648, 5669, 5683, 5700, 5718, 5733, 5753, 5772, 5794, 5825, 5845, 5859, 5873, 5883, 5906, 5928, 5947, 5963, 5984, 6008, 6029, 6050, 6059, 6072, 6092, 6110, 6123, 6140, 6158, 6170, 6190, 6212, 6234, 6252, 6271, 6292, 6312, 6332, 6352, 6372, 6393, 6411, 6427, 6443, 6463, 6482, 6497, 6517, 6538, 6556, 6570, 6596, 6619, 6649, 6672, 6704, 6713} func (i Kind) String() string { if i < 0 || i >= Kind(len(_Kind_index)-1) { diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index 2993e9b489..77e62f635a 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -638,6 +638,7 @@ func isDeclarationStatementKind(kind Kind) bool { KindClassDeclaration, KindInterfaceDeclaration, KindTypeAliasDeclaration, + KindJSTypeAliasDeclaration, KindEnumDeclaration, KindModuleDeclaration, KindImportDeclaration, @@ -2033,6 +2034,7 @@ func GetMeaningFromDeclaration(node *Node) SemanticMeaning { case KindTypeParameter, KindInterfaceDeclaration, KindTypeAliasDeclaration, + KindJSTypeAliasDeclaration, KindTypeLiteral: return SemanticMeaningType case KindEnumMember, KindClassDeclaration: @@ -2160,7 +2162,7 @@ func getModuleInstanceStateCached(node *Node, ancestors []*Node, visited map[Nod func getModuleInstanceStateWorker(node *Node, ancestors []*Node, visited map[NodeId]ModuleInstanceState) ModuleInstanceState { // A module is uninstantiated if it contains only switch node.Kind { - case KindInterfaceDeclaration, KindTypeAliasDeclaration: + case KindInterfaceDeclaration, KindTypeAliasDeclaration, KindJSTypeAliasDeclaration: return ModuleInstanceStateNonInstantiated case KindEnumDeclaration: if IsEnumConst(node) { @@ -2297,9 +2299,9 @@ func IsGlobalSourceFile(node *Node) bool { return node.Kind == KindSourceFile && !IsExternalOrCommonJSModule(node.AsSourceFile()) } -func IsParameterLikeOrReturnTag(node *Node) bool { +func IsParameterLike(node *Node) bool { switch node.Kind { - case KindParameter, KindTypeParameter, KindJSDocParameterTag, KindJSDocReturnTag: + case KindParameter, KindTypeParameter: return true } return false diff --git a/internal/binder/binder.go b/internal/binder/binder.go index e5927d7718..9a480c5ad3 100644 --- a/internal/binder/binder.go +++ b/internal/binder/binder.go @@ -446,7 +446,7 @@ func (b *Binder) declareSymbolAndAddToSymbolTable(node *ast.Node, symbolFlags as case ast.KindFunctionType, ast.KindConstructorType, ast.KindCallSignature, ast.KindConstructSignature, ast.KindJSDocSignature, ast.KindIndexSignature, ast.KindMethodDeclaration, ast.KindMethodSignature, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction, - ast.KindClassStaticBlockDeclaration, ast.KindTypeAliasDeclaration, ast.KindMappedType: + ast.KindClassStaticBlockDeclaration, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindMappedType: return b.declareSymbol(ast.GetLocals(b.container), nil /*parent*/, node, symbolFlags, symbolExcludes) } panic("Unhandled case in declareSymbolAndAddToSymbolTable") @@ -679,7 +679,7 @@ func (b *Binder) bind(node *ast.Node) bool { b.bindClassLikeDeclaration(node) case ast.KindInterfaceDeclaration: b.bindBlockScopedDeclaration(node, ast.SymbolFlagsInterface, ast.SymbolFlagsInterfaceExcludes) - case ast.KindTypeAliasDeclaration: + case ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: b.bindBlockScopedDeclaration(node, ast.SymbolFlagsTypeAlias, ast.SymbolFlagsTypeAliasExcludes) case ast.KindEnumDeclaration: b.bindEnumDeclaration(node) @@ -1703,7 +1703,7 @@ func (b *Binder) isExecutableStatement(s *ast.Node) bool { func (b *Binder) isPurelyTypeDeclaration(s *ast.Node) bool { switch s.Kind { - case ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration: + case ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: return true case ast.KindModuleDeclaration: return ast.GetModuleInstanceState(s) != ast.ModuleInstanceStateInstantiated @@ -2500,7 +2500,7 @@ func GetContainerFlags(node *ast.Node) ContainerFlags { return ContainerFlagsIsContainer case ast.KindInterfaceDeclaration: return ContainerFlagsIsContainer | ContainerFlagsIsInterface - case ast.KindModuleDeclaration, ast.KindTypeAliasDeclaration, ast.KindMappedType, ast.KindIndexSignature: + case ast.KindModuleDeclaration, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindMappedType, ast.KindIndexSignature: return ContainerFlagsIsContainer | ContainerFlagsHasLocals case ast.KindSourceFile: return ContainerFlagsIsContainer | ContainerFlagsIsControlFlowContainer | ContainerFlagsHasLocals @@ -2812,7 +2812,7 @@ func GetErrorRangeForNode(sourceFile *ast.SourceFile, node *ast.Node) core.TextR // This list is a work in progress. Add missing node kinds to improve their error spans case ast.KindVariableDeclaration, ast.KindBindingElement, ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration, ast.KindModuleDeclaration, ast.KindEnumDeclaration, ast.KindEnumMember, ast.KindFunctionDeclaration, ast.KindFunctionExpression, - ast.KindMethodDeclaration, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindTypeAliasDeclaration, ast.KindPropertyDeclaration, + ast.KindMethodDeclaration, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindPropertyDeclaration, ast.KindPropertySignature, ast.KindNamespaceImport: errorNode = ast.GetNameOfDeclaration(node) case ast.KindArrowFunction: diff --git a/internal/binder/nameresolver.go b/internal/binder/nameresolver.go index 5038905601..f3b80cb6f4 100644 --- a/internal/binder/nameresolver.go +++ b/internal/binder/nameresolver.go @@ -55,12 +55,8 @@ loop: // - Type parameters of a function are in scope in the entire function declaration, including the parameter // list and return type. However, local types are only in scope in the function body. // - parameters are only in the scope of function body - // This restriction does not apply to JSDoc comment types because they are parented - // at a higher level than type parameters would normally be - if meaning&result.Flags&ast.SymbolFlagsType != 0 && lastLocation.Kind != ast.KindJSDoc { - useResult = result.Flags&ast.SymbolFlagsTypeParameter != 0 && (lastLocation.Flags&ast.NodeFlagsSynthesized != 0 || - lastLocation == location.Type() || - ast.IsParameterLikeOrReturnTag(lastLocation)) + if meaning&result.Flags&ast.SymbolFlagsType != 0 { + useResult = result.Flags&ast.SymbolFlagsTypeParameter != 0 && (lastLocation == location.Type() || ast.IsParameterLike(lastLocation)) } if meaning&result.Flags&ast.SymbolFlagsVariable != 0 { // expression inside parameter will lookup as normal variable scope when targeting es2015+ @@ -290,19 +286,11 @@ loop: if isSelfReferenceLocation(location, lastLocation) { lastSelfReferenceLocation = location } - lastLocation = location - switch { - // case isJSDocTemplateTag(location): - // location = getEffectiveContainerForJSDocTemplateTag(location.(*JSDocTemplateTag)) - // if location == nil { - // location = location.parent - // } - // case isJSDocParameterTag(location) || isJSDocReturnTag(location): - // location = getHostSignatureFromJSDoc(location) - // if location == nil { - // location = location.parent - // } - default: + if location.Kind == ast.KindJSDocTypeExpression && location.AsJSDocTypeExpression().Host != nil { + lastLocation = location.AsJSDocTypeExpression().Host.Type() + location = location.AsJSDocTypeExpression().Host + } else { + lastLocation = location location = location.Parent } } @@ -491,7 +479,7 @@ func isSelfReferenceLocation(node *ast.Node, lastLocation *ast.Node) bool { case ast.KindParameter: return lastLocation != nil && lastLocation == node.Name() case ast.KindFunctionDeclaration, ast.KindClassDeclaration, ast.KindInterfaceDeclaration, ast.KindEnumDeclaration, - ast.KindTypeAliasDeclaration, ast.KindModuleDeclaration: // For `namespace N { N; }` + ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindModuleDeclaration: // For `namespace N { N; }` return true } return false diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 26ac5c689c..f2f5a76d2b 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -2183,7 +2183,7 @@ func (c *Checker) checkSourceElementWorker(node *ast.Node) { c.checkClassDeclaration(node) case ast.KindInterfaceDeclaration: c.checkInterfaceDeclaration(node) - case ast.KindTypeAliasDeclaration: + case ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: c.checkTypeAliasDeclaration(node) case ast.KindEnumDeclaration: c.checkEnumDeclaration(node) @@ -2348,12 +2348,12 @@ func (c *Checker) checkTypeParameter(node *ast.Node) { } func (c *Checker) checkTypeParameterDeferred(node *ast.Node) { - if ast.IsInterfaceDeclaration(node.Parent) || ast.IsClassLike(node.Parent) || ast.IsTypeAliasDeclaration(node.Parent) { + if ast.IsInterfaceDeclaration(node.Parent) || ast.IsClassLike(node.Parent) || ast.IsTypeOrJSTypeAliasDeclaration(node.Parent) { typeParameter := c.getDeclaredTypeOfTypeParameter(c.getSymbolOfDeclaration(node)) modifiers := c.getTypeParameterModifiers(typeParameter) & (ast.ModifierFlagsIn | ast.ModifierFlagsOut) if modifiers != 0 { symbol := c.getSymbolOfDeclaration(node.Parent) - if ast.IsTypeAliasDeclaration(node.Parent) && c.getDeclaredTypeOfSymbol(symbol).objectFlags&(ObjectFlagsAnonymous|ObjectFlagsMapped) == 0 { + if ast.IsTypeOrJSTypeAliasDeclaration(node.Parent) && c.getDeclaredTypeOfSymbol(symbol).objectFlags&(ObjectFlagsAnonymous|ObjectFlagsMapped) == 0 { c.error(node, diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types) } else if modifiers == ast.ModifierFlagsIn || modifiers == ast.ModifierFlagsOut { source := c.createMarkerType(symbol, typeParameter, core.IfElse(modifiers == ast.ModifierFlagsOut, c.markerSubTypeForCheck, c.markerSuperTypeForCheck)) @@ -2663,8 +2663,8 @@ func (c *Checker) checkAccessorDeclaration(node *ast.Node) { setter := ast.GetDeclarationOfKind(symbol, ast.KindSetAccessor) if getter != nil && setter != nil && c.nodeLinks.Get(getter).flags&NodeCheckFlagsTypeChecked == 0 { c.nodeLinks.Get(getter).flags |= NodeCheckFlagsTypeChecked - getterFlags := getEffectiveModifierFlags(getter) - setterFlags := getEffectiveModifierFlags(setter) + getterFlags := getter.ModifierFlags() + setterFlags := setter.ModifierFlags() if (getterFlags & ast.ModifierFlagsAbstract) != (setterFlags & ast.ModifierFlagsAbstract) { c.error(getter.Name(), diagnostics.Accessors_must_both_be_abstract_or_non_abstract) c.error(setter.Name(), diagnostics.Accessors_must_both_be_abstract_or_non_abstract) @@ -4104,7 +4104,7 @@ func (c *Checker) checkBaseTypeAccessibility(t *Type, node *ast.Node) { signatures := c.getSignaturesOfType(t, SignatureKindConstruct) if len(signatures) != 0 { declaration := signatures[0].declaration - if declaration != nil && hasEffectiveModifier(declaration, ast.ModifierFlagsPrivate) { + if declaration != nil && hasModifier(declaration, ast.ModifierFlagsPrivate) { typeClassDeclaration := getClassLikeDeclarationOfSymbol(t.symbol) if !c.isNodeWithinClass(node, typeClassDeclaration) { c.error(node, diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, c.getFullyQualifiedName(t.symbol, nil)) @@ -4554,7 +4554,7 @@ func (c *Checker) checkPropertyInitialization(node *ast.Node) { } constructor := ast.FindConstructorDeclaration(node) for _, member := range node.Members() { - if getEffectiveModifierFlags(member)&ast.ModifierFlagsAmbient != 0 { + if member.ModifierFlags()&ast.ModifierFlagsAmbient != 0 { continue } if !ast.IsStatic(member) && c.isPropertyWithoutInitializer(member) { @@ -6272,7 +6272,7 @@ func (c *Checker) checkAliasSymbol(node *ast.Node) { name := node.PropertyNameOrName().Text() c.addTypeOnlyDeclarationRelatedInfo(c.error(node, message, name), core.IfElse(isType, nil, typeOnlyAlias), name) } - if isType && node.Kind == ast.KindImportEqualsDeclaration && hasEffectiveModifier(node, ast.ModifierFlagsExport) { + if isType && node.Kind == ast.KindImportEqualsDeclaration && hasModifier(node, ast.ModifierFlagsExport) { c.error(node, diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_0_is_enabled, c.getIsolatedModulesLikeFlagName()) } case ast.KindExportSpecifier: @@ -6326,7 +6326,7 @@ func (c *Checker) areDeclarationFlagsIdentical(left *ast.Declaration, right *ast return false } interestingFlags := ast.ModifierFlagsPrivate | ast.ModifierFlagsProtected | ast.ModifierFlagsAsync | ast.ModifierFlagsAbstract | ast.ModifierFlagsReadonly | ast.ModifierFlagsStatic - return getSelectedEffectiveModifierFlags(left, interestingFlags) == getSelectedEffectiveModifierFlags(right, interestingFlags) + return getSelectedModifierFlags(left, interestingFlags) == getSelectedModifierFlags(right, interestingFlags) } func (c *Checker) checkTypeAliasDeclaration(node *ast.Node) { @@ -6338,7 +6338,7 @@ func (c *Checker) checkTypeAliasDeclaration(node *ast.Node) { typeNode := node.AsTypeAliasDeclaration().Type typeParameters := node.TypeParameters() c.checkTypeParameters(typeParameters) - if typeNode.Kind == ast.KindIntrinsicKeyword { + if typeNode != nil && typeNode.Kind == ast.KindIntrinsicKeyword { if !(len(typeParameters) == 0 && node.Name().Text() == "BuiltinIteratorReturn" || len(typeParameters) == 1 && intrinsicTypeKinds[node.Name().Text()] != IntrinsicTypeKindUnknown) { c.error(typeNode, diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types) @@ -6411,7 +6411,7 @@ func (c *Checker) checkExportsOnMergedDeclarations(node *ast.Node) { func (c *Checker) getDeclarationSpaces(node *ast.Declaration) DeclarationSpaces { switch node.Kind { - case ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration, ast.KindJSDocTypedefTag, ast.KindJSDocCallbackTag: + case ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindJSDocTypedefTag, ast.KindJSDocCallbackTag: return DeclarationSpacesExportType case ast.KindModuleDeclaration: if ast.IsAmbientModule(node) || ast.GetModuleInstanceState(node) != ast.ModuleInstanceStateNonInstantiated { @@ -6512,7 +6512,7 @@ func (c *Checker) checkUnusedIdentifiers(potentiallyUnusedIdentifiers []*ast.Nod } c.checkUnusedTypeParameters(node) case ast.KindMethodSignature, ast.KindCallSignature, ast.KindConstructSignature, ast.KindFunctionType, ast.KindConstructorType, - ast.KindTypeAliasDeclaration, ast.KindInterfaceDeclaration: + ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindInterfaceDeclaration: c.checkUnusedTypeParameters(node) case ast.KindInferType: c.checkUnusedInferTypeParameter(node) @@ -6556,7 +6556,7 @@ func (c *Checker) checkUnusedClassMembers(node *ast.Node) { break // Already would have reported an error on the getter. } symbol := c.getSymbolOfDeclaration(member) - if !c.isReferenced(symbol) && (hasEffectiveModifier(member, ast.ModifierFlagsPrivate) || member.Name() != nil && ast.IsPrivateIdentifier(member.Name())) && member.Flags&ast.NodeFlagsAmbient == 0 { + if !c.isReferenced(symbol) && (hasModifier(member, ast.ModifierFlagsPrivate) || member.Name() != nil && ast.IsPrivateIdentifier(member.Name())) && member.Flags&ast.NodeFlagsAmbient == 0 { c.reportUnused(member, UnusedKindLocal, NewDiagnosticForNode(member.Name(), diagnostics.X_0_is_declared_but_its_value_is_never_read, c.symbolToString(symbol))) } case ast.KindConstructor: @@ -8108,7 +8108,7 @@ func (c *Checker) resolveNewExpression(node *ast.Node, candidatesOutArray *[]*Si } if expressionType.symbol != nil { valueDecl := getClassLikeDeclarationOfSymbol(expressionType.symbol) - if valueDecl != nil && hasEffectiveModifier(valueDecl, ast.ModifierFlagsAbstract) { + if valueDecl != nil && hasModifier(valueDecl, ast.ModifierFlagsAbstract) { c.error(node, diagnostics.Cannot_create_an_instance_of_an_abstract_class) return c.resolveErrorCall(node) } @@ -8141,7 +8141,7 @@ func (c *Checker) isConstructorAccessible(node *ast.Node, signature *Signature) return true } declaration := signature.declaration - modifiers := getSelectedEffectiveModifierFlags(declaration, ast.ModifierFlagsNonPublicAccessibilityModifier) + modifiers := getSelectedModifierFlags(declaration, ast.ModifierFlagsNonPublicAccessibilityModifier) // (1) Public constructors and (2) constructor functions are always accessible. if modifiers == 0 || !ast.IsConstructorDeclaration(declaration) { return true @@ -10534,7 +10534,7 @@ func (c *Checker) parameterInitializerContainsUndefined(declaration *ast.Node) b func (c *Checker) isInAmbientOrTypeNode(node *ast.Node) bool { return node.Flags&ast.NodeFlagsAmbient != 0 || ast.FindAncestor(node, func(n *ast.Node) bool { - return ast.IsInterfaceDeclaration(n) || ast.IsTypeAliasDeclaration(n) || ast.IsTypeLiteralNode(n) + return ast.IsInterfaceDeclaration(n) || ast.IsTypeAliasDeclaration(n) || ast.IsJSTypeAliasDeclaration(n) || ast.IsTypeLiteralNode(n) }) != nil } @@ -10721,7 +10721,7 @@ func (c *Checker) getControlFlowContainer(node *ast.Node) *ast.Node { func (c *Checker) getFlowTypeOfProperty(reference *ast.Node, prop *ast.Symbol) *Type { initialType := c.undefinedType - if prop != nil && prop.ValueDeclaration != nil && (!c.isAutoTypedProperty(prop) || getEffectiveModifierFlags(prop.ValueDeclaration)&ast.ModifierFlagsAmbient != 0) { + if prop != nil && prop.ValueDeclaration != nil && (!c.isAutoTypedProperty(prop) || prop.ValueDeclaration.ModifierFlags()&ast.ModifierFlagsAmbient != 0) { initialType = c.getTypeOfPropertyInBaseClass(prop) } return c.getFlowTypeOfReferenceEx(reference, c.autoType, initialType, nil, nil) @@ -15277,7 +15277,7 @@ func (c *Checker) getTypeForVariableLikeDeclaration(declaration *ast.Node, inclu isProperty := ast.IsPropertyDeclaration(declaration) && !ast.HasAccessorModifier(declaration) || ast.IsPropertySignatureDeclaration(declaration) isOptional := includeOptionality && isOptionalDeclaration(declaration) // Use type from type annotation if one is present - declaredType := c.tryGetTypeFromEffectiveTypeNode(declaration) + declaredType := c.tryGetTypeFromTypeNode(declaration) if ast.IsCatchClauseVariableDeclarationOrBindingElement(declaration) { if declaredType != nil { // If the catch clause is explicitly annotated with any or unknown, accept it, otherwise error. @@ -17005,7 +17005,7 @@ func (c *Checker) getExportAssignmentType(symbol *ast.Symbol) *Type { if symbol != nil { for _, d := range symbol.Declarations { if ast.IsExportAssignment(d) { - t := c.tryGetTypeFromEffectiveTypeNode(d) + t := c.tryGetTypeFromTypeNode(d) if t != nil { return t } @@ -18030,7 +18030,7 @@ func (c *Checker) getIndexInfosOfIndexSymbol(indexSymbol *ast.Symbol, siblingSym } forEachType(c.getTypeFromTypeNode(typeNode), func(keyType *Type) { if c.isValidIndexKeyType(keyType) && findIndexInfo(indexInfos, keyType) == nil { - indexInfo := c.newIndexInfo(keyType, valueType, hasEffectiveModifier(declaration, ast.ModifierFlagsReadonly), declaration) + indexInfo := c.newIndexInfo(keyType, valueType, hasModifier(declaration, ast.ModifierFlagsReadonly), declaration) indexInfos = append(indexInfos, indexInfo) } }) @@ -18056,17 +18056,17 @@ func (c *Checker) getIndexInfosOfIndexSymbol(indexSymbol *ast.Symbol, siblingSym if c.isTypeAssignableTo(keyType, c.stringNumberSymbolType) { if c.isTypeAssignableTo(keyType, c.numberType) { hasComputedNumberProperty = true - if !hasEffectiveReadonlyModifier(declaration) { + if !hasReadonlyModifier(declaration) { readonlyComputedNumberProperty = false } } else if c.isTypeAssignableTo(keyType, c.esSymbolType) { hasComputedSymbolProperty = true - if !hasEffectiveReadonlyModifier(declaration) { + if !hasReadonlyModifier(declaration) { readonlyComputedSymbolProperty = false } } else { hasComputedStringProperty = true - if !hasEffectiveReadonlyModifier(declaration) { + if !hasReadonlyModifier(declaration) { readonlyComputedStringProperty = false } } @@ -20469,6 +20469,9 @@ func (c *Checker) couldContainTypeVariablesWorker(t *Type) bool { func (c *Checker) isNonGenericTopLevelType(t *Type) bool { if t.alias != nil && len(t.alias.typeArguments) == 0 { declaration := ast.GetDeclarationOfKind(t.alias.symbol, ast.KindTypeAliasDeclaration) + if declaration == nil { + declaration = ast.GetDeclarationOfKind(t.alias.symbol, ast.KindJSTypeAliasDeclaration) + } return declaration != nil && ast.FindAncestorOrQuit(declaration.Parent, func(n *ast.Node) ast.FindAncestorResult { switch n.Kind { case ast.KindSourceFile: @@ -21071,7 +21074,7 @@ func instantiateList[T comparable](c *Checker, values []T, m *TypeMapper, instan return values } -func (c *Checker) tryGetTypeFromEffectiveTypeNode(node *ast.Node) *Type { +func (c *Checker) tryGetTypeFromTypeNode(node *ast.Node) *Type { typeNode := node.Type() if typeNode != nil { return c.getTypeFromTypeNode(typeNode) @@ -21121,11 +21124,7 @@ func (c *Checker) getTypeFromTypeNodeWorker(node *ast.Node) *Type { case ast.KindNeverKeyword: return c.neverType case ast.KindObjectKeyword: - if node.Flags&ast.NodeFlagsJavaScriptFile != 0 && !c.noImplicitAny { - return c.anyType - } else { - return c.nonPrimitiveType - } + return c.nonPrimitiveType case ast.KindIntrinsicKeyword: return c.intrinsicMarkerType case ast.KindThisType, ast.KindThisKeyword: @@ -21461,7 +21460,7 @@ func (c *Checker) isResolvedByTypeAlias(node *ast.Node) bool { case ast.KindParenthesizedType, ast.KindNamedTupleMember, ast.KindTypeReference, ast.KindUnionType, ast.KindIntersectionType, ast.KindIndexedAccessType, ast.KindConditionalType, ast.KindTypeOperator, ast.KindArrayType, ast.KindTupleType: return c.isResolvedByTypeAlias(parent) - case ast.KindTypeAliasDeclaration: + case ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: return true } return false @@ -21959,7 +21958,7 @@ func (c *Checker) getOuterTypeParameters(node *ast.Node, includeThisTypes bool) switch kind { case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration, ast.KindCallSignature, ast.KindConstructSignature, ast.KindMethodSignature, ast.KindFunctionType, ast.KindConstructorType, ast.KindFunctionDeclaration, - ast.KindMethodDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction, ast.KindTypeAliasDeclaration, ast.KindMappedType, + ast.KindMethodDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindMappedType, ast.KindConditionalType: outerTypeParameters := c.getOuterTypeParameters(node, includeThisTypes) if (kind == ast.KindFunctionExpression || kind == ast.KindArrowFunction || ast.IsObjectLiteralMethod(node)) && c.isContextSensitive(node) { @@ -22038,7 +22037,7 @@ func (c *Checker) getDeclaredTypeOfTypeAlias(symbol *ast.Symbol) *Type { if !c.pushTypeResolution(symbol, TypeSystemPropertyNameDeclaredType) { return c.errorType } - declaration := core.Find(symbol.Declarations, ast.IsTypeAliasDeclaration) + declaration := core.Find(symbol.Declarations, ast.IsTypeOrJSTypeAliasDeclaration) typeNode := declaration.AsTypeAliasDeclaration().Type t := c.getTypeFromTypeNode(typeNode) if c.popTypeResolution() { @@ -25794,7 +25793,7 @@ func (c *Checker) markPropertyAsReferenced(prop *ast.Symbol, nodeForCheckWriteOn if prop.Flags&ast.SymbolFlagsClassMember == 0 || prop.ValueDeclaration == nil { return } - hasPrivateModifier := hasEffectiveModifier(prop.ValueDeclaration, ast.ModifierFlagsPrivate) + hasPrivateModifier := hasModifier(prop.ValueDeclaration, ast.ModifierFlagsPrivate) hasPrivateIdentifier := prop.ValueDeclaration.Name() != nil && ast.IsPrivateIdentifier(prop.ValueDeclaration.Name()) if !hasPrivateModifier && !hasPrivateIdentifier { return @@ -27127,7 +27126,7 @@ func (c *Checker) getContextualType(node *ast.Node, contextFlags ContextFlags) * case ast.KindSatisfiesExpression: return c.getTypeFromTypeNode(parent.AsSatisfiesExpression().Type) case ast.KindExportAssignment: - return c.tryGetTypeFromEffectiveTypeNode(parent) + return c.tryGetTypeFromTypeNode(parent) case ast.KindJsxExpression: return c.getContextualTypeForJsxExpression(parent, contextFlags) case ast.KindJsxAttribute, ast.KindJsxSpreadAttribute: diff --git a/internal/checker/emitresolver.go b/internal/checker/emitresolver.go index a40e52f8b3..1b2bca67c0 100644 --- a/internal/checker/emitresolver.go +++ b/internal/checker/emitresolver.go @@ -38,7 +38,7 @@ func (r *emitResolver) IsReferencedAliasDeclaration(node *ast.Node) bool { return true } target := aliasLinks.aliasTarget - if target != nil && getEffectiveModifierFlags(node)&ast.ModifierFlagsExport != 0 && + if target != nil && node.ModifierFlags()&ast.ModifierFlagsExport != 0 && c.getSymbolFlags(target)&ast.SymbolFlagsValue != 0 && (c.compilerOptions.ShouldPreserveConstEnums() || !isConstEnumOrConstEnumOnlyModule(target)) { return true diff --git a/internal/checker/flow.go b/internal/checker/flow.go index 2fd399d743..c9f0a0b912 100644 --- a/internal/checker/flow.go +++ b/internal/checker/flow.go @@ -1713,7 +1713,7 @@ func (c *Checker) tryGetNameFromEntityNameExpression(node *ast.Node) (string, bo if declaration == nil { return "", false } - t := c.tryGetTypeFromEffectiveTypeNode(declaration) + t := c.tryGetTypeFromTypeNode(declaration) if t != nil { if name, ok := tryGetNameFromType(t); ok { return name, true @@ -2686,6 +2686,7 @@ func (c *Checker) markNodeAssignmentsWorker(node *ast.Node) bool { return false case ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration, + ast.KindJSTypeAliasDeclaration, ast.KindEnumDeclaration: return false } diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index a1728c887c..2930d16e8c 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -400,7 +400,7 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "export", "abstract") } else if flags&ast.ModifierFlagsAsync != 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "export", "async") - } else if ast.IsClassLike(node.Parent) { + } else if ast.IsClassLike(node.Parent) && !ast.IsJSTypeAliasDeclaration(node) { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_appear_on_class_elements_of_this_kind, "export") } else if node.Kind == ast.KindParameter { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_appear_on_a_parameter, "export") @@ -604,7 +604,8 @@ func (c *Checker) findFirstIllegalModifier(node *ast.Node) *ast.Node { ast.KindFunctionExpression, ast.KindArrowFunction, ast.KindParameter, - ast.KindTypeParameter: + ast.KindTypeParameter, + ast.KindJSTypeAliasDeclaration: return nil case ast.KindClassStaticBlockDeclaration, ast.KindPropertyAssignment, @@ -1395,7 +1396,7 @@ func (c *Checker) checkGrammarTypeOperatorNode(node *ast.TypeOperatorNode) bool return c.grammarErrorOnNode((parent.AsVariableDeclaration()).Name(), diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const) } case ast.KindPropertyDeclaration: - if !ast.IsStatic(parent) || !hasEffectiveReadonlyModifier(parent) { + if !ast.IsStatic(parent) || !hasReadonlyModifier(parent) { return c.grammarErrorOnNode((parent.AsPropertyDeclaration()).Name(), diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly) } case ast.KindPropertySignature: @@ -1848,16 +1849,6 @@ func (c *Checker) checkGrammarMetaProperty(node *ast.MetaProperty) bool { } func (c *Checker) checkGrammarConstructorTypeParameters(node *ast.ConstructorDeclaration) bool { - // !!! - // var jsdocTypeParameters []*ast.TypeParameterDeclaration - // if ast.IsInJSFile(node.AsNode()) { - // jsdocTypeParameters = getJSDocTypeParameterDeclarations(node) - // } else { - // jsdocTypeParameters = nil - // } - // if range_ == nil { - // range_ = core.FirstOrNil(jsdocTypeParameters) - // } range_ := node.TypeParameters if range_ != nil { var pos int diff --git a/internal/checker/relater.go b/internal/checker/relater.go index dd93548c74..4cca82aa2c 100644 --- a/internal/checker/relater.go +++ b/internal/checker/relater.go @@ -1411,7 +1411,7 @@ func (c *Checker) getTypeParameterModifiers(tp *Type) ast.ModifierFlags { var flags ast.ModifierFlags if tp.symbol != nil { for _, d := range tp.symbol.Declarations { - flags |= getEffectiveModifierFlags(d) + flags |= d.ModifierFlags() } } return flags & (ast.ModifierFlagsIn | ast.ModifierFlagsOut | ast.ModifierFlagsConst) @@ -4430,8 +4430,8 @@ func (r *Relater) constructorVisibilitiesAreCompatible(sourceSignature *Signatur if sourceSignature.declaration == nil || targetSignature.declaration == nil { return true } - sourceAccessibility := getEffectiveModifierFlags(sourceSignature.declaration) & ast.ModifierFlagsNonPublicAccessibilityModifier - targetAccessibility := getEffectiveModifierFlags(targetSignature.declaration) & ast.ModifierFlagsNonPublicAccessibilityModifier + sourceAccessibility := sourceSignature.declaration.ModifierFlags() & ast.ModifierFlagsNonPublicAccessibilityModifier + targetAccessibility := targetSignature.declaration.ModifierFlags() & ast.ModifierFlagsNonPublicAccessibilityModifier // A public, protected and private signature is assignable to a private signature. if targetAccessibility == ast.ModifierFlagsPrivate { return true diff --git a/internal/checker/utilities.go b/internal/checker/utilities.go index a569342974..ed78f7a40e 100644 --- a/internal/checker/utilities.go +++ b/internal/checker/utilities.go @@ -83,20 +83,16 @@ func hasDecorators(node *ast.Node) bool { return ast.HasSyntacticModifier(node, ast.ModifierFlagsDecorator) } -func getEffectiveModifierFlags(node *ast.Node) ast.ModifierFlags { - return node.ModifierFlags() // !!! Handle JSDoc +func getSelectedModifierFlags(node *ast.Node, flags ast.ModifierFlags) ast.ModifierFlags { + return node.ModifierFlags() & flags } -func getSelectedEffectiveModifierFlags(node *ast.Node, flags ast.ModifierFlags) ast.ModifierFlags { - return getEffectiveModifierFlags(node) & flags +func hasModifier(node *ast.Node, flags ast.ModifierFlags) bool { + return node.ModifierFlags()&flags != 0 } -func hasEffectiveModifier(node *ast.Node, flags ast.ModifierFlags) bool { - return getEffectiveModifierFlags(node)&flags != 0 -} - -func hasEffectiveReadonlyModifier(node *ast.Node) bool { - return hasEffectiveModifier(node, ast.ModifierFlagsReadonly) +func hasReadonlyModifier(node *ast.Node) bool { + return hasModifier(node, ast.ModifierFlagsReadonly) } func isBindingElementOfBareOrAccessedRequire(node *ast.Node) bool { @@ -365,7 +361,7 @@ func isShorthandPropertyNameUseSite(useSite *ast.Node) bool { func isTypeDeclaration(node *ast.Node) bool { switch node.Kind { - case ast.KindTypeParameter, ast.KindClassDeclaration, ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration, ast.KindEnumDeclaration: + case ast.KindTypeParameter, ast.KindClassDeclaration, ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindEnumDeclaration: return true case ast.KindImportClause: return node.AsImportClause().IsTypeOnly @@ -385,14 +381,13 @@ func canHaveSymbol(node *ast.Node) bool { ast.KindConstructSignature, ast.KindElementAccessExpression, ast.KindEnumDeclaration, ast.KindEnumMember, ast.KindExportAssignment, ast.KindExportDeclaration, ast.KindExportSpecifier, ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindFunctionType, ast.KindGetAccessor, ast.KindIdentifier, ast.KindImportClause, ast.KindImportEqualsDeclaration, ast.KindImportSpecifier, - ast.KindIndexSignature, ast.KindInterfaceDeclaration, ast.KindJSDocCallbackTag, - ast.KindJSDocParameterTag, ast.KindJSDocPropertyTag, ast.KindJSDocSignature, ast.KindJSDocTypedefTag, ast.KindJSDocTypeLiteral, + ast.KindIndexSignature, ast.KindInterfaceDeclaration, ast.KindJSDocSignature, ast.KindJSDocTypeLiteral, ast.KindJsxAttribute, ast.KindJsxAttributes, ast.KindJsxSpreadAttribute, ast.KindMappedType, ast.KindMethodDeclaration, ast.KindMethodSignature, ast.KindModuleDeclaration, ast.KindNamedTupleMember, ast.KindNamespaceExport, ast.KindNamespaceExportDeclaration, ast.KindNamespaceImport, ast.KindNewExpression, ast.KindNoSubstitutionTemplateLiteral, ast.KindNumericLiteral, ast.KindObjectLiteralExpression, ast.KindParameter, ast.KindPropertyAccessExpression, ast.KindPropertyAssignment, ast.KindPropertyDeclaration, ast.KindPropertySignature, ast.KindSetAccessor, ast.KindShorthandPropertyAssignment, ast.KindSourceFile, ast.KindSpreadAssignment, ast.KindStringLiteral, - ast.KindTypeAliasDeclaration, ast.KindTypeLiteral, ast.KindTypeParameter, ast.KindVariableDeclaration: + ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindTypeLiteral, ast.KindTypeParameter, ast.KindVariableDeclaration: return true } return false @@ -403,10 +398,10 @@ func canHaveLocals(node *ast.Node) bool { case ast.KindArrowFunction, ast.KindBlock, ast.KindCallSignature, ast.KindCaseBlock, ast.KindCatchClause, ast.KindClassStaticBlockDeclaration, ast.KindConditionalType, ast.KindConstructor, ast.KindConstructorType, ast.KindConstructSignature, ast.KindForStatement, ast.KindForInStatement, ast.KindForOfStatement, ast.KindFunctionDeclaration, - ast.KindFunctionExpression, ast.KindFunctionType, ast.KindGetAccessor, ast.KindIndexSignature, ast.KindJSDocCallbackTag, - ast.KindJSDocSignature, ast.KindJSDocTypedefTag, ast.KindMappedType, + ast.KindFunctionExpression, ast.KindFunctionType, ast.KindGetAccessor, ast.KindIndexSignature, + ast.KindJSDocSignature, ast.KindMappedType, ast.KindMethodDeclaration, ast.KindMethodSignature, ast.KindModuleDeclaration, ast.KindSetAccessor, ast.KindSourceFile, - ast.KindTypeAliasDeclaration: + ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: return true } return false @@ -522,7 +517,7 @@ func hasExportAssignmentSymbol(moduleSymbol *ast.Symbol) bool { } func isTypeAlias(node *ast.Node) bool { - return ast.IsTypeAliasDeclaration(node) + return ast.IsTypeOrJSTypeAliasDeclaration(node) } func hasOnlyExpressionInitializer(node *ast.Node) bool { @@ -593,7 +588,7 @@ func declarationBelongsToPrivateAmbientMember(declaration *ast.Node) bool { } func isPrivateWithinAmbient(node *ast.Node) bool { - return (hasEffectiveModifier(node, ast.ModifierFlagsPrivate) || ast.IsPrivateIdentifierClassElementDeclaration(node)) && node.Flags&ast.NodeFlagsAmbient != 0 + return (hasModifier(node, ast.ModifierFlagsPrivate) || ast.IsPrivateIdentifierClassElementDeclaration(node)) && node.Flags&ast.NodeFlagsAmbient != 0 } func isTypeAssertion(node *ast.Node) bool { @@ -1244,9 +1239,9 @@ func isValidESSymbolDeclaration(node *ast.Node) bool { return ast.IsVarConst(node) && ast.IsIdentifier(node.AsVariableDeclaration().Name()) && isVariableDeclarationInVariableStatement(node) } if ast.IsPropertyDeclaration(node) { - return hasEffectiveReadonlyModifier(node) && ast.HasStaticModifier(node) + return hasReadonlyModifier(node) && ast.HasStaticModifier(node) } - return ast.IsPropertySignatureDeclaration(node) && hasEffectiveReadonlyModifier(node) + return ast.IsPropertySignatureDeclaration(node) && hasReadonlyModifier(node) } func isVariableDeclarationInVariableStatement(node *ast.Node) bool { @@ -1444,7 +1439,7 @@ func (c *Checker) isMutableLocalVariableDeclaration(declaration *ast.Node) bool func isInAmbientOrTypeNode(node *ast.Node) bool { return node.Flags&ast.NodeFlagsAmbient != 0 || ast.FindAncestor(node, func(n *ast.Node) bool { - return ast.IsInterfaceDeclaration(n) || ast.IsTypeAliasDeclaration(n) || ast.IsTypeLiteralNode(n) + return ast.IsInterfaceDeclaration(n) || ast.IsTypeOrJSTypeAliasDeclaration(n) || ast.IsTypeLiteralNode(n) }) != nil } diff --git a/internal/parser/jsdoc.go b/internal/parser/jsdoc.go index 5ab404df55..421b58f35f 100644 --- a/internal/parser/jsdoc.go +++ b/internal/parser/jsdoc.go @@ -56,10 +56,233 @@ func (p *Parser) withJSDoc(node *ast.Node, hasJSDoc bool) { p.hasDeprecatedTag = false node.Flags |= ast.NodeFlagsDeprecated } + if p.scriptKind == core.ScriptKindJS || p.scriptKind == core.ScriptKindJSX { + p.attachTagsToHost(node, jsdoc) + } p.jsdocCache[node] = jsdoc } } +// Unhosted tags add synthetic nodes to the reparse list instead of finding and modifying a host +func (p *Parser) attachTagsToHost(parent *ast.Node, jsDoc []*ast.Node) { + for _, j := range jsDoc { + isLast := j == jsDoc[len(jsDoc)-1] + tags := j.AsJSDoc().Tags + if tags == nil { + continue + } + for _, tag := range j.AsJSDoc().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 { + prop := p.factory.NewPropertySignatureDeclaration(nil, member.Name(), nil /*postfixToken*/, 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) + // !!! @overload and other unattached tags (@callback, @import et al) support goes here + } + if !isLast { + continue + } + 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) + } + } + } 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) + } + 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) + } + } + } + } + } +} + +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 (p *Parser) gatherTypeParameters(j *ast.Node) *ast.NodeList { + typeParameters := p.nodeSlicePool.NewSlice(0) + pos := -1 + end := -1 + first := true + for _, tag := range j.AsJSDoc().Tags.Nodes { + if tag.Kind == ast.KindJSDocTemplateTag { + if first { + pos = tag.Pos() + first = false + } + end = tag.End() + + constraint := tag.AsJSDocTemplateTag().Constraint + for _, tp := range tag.AsJSDocTemplateTag().TypeParameters().Nodes { + typeParameter := tp.AsTypeParameter() + var reparse *ast.Node + if constraint == nil { + reparse = typeParameter.Clone(&p.factory) + } else { + clone := constraint.Type().Clone(&p.factory) + clone.Flags |= ast.NodeFlagsReparsed + reparse = p.factory.NewTypeParameterDeclaration(typeParameter.Modifiers(), typeParameter.Name(), clone, typeParameter.DefaultType) + reparse.Loc = typeParameter.Loc + } + reparse.Flags |= ast.NodeFlagsReparsed + typeParameters = append(typeParameters, reparse) + } + } + } + if len(typeParameters) == 0 { + return nil + } else { + return p.newNodeList(core.NewTextRange(pos, end), typeParameters) + } +} + +func getFunctionLikeHost(host *ast.Node) (*ast.Node, bool) { + fun := host + if host.Kind == ast.KindVariableStatement && host.AsVariableStatement().DeclarationList != nil { + for _, declaration := range host.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes { + if ast.IsFunctionLike(declaration.Initializer()) { + fun = declaration.Initializer() + break + } + } + } else if host.Kind == ast.KindPropertyAssignment { + fun = host.AsPropertyAssignment().Initializer + } else if host.Kind == ast.KindPropertyDeclaration { + fun = host.AsPropertyDeclaration().Initializer + } else if host.Kind == ast.KindExportAssignment { + fun = host.AsExportAssignment().Expression + } else if host.Kind == ast.KindReturnStatement { + fun = host.AsReturnStatement().Expression + } + if ast.IsFunctionLike(fun) { + return fun, true + } + return nil, false +} + +func (p *Parser) makeNewTypeAssertion(t *ast.TypeNode, e *ast.Node) *ast.Node { + assert := p.factory.NewTypeAssertion(t, e) + assert.Flags = p.contextFlags | ast.NodeFlagsReparsed + assert.Loc = core.NewTextRange(e.Pos(), e.End()) + return assert +} + +func (p *Parser) makeNewType(typeExpression *ast.TypeNode, host *ast.Node) *ast.Node { + if typeExpression == nil || typeExpression.Type() == nil { + return nil + } + if typeExpression.AsJSDocTypeExpression().Host == nil { + typeExpression.AsJSDocTypeExpression().Host = host + } else { + panic("JSDoc type expression already has a host: " + typeExpression.AsJSDocTypeExpression().Host.Kind.String()) + } + t := typeExpression.Type().Clone(&p.factory) + t.Flags |= ast.NodeFlagsReparsed + if host != nil { + t.Parent = host + } + return t +} + func (p *Parser) parseJSDocTypeExpression(mayOmitBraces bool) *ast.Node { pos := p.nodePos() var hasBrace bool @@ -901,8 +1124,7 @@ func (p *Parser) parseThisTag(start int, tagName *ast.IdentifierNode, margin int func (p *Parser) parseTypedefTag(start int, tagName *ast.IdentifierNode, indent int, indentText string) *ast.Node { typeExpression := p.tryParseTypeExpression() p.skipWhitespaceOrAsterisk() - - fullName := p.parseJSDocTypeNameWithNamespace(false /*nested*/) + fullName := p.parseJSDocIdentifierName(nil) p.skipWhitespace() comment := p.parseTagComments(indent, nil) @@ -974,19 +1196,6 @@ func (p *Parser) parseTypedefTag(start int, tagName *ast.IdentifierNode, indent return typedefTag } -func (p *Parser) parseJSDocTypeNameWithNamespace(nested bool) *ast.Node { - start := p.scanner.TokenStart() - typeNameOrNamespaceName := p.parseJSDocIdentifierName(nil) - if p.parseOptional(ast.KindDotToken) { - body := p.parseJSDocTypeNameWithNamespace(true) - jsdocNamespaceNode := p.factory.NewModuleDeclaration(nil /*modifiers*/, ast.KindModuleKeyword, typeNameOrNamespaceName, body) - p.finishNode(jsdocNamespaceNode, start) - return jsdocNamespaceNode - } - - return typeNameOrNamespaceName -} - func (p *Parser) parseCallbackTagParameters(indent int) *ast.NodeList { var child *ast.Node var parameters []*ast.Node @@ -1026,7 +1235,7 @@ func (p *Parser) parseJSDocSignature(start int, indent int) *ast.Node { } func (p *Parser) parseCallbackTag(start int, tagName *ast.IdentifierNode, indent int, indentText string) *ast.Node { - fullName := p.parseJSDocTypeNameWithNamespace(false /*nested*/) + fullName := p.parseJSDocIdentifierName(nil) p.skipWhitespace() comment := p.parseTagComments(indent, nil) typeExpression := p.parseJSDocSignature(start, indent) @@ -1165,7 +1374,7 @@ func (p *Parser) parseTemplateTagTypeParameter() *ast.Node { if ast.NodeIsMissing(name) { return nil } - result := p.factory.NewTypeParameterDeclaration(modifiers, name /*constraint*/, nil, defaultType) + result := p.factory.NewTypeParameterDeclaration(modifiers, name, nil /*constraint*/, defaultType) p.finishNode(result, typeParameterPos) return result } diff --git a/internal/parser/parser.go b/internal/parser/parser.go index bfb536d130..4b81fe2e0e 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -75,6 +75,7 @@ type Parser struct { jsdocCommentsSpace []string jsdocCommentRangesSpace []ast.CommentRange jsdocTagCommentsSpace []string + reparseList []*ast.Node } var viableKeywordSuggestions = scanner.GetViableKeywordSuggestions() @@ -469,7 +470,12 @@ func (p *Parser) parseListIndex(kind ParsingContext, parseElement func(p *Parser list := make([]*ast.Node, 0, 16) for i := 0; !p.isListTerminator(kind); i++ { if p.isListElement(kind, false /*inErrorRecovery*/) { - list = append(list, parseElement(p, i)) + elt := parseElement(p, i) + if len(p.reparseList) > 0 { + list = append(list, p.reparseList...) + p.reparseList = nil + } + list = append(list, elt) continue } if p.abortParsingListOrMoveToNextToken(kind) { diff --git a/internal/printer/printer.go b/internal/printer/printer.go index 9ae6052ceb..567b63fa76 100644 --- a/internal/printer/printer.go +++ b/internal/printer/printer.go @@ -807,6 +807,7 @@ func (p *Printer) shouldAllowTrailingComma(node *ast.Node, list *ast.NodeList) b ast.KindGetAccessor, ast.KindSetAccessor, ast.KindTypeAliasDeclaration, + ast.KindJSTypeAliasDeclaration, ast.KindFunctionType, ast.KindConstructorType, ast.KindCallSignature, @@ -1721,6 +1722,10 @@ func (p *Printer) emitClassElement(node *ast.ClassElement) { p.emitIndexSignature(node.AsIndexSignatureDeclaration()) case ast.KindSemicolonClassElement: p.emitSemicolonClassElement(node.AsSemicolonClassElement()) + case ast.KindNotEmittedStatement: + p.emitNotEmittedStatement(node.AsNotEmittedStatement()) + case ast.KindJSTypeAliasDeclaration: + p.emitTypeAliasDeclaration(node.AsTypeAliasDeclaration()) default: panic(fmt.Sprintf("unexpected ClassElement: %v", node.Kind)) } @@ -3865,7 +3870,7 @@ func (p *Printer) emitStatement(node *ast.Statement) { p.emitClassDeclaration(node.AsClassDeclaration()) case ast.KindInterfaceDeclaration: p.emitInterfaceDeclaration(node.AsInterfaceDeclaration()) - case ast.KindTypeAliasDeclaration: + case ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: p.emitTypeAliasDeclaration(node.AsTypeAliasDeclaration()) case ast.KindEnumDeclaration: p.emitEnumDeclaration(node.AsEnumDeclaration()) @@ -4485,7 +4490,7 @@ func (p *Printer) hasTrailingComma(parentNode *ast.Node, children *ast.NodeList) case parentNode.ParameterList(): originalList = originalParent.ParameterList() } - case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration: + case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: switch children { case parentNode.TypeParameterList(): originalList = originalParent.TypeParameterList() diff --git a/internal/printer/utilities.go b/internal/printer/utilities.go index 02d3da3dfb..f027217ac1 100644 --- a/internal/printer/utilities.go +++ b/internal/printer/utilities.go @@ -449,10 +449,8 @@ func getContainingNodeArray(node *ast.Node) *ast.NodeList { return parent.ClassLikeData().TypeParameters case ast.IsInterfaceDeclaration(parent): return parent.AsInterfaceDeclaration().TypeParameters - case ast.IsTypeAliasDeclaration(parent): + case ast.IsTypeOrJSTypeAliasDeclaration(parent): return parent.AsTypeAliasDeclaration().TypeParameters - // case ast.IsJSDocTemplateTag(parent): - // return parent.AsJSDocTemplateTag().TypeParameters case ast.IsInferTypeNode(parent): break default: diff --git a/internal/testutil/tsbaseline/type_symbol_baseline.go b/internal/testutil/tsbaseline/type_symbol_baseline.go index 8036566c9b..fdb9bda55a 100644 --- a/internal/testutil/tsbaseline/type_symbol_baseline.go +++ b/internal/testutil/tsbaseline/type_symbol_baseline.go @@ -316,6 +316,9 @@ func forEachASTNode(node *ast.Node) []*ast.Node { for len(work) > 0 { elem := work[len(work)-1] work = work[:len(work)-1] + if elem.Flags&ast.NodeFlagsReparsed != 0 && elem.Kind != ast.KindTypeAssertionExpression { + continue + } result = append(result, elem) elem.ForEachChild(addChild) slices.Reverse(resChildren) @@ -337,7 +340,7 @@ func (walker *typeWriterWalker) writeTypeOrSymbol(node *ast.Node, isSymbolWalk b if ast.IsPartOfTypeNode(node) || ast.IsIdentifier(node) && (ast.GetMeaningFromDeclaration(node.Parent)&ast.SemanticMeaningValue) == 0 && - !(ast.IsTypeAliasDeclaration(node.Parent) && node == node.Parent.Name()) { + !(ast.IsTypeOrJSTypeAliasDeclaration(node.Parent) && node == node.Parent.Name()) { return nil } diff --git a/internal/transformers/typeeraser.go b/internal/transformers/typeeraser.go index d173b47de2..aa5cfcf117 100644 --- a/internal/transformers/typeeraser.go +++ b/internal/transformers/typeeraser.go @@ -96,6 +96,7 @@ func (tx *TypeEraserTransformer) visit(node *ast.Node) *ast.Node { return nil case ast.KindTypeAliasDeclaration, + ast.KindJSTypeAliasDeclaration, ast.KindInterfaceDeclaration: // TypeScript type-only declarations are elided. return tx.elide(node) diff --git a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt index d0ffdf581a..2519b84308 100644 --- a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt @@ -1,4 +1,3 @@ -ExtendedClass.js(9,37): error TS2339: Property 'extends' does not exist on type 'unknown'. ExtendedClass.js(17,12): error TS2339: Property 'exports' does not exist on type '{}'. ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type '{}'. @@ -12,7 +11,7 @@ ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type } export = BaseClass; } -==== ExtendedClass.js (3 errors) ==== +==== ExtendedClass.js (2 errors) ==== define("lib/ExtendedClass", ["deps/BaseClass"], /** * {typeof import("deps/BaseClass")} @@ -22,8 +21,6 @@ ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type (BaseClass) => { const ExtendedClass = BaseClass.extends({ - ~~~~~~~ -!!! error TS2339: Property 'extends' does not exist on type 'unknown'. f: function() { return "something"; } diff --git a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.symbols b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.symbols index 2ea9dc696a..f76120be75 100644 --- a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.symbols +++ b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.symbols @@ -42,7 +42,9 @@ define("lib/ExtendedClass", ["deps/BaseClass"], const ExtendedClass = BaseClass.extends({ >ExtendedClass : Symbol(ExtendedClass, Decl(ExtendedClass.js, 8, 9)) +>BaseClass.extends : Symbol(extends, Decl(BaseClass.d.ts, 1, 21)) >BaseClass : Symbol(BaseClass, Decl(ExtendedClass.js, 6, 1)) +>extends : Symbol(extends, Decl(BaseClass.d.ts, 1, 21)) f: function() { >f : Symbol(f, Decl(ExtendedClass.js, 8, 45)) diff --git a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.symbols.diff b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.symbols.diff index d3b6c4eb67..0397def26c 100644 --- a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.symbols.diff @@ -14,12 +14,14 @@ const ExtendedClass = BaseClass.extends({ >ExtendedClass : Symbol(ExtendedClass, Decl(ExtendedClass.js, 8, 9)) ->BaseClass.extends : Symbol(BaseClass.extends, Decl(BaseClass.d.ts, 1, 21)) ++>BaseClass.extends : Symbol(extends, Decl(BaseClass.d.ts, 1, 21)) >BaseClass : Symbol(BaseClass, Decl(ExtendedClass.js, 6, 1)) ->extends : Symbol(BaseClass.extends, Decl(BaseClass.d.ts, 1, 21)) ++>extends : Symbol(extends, Decl(BaseClass.d.ts, 1, 21)) f: function() { >f : Symbol(f, Decl(ExtendedClass.js, 8, 45)) -@@= skipped -16, +14 lines =@@ +@@= skipped -16, +16 lines =@@ >module : Symbol(module, Decl(ExtendedClass.js, 15, 9)) module.exports = ExtendedClass diff --git a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.types b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.types index 0a23c37510..176cd065be 100644 --- a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.types +++ b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.types @@ -36,20 +36,20 @@ define("lib/ExtendedClass", ["deps/BaseClass"], * @returns */ (BaseClass) => { ->(BaseClass) => { const ExtendedClass = BaseClass.extends({ f: function() { return "something"; } }); // Exports the module in a way tsc recognize class export const module = {}; module.exports = ExtendedClass return module.exports;} : (BaseClass: unknown) => any ->BaseClass : unknown +>(BaseClass) => { const ExtendedClass = BaseClass.extends({ f: function() { return "something"; } }); // Exports the module in a way tsc recognize class export const module = {}; module.exports = ExtendedClass return module.exports;} : (BaseClass: typeof BaseClass) => any +>BaseClass : typeof BaseClass const ExtendedClass = BaseClass.extends({ ->ExtendedClass : any ->BaseClass.extends({ f: function() { return "something"; } }) : any ->BaseClass.extends : any ->BaseClass : unknown ->extends : any ->{ f: function() { return "something"; } } : { f: () => string; } +>ExtendedClass : new () => { f: () => "something"; } & BaseClass +>BaseClass.extends({ f: function() { return "something"; } }) : new () => { f: () => "something"; } & BaseClass +>BaseClass.extends : (a: A) => new () => A & BaseClass +>BaseClass : typeof BaseClass +>extends : (a: A) => new () => A & BaseClass +>{ f: function() { return "something"; } } : { f: () => "something"; } f: function() { ->f : () => string ->function() { return "something"; } : () => string +>f : () => "something" +>function() { return "something"; } : () => "something" return "something"; >"something" : "something" @@ -62,11 +62,11 @@ define("lib/ExtendedClass", ["deps/BaseClass"], >{} : {} module.exports = ExtendedClass ->module.exports = ExtendedClass : any +>module.exports = ExtendedClass : new () => { f: () => "something"; } & BaseClass >module.exports : any >module : {} >exports : any ->ExtendedClass : any +>ExtendedClass : new () => { f: () => "something"; } & BaseClass return module.exports; >module.exports : any diff --git a/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.types b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.types index c975abf862..eefa62c814 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.types @@ -37,13 +37,13 @@ someRest(1, 2, 3); * @param {number} x - a thing */ function jsdocced(x) { arguments; } ->jsdocced : (x: any) => void ->x : any +>jsdocced : (x: number) => void +>x : number >arguments : IArguments jsdocced(1); >jsdocced(1) : void ->jsdocced : (x: any) => void +>jsdocced : (x: number) => void >1 : 1 function dontDoubleRest(x, ...y) { arguments; } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types index 750afc8aa6..5ec6e757bb 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.types @@ -10,18 +10,18 @@ class A { * @param {object} [foo={}] */ constructor(foo = {}) { ->foo : {} +>foo : object >{} : {} /** * @type object */ this.arguments = foo; ->this.arguments = foo : {} +>this.arguments = foo : object >this.arguments : any >this : this >arguments : any ->foo : {} +>foo : object } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types index 9e405aa310..124673f048 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.types @@ -10,18 +10,18 @@ class A { * @param {object} [foo={}] */ constructor(foo = {}) { ->foo : {} +>foo : object >{} : {} /** * @type object */ this["arguments"] = foo; ->this["arguments"] = foo : {} +>this["arguments"] = foo : object >this["arguments"] : any >this : this >"arguments" : "arguments" ->foo : {} +>foo : object } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types index f1bff002bd..4c52d5ccde 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.types @@ -24,7 +24,7 @@ class B extends A { * @param {object} [foo={}] */ constructor(foo = {}) { ->foo : {} +>foo : object >{} : {} super(); @@ -35,11 +35,11 @@ class B extends A { * @type object */ this.foo = foo; ->this.foo = foo : {} +>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : {} +>foo : object /** * @type object diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt index 0bb2037a2d..fad3097c1e 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt @@ -1,11 +1,12 @@ /a.js(13,8): error TS2339: Property 'foo' does not exist on type 'A'. /a.js(18,9): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. /a.js(23,8): error TS2339: Property 'bar' does not exist on type 'A'. +/a.js(23,24): error TS2339: Property 'bar' does not exist on type 'object'. /a.js(28,8): error TS2339: Property 'baz' does not exist on type 'A'. /a.js(33,8): error TS2339: Property 'options' does not exist on type 'A'. -==== /a.js (5 errors) ==== +==== /a.js (6 errors) ==== class A { /** * Constructor @@ -35,6 +36,8 @@ this.bar = arguments.bar; ~~~ !!! error TS2339: Property 'bar' does not exist on type 'A'. + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'object'. /** * @type object diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.symbols b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.symbols index 8563ae3157..bfd81cc31b 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.symbols +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.symbols @@ -36,9 +36,7 @@ class A { */ this.bar = arguments.bar; >this : Symbol(A, Decl(a.js, 0, 0)) ->arguments.bar : Symbol(bar, Decl(a.js, 36, 10)) >arguments : Symbol(arguments, Decl(a.js, 17, 7)) ->bar : Symbol(bar, Decl(a.js, 36, 10)) /** * @type object diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.symbols.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.symbols.diff index cbf21c4795..09538b33ee 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.symbols.diff @@ -27,9 +27,7 @@ ->this.bar : Symbol(A.bar, Decl(a.js, 17, 35)) >this : Symbol(A, Decl(a.js, 0, 0)) ->bar : Symbol(A.bar, Decl(a.js, 17, 35)) -+>arguments.bar : Symbol(bar, Decl(a.js, 36, 10)) >arguments : Symbol(arguments, Decl(a.js, 17, 7)) -+>bar : Symbol(bar, Decl(a.js, 36, 10)) /** * @type object @@ -41,7 +39,7 @@ >arguments : Symbol(arguments, Decl(a.js, 17, 7)) >key : Symbol(key, Decl(a.js, 7, 7)) -@@= skipped -27, +25 lines =@@ +@@= skipped -27, +23 lines =@@ * @type object */ this.options = arguments; diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types index e725166520..849ed640e4 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.types @@ -10,7 +10,7 @@ class A { * @param {object} [foo={}] */ constructor(foo = {}) { ->foo : {} +>foo : object >{} : {} const key = "bar"; @@ -21,17 +21,17 @@ class A { * @type object */ this.foo = foo; ->this.foo = foo : {} +>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : {} +>foo : object /** * @type object */ const arguments = this.arguments; ->arguments : { bar: {}; } +>arguments : object >this.arguments : { bar: {}; } >this : this >arguments : { bar: {}; } @@ -40,35 +40,35 @@ class A { * @type object */ this.bar = arguments.bar; ->this.bar = arguments.bar : {} +>this.bar = arguments.bar : any >this.bar : any >this : this >bar : any ->arguments.bar : {} ->arguments : { bar: {}; } ->bar : {} +>arguments.bar : any +>arguments : object +>bar : any /** * @type object */ this.baz = arguments[key]; ->this.baz = arguments[key] : {} +>this.baz = arguments[key] : any >this.baz : any >this : this >baz : any ->arguments[key] : {} ->arguments : { bar: {}; } +>arguments[key] : any +>arguments : object >key : "bar" /** * @type object */ this.options = arguments; ->this.options = arguments : { bar: {}; } +>this.options = arguments : object >this.options : any >this : this >options : any ->arguments : { bar: {}; } +>arguments : object } get arguments() { diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types index 3f82b27a26..e5e5a9b627 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.types @@ -19,18 +19,18 @@ class A { * @param {object} [foo={}] */ constructor(foo = {}) { ->foo : {} +>foo : object >{} : {} /** * @type object */ this.foo = foo; ->this.foo = foo : {} +>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : {} +>foo : object /** * @type object diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types index 1c832ae2d5..354cf5c742 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.types @@ -8,19 +8,19 @@ class A { * @param {object} [foo={}] */ m(foo = {}) { ->m : (foo?: {}) => void ->foo : {} +>m : (foo?: object) => void +>foo : object >{} : {} /** * @type object */ this.arguments = foo; ->this.arguments = foo : {} +>this.arguments = foo : object >this.arguments : any >this : this >arguments : any ->foo : {} +>foo : object } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types index 5303eb500e..456fc6fecf 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.types @@ -8,19 +8,19 @@ class A { * @param {object} [foo={}] */ m(foo = {}) { ->m : (foo?: {}) => void ->foo : {} +>m : (foo?: object) => void +>foo : object >{} : {} /** * @type object */ this["arguments"] = foo; ->this["arguments"] = foo : {} +>this["arguments"] = foo : object >this["arguments"] : any >this : this >"arguments" : "arguments" ->foo : {} +>foo : object } } diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types index 41d13788ba..d7f5de01af 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.types @@ -22,19 +22,19 @@ class B extends A { * @param {object} [foo={}] */ m(foo = {}) { ->m : (foo?: {}) => void ->foo : {} +>m : (foo?: object) => void +>foo : object >{} : {} /** * @type object */ this.x = foo; ->this.x = foo : {} +>this.x = foo : object >this.x : any >this : this >x : any ->foo : {} +>foo : object /** * @type object diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt index ca8e4ed0a1..9dd493e140 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt @@ -1,11 +1,12 @@ /a.js(11,8): error TS2339: Property 'foo' does not exist on type 'A'. /a.js(16,9): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. /a.js(21,8): error TS2339: Property 'bar' does not exist on type 'A'. +/a.js(21,24): error TS2339: Property 'bar' does not exist on type 'object'. /a.js(26,8): error TS2339: Property 'baz' does not exist on type 'A'. /a.js(31,8): error TS2339: Property 'options' does not exist on type 'A'. -==== /a.js (5 errors) ==== +==== /a.js (6 errors) ==== class A { /** * @param {object} [foo={}] @@ -33,6 +34,8 @@ this.bar = arguments.bar; ~~~ !!! error TS2339: Property 'bar' does not exist on type 'A'. + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'object'. /** * @type object diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.symbols b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.symbols index 1e6cd7b1d6..1598196cb0 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.symbols +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.symbols @@ -35,9 +35,7 @@ class A { */ this.bar = arguments.bar; >this : Symbol(A, Decl(a.js, 0, 0)) ->arguments.bar : Symbol(bar, Decl(a.js, 34, 10)) >arguments : Symbol(arguments, Decl(a.js, 15, 7)) ->bar : Symbol(bar, Decl(a.js, 34, 10)) /** * @type object diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.symbols.diff b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.symbols.diff index 06205cf733..8462d0fb15 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.symbols.diff @@ -36,9 +36,7 @@ ->this.bar : Symbol(A.bar, Decl(a.js, 15, 35)) >this : Symbol(A, Decl(a.js, 0, 0)) ->bar : Symbol(A.bar, Decl(a.js, 15, 35)) -+>arguments.bar : Symbol(bar, Decl(a.js, 34, 10)) >arguments : Symbol(arguments, Decl(a.js, 15, 7)) -+>bar : Symbol(bar, Decl(a.js, 34, 10)) /** * @type object @@ -50,7 +48,7 @@ >arguments : Symbol(arguments, Decl(a.js, 15, 7)) >key : Symbol(key, Decl(a.js, 5, 7)) -@@= skipped -27, +25 lines =@@ +@@= skipped -27, +23 lines =@@ * @type object */ this.options = arguments; diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types index c0439ed232..0aff6a399e 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.types @@ -8,8 +8,8 @@ class A { * @param {object} [foo={}] */ m(foo = {}) { ->m : (foo?: {}) => void ->foo : {} +>m : (foo?: object) => void +>foo : object >{} : {} const key = "bar"; @@ -20,17 +20,17 @@ class A { * @type object */ this.foo = foo; ->this.foo = foo : {} +>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : {} +>foo : object /** * @type object */ const arguments = this.arguments; ->arguments : { bar: {}; } +>arguments : object >this.arguments : { bar: {}; } >this : this >arguments : { bar: {}; } @@ -39,35 +39,35 @@ class A { * @type object */ this.bar = arguments.bar; ->this.bar = arguments.bar : {} +>this.bar = arguments.bar : any >this.bar : any >this : this >bar : any ->arguments.bar : {} ->arguments : { bar: {}; } ->bar : {} +>arguments.bar : any +>arguments : object +>bar : any /** * @type object */ this.baz = arguments[key]; ->this.baz = arguments[key] : {} +>this.baz = arguments[key] : any >this.baz : any >this : this >baz : any ->arguments[key] : {} ->arguments : { bar: {}; } +>arguments[key] : any +>arguments : object >key : "bar" /** * @type object */ this.options = arguments; ->this.options = arguments : { bar: {}; } +>this.options = arguments : object >this.options : any >this : this >options : any ->arguments : { bar: {}; } +>arguments : object } get arguments() { diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types index 8e4c25ed66..98385d5311 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.types @@ -17,19 +17,19 @@ class A { * @param {object} [foo={}] */ m(foo = {}) { ->m : (foo?: {}) => void ->foo : {} +>m : (foo?: object) => void +>foo : object >{} : {} /** * @type object */ this.foo = foo; ->this.foo = foo : {} +>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : {} +>foo : object /** * @type object diff --git a/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.errors.txt b/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.errors.txt deleted file mode 100644 index e68ce05996..0000000000 --- a/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -index.js(4,19): error TS7006: Parameter 'v' implicitly has an 'any' type. -index.js(13,5): error TS7006: Parameter 'param' implicitly has an 'any' type. - - -==== index.js (2 errors) ==== - /** - * @param {any} v - */ - function identity(v) { - ~ -!!! error TS7006: Parameter 'v' implicitly has an 'any' type. - return v; - } - - const x = identity( - /** - * @param {number} param - * @returns {number=} - */ - param => param - ~~~~~ -!!! error TS7006: Parameter 'param' implicitly has an 'any' type. - ); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.types b/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.types index 8adc8041cf..962a6582b5 100644 --- a/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.types +++ b/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.types @@ -22,9 +22,9 @@ const x = identity( * @returns {number=} */ param => param ->param => param : (param: any) => any ->param : any ->param : any +>param => param : (param: number) => number | undefined +>param : number +>param : number ); diff --git a/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt new file mode 100644 index 0000000000..50e261254c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt @@ -0,0 +1,18 @@ +file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. + + +==== file.js (1 errors) ==== + // @ts-check + const obj = { + x: 1, + y: 2 + }; + + /** + * @type {keyof typeof obj} + */ + let selected = "x"; + selected = "z"; // should fail + ~~~~~~~~ +!!! error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.types b/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.types index a05fb67308..c8b0666cfc 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.types @@ -20,11 +20,11 @@ const obj = { * @type {keyof typeof obj} */ let selected = "x"; ->selected : string +>selected : "x" | "y" >"x" : "x" selected = "z"; // should fail >selected = "z" : "z" ->selected : string +>selected : "x" | "y" >"z" : "z" diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types index dcce2a86e6..2ebc2e80a2 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types @@ -24,11 +24,12 @@ export = Foo; /** @typedef {(foo: Foo) => string} FooFun */ module.exports = /** @type {FooFun} */(void 0); ->module.exports = /** @type {FooFun} */(void 0) : undefined +>module.exports = /** @type {FooFun} */(void 0) : (foo: typeof Foo) => string >module.exports : any >module : any >exports : any ->(void 0) : undefined +>(void 0) : (foo: typeof Foo) => string +>void 0 : (foo: typeof Foo) => string >void 0 : undefined >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt new file mode 100644 index 0000000000..5b7f3af8e4 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt @@ -0,0 +1,19 @@ +a.js(8,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b + + +==== a.js (1 errors) ==== + /** + * @typedef {Object} Foo + * @property {boolean} a + * @property {boolean} b + */ + + /** @type {Foo} */ + export default { c: false }; + ~~~~~~~~~~~~ +!!! error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b + +==== b.js (0 errors) ==== + import a from "./a"; + a; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.types index 64817d9e4c..fdc4ba3385 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment1.types @@ -11,14 +11,15 @@ /** @type {Foo} */ export default { c: false }; +>{ c: false } : Foo >{ c: false } : { c: boolean; } >c : boolean >false : false === b.js === import a from "./a"; ->a : { c: boolean; } +>a : Foo a; ->a : { c: boolean; } +>a : Foo diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt new file mode 100644 index 0000000000..9b6f314703 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt @@ -0,0 +1,19 @@ +b.js(2,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b + + +==== a.ts (0 errors) ==== + export interface Foo { + a: number; + b: number; + } + +==== 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 + +==== c.js (0 errors) ==== + import b from "./b"; + b; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.types index 0a84f62bfb..3e5351e9ba 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment2.types @@ -14,14 +14,15 @@ export interface Foo { === b.js === /** @type {import("./a").Foo} */ export default { c: false }; +>{ c: false } : Foo >{ c: false } : { c: boolean; } >c : boolean >false : false === c.js === import b from "./b"; ->b : { c: boolean; } +>b : Foo b; ->b : { c: boolean; } +>b : Foo diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.errors.txt new file mode 100644 index 0000000000..3938bc6f29 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.errors.txt @@ -0,0 +1,21 @@ +a.js(10,16): error TS2739: Type '{ c: number; }' is missing the following properties from type 'Foo': a, b + + +==== a.js (1 errors) ==== + /** + * @typedef {Object} Foo + * @property {boolean} a + * @property {boolean} b + */ + + const bar = { c: 1 }; + + /** @type {Foo} */ + export default bar; + ~~~ +!!! error TS2739: Type '{ c: number; }' is missing the following properties from type 'Foo': a, b + +==== b.js (0 errors) ==== + import a from "./a"; + a; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types index d74c8372b9..4d9d2874d4 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment3.types @@ -17,12 +17,13 @@ const bar = { c: 1 }; /** @type {Foo} */ export default bar; +>bar : Foo >bar : { c: number; } === b.js === import a from "./a"; ->a : { c: number; } +>a : Foo a; ->a : { c: number; } +>a : Foo diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt new file mode 100644 index 0000000000..f7ce3b5548 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt @@ -0,0 +1,14 @@ +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 (1 errors) ==== + /** + * @typedef {number} Foo + */ + + /** @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. + + \ 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 0a31928944..1917332358 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment4.types @@ -3,12 +3,13 @@ === 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 2ea78c1003..f90d3c5440 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment5.types @@ -11,6 +11,7 @@ /** @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 @@ -19,8 +20,8 @@ export default { a: 1, b: 1 }; === b.js === import a from "./a"; ->a : { a: number; b: number; } +>a : Foo a; ->a : { a: number; b: number; } +>a : Foo diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.types index 7c62aad49d..6a755b6417 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment6.types @@ -11,6 +11,7 @@ /** @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 @@ -21,8 +22,8 @@ export default { a: 1, b: 1, c: 1 }; === b.js === import a from "./a"; ->a : { a: number; b: number; c: number; } +>a : Foo a; ->a : { a: number; b: number; c: number; } +>a : Foo diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types index b7766d4109..981d52c5eb 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment7.types @@ -21,12 +21,13 @@ 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 : { a: number; b: number; c: number; } +>a : Foo a; ->a : { a: number; b: number; c: number; } +>a : Foo diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types index b8c62e6b5f..7b4ec2e042 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types @@ -11,6 +11,7 @@ /** @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/contextuallyTypedParametersOptionalInJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt index 0e7a53e74f..dbf4731034 100644 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt @@ -1,20 +1,15 @@ -index.js(5,20): error TS7006: Parameter 'num' implicitly has an 'any' type. -index.js(16,17): error TS7006: Parameter 'a' implicitly has an 'any' type. -index.js(16,20): error TS7006: Parameter 'b' implicitly has an 'any' type. -index.js(18,5): error TS2554: Expected 2 arguments, but got 1. -index.js(27,17): error TS7006: Parameter 'a' implicitly has an 'any' type. -index.js(27,20): error TS7006: Parameter 'b' implicitly has an 'any' type. -index.js(29,5): error TS2554: Expected 2 arguments, but got 1. +index.js(17,15): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. + Type 'undefined' is not assignable to type 'number'. +index.js(28,15): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. + Type 'undefined' is not assignable to type 'number'. -==== index.js (7 errors) ==== +==== index.js (2 errors) ==== /** * * @param {number} num */ function acceptNum(num) {} - ~~~ -!!! error TS7006: Parameter 'num' implicitly has an 'any' type. /** * @typedef {(a: string, b: number) => void} Fn @@ -26,15 +21,11 @@ index.js(29,5): error TS2554: Expected 2 arguments, but got 1. * @param [b] */ function self(a, b) { - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. acceptNum(b); // error + ~ +!!! error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. +!!! error TS2345: Type 'undefined' is not assignable to type 'number'. self(""); - ~~~~ -!!! error TS2554: Expected 2 arguments, but got 1. -!!! related TS6210 index.js:16:20: An argument for 'b' was not provided. self("", undefined); }; @@ -44,15 +35,11 @@ index.js(29,5): error TS2554: Expected 2 arguments, but got 1. * @param {number} [b] */ function self(a, b) { - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. acceptNum(b); // error + ~ +!!! error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. +!!! error TS2345: Type 'undefined' is not assignable to type 'number'. self(""); - ~~~~ -!!! error TS2554: Expected 2 arguments, but got 1. -!!! related TS6210 index.js:27:20: An argument for 'b' was not provided. self("", undefined); }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types index de660c400e..7fe7125499 100644 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types +++ b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.types @@ -6,8 +6,8 @@ * @param {number} num */ function acceptNum(num) {} ->acceptNum : (num: any) => void ->num : any +>acceptNum : (num: number) => void +>num : number /** * @typedef {(a: string, b: number) => void} Fn @@ -15,30 +15,30 @@ function acceptNum(num) {} /** @type {Fn} */ const fn1 = ->fn1 : (a: any, b: any) => void +>fn1 : (a: string, b: number) => void /** * @param [b] */ function self(a, b) { ->function self(a, b) { acceptNum(b); // error self(""); self("", undefined); } : (a: any, b: any) => void ->self : (a: any, b: any) => void ->a : any ->b : any +>function self(a, b) { acceptNum(b); // error self(""); self("", undefined); } : (a: string, b?: number | undefined) => void +>self : (a: string, b?: number | undefined) => void +>a : string +>b : number | undefined acceptNum(b); // error >acceptNum(b) : void ->acceptNum : (num: any) => void ->b : any +>acceptNum : (num: number) => void +>b : number | undefined self(""); >self("") : void ->self : (a: any, b: any) => void +>self : (a: string, b?: number | undefined) => void >"" : "" self("", undefined); >self("", undefined) : void ->self : (a: any, b: any) => void +>self : (a: string, b?: number | undefined) => void >"" : "" >undefined : undefined @@ -46,30 +46,30 @@ const fn1 = /** @type {Fn} */ const fn2 = ->fn2 : (a: any, b: any) => void +>fn2 : (a: string, b: number) => void /** * @param {number} [b] */ function self(a, b) { ->function self(a, b) { acceptNum(b); // error self(""); self("", undefined); } : (a: any, b: any) => void ->self : (a: any, b: any) => void ->a : any ->b : any +>function self(a, b) { acceptNum(b); // error self(""); self("", undefined); } : (a: string, b?: number | undefined) => void +>self : (a: string, b?: number | undefined) => void +>a : string +>b : number | undefined acceptNum(b); // error >acceptNum(b) : void ->acceptNum : (num: any) => void ->b : any +>acceptNum : (num: number) => void +>b : number | undefined self(""); >self("") : void ->self : (a: any, b: any) => void +>self : (a: string, b?: number | undefined) => void >"" : "" self("", undefined); >self("", undefined) : void ->self : (a: any, b: any) => void +>self : (a: string, b?: number | undefined) => void >"" : "" >undefined : undefined diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt deleted file mode 100644 index d9c6c3bfc0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -index.js(13,14): error TS7006: Parameter 'fns' implicitly has an 'any' type. -index.js(21,8): error TS7006: Parameter 'a' implicitly has an 'any' type. - - -==== index.js (2 errors) ==== - /** - * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs - * @template A - * @template {Record} B - */ - - /** - * @template A - * @template {Record} B - * @param {Funcs} fns - * @returns {[A, B]} - */ - function foo(fns) { - ~~~ -!!! error TS7006: Parameter 'fns' implicitly has an 'any' type. - return /** @type {any} */ (null); - } - - const result = foo({ - bar: { - fn: - /** @param {string} a */ - (a) => {}, - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - thing: "asd", - }, - }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types index b329e74838..1e4bd26212 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types @@ -14,30 +14,31 @@ * @returns {[A, B]} */ function foo(fns) { ->foo : (fns: any) => null ->fns : any +>foo : >(fns: Funcs) => [A, B] +>fns : Funcs return /** @type {any} */ (null); ->(null) : null +>(null) : any +>null : any } const result = foo({ ->result : null ->foo({ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },}) : null ->foo : (fns: any) => null ->{ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },} : { bar: { fn: (a: any) => void; thing: string; }; } +>result : [string, { bar: string; }] +>foo({ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },}) : [string, { bar: string; }] +>foo : >(fns: Funcs) => [A, B] +>{ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },} : { bar: { fn: (a: string) => void; thing: string; }; } bar: { ->bar : { fn: (a: any) => void; thing: string; } ->{ fn: /** @param {string} a */ (a) => {}, thing: "asd", } : { fn: (a: any) => void; thing: string; } +>bar : { fn: (a: string) => void; thing: string; } +>{ fn: /** @param {string} a */ (a) => {}, thing: "asd", } : { fn: (a: string) => void; thing: string; } fn: ->fn : (a: any) => void +>fn : (a: string) => void /** @param {string} a */ (a) => {}, ->(a) => {} : (a: any) => void ->a : any +>(a) => {} : (a: string) => void +>a : string thing: "asd", >thing : string diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt deleted file mode 100644 index 3415d56135..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -index.js(6,17): error TS7006: Parameter 'predicate' implicitly has an 'any' type. -index.js(14,4): error TS7006: Parameter 'pose' implicitly has an 'any' type. -index.js(22,4): error TS7006: Parameter 'pose' implicitly has an 'any' type. -index.js(22,10): error TS7006: Parameter '_' implicitly has an 'any' type. - - -==== index.js (4 errors) ==== - /** - * @template T - * @param {(value: T, index: number) => boolean} predicate - * @returns {T} - */ - function filter(predicate) { - ~~~~~~~~~ -!!! error TS7006: Parameter 'predicate' implicitly has an 'any' type. - return /** @type {any} */ (null); - } - - const a = filter( - /** - * @param {number} [pose] - */ - (pose) => true - ~~~~ -!!! error TS7006: Parameter 'pose' implicitly has an 'any' type. - ); - - const b = filter( - /** - * @param {number} [pose] - * @param {number} [_] - */ - (pose, _) => true - ~~~~ -!!! error TS7006: Parameter 'pose' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter '_' implicitly has an 'any' type. - ); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types index 5fce33cb18..87ac4ac308 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types @@ -7,41 +7,42 @@ * @returns {T} */ function filter(predicate) { ->filter : (predicate: any) => null ->predicate : any +>filter : (predicate: (value: T, index: number) => boolean) => T +>predicate : (value: T, index: number) => boolean return /** @type {any} */ (null); ->(null) : null +>(null) : any +>null : any } const a = filter( ->a : null ->filter( /** * @param {number} [pose] */ (pose) => true) : null ->filter : (predicate: any) => null +>a : number | undefined +>filter( /** * @param {number} [pose] */ (pose) => true) : number | undefined +>filter : (predicate: (value: T, index: number) => boolean) => T /** * @param {number} [pose] */ (pose) => true ->(pose) => true : (pose: any) => boolean ->pose : any +>(pose) => true : (pose?: number | undefined) => true +>pose : number | undefined >true : true ); const b = filter( ->b : null ->filter( /** * @param {number} [pose] * @param {number} [_] */ (pose, _) => true) : null ->filter : (predicate: any) => null +>b : number | undefined +>filter( /** * @param {number} [pose] * @param {number} [_] */ (pose, _) => true) : number | undefined +>filter : (predicate: (value: T, index: number) => boolean) => T /** * @param {number} [pose] * @param {number} [_] */ (pose, _) => true ->(pose, _) => true : (pose: any, _: any) => boolean ->pose : any ->_ : any +>(pose, _) => true : (pose?: number | undefined, _?: number | undefined) => true +>pose : number | undefined +>_ : number | undefined >true : true ); diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt index eb26152e91..d525041aed 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt @@ -1,5 +1,4 @@ -uglify.js(5,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. -uglify.js(6,7): error TS2339: Property 'val' does not exist on type 'number'. +uglify.js(6,7): error TS2339: Property 'val' does not exist on type '{}'. ==== controlFlowInstanceof.ts (0 errors) ==== @@ -111,16 +110,14 @@ uglify.js(6,7): error TS2339: Property 'val' does not exist on type 'number'. } // Repro from #27550 (based on uglify code) -==== uglify.js (2 errors) ==== +==== uglify.js (1 errors) ==== /** @constructor */ function AtTop(val) { this.val = val } /** @type {*} */ var v = 1; if (v instanceof AtTop) { - ~ -!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. v.val ~~~ -!!! error TS2339: Property 'val' does not exist on type 'number'. +!!! error TS2339: Property 'val' does not exist on type '{}'. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.types b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.types index 35f27c01f2..428048cfd2 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.types +++ b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.types @@ -276,17 +276,17 @@ function AtTop(val) { this.val = val } /** @type {*} */ var v = 1; ->v : number +>v : any >1 : 1 if (v instanceof AtTop) { >v instanceof AtTop : boolean ->v : number +>v : any >AtTop : (val: any) => void v.val >v.val : any ->v : number +>v : {} >val : any } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt deleted file mode 100644 index 12832c191f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt +++ /dev/null @@ -1,52 +0,0 @@ -input.js(5,7): error TS7005: Variable 'something' implicitly has an 'any' type. -input.js(13,77): error TS7006: Parameter 'req' implicitly has an 'any' type. -input.js(21,64): error TS7006: Parameter 'req' implicitly has an 'any' type. -input.js(37,88): error TS7006: Parameter 'b' implicitly has an 'any' type. - - -==== input.js (4 errors) ==== - /** - * @typedef {{ } & { name?: string }} P - */ - - const something = /** @type {*} */(null); - ~~~~~~~~~ -!!! error TS7005: Variable 'something' implicitly has an 'any' type. - - export let vLet = /** @type {P} */(something); - export const vConst = /** @type {P} */(something); - - export function fn(p = /** @type {P} */(something)) {} - - /** @param {number} req */ - export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} - ~~~ -!!! error TS7006: Parameter 'req' implicitly has an 'any' type. - - export class C { - field = /** @type {P} */(something); - /** @optional */ optField = /** @type {P} */(something); // not a thing - /** @readonly */ roFiled = /** @type {P} */(something); - method(p = /** @type {P} */(something)) {} - /** @param {number} req */ - methodWithRequiredDefault(p = /** @type {P} */(something), req) {} - ~~~ -!!! error TS7006: Parameter 'req' implicitly has an 'any' type. - - constructor(ctorField = /** @type {P} */(something)) {} - - get x() { return /** @type {P} */(something) } - set x(v) { } - } - - export default /** @type {P} */(something); - - // allows `undefined` on the input side, thanks to the initializer - /** - * - * @param {P} x - * @param {number} b - */ - export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt deleted file mode 100644 index 16b7800eb5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt +++ /dev/null @@ -1,49 +0,0 @@ -input.js(13,77): error TS7006: Parameter 'req' implicitly has an 'any' type. -input.js(21,64): error TS7006: Parameter 'req' implicitly has an 'any' type. -input.js(37,88): error TS7006: Parameter 'b' implicitly has an 'any' type. - - -==== input.js (3 errors) ==== - /** - * @typedef {{ } & { name?: string }} P - */ - - const something = /** @type {*} */(null); - - export let vLet = /** @type {P} */(something); - export const vConst = /** @type {P} */(something); - - export function fn(p = /** @type {P} */(something)) {} - - /** @param {number} req */ - export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} - ~~~ -!!! error TS7006: Parameter 'req' implicitly has an 'any' type. - - export class C { - field = /** @type {P} */(something); - /** @optional */ optField = /** @type {P} */(something); // not a thing - /** @readonly */ roFiled = /** @type {P} */(something); - method(p = /** @type {P} */(something)) {} - /** @param {number} req */ - methodWithRequiredDefault(p = /** @type {P} */(something), req) {} - ~~~ -!!! error TS7006: Parameter 'req' implicitly has an 'any' type. - - constructor(ctorField = /** @type {P} */(something)) {} - - get x() { return /** @type {P} */(something) } - set x(v) { } - } - - export default /** @type {P} */(something); - - // allows `undefined` on the input side, thanks to the initializer - /** - * - * @param {P} x - * @param {number} b - */ - export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.types b/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.types index df731ebadf..e8ac74c47f 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.types +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.types @@ -21,7 +21,7 @@ export class VFile { */ set path(path) { >path : string ->path : string +>path : string | URL } } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.types b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.types index dd5665f03f..be39b7f5a6 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.types +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.types @@ -12,7 +12,7 @@ export class Foo { * @param {string} baz Baz. */ set bar(baz) {} ->bar : any ->baz : any +>bar : string +>baz : string } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt deleted file mode 100644 index 8be1ee55b1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt +++ /dev/null @@ -1,59 +0,0 @@ -index.js(48,7): error TS7032: Property 'x' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -index.js(48,9): error TS7006: Parameter 'a' implicitly has an 'any' type. - - -==== index.js (2 errors) ==== - // same type accessors - export const obj1 = { - /** - * my awesome getter (first in source order) - * @returns {string} - */ - get x() { - return ""; - }, - /** - * my awesome setter (second in source order) - * @param {string} a - */ - set x(a) {}, - }; - - // divergent accessors - export const obj2 = { - /** - * my awesome getter - * @returns {string} - */ - get x() { - return ""; - }, - /** - * my awesome setter - * @param {number} a - */ - set x(a) {}, - }; - - export const obj3 = { - /** - * my awesome getter - * @returns {string} - */ - get x() { - return ""; - }, - }; - - export const obj4 = { - /** - * my awesome setter - * @param {number} a - */ - set x(a) {}, - ~ -!!! error TS7032: Property 'x' implicitly has type 'any', because its set accessor lacks a parameter type annotation. - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.types b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.types index 602610b8d4..1217753d64 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.types +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.types @@ -49,7 +49,7 @@ export const obj2 = { */ set x(a) {}, >x : string ->a : string +>a : number }; @@ -71,16 +71,16 @@ export const obj3 = { }; export const obj4 = { ->obj4 : { x: any; } ->{ /** * my awesome setter * @param {number} a */ set x(a) {},} : { x: any; } +>obj4 : { x: number; } +>{ /** * my awesome setter * @param {number} a */ set x(a) {},} : { x: number; } /** * my awesome setter * @param {number} a */ set x(a) {}, ->x : any ->a : any +>x : number +>a : number }; diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt index 602c5117a3..f18be0c0f6 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt @@ -1,13 +1,16 @@ +input.js(5,48): error TS2304: Cannot find name 'P'. input.js(48,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. input.js(52,24): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== input.js (2 errors) ==== +==== input.js (3 errors) ==== /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ /** * @template P * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ + ~ +!!! error TS2304: Cannot find name 'P'. /** * @type {StatelessComponent} diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols index 9e8ff6f580..6096d22301 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols @@ -14,9 +14,9 @@ const MyComponent = () => /* @type {any} */(null); >MyComponent : Symbol(MyComponent, Decl(input.js, 9, 5)) MyComponent.defaultProps = { ->MyComponent.defaultProps : Symbol(defaultProps, Decl(input.js, 9, 50)) +>MyComponent.defaultProps : Symbol(defaultProps, Decl(input.js, 4, 23)) >MyComponent : Symbol(MyComponent, Decl(input.js, 9, 5)) ->defaultProps : Symbol(defaultProps, Decl(input.js, 9, 50)) +>defaultProps : Symbol(defaultProps, Decl(input.js, 4, 23)) color: "red" >color : Symbol(color, Decl(input.js, 11, 28)) diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols.diff index 0c95b7d058..372acfcf31 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.symbols.diff @@ -8,15 +8,12 @@ +>MyComponent : Symbol(MyComponent, Decl(input.js, 9, 5)) MyComponent.defaultProps = { -->MyComponent.defaultProps : Symbol(defaultProps, Decl(input.js, 4, 23)) + >MyComponent.defaultProps : Symbol(defaultProps, Decl(input.js, 4, 23)) ->MyComponent : Symbol(MyComponent, Decl(input.js, 9, 5), Decl(input.js, 9, 50)) -->defaultProps : Symbol(defaultProps, Decl(input.js, 4, 23)) -+>MyComponent.defaultProps : Symbol(defaultProps, Decl(input.js, 9, 50)) +>MyComponent : Symbol(MyComponent, Decl(input.js, 9, 5)) -+>defaultProps : Symbol(defaultProps, Decl(input.js, 9, 50)) + >defaultProps : Symbol(defaultProps, Decl(input.js, 4, 23)) color: "red" - >color : Symbol(color, Decl(input.js, 11, 28)) @@= skipped -13, +13 lines =@@ }; diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types index e83844de53..002b1288c6 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types @@ -11,15 +11,15 @@ * @type {StatelessComponent} */ const MyComponent = () => /* @type {any} */(null); ->MyComponent : { (): any; defaultProps: { color: string; }; } +>MyComponent : { (): any; defaultProps?: P; } >() => /* @type {any} */(null) : { (): any; defaultProps: { color: string; }; } >(null) : null MyComponent.defaultProps = { >MyComponent.defaultProps = { color: "red"} : { color: string; } ->MyComponent.defaultProps : { color: string; } ->MyComponent : { (): any; defaultProps: { color: string; }; } ->defaultProps : { color: string; } +>MyComponent.defaultProps : P +>MyComponent : { (): any; defaultProps?: P; } +>defaultProps : P >{ color: "red"} : { color: string; } color: "red" @@ -51,7 +51,7 @@ MyComponent2.defaultProps = { * @type {StatelessComponent} */ const check = MyComponent2; ->check : { (): any; defaultProps: { color: string; }; } +>check : { (): any; defaultProps?: P; } >MyComponent2 : { (): any; defaultProps: { color: string; }; } /** @@ -59,8 +59,8 @@ const check = MyComponent2; * @param {{ props: MyComponentProps }} p */ function expectLiteral(p) {} ->expectLiteral : (p: any) => void ->p : any +>expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void +>p : { props: { color: "blue" | "red"; }; } function foo() { >foo : () => void @@ -79,7 +79,7 @@ function foo() { expectLiteral(this); >expectLiteral(this) : void ->expectLiteral : (p: any) => void +>expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void >this : any } @@ -100,7 +100,7 @@ module.exports = { expectLiteral({ props: module.exports }); >expectLiteral({ props: module.exports }) : void ->expectLiteral : (p: any) => void +>expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void >{ props: module.exports } : { props: any; } >props : any >module.exports : any diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.types b/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.types index 40716d3972..82846722f7 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.types +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.types @@ -21,7 +21,7 @@ import { symb } from "./types"; * @returns {import("./types").TestSymb} */ export function test() { ->test : () => { (): void; inner[symb]: boolean; } +>test : () => TestSymb function inner() {} >inner : { (): void; inner[symb]: boolean; } diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types index 8f0db308a6..03b13b004b 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc1.types @@ -7,15 +7,16 @@ */ /** @type {NumberLike[]} */export default ([ ]); +>([ ]) : (string | number)[] >([ ]) : undefined[] >[ ] : undefined[] === b.ts === import A from './a' ->A : any[] +>A : (string | number)[] A[0] ->A[0] : any ->A : any[] +>A[0] : string | number +>A : (string | number)[] >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types index 8347487f4e..cf343ba62c 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types @@ -7,15 +7,16 @@ */ export default /** @type {NumberLike[]} */([ ]); ->([ ]) : undefined[] +>([ ]) : (string | number)[] +>[ ] : (string | number)[] >[ ] : undefined[] === b.ts === import A from './a' ->A : any[] +>A : (string | number)[] A[0] ->A[0] : any ->A : any[] +>A[0] : string | number +>A : (string | number)[] >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.types b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.types index d8a79b3b31..859dc355e0 100644 --- a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.types +++ b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.types @@ -7,16 +7,16 @@ * @param {number} 𝑀 */ function foo(𝑚, 𝑀) { ->foo : (𝑚: any, 𝑀: any) => void ->𝑚 : any ->𝑀 : any +>foo : (𝑚: number, 𝑀: number) => void +>𝑚 : number +>𝑀 : number console.log(𝑀 + 𝑚); >console.log(𝑀 + 𝑚) : void >console.log : (...data: any[]) => void >console : Console >log : (...data: any[]) => void ->𝑀 + 𝑚 : any ->𝑀 : any ->𝑚 : any +>𝑀 + 𝑚 : number +>𝑀 : number +>𝑚 : number } diff --git a/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.errors.txt b/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.errors.txt new file mode 100644 index 0000000000..3f5fe39172 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.errors.txt @@ -0,0 +1,15 @@ +usage.js(1,12): error TS2304: Cannot find name 'Bar'. + + +==== interfaces.d.ts (0 errors) ==== + export interface Bar { + prop: string + } + +==== usage.js (1 errors) ==== + /** @type {Bar} */ + ~~~ +!!! error TS2304: Cannot find name 'Bar'. + export let bar; + + /** @typedef {import('./interfaces').Bar} Bar */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.types b/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.types index 8ac7c588a1..fad53ca758 100644 --- a/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.types +++ b/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.types @@ -9,6 +9,6 @@ export interface Bar { === usage.js === /** @type {Bar} */ export let bar; ->bar : any +>bar : Bar /** @typedef {import('./interfaces').Bar} Bar */ diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.symbols b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.symbols index 6beb97fe7a..8918628870 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.symbols @@ -39,11 +39,15 @@ class X extends Test { >super : Symbol(Test, Decl(Test.js, 0, 0)) if (options.test) { +>options.test : Symbol(test, Decl(index.js, 4, 3)) >options : Symbol(options, Decl(index.js, 11, 16)) +>test : Symbol(test, Decl(index.js, 4, 3)) this.test = new options.test(); >this : Symbol(X, Decl(index.js, 0, 33)) +>options.test : Symbol(test, Decl(index.js, 4, 3)) >options : Symbol(options, Decl(index.js, 11, 16)) +>test : Symbol(test, Decl(index.js, 4, 3)) } } } diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.symbols.diff index f3923b5792..23c36473e0 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.symbols.diff @@ -1,20 +1,12 @@ --- old.jsDeclarationEmitDoesNotRenameImport.symbols +++ new.jsDeclarationEmitDoesNotRenameImport.symbols -@@= skipped -38, +38 lines =@@ - >super : Symbol(Test, Decl(Test.js, 0, 0)) - - if (options.test) { -->options.test : Symbol(test, Decl(index.js, 4, 3)) - >options : Symbol(options, Decl(index.js, 11, 16)) -->test : Symbol(test, Decl(index.js, 4, 3)) +@@= skipped -43, +43 lines =@@ + >test : Symbol(test, Decl(index.js, 4, 3)) this.test = new options.test(); ->this.test : Symbol(X.test, Decl(index.js, 13, 27)) >this : Symbol(X, Decl(index.js, 0, 33)) ->test : Symbol(X.test, Decl(index.js, 13, 27)) -->options.test : Symbol(test, Decl(index.js, 4, 3)) + >options.test : Symbol(test, Decl(index.js, 4, 3)) >options : Symbol(options, Decl(index.js, 11, 16)) -->test : Symbol(test, Decl(index.js, 4, 3)) - } - } - } + >test : Symbol(test, Decl(index.js, 4, 3)) diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.types b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.types index 380b84a5d6..7153b102ef 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.types +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.types @@ -33,7 +33,7 @@ class X extends Test { * @param {Options} options */ constructor(options) { ->options : any +>options : Options super(); >super() : void @@ -41,7 +41,7 @@ class X extends Test { if (options.test) { >options.test : any ->options : any +>options : Options >test : any this.test = new options.test(); @@ -51,7 +51,7 @@ class X extends Test { >test : any >new options.test() : any >options.test : any ->options : any +>options : Options >test : any } } diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.types b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.types index 72943a7e96..1dadd19467 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.types +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.types @@ -18,7 +18,7 @@ * @type {A} */ value; ->value : any +>value : A } class C2 extends C1 { @@ -29,7 +29,7 @@ class C2 extends C1 { * @type {A} */ value; ->value : any +>value : A } class C3 extends C1 { @@ -40,6 +40,6 @@ class C3 extends C1 { * @type {A & B} */ value; ->value : any +>value : A & B } diff --git a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt deleted file mode 100644 index 4fabc2c738..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt +++ /dev/null @@ -1,48 +0,0 @@ -index.js(9,49): error TS7006: Parameter 'init' implicitly has an 'any' type. - - -==== package.json (0 errors) ==== - { - "name": "typescript-issue", - "private": true, - "version": "0.0.0", - "type": "module" - } -==== node_modules/@lion/ajax/package.json (0 errors) ==== - { - "name": "@lion/ajax", - "version": "2.0.2", - "type": "module", - "exports": { - ".": { - "types": "./dist-types/src/index.d.ts", - "default": "./src/index.js" - }, - "./docs/*": "./docs/*" - } - } -==== node_modules/@lion/ajax/dist-types/src/index.d.ts (0 errors) ==== - export type LionRequestInit = import('../types/types.js').LionRequestInit; -==== node_modules/@lion/ajax/dist-types/types/types.d.ts (0 errors) ==== - export interface LionRequestInit { - body?: null | Object; - } -==== index.js (1 errors) ==== - /** - * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit - */ - - export class NewAjax { - /** - * @param {LionRequestInit} [init] - */ - case5_unexpectedlyResolvesPathToNodeModules(init) {} - ~~~~ -!!! error TS7006: Parameter 'init' implicitly has an 'any' type. - } - - /** - * @type {(init?: LionRequestInit) => void} - */ - // @ts-expect-error - NewAjax.prototype.case6_unexpectedlyResolvesPathToNodeModules; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types index e7f00dd9c5..da661d7226 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types +++ b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types @@ -21,8 +21,8 @@ export class NewAjax { * @param {LionRequestInit} [init] */ case5_unexpectedlyResolvesPathToNodeModules(init) {} ->case5_unexpectedlyResolvesPathToNodeModules : (init: any) => void ->init : any +>case5_unexpectedlyResolvesPathToNodeModules : (init?: LionRequestInit | undefined) => void +>init : LionRequestInit | undefined } /** diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt index f441eb2c8d..313ac6eb7b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt @@ -2,7 +2,10 @@ enumDef.js(2,6): error TS2339: Property 'UserMetrics' does not exist on type '{} enumDef.js(4,6): error TS2339: Property 'UserMetrics' does not exist on type '{}'. enumDef.js(16,6): error TS2339: Property 'UserMetrics' does not exist on type '{}'. index.js(2,7): error TS2339: Property 'Cls' does not exist on type '{}'. -index.js(8,26): error TS2339: Property 'UserMetrics' does not exist on type '{}'. +index.js(4,17): error TS2503: Cannot find namespace 'Host'. +index.js(8,21): error TS2304: Cannot find name 'Host'. +index.js(13,11): error TS2503: Cannot find namespace 'Host'. +index.js(18,11): error TS2503: Cannot find namespace 'Host'. ==== enumDef.js (3 errors) ==== @@ -30,29 +33,35 @@ index.js(8,26): error TS2339: Property 'UserMetrics' does not exist on type '{}' !!! error TS2339: Property 'UserMetrics' does not exist on type '{}'. x: 12 } -==== index.js (2 errors) ==== +==== index.js (5 errors) ==== var Other = {}; Other.Cls = class { ~~~ !!! error TS2339: Property 'Cls' does not exist on type '{}'. /** * @param {!Host.UserMetrics.Action} p + ~~~~ +!!! error TS2503: Cannot find namespace 'Host'. */ method(p) {} usage() { this.method(Host.UserMetrics.Action.WindowDocked); - ~~~~~~~~~~~ -!!! error TS2339: Property 'UserMetrics' does not exist on type '{}'. + ~~~~ +!!! error TS2304: Cannot find name 'Host'. } } /** * @type {Host.UserMetrics.Bargh} + ~~~~ +!!! error TS2503: Cannot find namespace 'Host'. */ var x = "ok"; /** * @type {Host.UserMetrics.Blah} + ~~~~ +!!! error TS2503: Cannot find namespace 'Host'. */ var y = "ok"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols index 90f61ad2c3..ac90bfca9d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols @@ -2,14 +2,14 @@ === enumDef.js === var Host = {}; ->Host : Symbol(Host, Decl(enumDef.js, 0, 3)) +>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) Host.UserMetrics = {}; ->Host : Symbol(Host, Decl(enumDef.js, 0, 3)) +>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) /** @enum {number} */ Host.UserMetrics.Action = { ->Host : Symbol(Host, Decl(enumDef.js, 0, 3)) +>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) WindowDocked: 1, >WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) @@ -31,7 +31,7 @@ Host.UserMetrics.Action = { * @typedef {string} */ Host.UserMetrics.Blah = { ->Host : Symbol(Host, Decl(enumDef.js, 0, 3)) +>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) x: 12 >x : Symbol(x, Decl(enumDef.js, 15, 25)) @@ -57,7 +57,6 @@ Other.Cls = class { >this.method : Symbol(method, Decl(index.js, 1, 19)) >this : Symbol(Cls, Decl(index.js, 1, 11)) >method : Symbol(method, Decl(index.js, 1, 19)) ->Host : Symbol(Host, Decl(enumDef.js, 0, 3)) } } diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff index 9afcfcb679..517a97f509 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff @@ -5,13 +5,13 @@ === enumDef.js === var Host = {}; ->Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 0, 14), Decl(enumDef.js, 1, 22), Decl(enumDef.js, 8, 2), Decl(enumDef.js, 10, 21)) -+>Host : Symbol(Host, Decl(enumDef.js, 0, 3)) ++>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) Host.UserMetrics = {}; ->Host.UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) ->Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 0, 14), Decl(enumDef.js, 1, 22), Decl(enumDef.js, 8, 2), Decl(enumDef.js, 10, 21)) ->UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) -+>Host : Symbol(Host, Decl(enumDef.js, 0, 3)) ++>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) /** @enum {number} */ Host.UserMetrics.Action = { @@ -20,7 +20,7 @@ ->Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 0, 14), Decl(enumDef.js, 1, 22), Decl(enumDef.js, 8, 2), Decl(enumDef.js, 10, 21)) ->UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) ->Action : Symbol(Host.UserMetrics.Action, Decl(enumDef.js, 1, 22), Decl(enumDef.js, 3, 17), Decl(enumDef.js, 2, 4)) -+>Host : Symbol(Host, Decl(enumDef.js, 0, 3)) ++>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) WindowDocked: 1, >WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) @@ -33,7 +33,7 @@ ->Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 0, 14), Decl(enumDef.js, 1, 22), Decl(enumDef.js, 8, 2), Decl(enumDef.js, 10, 21)) ->UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) ->Blah : Symbol(Host.UserMetrics.Blah, Decl(enumDef.js, 8, 2), Decl(enumDef.js, 15, 17), Decl(enumDef.js, 13, 3)) -+>Host : Symbol(Host, Decl(enumDef.js, 0, 3)) ++>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) x: 12 >x : Symbol(x, Decl(enumDef.js, 15, 25)) @@ -74,7 +74,6 @@ ->Action : Symbol(Host.UserMetrics.Action, Decl(enumDef.js, 1, 22), Decl(enumDef.js, 3, 17), Decl(enumDef.js, 2, 4)) ->WindowDocked : Symbol(WindowDocked, Decl(enumDef.js, 3, 27)) +>method : Symbol(method, Decl(index.js, 1, 19)) -+>Host : Symbol(Host, Decl(enumDef.js, 0, 3)) } } diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types index 3a053ba851..f3d61380fc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types @@ -74,21 +74,21 @@ Other.Cls = class { * @param {!Host.UserMetrics.Action} p */ method(p) {} ->method : (p: any) => void ->p : any +>method : (p: Action) => void +>p : Action usage() { >usage : () => void this.method(Host.UserMetrics.Action.WindowDocked); >this.method(Host.UserMetrics.Action.WindowDocked) : void ->this.method : (p: any) => void +>this.method : (p: Action) => void >this : this ->method : (p: any) => void +>method : (p: Action) => void >Host.UserMetrics.Action.WindowDocked : any >Host.UserMetrics.Action : any >Host.UserMetrics : any ->Host : {} +>Host : any >UserMetrics : any >Action : any >WindowDocked : any @@ -99,13 +99,13 @@ Other.Cls = class { * @type {Host.UserMetrics.Bargh} */ var x = "ok"; ->x : string +>x : Bargh >"ok" : "ok" /** * @type {Host.UserMetrics.Blah} */ var y = "ok"; ->y : string +>y : Blah >"ok" : "ok" diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types index f17480103c..a845130443 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types +++ b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types @@ -30,7 +30,7 @@ cbThing(type => { /** @type {LogEntry} */ const logEntry = { ->logEntry : { time: number; type: any; } +>logEntry : LogEntry >{ time: Date.now(), type, } : { time: number; type: any; } time: Date.now(), diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.types b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.types index 5f2e6574f4..da00b8944d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.types +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.types @@ -6,7 +6,7 @@ class Abcde { /** @type {string} */ x; ->x : any +>x : string } module.exports = { diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.symbols b/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.symbols index 2dfc1c07a7..e3f8506167 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.symbols @@ -27,29 +27,39 @@ function apply(func, thisArg, ...args) { >length : Symbol(length, Decl(_apply.js, 11, 7)) case 0: return func.call(thisArg); +>func.call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) +>call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) case 1: return func.call(thisArg, args[0]); +>func.call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) +>call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) >args : Symbol(args, Decl(_apply.js, 10, 29)) case 2: return func.call(thisArg, args[0], args[1]); +>func.call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) +>call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) >args : Symbol(args, Decl(_apply.js, 10, 29)) >args : Symbol(args, Decl(_apply.js, 10, 29)) case 3: return func.call(thisArg, args[0], args[1], args[2]); +>func.call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) +>call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) >args : Symbol(args, Decl(_apply.js, 10, 29)) >args : Symbol(args, Decl(_apply.js, 10, 29)) >args : Symbol(args, Decl(_apply.js, 10, 29)) } return func.apply(thisArg, args); +>func.apply : Symbol(apply, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) +>apply : Symbol(apply, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) >args : Symbol(args, Decl(_apply.js, 10, 29)) } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.symbols.diff index 528cc70ef5..b6fe49ba6d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.symbols.diff @@ -15,29 +15,37 @@ case 0: return func.call(thisArg); ->func.call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) ++>func.call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) ->call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) ++>call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) case 1: return func.call(thisArg, args[0]); ->func.call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) ++>func.call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) ->call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) ++>call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) >args : Symbol(args, Decl(_apply.js, 10, 29)) case 2: return func.call(thisArg, args[0], args[1]); ->func.call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) ++>func.call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) ->call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) ++>call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) >args : Symbol(args, Decl(_apply.js, 10, 29)) >args : Symbol(args, Decl(_apply.js, 10, 29)) case 3: return func.call(thisArg, args[0], args[1], args[2]); ->func.call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) ++>func.call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) ->call : Symbol(Function.call, Decl(lib.es5.d.ts, --, --)) ++>call : Symbol(call, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) >args : Symbol(args, Decl(_apply.js, 10, 29)) >args : Symbol(args, Decl(_apply.js, 10, 29)) @@ -45,8 +53,10 @@ } return func.apply(thisArg, args); ->func.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) ++>func.apply : Symbol(apply, Decl(lib.es5.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 10, 15)) ->apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) ++>apply : Symbol(apply, Decl(lib.es5.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) >args : Symbol(args, Decl(_apply.js, 10, 29)) } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.types index 35f0505a2b..ae2faddc79 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationRestParamJsDocFunction.types @@ -12,8 +12,8 @@ * @returns {*} Returns the result of `func`. */ function apply(func, thisArg, ...args) { ->apply : (func: any, thisArg: any, ...args: any[]) => any ->func : any +>apply : (func: Function, thisArg: any, ...args: any[]) => any +>func : Function >thisArg : any >args : any[] @@ -29,17 +29,17 @@ function apply(func, thisArg, ...args) { case 0: return func.call(thisArg); >0 : 0 >func.call(thisArg) : any ->func.call : any ->func : any ->call : any +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any +>func : Function +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any case 1: return func.call(thisArg, args[0]); >1 : 1 >func.call(thisArg, args[0]) : any ->func.call : any ->func : any ->call : any +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any +>func : Function +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any >args : any[] @@ -48,9 +48,9 @@ function apply(func, thisArg, ...args) { case 2: return func.call(thisArg, args[0], args[1]); >2 : 2 >func.call(thisArg, args[0], args[1]) : any ->func.call : any ->func : any ->call : any +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any +>func : Function +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any >args : any[] @@ -62,9 +62,9 @@ function apply(func, thisArg, ...args) { case 3: return func.call(thisArg, args[0], args[1], args[2]); >3 : 3 >func.call(thisArg, args[0], args[1], args[2]) : any ->func.call : any ->func : any ->call : any +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any +>func : Function +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any >args : any[] @@ -78,13 +78,13 @@ function apply(func, thisArg, ...args) { } return func.apply(thisArg, args); >func.apply(thisArg, args) : any ->func.apply : any ->func : any ->apply : any +>func.apply : (this: Function, thisArg: any, argArray?: any) => any +>func : Function +>apply : (this: Function, thisArg: any, argArray?: any) => any >thisArg : any >args : any[] } export default apply; ->apply : (func: any, thisArg: any, ...args: any[]) => any +>apply : (func: Function, thisArg: any, ...args: any[]) => any diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.types index 7e106890a7..42c5386bac 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.types @@ -6,5 +6,5 @@ * @type {string} */ var v; ->v : any +>v : number diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.symbols b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.symbols index c34e289aaa..06d3e43822 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.symbols @@ -70,7 +70,9 @@ function flatMap(array, iterable = identity) { for (let i = 0; i < array.length; i += 1) { >i : Symbol(i, Decl(jsFileFunctionOverloads.js, 52, 10)) >i : Symbol(i, Decl(jsFileFunctionOverloads.js, 52, 10)) +>array.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >array : Symbol(array, Decl(jsFileFunctionOverloads.js, 49, 17)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >i : Symbol(i, Decl(jsFileFunctionOverloads.js, 52, 10)) result.push(.../** @type {unknown[]} */(iterable(array[i]))); diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.symbols.diff index c8c88cff47..f653c587e3 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.symbols.diff @@ -5,8 +5,10 @@ >i : Symbol(i, Decl(jsFileFunctionOverloads.js, 52, 10)) >i : Symbol(i, Decl(jsFileFunctionOverloads.js, 52, 10)) ->array.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) ++>array.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >array : Symbol(array, Decl(jsFileFunctionOverloads.js, 49, 17)) ->length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >i : Symbol(i, Decl(jsFileFunctionOverloads.js, 52, 10)) result.push(.../** @type {unknown[]} */(iterable(array[i]))); diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types index b38bffc913..112ad7ff6f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types @@ -21,12 +21,12 @@ * @returns {string} */ function getTypeName(x) { ->getTypeName : (x: any) => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->x : any +>getTypeName : (x: unknown) => string +>x : unknown return typeof x; >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->x : any +>x : unknown } /** @@ -35,10 +35,10 @@ * @returns {T} */ const identity = x => x; ->identity : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>identity : (x: T) => T +>x => x : (x: T) => T +>x : T +>x : T /** * @template T @@ -60,14 +60,14 @@ const identity = x => x; * @returns {unknown[]} */ function flatMap(array, iterable = identity) { ->flatMap : (array: any, iterable?: (x: any) => any) => any[] ->array : any ->iterable : (x: any) => any ->identity : (x: any) => any +>flatMap : (array: unknown[], iterable?: (x: unknown) => unknown) => unknown[] +>array : unknown[] +>iterable : (x: unknown) => unknown +>identity : (x: T) => T /** @type {unknown[]} */ const result = []; ->result : any[] +>result : unknown[] >[] : undefined[] for (let i = 0; i < array.length; i += 1) { @@ -75,27 +75,28 @@ function flatMap(array, iterable = identity) { >0 : 0 >i < array.length : boolean >i : number ->array.length : any ->array : any ->length : any +>array.length : number +>array : unknown[] +>length : number >i += 1 : number >i : number >1 : 1 result.push(.../** @type {unknown[]} */(iterable(array[i]))); >result.push(.../** @type {unknown[]} */(iterable(array[i]))) : number ->result.push : (...items: any[]) => number ->result : any[] ->push : (...items: any[]) => number ->.../** @type {unknown[]} */(iterable(array[i])) : any ->(iterable(array[i])) : any ->iterable(array[i]) : any ->iterable : (x: any) => any ->array[i] : any ->array : any +>result.push : (...items: unknown[]) => number +>result : unknown[] +>push : (...items: unknown[]) => number +>.../** @type {unknown[]} */(iterable(array[i])) : unknown +>(iterable(array[i])) : unknown[] +>iterable(array[i]) : unknown[] +>iterable(array[i]) : unknown +>iterable : (x: unknown) => unknown +>array[i] : unknown +>array : unknown[] >i : number } return result; ->result : any[] +>result : unknown[] } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.symbols b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.symbols index ad011c6104..226798dfdc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.symbols @@ -65,7 +65,9 @@ function flatMap(array, iterable = identity) { for (let i = 0; i < array.length; i += 1) { >i : Symbol(i, Decl(jsFileFunctionOverloads2.js, 47, 10)) >i : Symbol(i, Decl(jsFileFunctionOverloads2.js, 47, 10)) +>array.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >array : Symbol(array, Decl(jsFileFunctionOverloads2.js, 44, 17)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >i : Symbol(i, Decl(jsFileFunctionOverloads2.js, 47, 10)) result.push(.../** @type {unknown[]} */(iterable(array[i]))); diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.symbols.diff index 397b980305..3a61f98336 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.symbols.diff @@ -5,8 +5,10 @@ >i : Symbol(i, Decl(jsFileFunctionOverloads2.js, 47, 10)) >i : Symbol(i, Decl(jsFileFunctionOverloads2.js, 47, 10)) ->array.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) ++>array.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >array : Symbol(array, Decl(jsFileFunctionOverloads2.js, 44, 17)) ->length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >i : Symbol(i, Decl(jsFileFunctionOverloads2.js, 47, 10)) result.push(.../** @type {unknown[]} */(iterable(array[i]))); diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types index ea16329399..240501cb14 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types @@ -19,12 +19,12 @@ * @returns {string} */ function getTypeName(x) { ->getTypeName : (x: any) => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->x : any +>getTypeName : (x: unknown) => string +>x : unknown return typeof x; >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->x : any +>x : unknown } /** @@ -33,10 +33,10 @@ * @returns {T} */ const identity = x => x; ->identity : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>identity : (x: T) => T +>x => x : (x: T) => T +>x : T +>x : T /** * @template T @@ -55,14 +55,14 @@ const identity = x => x; * @returns {unknown[]} */ function flatMap(array, iterable = identity) { ->flatMap : (array: any, iterable?: (x: any) => any) => any[] ->array : any ->iterable : (x: any) => any ->identity : (x: any) => any +>flatMap : (array: unknown[], iterable?: (x: unknown) => unknown) => unknown[] +>array : unknown[] +>iterable : (x: unknown) => unknown +>identity : (x: T) => T /** @type {unknown[]} */ const result = []; ->result : any[] +>result : unknown[] >[] : undefined[] for (let i = 0; i < array.length; i += 1) { @@ -70,27 +70,28 @@ function flatMap(array, iterable = identity) { >0 : 0 >i < array.length : boolean >i : number ->array.length : any ->array : any ->length : any +>array.length : number +>array : unknown[] +>length : number >i += 1 : number >i : number >1 : 1 result.push(.../** @type {unknown[]} */(iterable(array[i]))); >result.push(.../** @type {unknown[]} */(iterable(array[i]))) : number ->result.push : (...items: any[]) => number ->result : any[] ->push : (...items: any[]) => number ->.../** @type {unknown[]} */(iterable(array[i])) : any ->(iterable(array[i])) : any ->iterable(array[i]) : any ->iterable : (x: any) => any ->array[i] : any ->array : any +>result.push : (...items: unknown[]) => number +>result : unknown[] +>push : (...items: unknown[]) => number +>.../** @type {unknown[]} */(iterable(array[i])) : unknown +>(iterable(array[i])) : unknown[] +>iterable(array[i]) : unknown[] +>iterable(array[i]) : unknown +>iterable : (x: unknown) => unknown +>array[i] : unknown +>array : unknown[] >i : number } return result; ->result : any[] +>result : unknown[] } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt index 195fc4054f..afd42d87b7 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt @@ -1,5 +1,5 @@ -index.js(9,10): error TS7006: Parameter 'obj' implicitly has an 'any' type. -index.js(9,15): error TS7006: Parameter 'vm' implicitly has an 'any' type. +index.js(11,12): error TS2339: Property 'objects' does not exist on type 'object'. +index.js(13,26): error TS2698: Spread types may only be created from object types. ==== dash.d.ts (0 errors) ==== @@ -22,14 +22,14 @@ index.js(9,15): error TS7006: Parameter 'vm' implicitly has an 'any' type. * @param {object} vm */ test(obj, vm) { - ~~~ -!!! error TS7006: Parameter 'obj' implicitly has an 'any' type. - ~~ -!!! error TS7006: Parameter 'vm' implicitly has an 'any' type. let index = 0; vm.objects = _.mapValues( + ~~~~~~~ +!!! error TS2339: Property 'objects' does not exist on type 'object'. obj, object => ({ ...object, [INDEX_FIELD]: index++ }), + ~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. ); } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.types b/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.types index 634d15ef90..9d91b4b1de 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.types @@ -39,33 +39,33 @@ export class Test { * @param {object} vm */ test(obj, vm) { ->test : (obj: any, vm: any) => void ->obj : any ->vm : any +>test : (obj: object, vm: object) => void +>obj : object +>vm : object let index = 0; >index : number >0 : 0 vm.objects = _.mapValues( ->vm.objects = _.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : { [x: string]: any; } +>vm.objects = _.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : object >vm.objects : any ->vm : any +>vm : object >objects : any ->_.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : { [x: string]: any; } +>_.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : object >_.mapValues : (obj: T | null | undefined, callback: ObjectIterator) => { [P in keyof T]: TResult; } >_ : LoDashStatic >mapValues : (obj: T | null | undefined, callback: ObjectIterator) => { [P in keyof T]: TResult; } obj, ->obj : any +>obj : object object => ({ ...object, [INDEX_FIELD]: index++ }), ->object => ({ ...object, [INDEX_FIELD]: index++ }) : (object: any) => any ->object : any +>object => ({ ...object, [INDEX_FIELD]: index++ }) : (object: never) => any +>object : never >({ ...object, [INDEX_FIELD]: index++ }) : any >{ ...object, [INDEX_FIELD]: index++ } : any ->object : any +>object : never >[INDEX_FIELD] : number >INDEX_FIELD : "__INDEX" >index++ : number diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt index 942187b6f0..89bd8e1449 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt @@ -1,7 +1,7 @@ -jsFileMethodOverloads.js(9,10): error TS2339: Property 'value' does not exist on type 'Example'. -jsFileMethodOverloads.js(26,24): error TS2339: Property 'value' does not exist on type 'Example'. -jsFileMethodOverloads.js(44,25): error TS2339: Property 'value' does not exist on type 'Example'. -jsFileMethodOverloads.js(44,39): error TS2339: Property 'value' does not exist on type 'Example'. +jsFileMethodOverloads.js(9,10): error TS2339: Property 'value' does not exist on type 'Example'. +jsFileMethodOverloads.js(26,24): error TS2339: Property 'value' does not exist on type 'Example'. +jsFileMethodOverloads.js(44,25): error TS2339: Property 'value' does not exist on type 'Example'. +jsFileMethodOverloads.js(44,39): error TS2339: Property 'value' does not exist on type 'Example'. ==== jsFileMethodOverloads.js (4 errors) ==== @@ -15,7 +15,7 @@ jsFileMethodOverloads.js(44,39): error TS2339: Property 'value' does not exist o constructor(value) { this.value = value; ~~~~~ -!!! error TS2339: Property 'value' does not exist on type 'Example'. +!!! error TS2339: Property 'value' does not exist on type 'Example'. } /** @@ -34,7 +34,7 @@ jsFileMethodOverloads.js(44,39): error TS2339: Property 'value' does not exist o getTypeName() { return typeof this.value; ~~~~~ -!!! error TS2339: Property 'value' does not exist on type 'Example'. +!!! error TS2339: Property 'value' does not exist on type 'Example'. } /** @@ -54,9 +54,9 @@ jsFileMethodOverloads.js(44,39): error TS2339: Property 'value' does not exist o transform(fn) { return fn ? fn(this.value) : this.value; ~~~~~ -!!! error TS2339: Property 'value' does not exist on type 'Example'. +!!! error TS2339: Property 'value' does not exist on type 'Example'. ~~~~~ -!!! error TS2339: Property 'value' does not exist on type 'Example'. +!!! error TS2339: Property 'value' does not exist on type 'Example'. } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.types b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.types index 45753f8947..bc65bc8731 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.types @@ -5,20 +5,20 @@ * @template T */ class Example { ->Example : Example +>Example : Example /** * @param {T} value */ constructor(value) { ->value : any +>value : T this.value = value; ->this.value = value : any +>this.value = value : T >this.value : any >this : this >value : any ->value : any +>value : T } /** @@ -35,7 +35,7 @@ * @returns {string} */ getTypeName() { ->getTypeName : () => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>getTypeName : () => string return typeof this.value; >typeof this.value : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" @@ -59,14 +59,14 @@ * @returns {unknown} */ transform(fn) { ->transform : (fn: any) => any ->fn : any +>transform : (fn?: (y: T) => unknown) => unknown +>fn : (y: T) => unknown return fn ? fn(this.value) : this.value; >fn ? fn(this.value) : this.value : any ->fn : any ->fn(this.value) : any ->fn : any +>fn : (y: T) => unknown +>fn(this.value) : unknown +>fn : (y: T) => unknown >this.value : any >this : this >value : any diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt index 4e6cf1d02b..1a58e0d84c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt @@ -1,7 +1,7 @@ -jsFileMethodOverloads2.js(10,10): error TS2339: Property 'value' does not exist on type 'Example'. -jsFileMethodOverloads2.js(25,24): error TS2339: Property 'value' does not exist on type 'Example'. -jsFileMethodOverloads2.js(41,25): error TS2339: Property 'value' does not exist on type 'Example'. -jsFileMethodOverloads2.js(41,39): error TS2339: Property 'value' does not exist on type 'Example'. +jsFileMethodOverloads2.js(10,10): error TS2339: Property 'value' does not exist on type 'Example'. +jsFileMethodOverloads2.js(25,24): error TS2339: Property 'value' does not exist on type 'Example'. +jsFileMethodOverloads2.js(41,25): error TS2339: Property 'value' does not exist on type 'Example'. +jsFileMethodOverloads2.js(41,39): error TS2339: Property 'value' does not exist on type 'Example'. ==== jsFileMethodOverloads2.js (4 errors) ==== @@ -16,7 +16,7 @@ jsFileMethodOverloads2.js(41,39): error TS2339: Property 'value' does not exist constructor(value) { this.value = value; ~~~~~ -!!! error TS2339: Property 'value' does not exist on type 'Example'. +!!! error TS2339: Property 'value' does not exist on type 'Example'. } /** @@ -33,7 +33,7 @@ jsFileMethodOverloads2.js(41,39): error TS2339: Property 'value' does not exist getTypeName() { return typeof this.value; ~~~~~ -!!! error TS2339: Property 'value' does not exist on type 'Example'. +!!! error TS2339: Property 'value' does not exist on type 'Example'. } /** @@ -51,9 +51,9 @@ jsFileMethodOverloads2.js(41,39): error TS2339: Property 'value' does not exist transform(fn) { return fn ? fn(this.value) : this.value; ~~~~~ -!!! error TS2339: Property 'value' does not exist on type 'Example'. +!!! error TS2339: Property 'value' does not exist on type 'Example'. ~~~~~ -!!! error TS2339: Property 'value' does not exist on type 'Example'. +!!! error TS2339: Property 'value' does not exist on type 'Example'. } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types index ec63a0dce3..070ca77f5a 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types @@ -6,20 +6,20 @@ * @template T */ class Example { ->Example : Example +>Example : Example /** * @param {T} value */ constructor(value) { ->value : any +>value : T this.value = value; ->this.value = value : any +>this.value = value : T >this.value : any >this : this >value : any ->value : any +>value : T } /** @@ -34,7 +34,7 @@ * @returns {string} */ getTypeName() { ->getTypeName : () => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>getTypeName : () => string return typeof this.value; >typeof this.value : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" @@ -56,14 +56,14 @@ * @returns {unknown} */ transform(fn) { ->transform : (fn: any) => any ->fn : any +>transform : (fn?: (y: T) => unknown) => unknown +>fn : (y: T) => unknown return fn ? fn(this.value) : this.value; >fn ? fn(this.value) : this.value : any ->fn : any ->fn(this.value) : any ->fn : any +>fn : (y: T) => unknown +>fn(this.value) : unknown +>fn : (y: T) => unknown >this.value : any >this : this >value : any diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt deleted file mode 100644 index a97d142c96..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -/a.js(15,13): error TS7006: Parameter 'x' implicitly has an 'any' type. - - -==== /a.js (1 errors) ==== - /** - * @overload - * @param {number} x - */ - - /** - * @overload - * @param {string} x - */ - - /** - * @param {string | number} x - * @returns {string | number} - */ - function id(x) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - return x; - } - - export let a = id(123); - export let b = id("hello"); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.types b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.types index e1287e3d94..ce1d43bf3e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.types @@ -16,22 +16,22 @@ * @returns {string | number} */ function id(x) { ->id : (x: any) => any ->x : any +>id : (x: string | number) => string | number +>x : string | number return x; ->x : any +>x : string | number } export let a = id(123); ->a : any ->id(123) : any ->id : (x: any) => any +>a : string | number +>id(123) : string | number +>id : (x: string | number) => string | number >123 : 123 export let b = id("hello"); ->b : any ->id("hello") : any ->id : (x: any) => any +>b : string | number +>id("hello") : string | number +>id : (x: string | number) => string | number >"hello" : "hello" diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.types b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.types index 3fa2a07bb4..ac868dedf5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.types @@ -19,8 +19,8 @@ * @param {number} [b] */ export const foo = function (a, b) { } ->foo : (a: any, b: any) => void ->function (a, b) { } : (a: any, b: any) => void ->a : any ->b : any +>foo : (a: string | number, b?: number) => void +>function (a, b) { } : (a: string | number, b?: number) => void +>a : string | number +>b : number diff --git a/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.types b/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.types index b2876f7741..19126cb8a8 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.types @@ -11,7 +11,7 @@ import { E } from "./a"; /** @type {E} */ const e = E.A; ->e : E.A +>e : E >E.A : E >E : typeof E >A : E diff --git a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt new file mode 100644 index 0000000000..1d9b3df6af --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt @@ -0,0 +1,69 @@ +jsdocArrayObjectPromiseImplicitAny.js(1,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). +jsdocArrayObjectPromiseImplicitAny.js(8,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). +jsdocArrayObjectPromiseImplicitAny.js(9,13): error TS2314: Generic type 'T[]' requires 1 type argument(s). +jsdocArrayObjectPromiseImplicitAny.js(15,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). +jsdocArrayObjectPromiseImplicitAny.js(22,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). +jsdocArrayObjectPromiseImplicitAny.js(23,13): error TS2314: Generic type 'Promise' requires 1 type argument(s). +jsdocArrayObjectPromiseImplicitAny.js(30,18): error TS2322: Type 'number' is not assignable to type '() => Object'. +jsdocArrayObjectPromiseImplicitAny.js(32,12): error TS2315: Type 'Object' is not generic. + + +==== jsdocArrayObjectPromiseImplicitAny.js (8 errors) ==== + /** @type {Array} */ + ~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). + var anyArray = [5]; + + /** @type {Array} */ + var numberArray = [5]; + + /** + * @param {Array} arr + ~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). + * @return {Array} + ~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). + */ + function returnAnyArray(arr) { + return arr; + } + + /** @type {Promise} */ + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + var anyPromise = Promise.resolve(5); + + /** @type {Promise} */ + var numberPromise = Promise.resolve(5); + + /** + * @param {Promise} pr + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + * @return {Promise} + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + */ + function returnAnyPromise(pr) { + return pr; + } + + /** @type {Object} */ + var anyObject = {valueOf: 1}; // not an error since assigning to any. + ~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type '() => Object'. + + /** @type {Object} */ + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + var paramedObject = {valueOf: 1}; + + /** + * @param {Object} obj + * @return {Object} + */ + function returnAnyObject(obj) { + return obj; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.types b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.types index 297a113198..bc48d858c0 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.types @@ -3,7 +3,7 @@ === jsdocArrayObjectPromiseImplicitAny.js === /** @type {Array} */ var anyArray = [5]; ->anyArray : number[] +>anyArray : any >[5] : number[] >5 : 5 @@ -27,7 +27,7 @@ function returnAnyArray(arr) { /** @type {Promise} */ var anyPromise = Promise.resolve(5); ->anyPromise : Promise +>anyPromise : any >Promise.resolve(5) : Promise >Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } >Promise : PromiseConstructor @@ -57,14 +57,14 @@ function returnAnyPromise(pr) { /** @type {Object} */ var anyObject = {valueOf: 1}; // not an error since assigning to any. ->anyObject : { valueOf: number; } +>anyObject : Object >{valueOf: 1} : { valueOf: number; } >valueOf : number >1 : 1 /** @type {Object} */ var paramedObject = {valueOf: 1}; ->paramedObject : { valueOf: number; } +>paramedObject : any >{valueOf: 1} : { valueOf: number; } >valueOf : number >1 : 1 @@ -74,10 +74,10 @@ var paramedObject = {valueOf: 1}; * @return {Object} */ function returnAnyObject(obj) { ->returnAnyObject : (obj: any) => any ->obj : any +>returnAnyObject : (obj: Object) => Object +>obj : Object return obj; ->obj : any +>obj : Object } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt index df10787ae2..c88b521e45 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt @@ -1,10 +1,17 @@ -jsdocArrayObjectPromiseNoImplicitAny.js(11,28): error TS7006: Parameter 'arr' implicitly has an 'any' type. -jsdocArrayObjectPromiseNoImplicitAny.js(25,30): error TS7006: Parameter 'pr' implicitly has an 'any' type. -jsdocArrayObjectPromiseNoImplicitAny.js(39,29): error TS7006: Parameter 'obj' implicitly has an 'any' type. +jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS2314: Generic type 'T[]' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS2314: Generic type 'Promise' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(30,21): error TS2322: Type 'number' is not assignable to type '() => Object'. +jsdocArrayObjectPromiseNoImplicitAny.js(32,12): error TS2315: Type 'Object' is not generic. -==== jsdocArrayObjectPromiseNoImplicitAny.js (3 errors) ==== +==== jsdocArrayObjectPromiseNoImplicitAny.js (8 errors) ==== /** @type {Array} */ + ~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). var notAnyArray = [5]; /** @type {Array} */ @@ -12,15 +19,19 @@ jsdocArrayObjectPromiseNoImplicitAny.js(39,29): error TS7006: Parameter 'obj' im /** * @param {Array} arr + ~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). * @return {Array} + ~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). */ function returnNotAnyArray(arr) { - ~~~ -!!! error TS7006: Parameter 'arr' implicitly has an 'any' type. return arr; } /** @type {Promise} */ + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). var notAnyPromise = Promise.resolve(5); /** @type {Promise} */ @@ -28,18 +39,24 @@ jsdocArrayObjectPromiseNoImplicitAny.js(39,29): error TS7006: Parameter 'obj' im /** * @param {Promise} pr + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). * @return {Promise} + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). */ function returnNotAnyPromise(pr) { - ~~ -!!! error TS7006: Parameter 'pr' implicitly has an 'any' type. return pr; } /** @type {Object} */ var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. + ~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type '() => Object'. /** @type {Object} */ + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. var paramedObject = {valueOf: 1}; /** @@ -47,8 +64,6 @@ jsdocArrayObjectPromiseNoImplicitAny.js(39,29): error TS7006: Parameter 'obj' im * @return {Object} */ function returnNotAnyObject(obj) { - ~~~ -!!! error TS7006: Parameter 'obj' implicitly has an 'any' type. return obj; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.types b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.types index 86c778286f..87eee09470 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.types @@ -3,7 +3,7 @@ === jsdocArrayObjectPromiseNoImplicitAny.js === /** @type {Array} */ var notAnyArray = [5]; ->notAnyArray : number[] +>notAnyArray : any >[5] : number[] >5 : 5 @@ -27,7 +27,7 @@ function returnNotAnyArray(arr) { /** @type {Promise} */ var notAnyPromise = Promise.resolve(5); ->notAnyPromise : Promise +>notAnyPromise : any >Promise.resolve(5) : Promise >Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } >Promise : PromiseConstructor @@ -57,14 +57,14 @@ function returnNotAnyPromise(pr) { /** @type {Object} */ var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. ->notAnyObject : { valueOf: number; } +>notAnyObject : Object >{valueOf: 1} : { valueOf: number; } >valueOf : number >1 : 1 /** @type {Object} */ var paramedObject = {valueOf: 1}; ->paramedObject : { valueOf: number; } +>paramedObject : any >{valueOf: 1} : { valueOf: number; } >valueOf : number >1 : 1 @@ -74,10 +74,10 @@ var paramedObject = {valueOf: 1}; * @return {Object} */ function returnNotAnyObject(obj) { ->returnNotAnyObject : (obj: any) => any ->obj : any +>returnNotAnyObject : (obj: Object) => Object +>obj : Object return obj; ->obj : any +>obj : Object } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt index 9697d6f2aa..d8a5fdf957 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt @@ -1,7 +1,8 @@ index.js(12,14): error TS7006: Parameter 'arg' implicitly has an 'any' type. +index.js(20,16): error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== /** @type () => string */ function fn1() { return 42; @@ -24,4 +25,7 @@ index.js(12,14): error TS7006: Parameter 'arg' implicitly has an 'any' type. /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ const obj2 = { type: "other", prop: 10 }; + ~~~~ +!!! error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. +!!! related TS6500 index.js:19:14: The expected type comes from property 'type' which is declared here on type '({ type: "foo"; } | { type: "bar"; }) & { prop: number; }' \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.types b/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.types index 3ac9df5434..7b33e57538 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.types @@ -28,18 +28,18 @@ function fn3(arg) { /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ const obj1 = { type: "foo", prop: 10 }; ->obj1 : { type: string; prop: number; } ->{ type: "foo", prop: 10 } : { type: string; prop: number; } ->type : string +>obj1 : ({ type: "foo"; } | { type: "bar"; }) & { prop: number; } +>{ type: "foo", prop: 10 } : { type: "foo"; prop: number; } +>type : "foo" >"foo" : "foo" >prop : number >10 : 10 /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ const obj2 = { type: "other", prop: 10 }; ->obj2 : { type: string; prop: number; } ->{ type: "other", prop: 10 } : { type: string; prop: number; } ->type : string +>obj2 : ({ type: "foo"; } | { type: "bar"; }) & { prop: number; } +>{ type: "other", prop: 10 } : { type: "other"; prop: number; } +>type : "other" >"other" : "other" >prop : number >10 : 10 diff --git a/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt new file mode 100644 index 0000000000..79546958ff --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt @@ -0,0 +1,15 @@ +/a.js(5,12): error TS2304: Cannot find name 'B'. + + +==== /a.js (1 errors) ==== + /** + * @template T + * @callback B + */ + /** @type {B} */ + ~ +!!! error TS2304: Cannot find name 'B'. + let b; + b(); + b(1); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.types b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.types index bf983c11a3..c4f0ae9435 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.types @@ -7,14 +7,14 @@ */ /** @type {B} */ let b; ->b : any +>b : B b(); >b() : any ->b : any +>b : B b(1); >b(1) : any ->b : any +>b : B >1 : 1 diff --git a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt index 6e095e3bd3..ae966c3990 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt @@ -1,4 +1,4 @@ -/a.js(5,12): error TS7006: Parameter 'p' implicitly has an 'any' type. +/a.js(4,13): error TS2314: Generic type 'C' requires 1 type argument(s). ==== /a.js (1 errors) ==== @@ -6,7 +6,7 @@ class C {} /** @param {C} p */ + ~ +!!! error TS2314: Generic type 'C' requires 1 type argument(s). function f(p) {} - ~ -!!! error TS7006: Parameter 'p' implicitly has an 'any' type. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.types b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.types index b458dedce9..4ea043d906 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.types @@ -3,7 +3,7 @@ === /a.js === /** @template T */ class C {} ->C : C +>C : C /** @param {C} p */ function f(p) {} diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt index 1164ca5f46..eef47833f9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt @@ -1,21 +1,15 @@ -/a.js(5,21): error TS7006: Parameter 'x' implicitly has an 'any' type. -/a.js(5,24): error TS7006: Parameter 'y' implicitly has an 'any' type. /a.js(6,11): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. /a.js(7,16): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. /a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. /a.js(10,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -==== /a.js (6 errors) ==== +==== /a.js (4 errors) ==== /** * @param {number | undefined} x * @param {number | undefined} y */ export function Foo(x, y) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'y' implicitly has an 'any' type. if (!(this instanceof Foo)) { ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.types b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.types index 63a9c61048..a39bf86359 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.types @@ -6,35 +6,35 @@ * @param {number | undefined} y */ export function Foo(x, y) { ->Foo : (x: any, y: any) => any ->x : any ->y : any +>Foo : (x: number | undefined, y: number | undefined) => any +>x : number | undefined +>y : number | undefined if (!(this instanceof Foo)) { >!(this instanceof Foo) : boolean >(this instanceof Foo) : boolean >this instanceof Foo : boolean >this : any ->Foo : (x: any, y: any) => any +>Foo : (x: number | undefined, y: number | undefined) => any return new Foo(x, y); >new Foo(x, y) : any ->Foo : (x: any, y: any) => any ->x : any ->y : any +>Foo : (x: number | undefined, y: number | undefined) => any +>x : number | undefined +>y : number | undefined } this.x = x; ->this.x = x : any +>this.x = x : number | undefined >this.x : any >this : any >x : any ->x : any +>x : number | undefined this.y = y; ->this.y = y : any +>this.y = y : number | undefined >this.y : any >this : any >y : any ->y : any +>y : number | undefined } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt new file mode 100644 index 0000000000..4147bce1d5 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt @@ -0,0 +1,9 @@ +/a.js(1,13): error TS1098: Type parameter list cannot be empty. + + +==== /a.js (1 errors) ==== + /** @param {<} x */ + ~~ +!!! error TS1098: Type parameter list cannot be empty. + function f(x) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.types b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.types index 6c6737f256..022619f274 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.types @@ -3,6 +3,6 @@ === /a.js === /** @param {<} x */ function f(x) {} ->f : (x: any) => void ->x : any +>f : (x: () => any) => void +>x : () => any diff --git a/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt new file mode 100644 index 0000000000..018ec07e52 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt @@ -0,0 +1,18 @@ +/a.js(2,9): error TS1092: Type parameters cannot appear on a constructor declaration. +/a.js(6,18): error TS1093: Type annotation cannot appear on a constructor declaration. + + +==== /a.js (2 errors) ==== + class C { + /** @template T */ + ~~~~~~~~~~~~ +!!! error TS1092: Type parameters cannot appear on a constructor declaration. + constructor() { } + } + class D { + /** @return {number} */ + ~~~~~~ +!!! error TS1093: Type annotation cannot appear on a constructor declaration. + constructor() {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.errors.txt new file mode 100644 index 0000000000..ba53f8f4d7 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.errors.txt @@ -0,0 +1,16 @@ +Main.js(2,49): error TS2694: Namespace '"GeometryType"' has no exported member 'default'. + + +==== GeometryType.d.ts (0 errors) ==== + declare namespace _default { + export const POINT: string; + } + export default _default; + +==== Main.js (1 errors) ==== + export default function () { + return /** @type {import('./GeometryType.js').default} */ ('Point'); + ~~~~~~~ +!!! error TS2694: Namespace '"GeometryType"' has no exported member 'default'. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types index 61a78c7d38..c851fa7232 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types @@ -13,7 +13,8 @@ export default _default; === Main.js === export default function () { return /** @type {import('./GeometryType.js').default} */ ('Point'); ->('Point') : "Point" +>('Point') : any +>'Point' : any >'Point' : "Point" } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.types b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.types index 71d6a2daa6..5dfcd2bb11 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.types @@ -12,5 +12,5 @@ export class MyClass { */ /** @type {options} */ let v; ->v : any +>v : options diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.errors.txt deleted file mode 100644 index e65be0d9ba..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -/a.js(3,9): error TS7006: Parameter 'x' implicitly has an 'any' type. - - -==== /a.js (1 errors) ==== - class Foo { - /**@param {string} x */ - m = x => x.toLowerCase(); - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.symbols b/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.symbols index 45e5696a1a..8e62ab992a 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.symbols @@ -8,6 +8,8 @@ class Foo { m = x => x.toLowerCase(); >m : Symbol(m, Decl(a.js, 0, 11)) >x : Symbol(x, Decl(a.js, 2, 7)) +>x.toLowerCase : Symbol(toLowerCase, Decl(lib.es5.d.ts, --, --)) >x : Symbol(x, Decl(a.js, 2, 7)) +>toLowerCase : Symbol(toLowerCase, Decl(lib.es5.d.ts, --, --)) } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.symbols.diff index 9d7a20e19d..da85b80884 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.symbols.diff @@ -8,7 +8,9 @@ +>m : Symbol(m, Decl(a.js, 0, 11)) >x : Symbol(x, Decl(a.js, 2, 7)) ->x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) ++>x.toLowerCase : Symbol(toLowerCase, Decl(lib.es5.d.ts, --, --)) >x : Symbol(x, Decl(a.js, 2, 7)) ->toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) ++>toLowerCase : Symbol(toLowerCase, Decl(lib.es5.d.ts, --, --)) } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.types b/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.types index f70e8dc78c..9602588f55 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.types @@ -6,12 +6,12 @@ class Foo { /**@param {string} x */ m = x => x.toLowerCase(); ->m : (x: any) => any ->x => x.toLowerCase() : (x: any) => any ->x : any ->x.toLowerCase() : any ->x.toLowerCase : any ->x : any ->toLowerCase : any +>m : (x: string) => string +>x => x.toLowerCase() : (x: string) => string +>x : string +>x.toLowerCase() : string +>x.toLowerCase : () => string +>x : string +>toLowerCase : () => string } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt new file mode 100644 index 0000000000..1b0b2a8cd2 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt @@ -0,0 +1,12 @@ +example.js(3,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + +==== example.js (1 errors) ==== + // @ts-check + /** + * @type {function(@foo)} + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + */ + let x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.types b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.types index 314873b882..3d6f8823f8 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.types @@ -6,5 +6,5 @@ * @type {function(@foo)} */ let x; ->x : any +>x : function diff --git a/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.types b/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.types index 597373ce56..53f50b7fe4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.types @@ -8,16 +8,16 @@ /** @param {MyType} p */ export function f(p) { } ->f : (p: any) => void ->p : any +>f : (p: MyType) => void +>p : MyType === /b.js === import { f } from "./a.js" ->f : (p: any) => void +>f : (p: MyType) => void f({ x: 42 }) >f({ x: 42 }) : void ->f : (p: any) => void +>f : (p: MyType) => void >{ x: 42 } : { x: number; } >x : number >42 : 42 diff --git a/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.types b/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.types index 8300ebe55f..8df103b0e1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.types @@ -9,7 +9,7 @@ const other = require('./other'); /** @type {Puppeteer.Keyboard} */ var ppk; ->ppk : any +>ppk : Keyboard Puppeteer.connect; >Puppeteer.connect : (name: string) => void diff --git a/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt new file mode 100644 index 0000000000..6c3a675c1e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt @@ -0,0 +1,15 @@ +/a.js(2,12): error TS2304: Cannot find name 'Ty'. + + +==== /a.js (1 errors) ==== + /** + * @param {Ty} x + ~~ +!!! error TS2304: Cannot find name 'Ty'. + */ + function f(x) {} + + /** + * @typedef {CantResolveThis} Ty + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.types b/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.types index 901d06a344..475bea13be 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.types @@ -5,8 +5,8 @@ * @param {Ty} x */ function f(x) {} ->f : (x: any) => void ->x : any +>f : (x: Ty) => void +>x : Ty /** * @typedef {CantResolveThis} Ty diff --git a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt index 9d767c9949..40e75b1fda 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt @@ -1,13 +1,10 @@ -/a.js(2,12): error TS7006: Parameter 'a' implicitly has an 'any' type. /a.js(8,6): error TS2554: Expected 1 arguments, but got 2. /a.js(9,6): error TS2554: Expected 1 arguments, but got 2. -==== /a.js (3 errors) ==== +==== /a.js (2 errors) ==== /** @param {...number} a */ function f(a) { - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. a; // number | undefined // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. arguments[0]; diff --git a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.types b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.types index d9826557ab..21e6295150 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.types @@ -3,11 +3,11 @@ === /a.js === /** @param {...number} a */ function f(a) { ->f : (a: any) => void ->a : any +>f : (a: number[]) => void +>a : number[] a; // number | undefined ->a : any +>a : number[] // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. arguments[0]; @@ -17,20 +17,20 @@ function f(a) { } f([1, 2]); // Error >f([1, 2]) : void ->f : (a: any) => void +>f : (a: number[]) => void >[1, 2] : number[] >1 : 1 >2 : 2 f(1, "2"); // Error >f(1, "2") : void ->f : (a: any) => void +>f : (a: number[]) => void >1 : 1 >"2" : "2" f(1, 2); >f(1, 2) : void ->f : (a: any) => void +>f : (a: number[]) => void >1 : 1 >2 : 2 diff --git a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.errors.txt deleted file mode 100644 index 1b9bff4e55..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -/a.js(2,12): error TS7019: Rest parameter 'a' implicitly has an 'any[]' type. - - -==== /a.js (1 errors) ==== - /** @param {...number} a */ - function f(...a) { - ~~~~ -!!! error TS7019: Rest parameter 'a' implicitly has an 'any[]' type. - a; // number[] - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.types b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.types index cd5374a8c5..f452668a53 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.types @@ -3,10 +3,10 @@ === /a.js === /** @param {...number} a */ function f(...a) { ->f : (...a: any[]) => void ->a : any[] +>f : (...a: number[]) => void +>a : number[] a; // number[] ->a : any[] +>a : number[] } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt new file mode 100644 index 0000000000..c104964181 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt @@ -0,0 +1,26 @@ +jsdocTypeCast.js(6,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. +jsdocTypeCast.js(10,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. + + +==== jsdocTypeCast.js (2 errors) ==== + /** + * @param {string} x + */ + function f(x) { + /** @type {'a' | 'b'} */ + let a = (x); // Error + ~ +!!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. + a; + + /** @type {'a' | 'b'} */ + let b = (((x))); // Error + ~ +!!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. + b; + + /** @type {'a' | 'b'} */ + let c = /** @type {'a' | 'b'} */ (x); // Ok + c; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types index 7a4cf5b041..1ba298ee22 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types @@ -5,36 +5,37 @@ * @param {string} x */ function f(x) { ->f : (x: any) => void ->x : any +>f : (x: string) => void +>x : string /** @type {'a' | 'b'} */ let a = (x); // Error ->a : any ->(x) : any ->x : any +>a : "a" | "b" +>(x) : string +>x : string a; ->a : any +>a : "a" | "b" /** @type {'a' | 'b'} */ let b = (((x))); // Error ->b : any ->(((x))) : any ->((x)) : any ->(x) : any ->x : any +>b : "a" | "b" +>(((x))) : string +>((x)) : string +>(x) : string +>x : string b; ->b : any +>b : "a" | "b" /** @type {'a' | 'b'} */ let c = /** @type {'a' | 'b'} */ (x); // Ok ->c : any ->(x) : any ->x : any +>c : "a" | "b" +>(x) : "a" | "b" +>x : "a" | "b" +>x : string c; ->c : any +>c : "a" | "b" } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.types b/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.types index e3a8cd07d7..e4bf7c2750 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.types @@ -5,10 +5,10 @@ * @param {Array<*>} list */ function thing(list) { ->thing : (list: any) => any ->list : any +>thing : (list: any[]) => any[] +>list : any[] return list; ->list : any +>list : any[] } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt new file mode 100644 index 0000000000..2bb4e07c0e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt @@ -0,0 +1,118 @@ +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) ==== + /** + * @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) ==== + /** + * @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) ==== + /** + * @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) ==== + /** + * @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) ==== + /** + * @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) ==== + /** + * @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) ==== + /** + * @param {(m: Object) => string} somebody + ~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS2304: Cannot find name 'T'. + */ + function sayHello7(somebody) { + return 'Hello ' + somebody; + } + +==== index8.js (2 errors) ==== + function fn() {} + + /** + * @param {fn} somebody + ~~ +!!! error TS2749: 'fn' refers to a value, but is being used as a type here. Did you mean 'typeof fn'? + ~ +!!! error TS2304: Cannot find name 'T'. + */ + function sayHello8(somebody) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.types b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.types index 946d5fc1c8..1783c242b0 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.types @@ -5,13 +5,13 @@ * @param {(m: Boolean) => string} somebody */ function sayHello(somebody) { ->sayHello : (somebody: any) => string ->somebody : any +>sayHello : (somebody: (m: any) => string) => string +>somebody : (m: any) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : any +>somebody : (m: any) => string } === index2.js === @@ -19,13 +19,13 @@ function sayHello(somebody) { * @param {(m: Void) => string} somebody */ function sayHello2(somebody) { ->sayHello2 : (somebody: any) => string ->somebody : any +>sayHello2 : (somebody: (m: Void) => string) => string +>somebody : (m: Void) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : any +>somebody : (m: Void) => string } @@ -34,13 +34,13 @@ function sayHello2(somebody) { * @param {(m: Undefined) => string} somebody */ function sayHello3(somebody) { ->sayHello3 : (somebody: any) => string ->somebody : any +>sayHello3 : (somebody: (m: Undefined) => string) => string +>somebody : (m: Undefined) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : any +>somebody : (m: Undefined) => string } @@ -49,13 +49,13 @@ function sayHello3(somebody) { * @param {(m: Function) => string} somebody */ function sayHello4(somebody) { ->sayHello4 : (somebody: any) => string ->somebody : any +>sayHello4 : (somebody: (m: any) => string) => string +>somebody : (m: any) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : any +>somebody : (m: any) => string } @@ -64,13 +64,13 @@ function sayHello4(somebody) { * @param {(m: String) => string} somebody */ function sayHello5(somebody) { ->sayHello5 : (somebody: any) => string ->somebody : any +>sayHello5 : (somebody: (m: any) => string) => string +>somebody : (m: any) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : any +>somebody : (m: any) => string } @@ -79,13 +79,13 @@ function sayHello5(somebody) { * @param {(m: Number) => string} somebody */ function sayHello6(somebody) { ->sayHello6 : (somebody: any) => string ->somebody : any +>sayHello6 : (somebody: (m: any) => string) => string +>somebody : (m: any) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : any +>somebody : (m: any) => string } @@ -94,13 +94,13 @@ function sayHello6(somebody) { * @param {(m: Object) => string} somebody */ function sayHello7(somebody) { ->sayHello7 : (somebody: any) => string ->somebody : any +>sayHello7 : (somebody: (m: any) => string) => string +>somebody : (m: any) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : any +>somebody : (m: any) => string } === index8.js === @@ -111,6 +111,6 @@ function fn() {} * @param {fn} somebody */ function sayHello8(somebody) { } ->sayHello8 : (somebody: any) => void ->somebody : any +>sayHello8 : (somebody: fn) => void +>somebody : fn diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.types b/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.types index 0e21514ee4..6a018ffbb1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.types @@ -27,7 +27,7 @@ * @param b {AlsoNotADuplicate} */ function makeSureTypedefsAreStillRecognized(a, b) {} ->makeSureTypedefsAreStillRecognized : (a: any, b: any) => void ->a : any ->b : any +>makeSureTypedefsAreStillRecognized : (a: number, b: number) => void +>a : number +>b : number diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.types b/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.types index 71b185202a..f011988191 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.types @@ -16,7 +16,7 @@ const t = 0; /** @type Person */ const person = { name: "" }; ->person : { name: string; } +>person : Person >{ name: "" } : { name: string; } >name : string >"" : "" diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.types b/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.types index d82a1e6fd1..3b56be2744 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.types @@ -8,7 +8,7 @@ /** @type {Foo} */ const x = { foo: 0 }; ->x : { foo: number; } +>x : Foo >{ foo: 0 } : { foo: number; } >foo : number >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/misspelledJsDocTypedefTags.errors.txt b/testdata/baselines/reference/submodule/compiler/misspelledJsDocTypedefTags.errors.txt index de941a86d5..3f08e2966f 100644 --- a/testdata/baselines/reference/submodule/compiler/misspelledJsDocTypedefTags.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/misspelledJsDocTypedefTags.errors.txt @@ -1,14 +1,17 @@ a.js(2,11): error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. +a.js(4,48): error TS2304: Cannot find name 'B'. a.js(5,11): error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. -==== a.js (2 errors) ==== +==== a.js (3 errors) ==== /** @typedef {{ endTime: number, screenshots: number}} A.*/ Animation.AnimationModel.ScreenshotCapture.Request; ~~~~~~~~~~~~~~ !!! error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. /** @typedef {{ endTime: number, screenshots: !B.}} */ + ~ +!!! error TS2304: Cannot find name 'B'. Animation.AnimationModel.ScreenshotCapture.Request; ~~~~~~~~~~~~~~ !!! error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt deleted file mode 100644 index ebff087957..0000000000 --- a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -index.js(8,26): error TS7006: Parameter 'key' implicitly has an 'any' type. - - -==== index.js (1 errors) ==== - /** @type {Map>} */ - const cache = new Map() - - /** - * @param {string} key - * @returns {() => string} - */ - const getStringGetter = (key) => { - ~~~ -!!! error TS7006: Parameter 'key' implicitly has an 'any' type. - return () => { - return /** @type {string} */ (cache.get(key)) - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.types b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.types index fa1dd127ea..ad819605f9 100644 --- a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.types +++ b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.types @@ -3,7 +3,7 @@ === index.js === /** @type {Map>} */ const cache = new Map() ->cache : Map +>cache : Map> >new Map() : Map >Map : MapConstructor @@ -12,20 +12,21 @@ const cache = new Map() * @returns {() => string} */ const getStringGetter = (key) => { ->getStringGetter : (key: any) => () => any ->(key) => { return () => { return /** @type {string} */ (cache.get(key)) }} : (key: any) => () => any ->key : any +>getStringGetter : (key: string) => () => string +>(key) => { return () => { return /** @type {string} */ (cache.get(key)) }} : (key: string) => () => string +>key : string return () => { ->() => { return /** @type {string} */ (cache.get(key)) } : () => any +>() => { return /** @type {string} */ (cache.get(key)) } : () => string return /** @type {string} */ (cache.get(key)) ->(cache.get(key)) : any ->cache.get(key) : any ->cache.get : (key: any) => any ->cache : Map ->get : (key: any) => any ->key : any +>(cache.get(key)) : string +>cache.get(key) : string +>cache.get(key) : string | Set | undefined +>cache.get : (key: string) => string | Set | undefined +>cache : Map> +>get : (key: string) => string | Set | undefined +>key : string } } diff --git a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt new file mode 100644 index 0000000000..c50bcf83c9 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt @@ -0,0 +1,22 @@ +index.js(12,8): error TS2678: Type '"invalid"' is not comparable to type '"bar" | "foo"'. + + +==== index.js (1 errors) ==== + let value = ""; + + switch (/** @type {"foo" | "bar"} */ (value)) { + case "bar": + value; + break; + + case "foo": + value; + break; + + case "invalid": + ~~~~~~~~~ +!!! error TS2678: Type '"invalid"' is not comparable to type '"bar" | "foo"'. + value; + break; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.types b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.types index 6b4d950d51..fd2f5c031c 100644 --- a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.types +++ b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.types @@ -6,14 +6,15 @@ let value = ""; >"" : "" switch (/** @type {"foo" | "bar"} */ (value)) { ->(value) : string +>(value) : "bar" | "foo" +>value : "bar" | "foo" >value : string case "bar": >"bar" : "bar" value; ->value : "bar" +>value : string break; @@ -21,7 +22,7 @@ switch (/** @type {"foo" | "bar"} */ (value)) { >"foo" : "foo" value; ->value : "foo" +>value : string break; @@ -29,7 +30,7 @@ switch (/** @type {"foo" | "bar"} */ (value)) { >"invalid" : "invalid" value; ->value : "invalid" +>value : string break; } diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.symbols b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.symbols index e68a2c1803..4d4e83f4f4 100644 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.symbols +++ b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.symbols @@ -12,7 +12,9 @@ const json1 = require("./json.json"); // No error (bad) >json1 : Symbol(json1, Decl(user.js, 4, 5)) json1.b; // No error (OK since that's the type annotation) +>json1.b : Symbol(b, Decl(user.js, 3, 12)) >json1 : Symbol(json1, Decl(user.js, 4, 5)) +>b : Symbol(b, Decl(user.js, 3, 12)) const js0 = require("./js.js"); >js0 : Symbol(js0, Decl(user.js, 7, 5)) @@ -25,7 +27,9 @@ const js1 = require("./js.js"); // Error (good) >js1 : Symbol(js1, Decl(user.js, 11, 5)) js1.b; +>js1.b : Symbol(b, Decl(user.js, 10, 12)) >js1 : Symbol(js1, Decl(user.js, 11, 5)) +>b : Symbol(b, Decl(user.js, 10, 12)) === /json.json === { "a": 0 } diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.symbols.diff b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.symbols.diff index 4a853f1c3a..99b69ac56e 100644 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.symbols.diff @@ -17,9 +17,8 @@ ->"./json.json" : Symbol("/json", Decl(json.json, 0, 0)) json1.b; // No error (OK since that's the type annotation) -->json1.b : Symbol(b, Decl(user.js, 3, 12)) - >json1 : Symbol(json1, Decl(user.js, 4, 5)) -->b : Symbol(b, Decl(user.js, 3, 12)) + >json1.b : Symbol(b, Decl(user.js, 3, 12)) +@@= skipped -10, +8 lines =@@ const js0 = require("./js.js"); >js0 : Symbol(js0, Decl(user.js, 7, 5)) @@ -28,7 +27,7 @@ json0.b; // Error (good) >json0 : Symbol(json0, Decl(user.js, 0, 5)) -@@= skipped -19, +13 lines =@@ +@@= skipped -9, +7 lines =@@ /** @type {{ b: number }} */ const js1 = require("./js.js"); // Error (good) >js1 : Symbol(js1, Decl(user.js, 11, 5)) @@ -36,9 +35,8 @@ ->"./js.js" : Symbol("/js", Decl(js.js, 0, 0)) js1.b; -->js1.b : Symbol(b, Decl(user.js, 10, 12)) - >js1 : Symbol(js1, Decl(user.js, 11, 5)) -->b : Symbol(b, Decl(user.js, 10, 12)) + >js1.b : Symbol(b, Decl(user.js, 10, 12)) +@@= skipped -10, +8 lines =@@ === /json.json === { "a": 0 } diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.types b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.types index af498ff59b..4afa7dc442 100644 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.types +++ b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.types @@ -14,15 +14,15 @@ json0.b; // Error (good) /** @type {{ b: number }} */ const json1 = require("./json.json"); // No error (bad) ->json1 : any +>json1 : { b: number; } >require("./json.json") : any >require : any >"./json.json" : "./json.json" json1.b; // No error (OK since that's the type annotation) ->json1.b : any ->json1 : any ->b : any +>json1.b : number +>json1 : { b: number; } +>b : number const js0 = require("./js.js"); >js0 : any @@ -37,15 +37,15 @@ json0.b; // Error (good) /** @type {{ b: number }} */ const js1 = require("./js.js"); // Error (good) ->js1 : any +>js1 : { b: number; } >require("./js.js") : any >require : any >"./js.js" : "./js.js" js1.b; ->js1.b : any ->js1 : any ->b : any +>js1.b : number +>js1 : { b: number; } +>b : number === /json.json === { "a": 0 } diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt new file mode 100644 index 0000000000..ae46bda792 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt @@ -0,0 +1,25 @@ +a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. + Types of property 'value' are incompatible. + Type 'undefined' is not assignable to type 'number'. + + +==== a.js (1 errors) ==== + /** + * @typedef {object} A + * @property {number} [value] + */ + + /** @type {A} */ + const a = { value: undefined }; // error + + /** + * @typedef {{ value?: number }} B + */ + + /** @type {B} */ + const b = { value: undefined }; // error + ~ +!!! error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. +!!! error TS2375: Types of property 'value' are incompatible. +!!! error TS2375: Type 'undefined' is not assignable to type 'number'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.types b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.types index 2eb9d12c85..72d35c1e04 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.types +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.types @@ -8,7 +8,7 @@ /** @type {A} */ const a = { value: undefined }; // error ->a : { value: undefined; } +>a : A >{ value: undefined } : { value: undefined; } >value : undefined >undefined : undefined @@ -19,7 +19,7 @@ const a = { value: undefined }; // error /** @type {B} */ const b = { value: undefined }; // error ->b : { value: undefined; } +>b : { value?: number; } >{ value: undefined } : { value: undefined; } >value : undefined >undefined : undefined diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.errors.txt b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.errors.txt deleted file mode 100644 index 768549149e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -a.js(7,3): error TS2339: Property 'foo' does not exist on type '{}'. -a.js(10,3): error TS2339: Property 'foo' does not exist on type '{}'. - - -==== a.js (2 errors) ==== - /** - * @typedef Foo - * @property {number} [foo] - */ - - const x = /** @type {Foo} */ ({}); - x.foo; // number | undefined - ~~~ -!!! error TS2339: Property 'foo' does not exist on type '{}'. - - const y = /** @type {Required} */ ({}); - y.foo; // number - ~~~ -!!! error TS2339: Property 'foo' does not exist on type '{}'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.symbols b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.symbols index 1499abdaf5..f048b853b5 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.symbols +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.symbols @@ -10,11 +10,15 @@ const x = /** @type {Foo} */ ({}); >x : Symbol(x, Decl(a.js, 5, 5)) x.foo; // number | undefined +>x.foo : Symbol(foo, Decl(a.js, 2, 3)) >x : Symbol(x, Decl(a.js, 5, 5)) +>foo : Symbol(foo, Decl(a.js, 2, 3)) const y = /** @type {Required} */ ({}); >y : Symbol(y, Decl(a.js, 8, 5)) y.foo; // number +>y.foo : Symbol(foo, Decl(a.js, 2, 3)) >y : Symbol(y, Decl(a.js, 8, 5)) +>foo : Symbol(foo, Decl(a.js, 2, 3)) diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.symbols.diff b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.symbols.diff deleted file mode 100644 index 4be70e1063..0000000000 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.symbols.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.strictOptionalProperties4.symbols -+++ new.strictOptionalProperties4.symbols -@@= skipped -9, +9 lines =@@ - >x : Symbol(x, Decl(a.js, 5, 5)) - - x.foo; // number | undefined -->x.foo : Symbol(foo, Decl(a.js, 2, 3)) - >x : Symbol(x, Decl(a.js, 5, 5)) -->foo : Symbol(foo, Decl(a.js, 2, 3)) - - const y = /** @type {Required} */ ({}); - >y : Symbol(y, Decl(a.js, 8, 5)) - - y.foo; // number -->y.foo : Symbol(foo, Decl(a.js, 2, 3)) - >y : Symbol(y, Decl(a.js, 8, 5)) -->foo : Symbol(foo, Decl(a.js, 2, 3)) - diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types index 9063ffd4a2..1773918b3c 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types @@ -7,22 +7,24 @@ */ const x = /** @type {Foo} */ ({}); ->x : {} ->({}) : {} +>x : Foo +>({}) : Foo +>{} : Foo >{} : {} x.foo; // number | undefined >x.foo : any ->x : {} +>x : Foo >foo : any const y = /** @type {Required} */ ({}); ->y : {} ->({}) : {} +>y : Required +>({}) : Required +>{} : Required >{} : {} y.foo; // number >y.foo : any ->y : {} +>y : Required >foo : any diff --git a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt index 222af3b09f..e97bdfb5ac 100644 --- a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt @@ -1,3 +1,5 @@ +file1.js(2,7): error TS2322: Type 'C' is not assignable to type 'ClassComponent'. + Index signature for type 'number' is missing in type 'C'. tile1.ts(2,30): error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle'. tile1.ts(6,81): error TS2744: Type parameter defaults can only reference previously declared type parameters. tile1.ts(11,40): error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle'. @@ -56,7 +58,10 @@ tile1.ts(24,7): error TS2322: Type 'C' is not assignable to type 'ClassComponent ~~~~~ !!! error TS2322: Type 'C' is not assignable to type 'ClassComponent'. !!! error TS2322: Index signature for type 'number' is missing in type 'C'. -==== file1.js (0 errors) ==== +==== file1.js (1 errors) ==== /** @type {ClassComponent} */ const test9 = new C(); + ~~~~~ +!!! error TS2322: Type 'C' is not assignable to type 'ClassComponent'. +!!! error TS2322: Index signature for type 'number' is missing in type 'C'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.types b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.types index d222d06700..a444bdcca5 100644 --- a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.types +++ b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.types @@ -52,7 +52,7 @@ const test8: ClassComponent = new C(); === file1.js === /** @type {ClassComponent} */ const test9 = new C(); ->test9 : C +>test9 : ClassComponent >new C() : C >C : typeof C diff --git a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.types b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.types index d2920b1889..146ad274af 100644 --- a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.types +++ b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.types @@ -57,7 +57,7 @@ const test8: ClassComponent = new C(); === file1.js === /** @type {ClassComponent} */ const test9 = new C(); ->test9 : C +>test9 : ClassComponent >new C() : C >C : typeof C diff --git a/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.types b/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.types index 70ff3c3075..04cb4fe45a 100644 --- a/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.types +++ b/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.types @@ -56,8 +56,8 @@ interface Person { * @param {Human} param used as a validation tool */ function doHumanThings(param) {} ->doHumanThings : (param: any) => void ->param : any +>doHumanThings : (param: Human) => void +>param : Human const dice1 = () => Math.floor(Math.random() * 6); >dice1 : { (): number; last: string; } @@ -115,7 +115,7 @@ dice1.last = 'Calrissian'; doHumanThings(dice2) >doHumanThings(dice2) : void ->doHumanThings : (param: any) => void +>doHumanThings : (param: Human) => void >dice2 : { (): number; first: string; last: string; } } diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.types b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.types index 815c6a477a..363466c2f6 100644 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.types +++ b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.types @@ -6,18 +6,18 @@ * @param {number} a\u0061 */ function foo(a, aa) { ->foo : (a: any, aa: any) => void ->a : any ->aa : any +>foo : (a: number, aa: number) => void +>a : number +>aa : number console.log(a + aa); >console.log(a + aa) : void >console.log : (...data: any[]) => void >console : Console >log : (...data: any[]) => void ->a + aa : any ->a : any ->aa : any +>a + aa : number +>a : number +>aa : number } /** @@ -25,17 +25,17 @@ function foo(a, aa) { * @param {number} a\u{0061} */ function bar(a, aa) { ->bar : (a: any, aa: any) => void ->a : any ->aa : any +>bar : (a: number, aa: number) => void +>a : number +>aa : number console.log(a + aa); >console.log(a + aa) : void >console.log : (...data: any[]) => void >console : Console >log : (...data: any[]) => void ->a + aa : any ->a : any ->aa : any +>a + aa : number +>a : number +>aa : number } diff --git a/testdata/baselines/reference/submodule/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt b/testdata/baselines/reference/submodule/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt new file mode 100644 index 0000000000..9e2a2f66c8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt @@ -0,0 +1,19 @@ +file1.js(3,21): error TS2304: Cannot find name 'T'. + + +==== file1.js (1 errors) ==== + /** + * @template {string} T + * @typedef {{ foo: T }} Foo + ~ +!!! error TS2304: Cannot find name 'T'. + */ + + export default {}; + +==== file2.js (0 errors) ==== + /** + * @template T + * @typedef {import('./file1').Foo} Bar + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.errors.txt b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.errors.txt new file mode 100644 index 0000000000..cfd276ebcd --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.errors.txt @@ -0,0 +1,9 @@ +/a.js(1,15): error TS6196: 'T' is declared but never used. + + +==== /a.js (1 errors) ==== + /** @template T */ + ~ +!!! error TS6196: 'T' is declared but never used. + function f() {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.types b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.types index 5e8dabf8aa..9123dc4771 100644 --- a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.types +++ b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.types @@ -3,5 +3,5 @@ === /a.js === /** @template T */ function f() {} ->f : () => void +>f : () => void diff --git a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt index 4ba937de21..941b063cbf 100644 --- a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt @@ -1,36 +1,49 @@ -/a.js(8,14): error TS2339: Property 'p' does not exist on type 'C1'. -/a.js(25,14): error TS2339: Property 'p' does not exist on type 'C3'. +/a.js(2,3): error TS6205: All type parameters are unused. +/a.js(8,14): error TS2339: Property 'p' does not exist on type 'C1'. +/a.js(13,3): error TS6205: All type parameters are unused. +/a.js(20,3): error TS6205: All type parameters are unused. +/a.js(25,14): error TS2339: Property 'p' does not exist on type 'C3'. -==== /a.js (2 errors) ==== +==== /a.js (5 errors) ==== /** * @template T + ~~~~~~~~~~~~ * @template V + ~~~~~~~~~~~~~~ */ + ~~ +!!! error TS6205: All type parameters are unused. class C1 { constructor() { /** @type {T} */ this.p; ~ -!!! error TS2339: Property 'p' does not exist on type 'C1'. +!!! error TS2339: Property 'p' does not exist on type 'C1'. } } /** * @template T,V + ~~~~~~~~~~~~~~ */ + ~~ +!!! error TS6205: All type parameters are unused. class C2 { constructor() { } } /** * @template T,V,X + ~~~~~~~~~~~~~~~~ */ + ~~ +!!! error TS6205: All type parameters are unused. class C3 { constructor() { /** @type {T} */ this.p; ~ -!!! error TS2339: Property 'p' does not exist on type 'C3'. +!!! error TS2339: Property 'p' does not exist on type 'C3'. } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.types b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.types index 677e8b9729..79efeecbe1 100644 --- a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.types +++ b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.types @@ -6,7 +6,7 @@ * @template V */ class C1 { ->C1 : C1 +>C1 : C1 constructor() { /** @type {T} */ @@ -21,7 +21,7 @@ class C1 { * @template T,V */ class C2 { ->C2 : C2 +>C2 : C2 constructor() { } } @@ -30,7 +30,7 @@ class C2 { * @template T,V,X */ class C3 { ->C3 : C3 +>C3 : C3 constructor() { /** @type {T} */ diff --git a/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.types b/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.types index 1646c3be5a..6dfed7c6ed 100644 --- a/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.types +++ b/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.types @@ -4,8 +4,8 @@ // from webpack/lib/Compilation.js and filed at #26427 /** @param {{ [s: string]: number }} map */ function mappy(map) {} ->mappy : (map: any) => void ->map : any +>mappy : (map: { [s: string]: number; }) => void +>map : { [s: string]: number; } export class C { >C : C @@ -24,7 +24,7 @@ export class C { mappy(this.assets) >mappy(this.assets) : void ->mappy : (map: any) => void +>mappy : (map: { [s: string]: number; }) => void >this.assets : any >this : this >assets : any diff --git a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt new file mode 100644 index 0000000000..472f0246c4 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt @@ -0,0 +1,33 @@ +assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. +assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. + + +==== assertionTypePredicates2.js (2 errors) ==== + /** + * @typedef {{ x: number }} A + */ + + /** + * @typedef { A & { y: number } } B + */ + + /** + * @param {A} a + * @returns { asserts a is B } + */ + const foo = (a) => { + if (/** @type { B } */ (a).y !== 0) throw TypeError(); + return undefined; + }; + + export const main = () => { + /** @type { A } */ + const a = { x: 1 }; + foo(a); + ~~~ +!!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. +!!! related TS2782 assertionTypePredicates2.js:13:7: 'foo' needs an explicit type annotation. + ~~~ +!!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. + }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.symbols b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.symbols index 3030bb1d97..2bb05c5574 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.symbols +++ b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.symbols @@ -18,7 +18,9 @@ const foo = (a) => { >a : Symbol(a, Decl(assertionTypePredicates2.js, 12, 13)) if (/** @type { B } */ (a).y !== 0) throw TypeError(); +>(a).y : Symbol(y, Decl(assertionTypePredicates2.js, 5, 19)) >a : Symbol(a, Decl(assertionTypePredicates2.js, 12, 13)) +>y : Symbol(y, Decl(assertionTypePredicates2.js, 5, 19)) >TypeError : Symbol(TypeError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return undefined; diff --git a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.symbols.diff b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.symbols.diff deleted file mode 100644 index a27b754ac7..0000000000 --- a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.assertionTypePredicates2.symbols -+++ new.assertionTypePredicates2.symbols -@@= skipped -17, +17 lines =@@ - >a : Symbol(a, Decl(assertionTypePredicates2.js, 12, 13)) - - if (/** @type { B } */ (a).y !== 0) throw TypeError(); -->(a).y : Symbol(y, Decl(assertionTypePredicates2.js, 5, 19)) - >a : Symbol(a, Decl(assertionTypePredicates2.js, 12, 13)) -->y : Symbol(y, Decl(assertionTypePredicates2.js, 5, 19)) - >TypeError : Symbol(TypeError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - - return undefined; diff --git a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types index caa9f13697..8aaa0c1341 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types +++ b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types @@ -14,16 +14,17 @@ * @returns { asserts a is B } */ const foo = (a) => { ->foo : (a: any) => any ->(a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); return undefined;} : (a: any) => any ->a : any +>foo : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } +>(a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); return undefined;} : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } +>a : { x: number; } if (/** @type { B } */ (a).y !== 0) throw TypeError(); >(a).y !== 0 : boolean ->(a).y : any ->(a) : any ->a : any ->y : any +>(a).y : number +>(a) : { x: number; } & { y: number; } +>a : { x: number; } & { y: number; } +>a : { x: number; } +>y : number >0 : 0 >TypeError() : TypeError >TypeError : TypeErrorConstructor @@ -45,8 +46,8 @@ export const main = () => { >1 : 1 foo(a); ->foo(a) : any ->foo : (a: any) => any +>foo(a) : void +>foo : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } >a : { x: number; } }; diff --git a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt new file mode 100644 index 0000000000..7925bfb827 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt @@ -0,0 +1,69 @@ +assertionsAndNonReturningFunctions.js(46,9): error TS7027: Unreachable code detected. +assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code detected. + + +==== assertionsAndNonReturningFunctions.js (2 errors) ==== + /** @typedef {(check: boolean) => asserts check} AssertFunc */ + + /** @type {AssertFunc} */ + const assert = check => { + if (!check) throw new Error(); + } + + /** @type {(x: unknown) => asserts x is string } */ + function assertIsString(x) { + if (!(typeof x === "string")) throw new Error(); + } + + /** + * @param {boolean} check + * @returns {asserts check} + */ + function assert2(check) { + if (!check) throw new Error(); + } + + /** + * @returns {never} + */ + function fail() { + throw new Error(); + } + + /** + * @param {*} x + */ + function f1(x) { + if (!!true) { + assert(typeof x === "string"); + x.length; + } + if (!!true) { + assert2(typeof x === "string"); + x.length; + } + if (!!true) { + assertIsString(x); + x.length; + } + if (!!true) { + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + } + + /** + * @param {boolean} b + */ + function f2(b) { + switch (b) { + case true: return 1; + case false: return 0; + } + b; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.symbols b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.symbols index 4e28ee1edd..5f8301528a 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.symbols +++ b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.symbols @@ -59,7 +59,9 @@ function f1(x) { >x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) x.length; +>x.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) } if (!!true) { assert2(typeof x === "string"); @@ -67,7 +69,9 @@ function f1(x) { >x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) x.length; +>x.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) } if (!!true) { assertIsString(x); diff --git a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.symbols.diff b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.symbols.diff index 50d5a23cbb..9040133d0e 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.symbols.diff @@ -5,22 +5,26 @@ x.length; ->x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ++>x.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) ->length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) } if (!!true) { assert2(typeof x === "string"); -@@= skipped -10, +8 lines =@@ +@@= skipped -10, +10 lines =@@ >x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) x.length; ->x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ++>x.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) ->length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) } if (!!true) { assertIsString(x); -@@= skipped -10, +8 lines =@@ +@@= skipped -10, +10 lines =@@ >x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) x.length; diff --git a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.types b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.types index c2ac1067df..460c077286 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.types +++ b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.types @@ -5,13 +5,13 @@ /** @type {AssertFunc} */ const assert = check => { ->assert : (check: any) => void ->check => { if (!check) throw new Error();} : (check: any) => void ->check : any +>assert : (check: boolean) => asserts check +>check => { if (!check) throw new Error();} : (check: boolean) => void +>check : boolean if (!check) throw new Error(); >!check : boolean ->check : any +>check : boolean >new Error() : Error >Error : ErrorConstructor } @@ -37,12 +37,12 @@ function assertIsString(x) { * @returns {asserts check} */ function assert2(check) { ->assert2 : (check: any) => void ->check : any +>assert2 : (check: boolean) => asserts check +>check : boolean if (!check) throw new Error(); >!check : boolean ->check : any +>check : boolean >new Error() : Error >Error : ErrorConstructor } @@ -51,7 +51,7 @@ function assert2(check) { * @returns {never} */ function fail() { ->fail : () => void +>fail : () => never throw new Error(); >new Error() : Error @@ -72,16 +72,16 @@ function f1(x) { assert(typeof x === "string"); >assert(typeof x === "string") : void ->assert : (check: any) => void +>assert : (check: boolean) => asserts check >typeof x === "string" : boolean >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" >x : any >"string" : "string" x.length; ->x.length : any ->x : any ->length : any +>x.length : number +>x : string +>length : number } if (!!true) { >!!true : boolean @@ -90,16 +90,16 @@ function f1(x) { assert2(typeof x === "string"); >assert2(typeof x === "string") : void ->assert2 : (check: any) => void +>assert2 : (check: boolean) => asserts check >typeof x === "string" : boolean >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" >x : any >"string" : "string" x.length; ->x.length : any ->x : any ->length : any +>x.length : number +>x : string +>length : number } if (!!true) { >!!true : boolean @@ -122,8 +122,8 @@ function f1(x) { >true : true fail(); ->fail() : void ->fail : () => void +>fail() : never +>fail : () => never x; // Unreachable >x : any @@ -134,11 +134,11 @@ function f1(x) { * @param {boolean} b */ function f2(b) { ->f2 : (b: any) => 0 | 1 ->b : any +>f2 : (b: boolean) => 0 | 1 +>b : boolean switch (b) { ->b : any +>b : boolean case true: return 1; >true : true @@ -149,6 +149,6 @@ function f2(b) { >0 : 0 } b; // Unreachable ->b : any +>b : never } diff --git a/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt b/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt new file mode 100644 index 0000000000..6dc5427f14 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt @@ -0,0 +1,50 @@ +file.js(2,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +file.js(6,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +file.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +file.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + +==== file.js (5 errors) ==== + // Error (good) + /** @type {function(): string} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const a = () => 0 + + // Error (good) + /** @type {function(): string} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const b = async () => 0 + + // No error (bad) + /** @type {function(): string} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const c = async () => { + return 0 + } + + // Error (good) + /** @type {function(): string} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const d = async () => { + return "" + } + + /** @type {function(function(): string): void} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const f = (p) => {} + + // Error (good) + f(async () => { + return 0 + }) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.types b/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.types index f54b0ced23..2e9f7ae259 100644 --- a/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.types +++ b/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.types @@ -4,21 +4,21 @@ // Error (good) /** @type {function(): string} */ const a = () => 0 ->a : () => number +>a : function >() => 0 : () => number >0 : 0 // Error (good) /** @type {function(): string} */ const b = async () => 0 ->b : () => Promise +>b : function >async () => 0 : () => Promise >0 : 0 // No error (bad) /** @type {function(): string} */ const c = async () => { ->c : () => Promise +>c : function >async () => { return 0} : () => Promise return 0 @@ -28,7 +28,7 @@ const c = async () => { // Error (good) /** @type {function(): string} */ const d = async () => { ->d : () => Promise +>d : function >async () => { return ""} : () => Promise return "" @@ -37,14 +37,14 @@ const d = async () => { /** @type {function(function(): string): void} */ const f = (p) => {} ->f : (p: any) => void +>f : function >(p) => {} : (p: any) => void >p : any // Error (good) f(async () => { ->f(async () => { return 0}) : void ->f : (p: any) => void +>f(async () => { return 0}) : any +>f : function >async () => { return 0} : () => Promise return 0 diff --git a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt new file mode 100644 index 0000000000..18d3c442d6 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt @@ -0,0 +1,67 @@ +/a.js(21,14): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? +/a.js(27,12): error TS2304: Cannot find name 'T1'. +/a.js(40,12): error TS2304: Cannot find name 'T2'. +/a.js(45,12): error TS2304: Cannot find name 'T3'. + + +==== /types.d.ts (0 errors) ==== + declare class Thenable { then(): void; } + +==== /a.js (4 errors) ==== + /** + * @callback T1 + * @param {string} str + * @returns {string} + */ + + /** + * @callback T2 + * @param {string} str + * @returns {Promise} + */ + + /** + * @callback T3 + * @param {string} str + * @returns {Thenable} + */ + + /** + * @param {string} str + * @returns {string} + ~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? + */ + const f1 = async str => { + return str; + } + + /** @type {T1} */ + ~~ +!!! error TS2304: Cannot find name 'T1'. + const f2 = async str => { + return str; + } + + /** + * @param {string} str + * @returns {Promise} + */ + const f3 = async str => { + return str; + } + + /** @type {T2} */ + ~~ +!!! error TS2304: Cannot find name 'T2'. + const f4 = async str => { + return str; + } + + /** @type {T3} */ + ~~ +!!! error TS2304: Cannot find name 'T3'. + const f5 = async str => { + return str; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.types b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.types index 0e885cffb4..3a95e08bd6 100644 --- a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.types +++ b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.types @@ -29,17 +29,17 @@ declare class Thenable { then(): void; } * @returns {string} */ const f1 = async str => { ->f1 : (str: any) => Promise ->async str => { return str;} : (str: any) => Promise ->str : any +>f1 : (str: string) => string +>async str => { return str;} : (str: string) => string +>str : string return str; ->str : any +>str : string } /** @type {T1} */ const f2 = async str => { ->f2 : (str: any) => Promise +>f2 : T1 >async str => { return str;} : (str: any) => Promise >str : any @@ -52,17 +52,17 @@ const f2 = async str => { * @returns {Promise} */ const f3 = async str => { ->f3 : (str: any) => Promise ->async str => { return str;} : (str: any) => Promise ->str : any +>f3 : (str: string) => Promise +>async str => { return str;} : (str: string) => Promise +>str : string return str; ->str : any +>str : string } /** @type {T2} */ const f4 = async str => { ->f4 : (str: any) => Promise +>f4 : T2 >async str => { return str;} : (str: any) => Promise >str : any @@ -72,7 +72,7 @@ const f4 = async str => { /** @type {T3} */ const f5 = async str => { ->f5 : (str: any) => Promise +>f5 : T3 >async str => { return str;} : (str: any) => Promise >str : any diff --git a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt index 2994a55aa7..dbbbe1f34c 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt @@ -1,4 +1,5 @@ mod1.js(5,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +use.js(1,20): error TS2306: File 'mod1.js' is not a module. ==== mod1.js (1 errors) ==== @@ -13,8 +14,10 @@ mod1.js(5,1): error TS2580: Cannot find name 'module'. Do you need to install ty this.p = 1 } -==== use.js (0 errors) ==== +==== use.js (1 errors) ==== /** @param {import('./mod1').Con} k */ + ~~~~~~~~ +!!! error TS2306: File 'mod1.js' is not a module. function f(k) { if (1 === 2 - 1) { // I guess basic math works! diff --git a/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt new file mode 100644 index 0000000000..9b0c649c61 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt @@ -0,0 +1,20 @@ +callbackOnConstructor.js(12,12): error TS2304: Cannot find name 'ValueGetter_2'. + + +==== callbackOnConstructor.js (1 errors) ==== + export class Preferences { + assignability = "no" + /** + * @callback ValueGetter_2 + * @param {string} name + * @returns {boolean|number|string|undefined} + */ + constructor() {} + } + + + /** @type {ValueGetter_2} */ + ~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'ValueGetter_2'. + var ooscope2 = s => s.length > 0 + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.types b/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.types index 87c02bf622..448a21aa29 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.types +++ b/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.types @@ -19,7 +19,7 @@ export class Preferences { /** @type {ValueGetter_2} */ var ooscope2 = s => s.length > 0 ->ooscope2 : (s: any) => boolean +>ooscope2 : ValueGetter_2 >s => s.length > 0 : (s: any) => boolean >s : any >s.length > 0 : boolean diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt new file mode 100644 index 0000000000..1ef41942a9 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt @@ -0,0 +1,27 @@ +cb.js(7,12): error TS2304: Cannot find name 'Sid'. +cb.js(11,12): error TS2304: Cannot find name 'NoReturn'. + + +==== cb.js (2 errors) ==== + /** @callback Sid + * @param {string} s + * @returns {string} What were you expecting + */ + var x = 1 + + /** @type {Sid} smallId */ + ~~~ +!!! error TS2304: Cannot find name 'Sid'. + var sid = s => s + "!"; + + + /** @type {NoReturn} */ + ~~~~~~~~ +!!! error TS2304: Cannot find name 'NoReturn'. + var noreturn = obj => void obj.title + + /** + * @callback NoReturn + * @param {{ e: number, m: number, title: string }} s - Knee deep, shores, etc + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag1.types b/testdata/baselines/reference/submodule/conformance/callbackTag1.types index 2ebad26f87..43c91380f7 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag1.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTag1.types @@ -11,7 +11,7 @@ var x = 1 /** @type {Sid} smallId */ var sid = s => s + "!"; ->sid : (s: any) => string +>sid : Sid >s => s + "!" : (s: any) => string >s : any >s + "!" : string @@ -21,7 +21,7 @@ var sid = s => s + "!"; /** @type {NoReturn} */ var noreturn = obj => void obj.title ->noreturn : (obj: any) => any +>noreturn : NoReturn >obj => void obj.title : (obj: any) => any >obj : any >void obj.title : undefined diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt index 2dbccc172d..c1bec010f7 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt @@ -1,7 +1,10 @@ -cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. +cb.js(8,12): error TS2304: Cannot find name 'Id'. +cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. +cb.js(22,12): error TS2304: Cannot find name 'SharedId'. +cb.js(25,12): error TS2304: Cannot find name 'Final'. -==== cb.js (1 errors) ==== +==== cb.js (4 errors) ==== /** @template T * @callback Id * @param {T} t @@ -10,6 +13,8 @@ cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. var x = 1 /** @type {Id} I actually wanted to write `const "120"` */ + ~~ +!!! error TS2304: Cannot find name 'Id'. var one_twenty = s => "120"; /** @template S @@ -22,13 +27,17 @@ cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. /** @type {SharedId} */ this.id; ~~ -!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. +!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. } } /** @type {SharedId} */ + ~~~~~~~~ +!!! error TS2304: Cannot find name 'SharedId'. var outside = n => n + 1; /** @type {Final<{ fantasy }, { heroes }>} */ + ~~~~~ +!!! error TS2304: Cannot find name 'Final'. var noreturn = (barts, tidus, noctis) => "cecil" /** diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag2.types b/testdata/baselines/reference/submodule/conformance/callbackTag2.types index 9480c8d69f..c6fb9fcc81 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag2.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTag2.types @@ -12,7 +12,7 @@ var x = 1 /** @type {Id} I actually wanted to write `const "120"` */ var one_twenty = s => "120"; ->one_twenty : (s: any) => string +>one_twenty : Id >s => "120" : (s: any) => string >s : any >"120" : "120" @@ -23,7 +23,7 @@ var one_twenty = s => "120"; * @return {S} */ class SharedClass { ->SharedClass : SharedClass +>SharedClass : SharedClass constructor() { /** @type {SharedId} */ @@ -35,7 +35,7 @@ class SharedClass { } /** @type {SharedId} */ var outside = n => n + 1; ->outside : (n: any) => any +>outside : SharedId >n => n + 1 : (n: any) => any >n : any >n + 1 : any @@ -44,7 +44,7 @@ var outside = n => n + 1; /** @type {Final<{ fantasy }, { heroes }>} */ var noreturn = (barts, tidus, noctis) => "cecil" ->noreturn : (barts: any, tidus: any, noctis: any) => string +>noreturn : Final<{ fantasy: any; }, { heroes: any; }> >(barts, tidus, noctis) => "cecil" : (barts: any, tidus: any, noctis: any) => string >barts : any >tidus : any diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt new file mode 100644 index 0000000000..0ea6446b4b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt @@ -0,0 +1,13 @@ +cb.js(4,12): error TS2304: Cannot find name 'Miracle'. + + +==== cb.js (1 errors) ==== + /** @callback Miracle + * @returns {string} What were you expecting + */ + /** @type {Miracle} smallId */ + ~~~~~~~ +!!! error TS2304: Cannot find name 'Miracle'. + var sid = () => "!"; + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag3.types b/testdata/baselines/reference/submodule/conformance/callbackTag3.types index 087e6ac571..044d714993 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag3.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTag3.types @@ -6,7 +6,7 @@ */ /** @type {Miracle} smallId */ var sid = () => "!"; ->sid : () => string +>sid : Miracle >() => "!" : () => string >"!" : "!" diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt index e4e4f3b568..654e48ca41 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt @@ -1,9 +1,10 @@ +a.js(9,12): error TS2304: Cannot find name 'C'. a.js(10,22): error TS7006: Parameter 'a' implicitly has an 'any' type. a.js(10,25): error TS7006: Parameter 'b' implicitly has an 'any' type. a.js(11,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -==== a.js (3 errors) ==== +==== a.js (4 errors) ==== /** * @callback C * @this {{ a: string, b: number }} @@ -13,6 +14,8 @@ a.js(11,5): error TS2683: 'this' implicitly has type 'any' because it does not h */ /** @type {C} */ + ~ +!!! error TS2304: Cannot find name 'C'. const cb = function (a, b) { ~ !!! error TS7006: Parameter 'a' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag4.types b/testdata/baselines/reference/submodule/conformance/callbackTag4.types index 759eb0650d..5e7d68b92d 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag4.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTag4.types @@ -11,7 +11,7 @@ /** @type {C} */ const cb = function (a, b) { ->cb : (a: any, b: any) => boolean +>cb : C >function (a, b) { this return true} : (a: any, b: any) => boolean >a : any >b : any diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt new file mode 100644 index 0000000000..fa694a91df --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt @@ -0,0 +1,23 @@ +cb_nested.js(11,12): error TS2304: Cannot find name 'WorksWithPeopleCallback'. + + +==== cb_nested.js (1 errors) ==== + /** + * @callback WorksWithPeopleCallback + * @param {Object} person + * @param {string} person.name + * @param {number} [person.age] + * @returns {void} + */ + + /** + * For each person, calls your callback. + * @param {WorksWithPeopleCallback} callback + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'WorksWithPeopleCallback'. + * @returns {void} + */ + function eachPerson(callback) { + callback({ name: "Empty" }); + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.types b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.types index 09a041e0ca..f51212f4e6 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.types @@ -15,12 +15,12 @@ * @returns {void} */ function eachPerson(callback) { ->eachPerson : (callback: any) => void ->callback : any +>eachPerson : (callback: WorksWithPeopleCallback) => void +>callback : WorksWithPeopleCallback callback({ name: "Empty" }); >callback({ name: "Empty" }) : any ->callback : any +>callback : WorksWithPeopleCallback >{ name: "Empty" } : { name: string; } >name : string >"Empty" : "Empty" diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt index b3b3740431..79b28e665e 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt @@ -1,4 +1,4 @@ -callbackTagVariadicType.js(9,13): error TS2554: Expected 0 arguments, but got 2. +callbackTagVariadicType.js(7,12): error TS2304: Cannot find name 'Foo'. ==== callbackTagVariadicType.js (1 errors) ==== @@ -9,8 +9,8 @@ callbackTagVariadicType.js(9,13): error TS2554: Expected 0 arguments, but got 2. */ /** @type {Foo} */ + ~~~ +!!! error TS2304: Cannot find name 'Foo'. export const x = () => 1 var res = x('a', 'b') - ~~~~~~~~ -!!! error TS2554: Expected 0 arguments, but got 2. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.types b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.types index fb68217605..a80d7af3a7 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.types @@ -9,14 +9,14 @@ /** @type {Foo} */ export const x = () => 1 ->x : () => number +>x : Foo >() => 1 : () => number >1 : 1 var res = x('a', 'b') ->res : number ->x('a', 'b') : number ->x : () => number +>res : any +>x('a', 'b') : any +>x : Foo >'a' : "a" >'b' : "b" diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt new file mode 100644 index 0000000000..b29c988e17 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt @@ -0,0 +1,14 @@ +0.js(7,20): error TS1016: A required parameter cannot follow an optional parameter. + + +==== 0.js (1 errors) ==== + // @ts-check + /** + * @param {number} a + * @param {number} [b] + * @param {number} c + */ + function foo(a, b, c) {} + ~ +!!! error TS1016: A required parameter cannot follow an optional parameter. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.types b/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.types index a487e8cda1..00c4c537df 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.types @@ -8,8 +8,8 @@ * @param {number} c */ function foo(a, b, c) {} ->foo : (a: any, b: any, c: any) => void ->a : any ->b : any ->c : any +>foo : (a: number, b: number, c: number) => void +>a : number +>b : number +>c : number diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.types b/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.types index f797aaae7d..56bcad7bfb 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.types @@ -7,11 +7,11 @@ * @param {string} [s] */ var x = function foo(n, s) {} ->x : (n: any, s: any) => void ->function foo(n, s) {} : (n: any, s: any) => void ->foo : (n: any, s: any) => void ->n : any ->s : any +>x : (n?: number, s?: string) => void +>function foo(n, s) {} : (n?: number, s?: string) => void +>foo : (n?: number, s?: string) => void +>n : number +>s : string var y; >y : any @@ -30,9 +30,9 @@ y = function bar(b) {} * @param {string} s */ var one = function (s) { }, two = function (untyped) { }; ->one : (s: any) => void ->function (s) { } : (s: any) => void ->s : any +>one : (s: string) => void +>function (s) { } : (s: string) => void +>s : string >two : (untyped: any) => void >function (untyped) { } : (untyped: any) => void >untyped : any diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.errors.txt deleted file mode 100644 index 6d58c39a5f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -0.js(8,1): error TS2554: Expected 2 arguments, but got 0. -0.js(9,1): error TS2554: Expected 2 arguments, but got 1. - - -==== 0.js (2 errors) ==== - // @ts-check - /** - * @param {number=} n - * @param {string} [s] - */ - function foo(n, s) {} - - foo(); - ~~~ -!!! error TS2554: Expected 2 arguments, but got 0. -!!! related TS6210 0.js:6:14: An argument for 'n' was not provided. - foo(1); - ~~~ -!!! error TS2554: Expected 2 arguments, but got 1. -!!! related TS6210 0.js:6:17: An argument for 's' was not provided. - foo(1, "hi"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.types index 4714ea7317..b5f97088c1 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.types @@ -7,22 +7,22 @@ * @param {string} [s] */ function foo(n, s) {} ->foo : (n: any, s: any) => void ->n : any ->s : any +>foo : (n?: number, s?: string) => void +>n : number +>s : string foo(); >foo() : void ->foo : (n: any, s: any) => void +>foo : (n?: number, s?: string) => void foo(1); >foo(1) : void ->foo : (n: any, s: any) => void +>foo : (n?: number, s?: string) => void >1 : 1 foo(1, "hi"); >foo(1, "hi") : void ->foo : (n: any, s: any) => void +>foo : (n?: number, s?: string) => void >1 : 1 >"hi" : "hi" diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.types index 6d52c3a702..39f1932261 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.types @@ -26,7 +26,7 @@ function f1() { * @returns {string|number} This comment is not currently exposed */ function f2() { ->f2 : () => "hello" | 5 +>f2 : () => string | number return 5 || "hello"; >5 || "hello" : "hello" | 5 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt index ab240f6d40..c5ab204ed8 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt @@ -1,13 +1,18 @@ +returns.js(6,5): error TS2322: Type 'number' is not assignable to type 'string'. +returns.js(13,5): error TS2322: Type 'number | boolean' is not assignable to type 'string | number'. + Type 'boolean' is not assignable to type 'string | number'. returns.js(13,12): error TS2872: This kind of expression is always truthy. -==== returns.js (1 errors) ==== +==== returns.js (3 errors) ==== // @ts-check /** * @returns {string} This comment is not currently exposed */ function f() { return 5; + ~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. } /** @@ -15,6 +20,9 @@ returns.js(13,12): error TS2872: This kind of expression is always truthy. */ function f1() { return 5 || true; + ~~~~~~ +!!! error TS2322: Type 'number | boolean' is not assignable to type 'string | number'. +!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'. ~ !!! error TS2872: This kind of expression is always truthy. } diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.types b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.types index bf6e5e53e5..6ad8c3fb20 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.types @@ -6,7 +6,7 @@ * @returns {string} This comment is not currently exposed */ function f() { ->f : () => number +>f : () => string return 5; >5 : 5 @@ -16,7 +16,7 @@ function f() { * @returns {string | number} This comment is not currently exposed */ function f1() { ->f1 : () => 5 | true +>f1 : () => string | number return 5 || true; >5 || true : 5 | true diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols index b2946f8e46..41e26adfcd 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols @@ -41,7 +41,9 @@ const t4 = /** @satisfies {T2} */ ({ a: "a" }); const t5 = /** @satisfies {T3} */((m) => m.substring(0)); >t5 : Symbol(t5, Decl(a.js, 27, 5)) >m : Symbol(m, Decl(a.js, 27, 35)) +>m.substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) >m : Symbol(m, Decl(a.js, 27, 35)) +>substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) const t6 = /** @satisfies {[number, number]} */ ([1, 2]); >t6 : Symbol(t6, Decl(a.js, 28, 5)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff index 6e16092f24..d1e4e15083 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff @@ -5,8 +5,10 @@ >t5 : Symbol(t5, Decl(a.js, 27, 5)) >m : Symbol(m, Decl(a.js, 27, 35)) ->m.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --)) ++>m.substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) >m : Symbol(m, Decl(a.js, 27, 35)) ->substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --)) ++>substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) const t6 = /** @satisfies {[number, number]} */ ([1, 2]); >t6 : Symbol(t6, Decl(a.js, 28, 5)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types index 9333923866..565314abff 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types @@ -43,7 +43,7 @@ const t3 = /** @satisfies {T1} */ ({}); /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); ->t4 : { a: string; } +>t4 : T2 >({ a: "a" }) : { a: string; } >{ a: "a" } : { a: string; } >a : string @@ -51,14 +51,14 @@ const t4 = /** @satisfies {T2} */ ({ a: "a" }); /** @type {(m: string) => string} */ const t5 = /** @satisfies {T3} */((m) => m.substring(0)); ->t5 : (m: any) => any ->((m) => m.substring(0)) : (m: any) => any ->(m) => m.substring(0) : (m: any) => any ->m : any ->m.substring(0) : any ->m.substring : any ->m : any ->substring : any +>t5 : (m: string) => string +>((m) => m.substring(0)) : (m: string) => string +>(m) => m.substring(0) : (m: string) => string +>m : string +>m.substring(0) : string +>m.substring : (start: number, end?: number) => string +>m : string +>substring : (start: number, end?: number) => string >0 : 0 const t6 = /** @satisfies {[number, number]} */ ([1, 2]); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt new file mode 100644 index 0000000000..c3c65f4fb8 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt @@ -0,0 +1,16 @@ +/a.js(1,15): error TS2315: Type 'Object' is not generic. +/a.js(1,21): error TS8020: JSDoc types can only be used inside documentation comments. + + +==== /a.js (2 errors) ==== + /** @typedef {Object. boolean>} Predicates */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + + const p = /** @satisfies {Predicates} */ ({ + isEven: n => n % 2 === 0, + isOdd: n => n % 2 === 1 + }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt index ff2916a9e4..f41bb7633d 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt @@ -1,14 +1,11 @@ -/a.js(3,7): error TS7006: Parameter 's' implicitly has an 'any' type. /a.js(4,7): error TS7006: Parameter 's' implicitly has an 'any' type. /a.js(8,49): error TS7006: Parameter 'x' implicitly has an 'any' type. -==== /a.js (3 errors) ==== +==== /a.js (2 errors) ==== /** @type {{ f(s: string): void } & Record }} */ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ f(s) { }, // "incorrect" implicit any on 's' - ~ -!!! error TS7006: Parameter 's' implicitly has an 'any' type. g(s) { } ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types index d25248b35d..7504a36f45 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types @@ -3,13 +3,13 @@ === /a.js === /** @type {{ f(s: string): void } & Record }} */ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ ->obj : { f: (s: any) => void; g: (s: any) => void; } ->({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f: (s: any) => void; g: (s: any) => void; } ->{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f: (s: any) => void; g: (s: any) => void; } +>obj : { f: (s: string) => void; } & Record +>({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f: (s: string) => void; g: (s: any) => void; } +>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f: (s: string) => void; g: (s: any) => void; } f(s) { }, // "incorrect" implicit any on 's' ->f : (s: any) => void ->s : any +>f : (s: string) => void +>s : string g(s) { } >g : (s: any) => void diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt new file mode 100644 index 0000000000..cc59dca024 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt @@ -0,0 +1,17 @@ +/a.js(1,15): error TS2315: Type 'Object' is not generic. +/a.js(1,21): error TS8020: JSDoc types can only be used inside documentation comments. + + +==== /a.js (2 errors) ==== + /** @typedef {Object.} Facts */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + + // Should be able to detect a failure here + const x = /** @satisfies {Facts} */ ({ + m: true, + s: "false" + }) + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt index c38dd87402..beeb1723a4 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt @@ -1,8 +1,10 @@ -0.js(10,1): error TS2322: Type 'string' is not assignable to type 'number'. -0.js(14,1): error TS2322: Type 'string' is not assignable to type 'number'. +0.js(20,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(24,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(28,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'props' must be of type 'object', but here has type 'Object'. -==== 0.js (2 errors) ==== +==== 0.js (4 errors) ==== // @ts-check /** @type {String} */ var S = "hello world"; @@ -13,28 +15,33 @@ /** @type {*} */ var anyT = 2; anyT = "hello"; - ~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. /** @type {?} */ var anyT1 = 2; anyT1 = "hi"; - ~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. /** @type {Function} */ const x = (a) => a + 1; x(1); /** @type {function} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. const y = (a) => a + 1; y(1); /** @type {function (number)} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. const x1 = (a) => a + 1; x1(0); /** @type {function (number): number} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. const x2 = (a) => a + 1; x2(0); @@ -47,4 +54,7 @@ * @type {Object} */ var props = {}; + ~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'props' must be of type 'object', but here has type 'Object'. +!!! related TS6203 0.js:35:5: 'props' was also declared here. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.types index f9016dbaac..35991b8037 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.types @@ -4,7 +4,7 @@ // @ts-check /** @type {String} */ var S = "hello world"; ->S : string +>S : String >"hello world" : "hello world" /** @type {number} */ @@ -14,27 +14,27 @@ var n = 10; /** @type {*} */ var anyT = 2; ->anyT : number +>anyT : any >2 : 2 anyT = "hello"; >anyT = "hello" : "hello" ->anyT : number +>anyT : any >"hello" : "hello" /** @type {?} */ var anyT1 = 2; ->anyT1 : number +>anyT1 : any >2 : 2 anyT1 = "hi"; >anyT1 = "hi" : "hi" ->anyT1 : number +>anyT1 : any >"hi" : "hi" /** @type {Function} */ const x = (a) => a + 1; ->x : (a: any) => any +>x : Function >(a) => a + 1 : (a: any) => any >a : any >a + 1 : any @@ -43,12 +43,12 @@ const x = (a) => a + 1; x(1); >x(1) : any ->x : (a: any) => any +>x : Function >1 : 1 /** @type {function} */ const y = (a) => a + 1; ->y : (a: any) => any +>y : function >(a) => a + 1 : (a: any) => any >a : any >a + 1 : any @@ -57,12 +57,12 @@ const y = (a) => a + 1; y(1); >y(1) : any ->y : (a: any) => any +>y : function >1 : 1 /** @type {function (number)} */ const x1 = (a) => a + 1; ->x1 : (a: any) => any +>x1 : function >(a) => a + 1 : (a: any) => any >a : any >a + 1 : any @@ -71,12 +71,12 @@ const x1 = (a) => a + 1; x1(0); >x1(0) : any ->x1 : (a: any) => any +>x1 : function >0 : 0 /** @type {function (number): number} */ const x2 = (a) => a + 1; ->x2 : (a: any) => any +>x2 : function >(a) => a + 1 : (a: any) => any >a : any >a + 1 : any @@ -85,20 +85,20 @@ const x2 = (a) => a + 1; x2(0); >x2(0) : any ->x2 : (a: any) => any +>x2 : function >0 : 0 /** * @type {object} */ var props = {}; ->props : {} +>props : object >{} : {} /** * @type {Object} */ var props = {}; ->props : {} +>props : object >{} : {} diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt new file mode 100644 index 0000000000..76933dc06a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt @@ -0,0 +1,50 @@ +0.js(3,5): error TS2322: Type 'boolean' is not assignable to type 'String'. +0.js(6,5): error TS2322: Type 'string' is not assignable to type 'number'. +0.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(12,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(23,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + +==== 0.js (6 errors) ==== + // @ts-check + /** @type {String} */ + var S = true; + ~ +!!! error TS2322: Type 'boolean' is not assignable to type 'String'. + + /** @type {number} */ + var n = "hello"; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + + /** @type {function (number)} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const x1 = (a) => a + 1; + x1("string"); + + /** @type {function (number): number} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const x2 = (a) => a + 1; + + /** @type {string} */ + var a; + a = x2(0); + + /** @type {function (number): number} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const x3 = (a) => a.concat("hi"); + x3(0); + + /** @type {function (number): string} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const x4 = (a) => a + 1; + x4(0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.types index a60c701770..7fc0f656f2 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.types @@ -4,17 +4,17 @@ // @ts-check /** @type {String} */ var S = true; ->S : boolean +>S : String >true : true /** @type {number} */ var n = "hello"; ->n : string +>n : number >"hello" : "hello" /** @type {function (number)} */ const x1 = (a) => a + 1; ->x1 : (a: any) => any +>x1 : function >(a) => a + 1 : (a: any) => any >a : any >a + 1 : any @@ -23,12 +23,12 @@ const x1 = (a) => a + 1; x1("string"); >x1("string") : any ->x1 : (a: any) => any +>x1 : function >"string" : "string" /** @type {function (number): number} */ const x2 = (a) => a + 1; ->x2 : (a: any) => any +>x2 : function >(a) => a + 1 : (a: any) => any >a : any >a + 1 : any @@ -37,18 +37,18 @@ const x2 = (a) => a + 1; /** @type {string} */ var a; ->a : any +>a : string a = x2(0); >a = x2(0) : any ->a : any +>a : string >x2(0) : any ->x2 : (a: any) => any +>x2 : function >0 : 0 /** @type {function (number): number} */ const x3 = (a) => a.concat("hi"); ->x3 : (a: any) => any +>x3 : function >(a) => a.concat("hi") : (a: any) => any >a : any >a.concat("hi") : any @@ -59,12 +59,12 @@ const x3 = (a) => a.concat("hi"); x3(0); >x3(0) : any ->x3 : (a: any) => any +>x3 : function >0 : 0 /** @type {function (number): string} */ const x4 = (a) => a + 1; ->x4 : (a: any) => any +>x4 : function >(a) => a + 1 : (a: any) => any >a : any >a + 1 : any @@ -73,6 +73,6 @@ const x4 = (a) => a + 1; x4(0); >x4(0) : any ->x4 : (a: any) => any +>x4 : function >0 : 0 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.types index eb35563b92..593bac0790 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.types @@ -3,5 +3,5 @@ === test.js === /** @type {Array} */ var nns; ->nns : any +>nns : number[] diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt new file mode 100644 index 0000000000..1120047dc2 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt @@ -0,0 +1,24 @@ +test.js(3,19): error TS2304: Cannot find name 'U'. +test.js(5,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. +test.js(7,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. + + +==== t.d.ts (0 errors) ==== + type A = { a: T } + +==== test.js (3 errors) ==== + /** Also should error for jsdoc typedefs + * @template {string} U + * @typedef {{ b: U }} B + ~ +!!! error TS2304: Cannot find name 'U'. + */ + /** @type {A} */ + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'string'. + var a; + /** @type {B} */ + ~~~~~~ +!!! error TS2344: Type 'number' does not satisfy the constraint 'string'. + var b; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types index dbf09e07c0..5004b47a1a 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types @@ -12,9 +12,9 @@ type A = { a: T } */ /** @type {A} */ var a; ->a : any +>a : A /** @type {B} */ var b; ->b : any +>b : { b: U; } diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt new file mode 100644 index 0000000000..285e2ac7c4 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt @@ -0,0 +1,64 @@ +test.js(5,14): error TS2322: Type 'number' is not assignable to type 'string'. +test.js(7,5): error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +test.js(12,14): error TS2322: Type 'number' is not assignable to type 'string'. +test.js(14,5): error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +test.js(24,5): error TS2322: Type 'number' is not assignable to type '0 | 1 | 2'. +test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. + Type '1' is not assignable to type '2 | 3'. + + +==== test.js (6 errors) ==== + // all 6 should error on return statement/expression + /** @type {(x: number) => string} */ + function h(x) { return x } + /** @type {(x: number) => string} */ + var f = x => x + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6502 test.js:4:12: The expected type comes from the return type of this signature. + /** @type {(x: number) => string} */ + var g = function (x) { return x } + ~ +!!! error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + /** @type {{ (x: number): string }} */ + function i(x) { return x } + /** @type {{ (x: number): string }} */ + var j = x => x + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6502 test.js:11:12: The expected type comes from the return type of this signature. + /** @type {{ (x: number): string }} */ + var k = function (x) { return x } + ~ +!!! error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + + /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ + /** @type {Argle} */ + function blargle(s) { + return 0; + } + + /** @type {0 | 1 | 2} - assignment should not error */ + var zeroonetwo = blargle('hi') + ~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type '0 | 1 | 2'. + + /** @typedef {{(s: string): 0 | 1; (b: boolean): 2 | 3 }} Gioconda */ + + /** @type {Gioconda} */ + function monaLisa(sb) { + return typeof sb === 'string' ? 1 : 2; + } + + /** @type {2 | 3} - overloads are not supported, so there will be an error */ + var twothree = monaLisa(false); + ~~~~~~~~ +!!! error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. +!!! error TS2322: Type '1' is not assignable to type '2 | 3'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.types index 0f3aa5e20d..e571cb95ec 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.types @@ -10,17 +10,17 @@ function h(x) { return x } /** @type {(x: number) => string} */ var f = x => x ->f : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>f : (x: number) => string +>x => x : (x: number) => number +>x : number +>x : number /** @type {(x: number) => string} */ var g = function (x) { return x } ->g : (x: any) => any ->function (x) { return x } : (x: any) => any ->x : any ->x : any +>g : (x: number) => string +>function (x) { return x } : (x: number) => number +>x : number +>x : number /** @type {{ (x: number): string }} */ function i(x) { return x } @@ -30,17 +30,17 @@ function i(x) { return x } /** @type {{ (x: number): string }} */ var j = x => x ->j : (x: any) => any ->x => x : (x: any) => any ->x : any ->x : any +>j : (x: number) => string +>x => x : (x: number) => number +>x : number +>x : number /** @type {{ (x: number): string }} */ var k = function (x) { return x } ->k : (x: any) => any ->function (x) { return x } : (x: any) => any ->x : any ->x : any +>k : (x: number) => string +>function (x) { return x } : (x: number) => number +>x : number +>x : number /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ @@ -55,7 +55,7 @@ function blargle(s) { /** @type {0 | 1 | 2} - assignment should not error */ var zeroonetwo = blargle('hi') ->zeroonetwo : number +>zeroonetwo : 0 | 1 | 2 >blargle('hi') : number >blargle : (s: any) => number >'hi' : "hi" @@ -79,7 +79,7 @@ function monaLisa(sb) { /** @type {2 | 3} - overloads are not supported, so there will be an error */ var twothree = monaLisa(false); ->twothree : number +>twothree : 2 | 3 >monaLisa(false) : 1 | 2 >monaLisa : (sb: any) => 1 | 2 >false : false diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt new file mode 100644 index 0000000000..34a62935d5 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt @@ -0,0 +1,52 @@ +test.js(7,5): error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. +test.js(27,7): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. + Target signature provides too few arguments. Expected 1 or more, but got 0. +test.js(30,7): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. + Target signature provides too few arguments. Expected 1 or more, but got 0. + + +==== test.js (3 errors) ==== + /** @type {number} */ + function f() { + return 1 + } + + /** @type {{ prop: string }} */ + var g = function (prop) { + ~ +!!! error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. + } + + /** @type {(a: number) => number} */ + function add1(a, b) { return a + b; } + + /** @type {(a: number, b: number) => number} */ + function add2(a, b) { return a + b; } + + // TODO: Should be an error since signature doesn't match. + /** @type {(a: number, b: number, c: number) => number} */ + function add3(a, b) { return a + b; } + + // Confirm initializers are compatible. + // They can't have more parameters than the type/context. + + /** @type {() => void} */ + function funcWithMoreParameters(more) {} // error + + /** @type {() => void} */ + const variableWithMoreParameters = function (more) {}; // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. +!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. + + /** @type {() => void} */ + const arrowWithMoreParameters = (more) => {}; // error + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. +!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. + + ({ + /** @type {() => void} */ + methodWithMoreParameters(more) {}, // error + }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.types index 66a0efe8a4..f965842389 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.types @@ -11,7 +11,7 @@ function f() { /** @type {{ prop: string }} */ var g = function (prop) { ->g : (prop: any) => void +>g : { prop: string; } >function (prop) {} : (prop: any) => void >prop : any } @@ -54,13 +54,13 @@ function funcWithMoreParameters(more) {} // error /** @type {() => void} */ const variableWithMoreParameters = function (more) {}; // error ->variableWithMoreParameters : (more: any) => void +>variableWithMoreParameters : () => void >function (more) {} : (more: any) => void >more : any /** @type {() => void} */ const arrowWithMoreParameters = (more) => {}; // error ->arrowWithMoreParameters : (more: any) => void +>arrowWithMoreParameters : () => void >(more) => {} : (more: any) => void >more : any diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.errors.txt index 14b4f4d795..35c7d11f52 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.errors.txt @@ -1,8 +1,7 @@ -0.js(19,1): error TS2322: Type '"string"' is not assignable to type 'undefined'. -0.js(21,1): error TS2322: Type 'undefined' is not assignable to type 'string'. +0.js(16,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -==== 0.js (2 errors) ==== +==== 0.js (1 errors) ==== // @ts-check var lol = "hello Lol" const obj = { @@ -19,15 +18,14 @@ /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. arrowFunc: (num) => num + 42 } obj.foo = 'string' - ~~~~~~~ -!!! error TS2322: Type '"string"' is not assignable to type 'undefined'. obj.lol obj.bar = undefined; - ~~~~~~~ -!!! error TS2322: Type 'undefined' is not assignable to type 'string'. var k = obj.method1(0); obj.bar1 = "42"; obj.arrowFunc(0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.types index cb261a3ebd..e62fd337bd 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty1.types @@ -7,17 +7,19 @@ var lol = "hello Lol" >"hello Lol" : "hello Lol" const obj = { ->obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } ->{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ arrowFunc: (num) => num + 42} : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } +>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } +>{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ arrowFunc: (num) => num + 42} : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } /** @type {string|undefined} */ foo: undefined, ->foo : undefined +>foo : string | undefined +>undefined : string | undefined >undefined : undefined /** @type {string|undefined} */ bar: "42", ->bar : string +>bar : string | undefined +>"42" : string | undefined >"42" : "42" /** @type {function(number): number} */ @@ -41,11 +43,13 @@ const obj = { >'b' + 'ar1' : string >'b' : "b" >'ar1' : "ar1" +>42 : number >42 : 42 /** @type {function(number): number} */ arrowFunc: (num) => num + 42 ->arrowFunc : (num: any) => any +>arrowFunc : function +>(num) => num + 42 : function >(num) => num + 42 : (num: any) => any >num : any >num + 42 : any @@ -54,42 +58,42 @@ const obj = { } obj.foo = 'string' >obj.foo = 'string' : "string" ->obj.foo : undefined ->obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } ->foo : undefined +>obj.foo : string | undefined +>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } +>foo : string | undefined >'string' : "string" obj.lol >obj.lol : string ->obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } +>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } >lol : string obj.bar = undefined; >obj.bar = undefined : undefined ->obj.bar : string ->obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } ->bar : string +>obj.bar : string | undefined +>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } +>bar : string | undefined >undefined : undefined var k = obj.method1(0); >k : any >obj.method1(0) : any >obj.method1 : (n1: any) => any ->obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } +>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } >method1 : (n1: any) => any >0 : 0 obj.bar1 = "42"; >obj.bar1 = "42" : "42" ->obj.bar1 : string | number | ((n1: any) => any) | undefined ->obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } ->bar1 : string | number | ((n1: any) => any) | undefined +>obj.bar1 : any +>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } +>bar1 : any >"42" : "42" obj.arrowFunc(0); >obj.arrowFunc(0) : any ->obj.arrowFunc : (num: any) => any ->obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } ->arrowFunc : (num: any) => any +>obj.arrowFunc : function +>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } +>arrowFunc : function >0 : 0 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt new file mode 100644 index 0000000000..579a296c34 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt @@ -0,0 +1,36 @@ +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'? + + +==== 0.js (3 errors) ==== + // @ts-check + var lol; + 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. + /** @type {function(number): number} */ + method1(n1) { + return "42"; + }, + /** @type {function(number): number} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + method2: (n1) => "lol", + /** @type {function(number): number} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + arrowFunc: (num="0") => num + 42, + /** @type {string} */ + lol + } + lol = "string" + /** @type {string} */ + var s = obj.method1(0); + + /** @type {string} */ + var s1 = obj.method2("0"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.types index 0976ecc6c6..442a08a945 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.types @@ -6,12 +6,13 @@ var lol; >lol : any const obj = { ->obj : { bar: number; method1: (n1: any) => string; method2: (n1: any) => string; arrowFunc: (num?: string) => string; 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: number; method1: (n1: any) => string; method2: (n1: any) => string; arrowFunc: (num?: string) => string; lol: any; } +>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; } /** @type {string|undefined} */ bar: 42, ->bar : number +>bar : string | undefined +>42 : string | undefined >42 : 42 /** @type {function(number): number} */ @@ -25,14 +26,16 @@ const obj = { }, /** @type {function(number): number} */ method2: (n1) => "lol", ->method2 : (n1: any) => string +>method2 : function +>(n1) => "lol" : function >(n1) => "lol" : (n1: any) => string >n1 : any >"lol" : "lol" /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, ->arrowFunc : (num?: string) => string +>arrowFunc : function +>(num="0") => num + 42 : function >(num="0") => num + 42 : (num?: string) => string >num : string >"0" : "0" @@ -54,16 +57,16 @@ var s = obj.method1(0); >s : string >obj.method1(0) : string >obj.method1 : (n1: any) => string ->obj : { bar: number; method1: (n1: any) => string; method2: (n1: any) => string; arrowFunc: (num?: string) => string; lol: any; } +>obj : { bar: string | undefined; method1: (n1: any) => string; method2: function; arrowFunc: function; lol: any; } >method1 : (n1: any) => string >0 : 0 /** @type {string} */ var s1 = obj.method2("0"); >s1 : string ->obj.method2("0") : string ->obj.method2 : (n1: any) => string ->obj : { bar: number; method1: (n1: any) => string; method2: (n1: any) => string; arrowFunc: (num?: string) => string; lol: any; } ->method2 : (n1: any) => string +>obj.method2("0") : any +>obj.method2 : function +>obj : { bar: string | undefined; method1: (n1: any) => string; method2: function; arrowFunc: function; lol: any; } +>method2 : function >"0" : "0" diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt new file mode 100644 index 0000000000..5c9948e856 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt @@ -0,0 +1,56 @@ +0.js(15,5): error TS2739: Type '{ x: string; }' is missing the following properties from type 'Opts': y, z, w +0.js(28,6): error TS2741: Property 'anotherY' is missing in type '{ anotherX: string; }' but required in type 'AnotherOpts'. +0.js(42,6): error TS2739: Type '{ x: string; }' is missing the following properties from type 'Opts1': y, z, w + + +==== 0.js (3 errors) ==== + // @ts-check + /** + * @typedef {Object} Opts + * @property {string} x + * @property {string=} y + * @property {string} [z] + * @property {string} [w="hi"] + * + * @param {Opts} opts + */ + function foo(opts) { + opts.x; + } + + foo({x: 'abc'}); + ~~~~~~~~~~ +!!! error TS2739: Type '{ x: string; }' is missing the following properties from type 'Opts': y, z, w + + /** + * @typedef {Object} AnotherOpts + * @property anotherX {string} + * @property anotherY {string=} + * + * @param {AnotherOpts} opts + */ + function foo1(opts) { + opts.anotherX; + } + + foo1({anotherX: "world"}); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2741: Property 'anotherY' is missing in type '{ anotherX: string; }' but required in type 'AnotherOpts'. +!!! related TS2728 0.js:20:14: 'anotherY' is declared here. + + /** + * @typedef {object} Opts1 + * @property {string} x + * @property {string=} y + * @property {string} [z] + * @property {string} [w="hi"] + * + * @param {Opts1} opts + */ + function foo2(opts) { + opts.x; + } + foo2({x: 'abc'}); + ~~~~~~~~~~ +!!! error TS2739: Type '{ x: string; }' is missing the following properties from type 'Opts1': y, z, w + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.symbols index 66488bb0b1..f0f06c6fc0 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.symbols @@ -16,7 +16,9 @@ function foo(opts) { >opts : Symbol(opts, Decl(0.js, 10, 13)) opts.x; +>opts.x : Symbol(x, Decl(0.js, 3, 3)) >opts : Symbol(opts, Decl(0.js, 10, 13)) +>x : Symbol(x, Decl(0.js, 3, 3)) } foo({x: 'abc'}); @@ -35,7 +37,9 @@ function foo1(opts) { >opts : Symbol(opts, Decl(0.js, 23, 14)) opts.anotherX; +>opts.anotherX : Symbol(anotherX, Decl(0.js, 18, 3)) >opts : Symbol(opts, Decl(0.js, 23, 14)) +>anotherX : Symbol(anotherX, Decl(0.js, 18, 3)) } foo1({anotherX: "world"}); @@ -56,7 +60,9 @@ function foo2(opts) { >opts : Symbol(opts, Decl(0.js, 38, 14)) opts.x; +>opts.x : Symbol(x, Decl(0.js, 31, 3)) >opts : Symbol(opts, Decl(0.js, 38, 14)) +>x : Symbol(x, Decl(0.js, 31, 3)) } foo2({x: 'abc'}); >foo2 : Symbol(foo2, Decl(0.js, 27, 26)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.symbols.diff deleted file mode 100644 index 3da9dac730..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.symbols.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.checkJsdocTypedefInParamTag1.symbols -+++ new.checkJsdocTypedefInParamTag1.symbols -@@= skipped -15, +15 lines =@@ - >opts : Symbol(opts, Decl(0.js, 10, 13)) - - opts.x; -->opts.x : Symbol(x, Decl(0.js, 3, 3)) - >opts : Symbol(opts, Decl(0.js, 10, 13)) -->x : Symbol(x, Decl(0.js, 3, 3)) - } - - foo({x: 'abc'}); -@@= skipped -21, +19 lines =@@ - >opts : Symbol(opts, Decl(0.js, 23, 14)) - - opts.anotherX; -->opts.anotherX : Symbol(anotherX, Decl(0.js, 18, 3)) - >opts : Symbol(opts, Decl(0.js, 23, 14)) -->anotherX : Symbol(anotherX, Decl(0.js, 18, 3)) - } - - foo1({anotherX: "world"}); -@@= skipped -23, +21 lines =@@ - >opts : Symbol(opts, Decl(0.js, 38, 14)) - - opts.x; -->opts.x : Symbol(x, Decl(0.js, 31, 3)) - >opts : Symbol(opts, Decl(0.js, 38, 14)) -->x : Symbol(x, Decl(0.js, 31, 3)) - } - foo2({x: 'abc'}); - >foo2 : Symbol(foo2, Decl(0.js, 27, 26)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.types index f92d9126fb..1f9d8338ed 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.types @@ -12,18 +12,18 @@ * @param {Opts} opts */ function foo(opts) { ->foo : (opts: any) => void ->opts : any +>foo : (opts: Opts) => void +>opts : Opts opts.x; >opts.x : any ->opts : any +>opts : Opts >x : any } foo({x: 'abc'}); >foo({x: 'abc'}) : void ->foo : (opts: any) => void +>foo : (opts: Opts) => void >{x: 'abc'} : { x: string; } >x : string >'abc' : "abc" @@ -36,18 +36,18 @@ foo({x: 'abc'}); * @param {AnotherOpts} opts */ function foo1(opts) { ->foo1 : (opts: any) => void ->opts : any +>foo1 : (opts: AnotherOpts) => void +>opts : AnotherOpts opts.anotherX; >opts.anotherX : any ->opts : any +>opts : AnotherOpts >anotherX : any } foo1({anotherX: "world"}); >foo1({anotherX: "world"}) : void ->foo1 : (opts: any) => void +>foo1 : (opts: AnotherOpts) => void >{anotherX: "world"} : { anotherX: string; } >anotherX : string >"world" : "world" @@ -62,17 +62,17 @@ foo1({anotherX: "world"}); * @param {Opts1} opts */ function foo2(opts) { ->foo2 : (opts: any) => void ->opts : any +>foo2 : (opts: Opts1) => void +>opts : Opts1 opts.x; >opts.x : any ->opts : any +>opts : Opts1 >x : any } foo2({x: 'abc'}); >foo2({x: 'abc'}) : void ->foo2 : (opts: any) => void +>foo2 : (opts: Opts1) => void >{x: 'abc'} : { x: string; } >x : string >'abc' : "abc" diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt index a2ec89dadf..7cb22b9170 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt @@ -1,10 +1,14 @@ +0.js(3,5): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. 0.js(8,9): error TS2339: Property 'SomeName' does not exist on type '{}'. +0.js(10,12): error TS2503: Cannot find namespace 'exports'. -==== 0.js (1 errors) ==== +==== 0.js (3 errors) ==== // @ts-check var exports = {}; + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. /** * @typedef {string} @@ -14,5 +18,7 @@ !!! error TS2339: Property 'SomeName' does not exist on type '{}'. /** @type {exports.SomeName} */ + ~~~~~~~ +!!! error TS2503: Cannot find namespace 'exports'. const myString = 'str'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.types index 79e4c53da7..7adcabd12e 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.types @@ -17,6 +17,6 @@ exports.SomeName; /** @type {exports.SomeName} */ const myString = 'str'; ->myString : "str" +>myString : SomeName >'str' : "str" diff --git a/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt b/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt index 9e51e0e0f0..f2698865d7 100644 --- a/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt @@ -1,7 +1,9 @@ bug24252.js(2,3): error TS2339: Property 'B' does not exist on type '{}'. +bug24252.js(8,9): error TS2322: Type 'string[]' is not assignable to type 'number[]'. + Type 'string' is not assignable to type 'number'. -==== bug24252.js (1 errors) ==== +==== bug24252.js (2 errors) ==== var A = {}; A.B = class { ~ @@ -12,6 +14,9 @@ bug24252.js(2,3): error TS2339: Property 'B' does not exist on type '{}'. /** @type {number[]} */ var y; y = x; + ~ +!!! error TS2322: Type 'string[]' is not assignable to type 'number[]'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. } }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.types b/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.types index 686e32f361..fdb014f9a0 100644 --- a/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.types +++ b/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.types @@ -17,17 +17,17 @@ A.B = class { /** @type {string[]} */ var x = []; ->x : any[] +>x : string[] >[] : undefined[] /** @type {number[]} */ var y; ->y : any +>y : number[] y = x; ->y = x : any[] ->y : any ->x : any[] +>y = x : string[] +>y : number[] +>x : string[] } }; diff --git a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt index 212636b13a..89f4bc9ab8 100644 --- a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt @@ -1,19 +1,20 @@ -first.js(21,19): error TS2507: Type '{ (numberOxen: any): void; circle: (wagons: any) => any; }' is not a constructor function type. +first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. first.js(24,14): error TS2339: Property 'foonly' does not exist on type 'Sql'. +first.js(27,21): error TS8020: JSDoc types can only be used inside documentation comments. first.js(44,4): error TS2339: Property 'numberOxen' does not exist on type 'Sql'. first.js(44,20): error TS2339: Property 'foonly' does not exist on type 'Sql'. first.js(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. -generic.js(9,23): error TS2507: Type '(flavour: any) => void' is not a constructor function type. +generic.js(9,23): error TS2507: Type '(flavour: T) => void' is not a constructor function type. generic.js(11,21): error TS2339: Property 'flavour' does not exist on type 'Chowder'. generic.js(17,27): error TS2554: Expected 0 arguments, but got 1. generic.js(18,9): error TS2339: Property 'flavour' does not exist on type 'Chowder'. generic.js(20,32): error TS2554: Expected 0 arguments, but got 1. second.ts(8,25): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. -second.ts(14,25): error TS2507: Type '{ (numberOxen: any): void; circle: (wagons: any) => any; }' is not a constructor function type. +second.ts(14,25): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== first.js (5 errors) ==== +==== first.js (6 errors) ==== /** * @constructor * @param {number} numberOxen @@ -36,7 +37,7 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con // ok class Sql extends Wagon { ~~~~~ -!!! error TS2507: Type '{ (numberOxen: any): void; circle: (wagons: any) => any; }' is not a constructor function type. +!!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. constructor() { super(); // error: not enough arguments this.foonly = 12 @@ -45,6 +46,8 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con } /** * @param {Array.} files + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. * @param {"csv" | "json" | "xmlolololol"} format * This is not assignable, so should have a type error */ @@ -92,7 +95,7 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con // ok class Conestoga extends Wagon { ~~~~~ -!!! error TS2507: Type '{ (numberOxen: any): void; circle: (wagons: any) => any; }' is not a constructor function type. +!!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. constructor(public drunkOO: true) { // error: wrong type super('nope'); @@ -119,7 +122,7 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { ~~~~ -!!! error TS2507: Type '(flavour: any) => void' is not a constructor function type. +!!! error TS2507: Type '(flavour: T) => void' is not a constructor function type. log() { return this.flavour ~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.types b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.types index 18242382b7..ff87ed7d40 100644 --- a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.types +++ b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.types @@ -6,21 +6,21 @@ * @param {number} numberOxen */ function Wagon(numberOxen) { ->Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } ->numberOxen : any +>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } +>numberOxen : number this.numberOxen = numberOxen ->this.numberOxen = numberOxen : any +>this.numberOxen = numberOxen : number >this.numberOxen : any >this : any >numberOxen : any ->numberOxen : any +>numberOxen : number } /** @param {Wagon[]=} wagons */ Wagon.circle = function (wagons) { >Wagon.circle = function (wagons) { return wagons ? wagons.length : 3.14;} : (wagons: any) => any >Wagon.circle : (wagons: any) => any ->Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } +>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } >circle : (wagons: any) => any >function (wagons) { return wagons ? wagons.length : 3.14;} : (wagons: any) => any >wagons : any @@ -38,7 +38,7 @@ Wagon.prototype.load = function (supplies) { >Wagon.prototype.load = function (supplies) {} : (supplies: any) => void >Wagon.prototype.load : any >Wagon.prototype : any ->Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } +>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } >prototype : any >load : any >function (supplies) {} : (supplies: any) => void @@ -49,7 +49,7 @@ Wagon.prototype.weight = supplies => supplies ? supplies.length : -1 >Wagon.prototype.weight = supplies => supplies ? supplies.length : -1 : (supplies: any) => any >Wagon.prototype.weight : any >Wagon.prototype : any ->Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } +>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } >prototype : any >weight : any >supplies => supplies ? supplies.length : -1 : (supplies: any) => any @@ -66,7 +66,7 @@ Wagon.prototype.speed = function () { >Wagon.prototype.speed = function () { return this.numberOxen / this.weight()} : () => number >Wagon.prototype.speed : any >Wagon.prototype : any ->Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } +>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } >prototype : any >speed : any >function () { return this.numberOxen / this.weight()} : () => number @@ -84,7 +84,7 @@ Wagon.prototype.speed = function () { // ok class Sql extends Wagon { >Sql : Sql ->Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } +>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } constructor() { super(); // error: not enough arguments @@ -104,13 +104,13 @@ class Sql extends Wagon { * This is not assignable, so should have a type error */ load(files, format) { ->load : (files: any, format: any) => void ->files : any ->format : any +>load : (files: string[], format: "csv" | "json" | "xmlolololol") => void +>files : string[] +>format : "csv" | "json" | "xmlolololol" if (format === "xmlolololol") { >format === "xmlolololol" : boolean ->format : any +>format : "csv" | "json" | "xmlolololol" >"xmlolololol" : "xmlolololol" throw new Error("please do not use XML. It was a joke."); @@ -188,7 +188,7 @@ class Firedrake extends Dragon { // ok class Conestoga extends Wagon { >Conestoga : Conestoga ->Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } +>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } constructor(public drunkOO: true) { >drunkOO : true @@ -202,13 +202,13 @@ class Conestoga extends Wagon { } // should error since others is not optional static circle(others: (typeof Wagon)[]) { ->circle : (others: { (numberOxen: any): void; circle: (wagons: any) => any; }[]) => number ->others : { (numberOxen: any): void; circle: (wagons: any) => any; }[] ->Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } +>circle : (others: { (numberOxen: number): void; circle: (wagons: any) => any; }[]) => number +>others : { (numberOxen: number): void; circle: (wagons: any) => any; }[] +>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } return others.length >others.length : number ->others : { (numberOxen: any): void; circle: (wagons: any) => any; }[] +>others : { (numberOxen: number): void; circle: (wagons: any) => any; }[] >length : number } } @@ -234,20 +234,20 @@ c.numberOxen * @param {T} flavour */ function Soup(flavour) { ->Soup : (flavour: any) => void ->flavour : any +>Soup : (flavour: T) => void +>flavour : T this.flavour = flavour ->this.flavour = flavour : any +>this.flavour = flavour : T >this.flavour : any >this : any >flavour : any ->flavour : any +>flavour : T } /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { >Chowder : Chowder ->Soup : (flavour: any) => void +>Soup : (flavour: T) => void log() { >log : () => any @@ -262,7 +262,7 @@ class Chowder extends Soup { var soup = new Soup(1); >soup : any >new Soup(1) : any ->Soup : (flavour: any) => void +>Soup : (flavour: T) => void >1 : 1 soup.flavour diff --git a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.types b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.types index 53e5d345b8..cc0fc9ebc6 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.types +++ b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.types @@ -9,10 +9,10 @@ const { funky } = require('./commonJSAliasedExport'); /** @type {boolean} */ var diddy ->diddy : any +>diddy : boolean var diddy = funky(1) ->diddy : any +>diddy : boolean >funky(1) : any >funky : any >1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt index 0cafdc45f5..04d5cfd894 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt @@ -1,6 +1,6 @@ main.js(1,9): error TS2451: Cannot redeclare block-scoped variable 'K'. main.js(1,15): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -main.js(3,12): error TS7006: Parameter 'k' implicitly has an 'any' type. +main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? mod1.js(1,7): error TS2451: Cannot redeclare block-scoped variable 'K'. mod1.js(6,1): error TS2304: Cannot find name 'exports'. @@ -13,9 +13,9 @@ mod1.js(6,1): error TS2304: Cannot find name 'exports'. ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @param {K} k */ + ~ +!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? function f(k) { - ~ -!!! error TS7006: Parameter 'k' implicitly has an 'any' type. k.values() } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.types b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.types index 98958f7c45..03ded8a6a7 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.types +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.types @@ -9,13 +9,13 @@ const { K } = require("./mod1"); /** @param {K} k */ function f(k) { ->f : (k: any) => void ->k : any +>f : (k: K) => void +>k : K k.values() >k.values() : any >k.values : any ->k : any +>k : K >values : any } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt index 4b5091844a..eb50cc5891 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt @@ -1,5 +1,5 @@ main.js(1,15): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -main.js(3,12): error TS7006: Parameter 'k' implicitly has an 'any' type. +main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? mod1.js(1,1): error TS2304: Cannot find name 'exports'. @@ -8,9 +8,9 @@ mod1.js(1,1): error TS2304: Cannot find name 'exports'. ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @param {K} k */ + ~ +!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? function f(k) { - ~ -!!! error TS7006: Parameter 'k' implicitly has an 'any' type. k.values() } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.types b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.types index a91436eab1..271bca849a 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.types +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.types @@ -9,13 +9,13 @@ const { K } = require("./mod1"); /** @param {K} k */ function f(k) { ->f : (k: any) => void ->k : any +>f : (k: K) => void +>k : K k.values() >k.values() : any >k.values : any ->k : any +>k : K >values : any } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt index f073a561ff..0444e83a7f 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt @@ -1,5 +1,5 @@ main.js(1,15): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -main.js(3,12): error TS7006: Parameter 'k' implicitly has an 'any' type. +main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? mod1.js(2,4): error TS2339: Property 'K' does not exist on type '{}'. mod1.js(4,23): error TS2339: Property 'K' does not exist on type '{}'. mod1.js(7,1): error TS2304: Cannot find name 'exports'. @@ -11,9 +11,9 @@ mod1.js(7,16): error TS2339: Property 'K' does not exist on type '{}'. ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @param {K} k */ + ~ +!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? function f(k) { - ~ -!!! error TS7006: Parameter 'k' implicitly has an 'any' type. k.values() } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.types b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.types index 14f792ae09..7176fdf016 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.types +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.types @@ -9,13 +9,13 @@ const { K } = require("./mod1"); /** @param {K} k */ function f(k) { ->f : (k: any) => void ->k : any +>f : (k: K) => void +>k : K k.values() >k.values() : any >k.values : any ->k : any +>k : K >values : any } diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt new file mode 100644 index 0000000000..051cf5113e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt @@ -0,0 +1,43 @@ +constructorFunctionMethodTypeParameters.js(22,16): error TS2304: Cannot find name 'T'. +constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find name 'T'. + + +==== constructorFunctionMethodTypeParameters.js (2 errors) ==== + /** + * @template {string} T + * @param {T} t + */ + function Cls(t) { + this.t = t; + } + + /** + * @template {string} V + * @param {T} t + * @param {V} v + * @return {V} + */ + Cls.prototype.topLevelComment = function (t, v) { + return v + }; + + Cls.prototype.nestedComment = + /** + * @template {string} U + * @param {T} t + ~ +!!! error TS2304: Cannot find name 'T'. + * @param {U} u + * @return {T} + ~ +!!! error TS2304: Cannot find name 'T'. + */ + function (t, u) { + return t + }; + + var c = new Cls('a'); + const s = c.topLevelComment('a', 'b'); + const t = c.nestedComment('a', 'b'); + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.types b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.types index b7173f4d71..3c44273775 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.types +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.types @@ -6,15 +6,15 @@ * @param {T} t */ function Cls(t) { ->Cls : (t: any) => void ->t : any +>Cls : (t: T) => void +>t : T this.t = t; ->this.t = t : any +>this.t = t : T >this.t : any >this : any >t : any ->t : any +>t : T } /** @@ -27,7 +27,7 @@ Cls.prototype.topLevelComment = function (t, v) { >Cls.prototype.topLevelComment = function (t, v) { return v} : (t: any, v: any) => any >Cls.prototype.topLevelComment : any >Cls.prototype : any ->Cls : (t: any) => void +>Cls : (t: T) => void >prototype : any >topLevelComment : any >function (t, v) { return v} : (t: any, v: any) => any @@ -40,10 +40,10 @@ Cls.prototype.topLevelComment = function (t, v) { }; Cls.prototype.nestedComment = ->Cls.prototype.nestedComment = /** * @template {string} U * @param {T} t * @param {U} u * @return {T} */ function (t, u) { return t } : (t: any, u: any) => any +>Cls.prototype.nestedComment = /** * @template {string} U * @param {T} t * @param {U} u * @return {T} */ function (t, u) { return t } : (t: T, u: U) => T >Cls.prototype.nestedComment : any >Cls.prototype : any ->Cls : (t: any) => void +>Cls : (t: T) => void >prototype : any >nestedComment : any @@ -54,19 +54,19 @@ Cls.prototype.nestedComment = * @return {T} */ function (t, u) { ->function (t, u) { return t } : (t: any, u: any) => any ->t : any ->u : any +>function (t, u) { return t } : (t: T, u: U) => T +>t : T +>u : U return t ->t : any +>t : T }; var c = new Cls('a'); >c : any >new Cls('a') : any ->Cls : (t: any) => void +>Cls : (t: T) => void >'a' : "a" const s = c.topLevelComment('a', 'b'); diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctions.types b/testdata/baselines/reference/submodule/conformance/constructorFunctions.types index 786e3438ed..e3e261c170 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctions.types +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctions.types @@ -176,11 +176,11 @@ var c6_v1 = new C6(); * @param {number} num */ function C7(num) {} ->C7 : (num: any) => void ->num : any +>C7 : (num: number) => void +>num : number var c7_v1 = new C7(); >c7_v1 : any >new C7() : any ->C7 : (num: any) => void +>C7 : (num: number) => void diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt index 7aa952a2a5..0744aa6348 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt @@ -1,15 +1,11 @@ -a.js(2,12): error TS7006: Parameter 'x' implicitly has an 'any' type. a.js(8,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -a.js(13,12): error TS7006: Parameter 'x' implicitly has an 'any' type. a.js(15,16): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. a.js(20,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -==== a.js (5 errors) ==== +==== a.js (3 errors) ==== /** @param {number} x */ function C(x) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. this.x = x } C.prototype.m = function() { @@ -23,8 +19,6 @@ a.js(20,9): error TS7009: 'new' expression, whose target lacks a construct signa /** @param {number} x */ function A(x) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. if (!(this instanceof A)) { return new A(x) ~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.types b/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.types index db8c347c84..1740c1a364 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.types +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.types @@ -3,21 +3,21 @@ === a.js === /** @param {number} x */ function C(x) { ->C : (x: any) => void ->x : any +>C : (x: number) => void +>x : number this.x = x ->this.x = x : any +>this.x = x : number >this.x : any >this : any >x : any ->x : any +>x : number } C.prototype.m = function() { >C.prototype.m = function() { this.y = 12} : () => void >C.prototype.m : any >C.prototype : any ->C : (x: any) => void +>C : (x: number) => void >prototype : any >m : any >function() { this.y = 12} : () => void @@ -32,7 +32,7 @@ C.prototype.m = function() { var c = new C(1) >c : any >new C(1) : any ->C : (x: any) => void +>C : (x: number) => void >1 : 1 c.x = undefined // should error @@ -51,38 +51,38 @@ c.y = undefined // ok /** @param {number} x */ function A(x) { ->A : (x: any) => any ->x : any +>A : (x: number) => any +>x : number if (!(this instanceof A)) { >!(this instanceof A) : boolean >(this instanceof A) : boolean >this instanceof A : boolean >this : any ->A : (x: any) => any +>A : (x: number) => any return new A(x) >new A(x) : any ->A : (x: any) => any ->x : any +>A : (x: number) => any +>x : number } this.x = x ->this.x = x : any +>this.x = x : number >this.x : any >this : any >x : any ->x : any +>x : number } var k = A(1) >k : any >A(1) : any ->A : (x: any) => any +>A : (x: number) => any >1 : 1 var j = new A(2) >j : any >new A(2) : any ->A : (x: any) => any +>A : (x: number) => any >2 : 2 k.x === j.x diff --git a/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.types b/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.types index e5b823c60c..82c90c7c6c 100644 --- a/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.types +++ b/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.types @@ -3,18 +3,18 @@ === index.js === /** @type {Array<[string, {x?:number, y?:number}]>} */ const arr = [ ->arr : ((string | { x: number; })[] | (string | { y: number; })[])[] ->[ ['a', { x: 1 }], ['b', { y: 2 }]] : ((string | { x: number; })[] | (string | { y: number; })[])[] +>arr : [string, { x?: number; y?: number; }][] +>[ ['a', { x: 1 }], ['b', { y: 2 }]] : ([string, { x: number; }] | [string, { y: number; }])[] ['a', { x: 1 }], ->['a', { x: 1 }] : (string | { x: number; })[] +>['a', { x: 1 }] : [string, { x: number; }] >'a' : "a" >{ x: 1 } : { x: number; } >x : number >1 : 1 ['b', { y: 2 }] ->['b', { y: 2 }] : (string | { y: number; })[] +>['b', { y: 2 }] : [string, { y: number; }] >'b' : "b" >{ y: 2 } : { y: number; } >y : number @@ -24,20 +24,20 @@ const arr = [ /** @return {Array<[string, {x?:number, y?:number}]>} */ function f() { ->f : () => ((string | { x: number; })[] | (string | { y: number; })[])[] +>f : () => [string, { x?: number; y?: number; }][] return [ ->[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ((string | { x: number; })[] | (string | { y: number; })[])[] +>[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ([string, { x: number; }] | [string, { y: number; }])[] ['a', { x: 1 }], ->['a', { x: 1 }] : (string | { x: number; })[] +>['a', { x: 1 }] : [string, { x: number; }] >'a' : "a" >{ x: 1 } : { x: number; } >x : number >1 : 1 ['b', { y: 2 }] ->['b', { y: 2 }] : (string | { y: number; })[] +>['b', { y: 2 }] : [string, { y: number; }] >'b' : "b" >{ y: 2 } : { y: number; } >y : number @@ -51,24 +51,24 @@ class C { /** @param {Array<[string, {x?:number, y?:number}]>} value */ set x(value) { } ->x : ((string | { x: number; })[] | (string | { y: number; })[])[] ->value : ((string | { x: number; })[] | (string | { y: number; })[])[] +>x : [string, { x?: number; y?: number; }][] +>value : [string, { x?: number; y?: number; }][] get x() { ->x : ((string | { x: number; })[] | (string | { y: number; })[])[] +>x : [string, { x?: number; y?: number; }][] return [ ->[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ((string | { x: number; })[] | (string | { y: number; })[])[] +>[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ([string, { x: number; }] | [string, { y: number; }])[] ['a', { x: 1 }], ->['a', { x: 1 }] : (string | { x: number; })[] +>['a', { x: 1 }] : [string, { x: number; }] >'a' : "a" >{ x: 1 } : { x: number; } >x : number >1 : 1 ['b', { y: 2 }] ->['b', { y: 2 }] : (string | { y: number; })[] +>['b', { y: 2 }] : [string, { y: number; }] >'b' : "b" >{ y: 2 } : { y: number; } >y : number diff --git a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt index 686855675a..800958af53 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt @@ -1,7 +1,11 @@ +a.js(24,13): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? +a.js(25,12): error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? +a.js(26,12): error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? +a.js(35,16): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? a.js(37,16): error TS2339: Property 'UNKNOWN' does not exist on type '{ START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; }'. -==== a.js (1 errors) ==== +==== a.js (5 errors) ==== /** @enum {string} */ const Target = { START: "start", @@ -26,8 +30,14 @@ a.js(37,16): error TS2339: Property 'UNKNOWN' does not exist on type '{ START: s } /** @param {Target} t + ~~~~~~ +!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? * @param {Second} s + ~~~~~~ +!!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? * @param {Fs} f + ~~ +!!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? */ function consume(t,s,f) { /** @type {string} */ @@ -37,6 +47,8 @@ a.js(37,16): error TS2339: Property 'UNKNOWN' does not exist on type '{ START: s /** @type {(n: number) => number} */ var fun = f /** @type {Target} */ + ~~~~~~ +!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? var v = Target.START v = Target.UNKNOWN // error, can't find 'UNKNOWN' ~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/enumTag.types b/testdata/baselines/reference/submodule/conformance/enumTag.types index 14215c159e..e8fa8e9905 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTag.types +++ b/testdata/baselines/reference/submodule/conformance/enumTag.types @@ -25,6 +25,7 @@ const Target = { /** @type {number} */ OK_I_GUESS: 2 >OK_I_GUESS : number +>2 : number >2 : 2 } /** @enum number */ @@ -43,6 +44,7 @@ const Second = { /** @type {number} */ FINE: 2, >FINE : number +>2 : number >2 : 2 } /** @enum {function(number): number} */ @@ -78,63 +80,63 @@ const Fs = { * @param {Fs} f */ function consume(t,s,f) { ->consume : (t: any, s: any, f: any) => void ->t : any ->s : any ->f : any +>consume : (t: Target, s: Second, f: Fs) => void +>t : Target +>s : Second +>f : Fs /** @type {string} */ var str = t ->str : any ->t : any +>str : string +>t : Target /** @type {number} */ var num = s ->num : any ->s : any +>num : number +>s : Second /** @type {(n: number) => number} */ var fun = f ->fun : any ->f : any +>fun : (n: number) => number +>f : Fs /** @type {Target} */ var v = Target.START ->v : string +>v : Target >Target.START : string >Target : { START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; } >START : string v = Target.UNKNOWN // error, can't find 'UNKNOWN' >v = Target.UNKNOWN : any ->v : string +>v : Target >Target.UNKNOWN : any >Target : { START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; } >UNKNOWN : any v = Second.MISTAKE // meh..ok, I guess? >v = Second.MISTAKE : string ->v : string +>v : Target >Second.MISTAKE : string >Second : { MISTAKE: string; OK: number; FINE: number; } >MISTAKE : string v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums >v = 'something else' : "something else" ->v : string +>v : Target >'something else' : "something else" } /** @param {string} s */ function ff(s) { ->ff : (s: any) => any ->s : any +>ff : (s: string) => any +>s : string // element access with arbitrary string is an error only with noImplicitAny if (!Target[s]) { >!Target[s] : boolean >Target[s] : any >Target : { START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; } ->s : any +>s : string return null } @@ -142,7 +144,7 @@ function ff(s) { return Target[s] >Target[s] : any >Target : { START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; } ->s : any +>s : string } } diff --git a/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt new file mode 100644 index 0000000000..5180e90595 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt @@ -0,0 +1,31 @@ +type.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. +type.js(4,29): error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. +value.js(2,12): error TS2749: 'TestEnum' refers to a value, but is being used as a type here. Did you mean 'typeof TestEnum'? + + +==== type.js (2 errors) ==== + /** @typedef {import("./mod1").TestEnum} TE */ + ~~~~~~~~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. + /** @type {TE} */ + const test = 'add' + /** @type {import("./mod1").TestEnum} */ + ~~~~~~~~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. + const tost = 'remove' + +==== value.js (1 errors) ==== + import { TestEnum } from "./mod1" + /** @type {TestEnum} */ + ~~~~~~~~ +!!! error TS2749: 'TestEnum' refers to a value, but is being used as a type here. Did you mean 'typeof TestEnum'? + const tist = TestEnum.ADD + + +==== mod1.js (0 errors) ==== + /** @enum {string} */ + export const TestEnum = { + ADD: 'add', + REMOVE: 'remove' + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumTagImported.types b/testdata/baselines/reference/submodule/conformance/enumTagImported.types index 361a32f1be..a7e576e4d9 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTagImported.types +++ b/testdata/baselines/reference/submodule/conformance/enumTagImported.types @@ -4,12 +4,12 @@ /** @typedef {import("./mod1").TestEnum} TE */ /** @type {TE} */ const test = 'add' ->test : "add" +>test : any >'add' : "add" /** @type {import("./mod1").TestEnum} */ const tost = 'remove' ->tost : "remove" +>tost : any >'remove' : "remove" === value.js === @@ -18,7 +18,7 @@ import { TestEnum } from "./mod1" /** @type {TestEnum} */ const tist = TestEnum.ADD ->tist : string +>tist : TestEnum >TestEnum.ADD : string >TestEnum : { ADD: string; REMOVE: string; } >ADD : string diff --git a/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt new file mode 100644 index 0000000000..5aebbf567d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt @@ -0,0 +1,16 @@ +bug27134.js(7,11): error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? + + +==== bug27134.js (1 errors) ==== + /** + * @enum {number} + */ + var foo = { }; + + /** + * @type {foo} + ~~~ +!!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? + */ + var s; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.types b/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.types index 2468c5b902..09e308a994 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.types +++ b/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.types @@ -12,5 +12,5 @@ var foo = { }; * @type {foo} */ var s; ->s : any +>s : foo diff --git a/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt new file mode 100644 index 0000000000..35cf4728a3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt @@ -0,0 +1,56 @@ +foo.js(20,12): error TS2304: Cannot find name 'FunctionReturningPromise'. +foo.js(44,12): error TS2304: Cannot find name 'FunctionReturningNever'. + + +==== foo.js (2 errors) ==== + /** + * @callback FunctionReturningPromise + * @returns {Promise} + */ + + /** @type {FunctionReturningPromise} */ + function testPromise1() { + console.log("Nope"); + } + + /** @type {FunctionReturningPromise} */ + async function testPromise2() { + return "asd"; + } + + var testPromise3 = /** @type {FunctionReturningPromise} */ function() { + console.log("test") + } + + /** @type {FunctionReturningPromise} */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'FunctionReturningPromise'. + var testPromise4 = function() { + console.log("test") + } + + /** + * @callback FunctionReturningNever + * @returns {never} + */ + + /** @type {FunctionReturningNever} */ + function testNever1() { + + } + + /** @type {FunctionReturningNever} */ + async function testNever2() { + return "asd"; + } + + var testNever3 = /** @type {FunctionReturningNever} */ function() { + console.log("test") + } + + /** @type {FunctionReturningNever} */ + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'FunctionReturningNever'. + var testNever4 = function() { + console.log("test") + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.types b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.types index 4f06c52f86..4a72817f54 100644 --- a/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.types +++ b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.types @@ -40,7 +40,7 @@ var testPromise3 = /** @type {FunctionReturningPromise} */ function() { /** @type {FunctionReturningPromise} */ var testPromise4 = function() { ->testPromise4 : () => void +>testPromise4 : FunctionReturningPromise >function() { console.log("test")} : () => void console.log("test") @@ -84,7 +84,7 @@ var testNever3 = /** @type {FunctionReturningNever} */ function() { /** @type {FunctionReturningNever} */ var testNever4 = function() { ->testNever4 : () => void +>testNever4 : FunctionReturningNever >function() { console.log("test")} : () => void console.log("test") diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.types b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.types index d7d5f0ab53..b984114ef5 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.types +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.types @@ -70,18 +70,18 @@ var classic = new s.Classic() /** @param {s.n.K} c @param {s.Classic} classic */ function f(c, classic) { ->f : (c: any, classic: any) => void ->c : any ->classic : any +>f : (c: K, classic: Classic) => void +>c : K +>classic : Classic c.x >c.x : any ->c : any +>c : K >x : any classic.p >classic.p : any ->classic : any +>classic : Classic >p : any } diff --git a/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt b/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt new file mode 100644 index 0000000000..3e7597d212 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt @@ -0,0 +1,19 @@ +use.js(3,12): error TS2749: 'MyEnum' refers to a value, but is being used as a type here. Did you mean 'typeof MyEnum'? + + +==== def.js (0 errors) ==== + /** @enum {number} */ + const MyEnum = { + a: 1, + b: 2 + }; + export default MyEnum; + +==== use.js (1 errors) ==== + import MyEnum from "./def"; + + /** @type {MyEnum} */ + ~~~~~~ +!!! error TS2749: 'MyEnum' refers to a value, but is being used as a type here. Did you mean 'typeof MyEnum'? + const v = MyEnum.b; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.types b/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.types index 2742f18d3c..ac3b962eb8 100644 --- a/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.types +++ b/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.types @@ -24,7 +24,7 @@ import MyEnum from "./def"; /** @type {MyEnum} */ const v = MyEnum.b; ->v : number +>v : MyEnum >MyEnum.b : number >MyEnum : { a: number; b: number; } >b : number diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag1.types b/testdata/baselines/reference/submodule/conformance/extendsTag1.types index a96398b3ed..1fe7b48839 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTag1.types +++ b/testdata/baselines/reference/submodule/conformance/extendsTag1.types @@ -6,6 +6,6 @@ * @extends {Set} Should prefer this Set, not the Set in the heritage clause */ class My extends Set {} ->My : My +>My : My >Set : Set diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt new file mode 100644 index 0000000000..8e78b2b91f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt @@ -0,0 +1,60 @@ +/a.js(26,17): error TS2314: Generic type 'A' requires 1 type argument(s). +/a.js(34,17): error TS2314: Generic type 'A' requires 1 type argument(s). +/a.js(39,17): error TS2314: Generic type 'A' requires 1 type argument(s). +/a.js(44,17): error TS2314: Generic type 'A' requires 1 type argument(s). + + +==== /a.js (4 errors) ==== + /** + * @typedef {{ + * a: number | string; + * b: boolean | string[]; + * }} Foo + */ + + /** + * @template {Foo} T + */ + class A { + /** + * @param {T} a + */ + constructor(a) { + return a + } + } + + /** + * @extends {A<{ + * a: string, + * b: string[] + * }>} + */ + class B extends A {} + ~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). + + /** + * @extends {A<{ + * a: string, + * b: string + * }>} + */ + class C extends A {} + ~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). + + /** + * @extends {A<{a: string, b: string[]}>} + */ + class D extends A {} + ~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). + + /** + * @extends {A<{a: string, b: string}>} + */ + class E extends A {} + ~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag5.types b/testdata/baselines/reference/submodule/conformance/extendsTag5.types index e09b74e91d..ac03511a17 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTag5.types +++ b/testdata/baselines/reference/submodule/conformance/extendsTag5.types @@ -12,16 +12,16 @@ * @template {Foo} T */ class A { ->A : A +>A : A /** * @param {T} a */ constructor(a) { ->a : any +>a : T return a ->a : any +>a : T } } @@ -33,7 +33,7 @@ class A { */ class B extends A {} >B : B ->A : A +>A : typeof A /** * @extends {A<{ @@ -43,19 +43,19 @@ class B extends A {} */ class C extends A {} >C : C ->A : A +>A : typeof A /** * @extends {A<{a: string, b: string[]}>} */ class D extends A {} >D : D ->A : A +>A : typeof A /** * @extends {A<{a: string, b: string}>} */ class E extends A {} >E : E ->A : A +>A : typeof A diff --git a/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.types b/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.types index 71259ab7ca..0ebdb3058f 100644 --- a/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.types +++ b/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.types @@ -5,20 +5,20 @@ * @template T */ class Box { ->Box : Box +>Box : Box #value; >#value : any /** @param {T} initialValue */ constructor(initialValue) { ->initialValue : any +>initialValue : T this.#value = initialValue; ->this.#value = initialValue : any +>this.#value = initialValue : T >this.#value : any >this : this ->initialValue : any +>initialValue : T } /** @type {T} */ @@ -45,7 +45,7 @@ new Box(3).value = 3; >new Box(3).value = 3 : 3 >new Box(3).value : any ->new Box(3) : Box +>new Box(3) : Box >Box : typeof Box >3 : 3 >value : any diff --git a/testdata/baselines/reference/submodule/conformance/importTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag1.errors.txt new file mode 100644 index 0000000000..bfac61ad4a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag1.errors.txt @@ -0,0 +1,20 @@ +/foo.js(6,13): error TS2304: Cannot find name 'Foo'. + + +==== /types.ts (0 errors) ==== + export interface Foo { + a: number; + } + +==== /foo.js (1 errors) ==== + /** + * @import { Foo } from "./types" + */ + + /** + * @param { Foo } foo + ~~~ +!!! error TS2304: Cannot find name 'Foo'. + */ + function f(foo) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag1.types b/testdata/baselines/reference/submodule/conformance/importTag1.types index 93665333bd..b442a09696 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag1.types +++ b/testdata/baselines/reference/submodule/conformance/importTag1.types @@ -15,6 +15,6 @@ export interface Foo { * @param { Foo } foo */ function f(foo) {} ->f : (foo: any) => void ->foo : any +>f : (foo: Foo) => void +>foo : Foo diff --git a/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt b/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt new file mode 100644 index 0000000000..021e5864c6 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt @@ -0,0 +1,15 @@ +1.js(4,13): error TS2304: Cannot find name 'I'. + + +==== 0.ts (0 errors) ==== + export interface I { } + +==== 1.js (1 errors) ==== + /** @import { I } from './0' with { type: "json" } */ + /** @import * as foo from './0' with { type: "json" } */ + + /** @param {I} a */ + ~ +!!! error TS2304: Cannot find name 'I'. + function f(a) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).types b/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).types index 839112d6c3..fb18e6928b 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).types +++ b/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).types @@ -10,6 +10,6 @@ export interface I { } /** @param {I} a */ function f(a) {} ->f : (a: any) => void ->a : any +>f : (a: I) => void +>a : I diff --git a/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt b/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt new file mode 100644 index 0000000000..021e5864c6 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt @@ -0,0 +1,15 @@ +1.js(4,13): error TS2304: Cannot find name 'I'. + + +==== 0.ts (0 errors) ==== + export interface I { } + +==== 1.js (1 errors) ==== + /** @import { I } from './0' with { type: "json" } */ + /** @import * as foo from './0' with { type: "json" } */ + + /** @param {I} a */ + ~ +!!! error TS2304: Cannot find name 'I'. + function f(a) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).types b/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).types index 839112d6c3..fb18e6928b 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).types +++ b/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).types @@ -10,6 +10,6 @@ export interface I { } /** @param {I} a */ function f(a) {} ->f : (a: any) => void ->a : any +>f : (a: I) => void +>a : I diff --git a/testdata/baselines/reference/submodule/conformance/importTag16.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag16.errors.txt new file mode 100644 index 0000000000..152fcdec23 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag16.errors.txt @@ -0,0 +1,21 @@ +b.js(4,12): error TS2304: Cannot find name 'Foo'. +b.js(5,12): error TS2304: Cannot find name 'I'. + + +==== a.ts (0 errors) ==== + export default interface Foo {} + export interface I {} + +==== b.js (2 errors) ==== + /** @import Foo, { I } from "./a" */ + + /** + * @param {Foo} a + ~~~ +!!! error TS2304: Cannot find name 'Foo'. + * @param {I} b + ~ +!!! error TS2304: Cannot find name 'I'. + */ + export function foo(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag16.types b/testdata/baselines/reference/submodule/conformance/importTag16.types index fca85aeb20..13356e92a7 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag16.types +++ b/testdata/baselines/reference/submodule/conformance/importTag16.types @@ -13,7 +13,7 @@ export interface I {} * @param {I} b */ export function foo(a, b) {} ->foo : (a: any, b: any) => void ->a : any ->b : any +>foo : (a: Foo, b: I) => void +>a : Foo +>b : I diff --git a/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt new file mode 100644 index 0000000000..049012688d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt @@ -0,0 +1,44 @@ +/a.js(5,15): error TS2304: Cannot find name 'Import'. +/a.js(12,15): error TS2552: Cannot find name 'Require'. Did you mean 'Required'? + + +==== /node_modules/@types/foo/package.json (0 errors) ==== + { + "name": "@types/foo", + "version": "1.0.0", + "exports": { + ".": { + "import": "./index.d.mts", + "require": "./index.d.cts" + } + } + } + +==== /node_modules/@types/foo/index.d.mts (0 errors) ==== + export declare const Import: "module"; + +==== /node_modules/@types/foo/index.d.cts (0 errors) ==== + export declare const Require: "script"; + +==== /a.js (2 errors) ==== + /** @import { Import } from 'foo' with { 'resolution-mode': 'import' } */ + /** @import { Require } from 'foo' with { 'resolution-mode': 'require' } */ + + /** + * @returns { Import } + ~~~~~~ +!!! error TS2304: Cannot find name 'Import'. + */ + export function f1() { + return 1; + } + + /** + * @returns { Require } + ~~~~~~~ +!!! error TS2552: Cannot find name 'Require'. Did you mean 'Required'? + */ + export function f2() { + return 1; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag17.types b/testdata/baselines/reference/submodule/conformance/importTag17.types index 3023630ace..1a4f3c365f 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag17.types +++ b/testdata/baselines/reference/submodule/conformance/importTag17.types @@ -16,7 +16,7 @@ export declare const Require: "script"; * @returns { Import } */ export function f1() { ->f1 : () => number +>f1 : () => Import return 1; >1 : 1 @@ -26,7 +26,7 @@ export function f1() { * @returns { Require } */ export function f2() { ->f2 : () => number +>f2 : () => Require return 1; >1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/importTag18.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag18.errors.txt new file mode 100644 index 0000000000..843e5470b9 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag18.errors.txt @@ -0,0 +1,20 @@ +b.js(8,12): error TS2304: Cannot find name 'Foo'. + + +==== a.ts (0 errors) ==== + export interface Foo {} + +==== b.js (1 errors) ==== + /** + * @import { + * Foo + * } from "./a" + */ + + /** + * @param {Foo} a + ~~~ +!!! error TS2304: Cannot find name 'Foo'. + */ + export function foo(a) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag18.types b/testdata/baselines/reference/submodule/conformance/importTag18.types index 3e9c1e14d3..71e2cc8b58 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag18.types +++ b/testdata/baselines/reference/submodule/conformance/importTag18.types @@ -15,6 +15,6 @@ export interface Foo {} * @param {Foo} a */ export function foo(a) {} ->foo : (a: any) => void ->a : any +>foo : (a: Foo) => void +>a : Foo diff --git a/testdata/baselines/reference/submodule/conformance/importTag19.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag19.errors.txt new file mode 100644 index 0000000000..1adc07dfbe --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag19.errors.txt @@ -0,0 +1,19 @@ +b.js(7,12): error TS2304: Cannot find name 'Foo'. + + +==== a.ts (0 errors) ==== + export interface Foo {} + +==== b.js (1 errors) ==== + /** + * @import { Foo } + * from "./a" + */ + + /** + * @param {Foo} a + ~~~ +!!! error TS2304: Cannot find name 'Foo'. + */ + export function foo(a) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag19.types b/testdata/baselines/reference/submodule/conformance/importTag19.types index 54bc1fbc9e..16ffb8480e 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag19.types +++ b/testdata/baselines/reference/submodule/conformance/importTag19.types @@ -14,6 +14,6 @@ export interface Foo {} * @param {Foo} a */ export function foo(a) {} ->foo : (a: any) => void ->a : any +>foo : (a: Foo) => void +>a : Foo diff --git a/testdata/baselines/reference/submodule/conformance/importTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag2.errors.txt new file mode 100644 index 0000000000..75e50ed132 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag2.errors.txt @@ -0,0 +1,20 @@ +/foo.js(6,13): error TS2503: Cannot find namespace 'types'. + + +==== /types.ts (0 errors) ==== + export interface Foo { + a: number; + } + +==== /foo.js (1 errors) ==== + /** + * @import * as types from "./types" + */ + + /** + * @param { types.Foo } foo + ~~~~~ +!!! error TS2503: Cannot find namespace 'types'. + */ + export function f(foo) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag2.types b/testdata/baselines/reference/submodule/conformance/importTag2.types index 5902e0b9fa..a8fd4d1a8e 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag2.types +++ b/testdata/baselines/reference/submodule/conformance/importTag2.types @@ -15,6 +15,6 @@ export interface Foo { * @param { types.Foo } foo */ export function f(foo) {} ->f : (foo: any) => void ->foo : any +>f : (foo: Foo) => void +>foo : Foo diff --git a/testdata/baselines/reference/submodule/conformance/importTag20.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag20.errors.txt new file mode 100644 index 0000000000..2ec34959d1 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag20.errors.txt @@ -0,0 +1,20 @@ +b.js(8,12): error TS2304: Cannot find name 'Foo'. + + +==== a.ts (0 errors) ==== + export interface Foo {} + +==== b.js (1 errors) ==== + /** + * @import + * { Foo + * } from './a' + */ + + /** + * @param {Foo} a + ~~~ +!!! error TS2304: Cannot find name 'Foo'. + */ + export function foo(a) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag20.types b/testdata/baselines/reference/submodule/conformance/importTag20.types index bd476769bc..40d8da038c 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag20.types +++ b/testdata/baselines/reference/submodule/conformance/importTag20.types @@ -15,6 +15,6 @@ export interface Foo {} * @param {Foo} a */ export function foo(a) {} ->foo : (a: any) => void ->a : any +>foo : (a: Foo) => void +>a : Foo diff --git a/testdata/baselines/reference/submodule/conformance/importTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag3.errors.txt new file mode 100644 index 0000000000..74ccb4534f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag3.errors.txt @@ -0,0 +1,20 @@ +/foo.js(6,13): error TS2304: Cannot find name 'Foo'. + + +==== /types.ts (0 errors) ==== + export default interface Foo { + a: number; + } + +==== /foo.js (1 errors) ==== + /** + * @import Foo from "./types" + */ + + /** + * @param { Foo } foo + ~~~ +!!! error TS2304: Cannot find name 'Foo'. + */ + export function f(foo) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag3.types b/testdata/baselines/reference/submodule/conformance/importTag3.types index 5272282eb7..da6d62466d 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag3.types +++ b/testdata/baselines/reference/submodule/conformance/importTag3.types @@ -15,6 +15,6 @@ export default interface Foo { * @param { Foo } foo */ export function f(foo) {} ->f : (foo: any) => void ->foo : any +>f : (foo: Foo) => void +>foo : Foo diff --git a/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt new file mode 100644 index 0000000000..23e58203fa --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt @@ -0,0 +1,24 @@ +/foo.js(10,13): error TS2304: Cannot find name 'Foo'. + + +==== /types.ts (0 errors) ==== + export interface Foo { + a: number; + } + +==== /foo.js (1 errors) ==== + /** + * @import { Foo } from "./types" + */ + + /** + * @import { Foo } from "./types" + */ + + /** + * @param { Foo } foo + ~~~ +!!! error TS2304: Cannot find name 'Foo'. + */ + function f(foo) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag4.types b/testdata/baselines/reference/submodule/conformance/importTag4.types index 601f5a039e..473a932a89 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag4.types +++ b/testdata/baselines/reference/submodule/conformance/importTag4.types @@ -19,6 +19,6 @@ export interface Foo { * @param { Foo } foo */ function f(foo) {} ->f : (foo: any) => void ->foo : any +>f : (foo: Foo) => void +>foo : Foo diff --git a/testdata/baselines/reference/submodule/conformance/importTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag5.errors.txt new file mode 100644 index 0000000000..bfac61ad4a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag5.errors.txt @@ -0,0 +1,20 @@ +/foo.js(6,13): error TS2304: Cannot find name 'Foo'. + + +==== /types.ts (0 errors) ==== + export interface Foo { + a: number; + } + +==== /foo.js (1 errors) ==== + /** + * @import { Foo } from "./types" + */ + + /** + * @param { Foo } foo + ~~~ +!!! error TS2304: Cannot find name 'Foo'. + */ + function f(foo) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag5.types b/testdata/baselines/reference/submodule/conformance/importTag5.types index 1bc075eb04..7d9641be55 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag5.types +++ b/testdata/baselines/reference/submodule/conformance/importTag5.types @@ -15,6 +15,6 @@ export interface Foo { * @param { Foo } foo */ function f(foo) {} ->f : (foo: any) => void ->foo : any +>f : (foo: Foo) => void +>foo : Foo diff --git a/testdata/baselines/reference/submodule/conformance/importTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag6.errors.txt new file mode 100644 index 0000000000..6a1ec95ceb --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag6.errors.txt @@ -0,0 +1,30 @@ +/foo.js(9,13): error TS2304: Cannot find name 'A'. +/foo.js(10,13): error TS2304: Cannot find name 'B'. + + +==== /types.ts (0 errors) ==== + export interface A { + a: number; + } + export interface B { + a: number; + } + +==== /foo.js (2 errors) ==== + /** + * @import { + * A, + * B, + * } from "./types" + */ + + /** + * @param { A } a + ~ +!!! error TS2304: Cannot find name 'A'. + * @param { B } b + ~ +!!! error TS2304: Cannot find name 'B'. + */ + function f(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag6.types b/testdata/baselines/reference/submodule/conformance/importTag6.types index 8d3e010dbc..0fd85537cd 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag6.types +++ b/testdata/baselines/reference/submodule/conformance/importTag6.types @@ -23,7 +23,7 @@ export interface B { * @param { B } b */ function f(a, b) {} ->f : (a: any, b: any) => void ->a : any ->b : any +>f : (a: A, b: B) => void +>a : A +>b : B diff --git a/testdata/baselines/reference/submodule/conformance/importTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag7.errors.txt new file mode 100644 index 0000000000..90936c1814 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag7.errors.txt @@ -0,0 +1,29 @@ +/foo.js(8,13): error TS2304: Cannot find name 'A'. +/foo.js(9,13): error TS2304: Cannot find name 'B'. + + +==== /types.ts (0 errors) ==== + export interface A { + a: number; + } + export interface B { + a: number; + } + +==== /foo.js (2 errors) ==== + /** + * @import { + * A, + * B } from "./types" + */ + + /** + * @param { A } a + ~ +!!! error TS2304: Cannot find name 'A'. + * @param { B } b + ~ +!!! error TS2304: Cannot find name 'B'. + */ + function f(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag7.types b/testdata/baselines/reference/submodule/conformance/importTag7.types index 1030a0467c..c4def0aa93 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag7.types +++ b/testdata/baselines/reference/submodule/conformance/importTag7.types @@ -22,7 +22,7 @@ export interface B { * @param { B } b */ function f(a, b) {} ->f : (a: any, b: any) => void ->a : any ->b : any +>f : (a: A, b: B) => void +>a : A +>b : B diff --git a/testdata/baselines/reference/submodule/conformance/importTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag8.errors.txt new file mode 100644 index 0000000000..dadfa9424e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag8.errors.txt @@ -0,0 +1,29 @@ +/foo.js(8,13): error TS2304: Cannot find name 'A'. +/foo.js(9,13): error TS2304: Cannot find name 'B'. + + +==== /types.ts (0 errors) ==== + export interface A { + a: number; + } + export interface B { + a: number; + } + +==== /foo.js (2 errors) ==== + /** + * @import + * { A, B } + * from "./types" + */ + + /** + * @param { A } a + ~ +!!! error TS2304: Cannot find name 'A'. + * @param { B } b + ~ +!!! error TS2304: Cannot find name 'B'. + */ + function f(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag8.types b/testdata/baselines/reference/submodule/conformance/importTag8.types index 717ac5a40a..8494d7cb28 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag8.types +++ b/testdata/baselines/reference/submodule/conformance/importTag8.types @@ -22,7 +22,7 @@ export interface B { * @param { B } b */ function f(a, b) {} ->f : (a: any, b: any) => void ->a : any ->b : any +>f : (a: A, b: B) => void +>a : A +>b : B diff --git a/testdata/baselines/reference/submodule/conformance/importTag9.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag9.errors.txt new file mode 100644 index 0000000000..44b7a7c5ba --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag9.errors.txt @@ -0,0 +1,29 @@ +/foo.js(8,13): error TS2503: Cannot find namespace 'types'. +/foo.js(9,13): error TS2503: Cannot find namespace 'types'. + + +==== /types.ts (0 errors) ==== + export interface A { + a: number; + } + export interface B { + a: number; + } + +==== /foo.js (2 errors) ==== + /** + * @import + * * as types + * from "./types" + */ + + /** + * @param { types.A } a + ~~~~~ +!!! error TS2503: Cannot find namespace 'types'. + * @param { types.B } b + ~~~~~ +!!! error TS2503: Cannot find namespace 'types'. + */ + function f(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag9.types b/testdata/baselines/reference/submodule/conformance/importTag9.types index c84ac65f52..994366bb98 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag9.types +++ b/testdata/baselines/reference/submodule/conformance/importTag9.types @@ -22,7 +22,7 @@ export interface B { * @param { types.B } b */ function f(a, b) {} ->f : (a: any, b: any) => void ->a : any ->b : any +>f : (a: A, b: B) => void +>a : A +>b : B diff --git a/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.types b/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.types index 987261934e..54cd2d1c4f 100644 --- a/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.types +++ b/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.types @@ -39,14 +39,16 @@ export = MyClass; */ let a = /** @type {Foo} */(/** @type {*} */(undefined)); ->a : any ->(/** @type {*} */(undefined)) : undefined ->(undefined) : undefined +>a : MyClass +>(/** @type {*} */(undefined)) : MyClass +>(undefined) : MyClass +>(undefined) : any +>undefined : any >undefined : undefined a = new Foo({doer: Foo.Bar}); >a = new Foo({doer: Foo.Bar}) : MyClass ->a : any +>a : MyClass >new Foo({doer: Foo.Bar}) : MyClass >Foo : typeof MyClass >{doer: Foo.Bar} : { doer: (x: string, y?: number) => void; } @@ -56,18 +58,20 @@ a = new Foo({doer: Foo.Bar}); >Bar : (x: string, y?: number) => void const q = /** @type {import("./externs").Bar} */({ doer: q => q }); ->q : { doer: (q: any) => any; } ->({ doer: q => q }) : { doer: (q: any) => any; } ->{ doer: q => q } : { doer: (q: any) => any; } ->doer : (q: any) => any ->q => q : (q: any) => any ->q : any ->q : any +>q : Bar +>({ doer: q => q }) : Bar +>{ doer: q => q } : Bar +>{ doer: q => q } : { doer: (q: string) => string; } +>doer : (q: string) => string +>q => q : (q: string) => string +>q : string +>q : string const r = /** @type {typeof import("./externs").Bar} */(r => r); ->r : (r: any) => any ->(r => r) : (r: any) => any ->r => r : (r: any) => any ->r : any ->r : any +>r : (x: string, y?: number) => void +>(r => r) : (x: string, y?: number) => void +>r => r : (x: string, y?: number) => void +>r => r : (r: string) => string +>r : string +>r : string diff --git a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.errors.txt index 1ed803ee47..38f2dac63d 100644 --- a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.errors.txt @@ -1,5 +1,4 @@ -/index.js(5,10): error TS2304: Cannot find name 'JSDocType'. -/index.js(6,10): error TS2304: Cannot find name 'JSDocType'. +/index.js(5,10): error TS2484: Export declaration conflicts with exported declaration of 'JSDocType'. ==== /node_modules/@types/node/index.d.ts (0 errors) ==== @@ -8,16 +7,14 @@ export function writeFile(path: string, data: any, options: WriteFileOptions, callback: (err: Error) => void): void; } -==== /index.js (2 errors) ==== +==== /index.js (1 errors) ==== import { writeFile, WriteFileOptions, WriteFileOptions as OtherName } from "fs"; /** @typedef {{ x: any }} JSDocType */ export { JSDocType }; ~~~~~~~~~ -!!! error TS2304: Cannot find name 'JSDocType'. +!!! error TS2484: Export declaration conflicts with exported declaration of 'JSDocType'. export { JSDocType as ThisIsFine }; - ~~~~~~~~~ -!!! error TS2304: Cannot find name 'JSDocType'. export { WriteFileOptions }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols index a4a47e30e7..e3d5cf7c06 100644 --- a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols +++ b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols @@ -28,9 +28,10 @@ import { writeFile, WriteFileOptions, WriteFileOptions as OtherName } from "fs"; /** @typedef {{ x: any }} JSDocType */ export { JSDocType }; ->JSDocType : Symbol(JSDocType, Decl(index.js, 4, 8)) +>JSDocType : Symbol(JSDocType, Decl(index.js, 2, 4), Decl(index.js, 4, 8)) export { JSDocType as ThisIsFine }; +>JSDocType : Symbol(JSDocType, Decl(index.js, 2, 4), Decl(index.js, 4, 8)) >ThisIsFine : Symbol(ThisIsFine, Decl(index.js, 5, 8)) export { WriteFileOptions }; diff --git a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols.diff b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols.diff index 5f1a636aa1..202b95d863 100644 --- a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols.diff @@ -5,10 +5,11 @@ export { JSDocType }; ->JSDocType : Symbol(JSDocType, Decl(index.js, 4, 8), Decl(index.js, 2, 4)) -+>JSDocType : Symbol(JSDocType, Decl(index.js, 4, 8)) ++>JSDocType : Symbol(JSDocType, Decl(index.js, 2, 4), Decl(index.js, 4, 8)) export { JSDocType as ThisIsFine }; ->JSDocType : Symbol(JSDocType, Decl(index.js, 4, 8), Decl(index.js, 2, 4)) ++>JSDocType : Symbol(JSDocType, Decl(index.js, 2, 4), Decl(index.js, 4, 8)) >ThisIsFine : Symbol(ThisIsFine, Decl(index.js, 5, 8)) export { WriteFileOptions }; diff --git a/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt b/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt new file mode 100644 index 0000000000..fcb93bba30 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt @@ -0,0 +1,40 @@ +/a.js(8,9): error TS2322: Type 'typeof C' is not assignable to type 'T'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'typeof C'. +/a.js(17,9): error TS2322: Type 'this' is not assignable to type 'T'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'this'. + + +==== /a.js (2 errors) ==== + export class C { + /** + * @template T + * @this {T} + * @return {T} + */ + static a() { + return this; + ~~~~~~ +!!! error TS2322: Type 'typeof C' is not assignable to type 'T'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'typeof C'. + } + + /** + * @template T + * @this {T} + * @return {T} + */ + b() { + return this; + ~~~~~~ +!!! error TS2322: Type 'this' is not assignable to type 'T'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'this'. + } + } + + const a = C.a(); + a; // typeof C + + const c = new C(); + const b = c.b(); + b; // C + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferThis.types b/testdata/baselines/reference/submodule/conformance/inferThis.types index fbdc443de5..2a0f14878e 100644 --- a/testdata/baselines/reference/submodule/conformance/inferThis.types +++ b/testdata/baselines/reference/submodule/conformance/inferThis.types @@ -10,7 +10,7 @@ export class C { * @return {T} */ static a() { ->a : () => typeof C +>a : () => T return this; >this : typeof C @@ -22,7 +22,7 @@ export class C { * @return {T} */ b() { ->b : () => this +>b : () => T return this; >this : this @@ -30,14 +30,14 @@ export class C { } const a = C.a(); ->a : typeof C ->C.a() : typeof C ->C.a : () => typeof C +>a : unknown +>C.a() : unknown +>C.a : () => T >C : typeof C ->a : () => typeof C +>a : () => T a; // typeof C ->a : typeof C +>a : unknown const c = new C(); >c : C @@ -45,12 +45,12 @@ const c = new C(); >C : typeof C const b = c.b(); ->b : C ->c.b() : C ->c.b : () => C +>b : unknown +>c.b() : unknown +>c.b : () => T >c : C ->b : () => C +>b : () => T b; // C ->b : C +>b : unknown diff --git a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types index 64b2da41db..72bbe8f04d 100644 --- a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types +++ b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types @@ -7,12 +7,12 @@ * @returns {(b: T) => T} */ const seq = a => b => b; ->seq : (a: any) => (b: any) => any ->a => b => b : (a: any) => (b: any) => any ->a : any ->b => b : (b: any) => any ->b : any ->b : any +>seq : (a: T) => (b: T) => T +>a => b => b : (a: T) => (b: T) => T +>a : T +>b => b : (b: T) => T +>b : T +>b : T const text1 = "hello"; >text1 : "hello" @@ -24,10 +24,10 @@ const text2 = "world"; /** @type {string} */ var text3 = seq(text1)(text2); ->text3 : any ->seq(text1)(text2) : any ->seq(text1) : (b: any) => any ->seq : (a: any) => (b: any) => any +>text3 : string +>seq(text1)(text2) : string +>seq(text1) : (b: string) => string +>seq : (a: T) => (b: T) => T >text1 : "hello" >text2 : "world" diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.types index 86041f5542..03bd1597c7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.types @@ -12,14 +12,14 @@ export interface Encoder { * @implements {IEncoder} */ export class Encoder { ->Encoder : Encoder +>Encoder : Encoder /** * @param {T} value */ encode(value) { ->encode : (value: any) => Uint8Array ->value : any +>encode : (value: T) => Uint8Array +>value : T return new Uint8Array(0) >new Uint8Array(0) : Uint8Array diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt index 33db52b103..2ca0a233f5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt @@ -4,8 +4,6 @@ jsDeclarationsClassMethod.js(19,33): error TS7006: Parameter 'x' implicitly has jsDeclarationsClassMethod.js(19,36): error TS7006: Parameter 'y' implicitly has an 'any' type. jsDeclarationsClassMethod.js(29,27): error TS7006: Parameter 'x' implicitly has an 'any' type. jsDeclarationsClassMethod.js(29,30): error TS7006: Parameter 'y' implicitly has an 'any' type. -jsDeclarationsClassMethod.js(40,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -jsDeclarationsClassMethod.js(40,16): error TS7006: Parameter 'y' implicitly has an 'any' type. jsDeclarationsClassMethod.js(51,14): error TS2551: Property 'method2' does not exist on type 'C2'. Did you mean 'method1'? jsDeclarationsClassMethod.js(51,34): error TS7006: Parameter 'x' implicitly has an 'any' type. jsDeclarationsClassMethod.js(51,37): error TS7006: Parameter 'y' implicitly has an 'any' type. @@ -14,7 +12,7 @@ jsDeclarationsClassMethod.js(61,27): error TS7006: Parameter 'x' implicitly has jsDeclarationsClassMethod.js(61,30): error TS7006: Parameter 'y' implicitly has an 'any' type. -==== jsDeclarationsClassMethod.js (14 errors) ==== +==== jsDeclarationsClassMethod.js (12 errors) ==== function C1() { /** * A comment prop @@ -67,10 +65,6 @@ jsDeclarationsClassMethod.js(61,30): error TS7006: Parameter 'y' implicitly has * @returns {number} */ method1(x, y) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'y' implicitly has an 'any' type. return x + y; } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.types index 285d0b527d..2ebdc39cc9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.types @@ -80,14 +80,14 @@ class C2 { * @returns {number} */ method1(x, y) { ->method1 : (x: any, y: any) => any ->x : any ->y : any +>method1 : (x: number, y: number) => number +>x : number +>y : number return x + y; ->x + y : any ->x : any ->y : any +>x + y : number +>x : number +>y : number } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt index 6a70384f9a..06fa15c729 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt @@ -2,11 +2,12 @@ index.js(138,14): error TS2339: Property 'p1' does not exist on type 'K'. index.js(139,14): error TS2339: Property 'p2' does not exist on type 'K'. index.js(143,21): error TS2339: Property 'p1' does not exist on type 'K'. index.js(151,14): error TS2339: Property 'prop' does not exist on type 'M'. -index.js(165,14): error TS2339: Property 'another' does not exist on type 'N'. -index.js(179,14): error TS2339: Property 'another2' does not exist on type 'O'. +index.js(165,14): error TS2339: Property 'another' does not exist on type 'N'. +index.js(173,24): error TS2314: Generic type 'N' requires 1 type argument(s). +index.js(179,14): error TS2339: Property 'another2' does not exist on type 'O'. -==== index.js (6 errors) ==== +==== index.js (7 errors) ==== export class A {} export class B { @@ -181,7 +182,7 @@ index.js(179,14): error TS2339: Property 'another2' does not exist on type 'O'. super(); this.another = param; ~~~~~~~ -!!! error TS2339: Property 'another' does not exist on type 'N'. +!!! error TS2339: Property 'another' does not exist on type 'N'. } } @@ -190,6 +191,8 @@ index.js(179,14): error TS2339: Property 'another2' does not exist on type 'O'. * @extends {N} */ export class O extends N { + ~ +!!! error TS2314: Generic type 'N' requires 1 type argument(s). /** * @param {U} param */ @@ -197,7 +200,7 @@ index.js(179,14): error TS2339: Property 'another2' does not exist on type 'O'. super(param); this.another2 = param; ~~~~~~~~ -!!! error TS2339: Property 'another2' does not exist on type 'O'. +!!! error TS2339: Property 'another2' does not exist on type 'O'. } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.symbols index e4f5dad2a0..cca7d7f567 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.symbols @@ -264,7 +264,6 @@ export class O extends N { >param : Symbol(param, Decl(index.js, 176, 16)) super(param); ->super : Symbol(N, Decl(index.js, 152, 1)) >param : Symbol(param, Decl(index.js, 176, 16)) this.another2 = param; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.symbols.diff index 2579a19ff3..f3c9432a46 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.symbols.diff @@ -182,7 +182,11 @@ >param : Symbol(param, Decl(index.js, 162, 16)) } } -@@= skipped -26, +24 lines =@@ +@@= skipped -22, +20 lines =@@ + >param : Symbol(param, Decl(index.js, 176, 16)) + + super(param); +->super : Symbol(N, Decl(index.js, 152, 1)) >param : Symbol(param, Decl(index.js, 176, 16)) this.another2 = param; @@ -192,7 +196,7 @@ >param : Symbol(param, Decl(index.js, 176, 16)) } } -@@= skipped -18, +16 lines =@@ +@@= skipped -22, +19 lines =@@ >HasStatics : Symbol(HasStatics, Decl(index.js, 184, 38)) static staticMethod() {} diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.types index 49af892548..c91b52d442 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.types @@ -28,21 +28,21 @@ export class D { * @param {number} b */ constructor(a, b) {} ->a : any ->b : any +>a : number +>b : number } /** * @template T,U */ export class E { ->E : E +>E : E /** * @type {T & U} */ field; ->field : any +>field : T & U // @readonly is currently unsupported, it seems - included here just in case that changes /** @@ -50,7 +50,7 @@ export class E { * @readonly */ readonlyField; ->readonlyField : any +>readonlyField : T & U initializedField = 12; >initializedField : number @@ -60,44 +60,46 @@ export class E { * @return {U} */ get f1() { return /** @type {*} */(null); } ->f1 : any ->(null) : null +>f1 : U +>(null) : any +>null : any /** * @param {U} _p */ set f1(_p) {} ->f1 : any ->_p : any +>f1 : U +>_p : U /** * @return {U} */ get f2() { return /** @type {*} */(null); } ->f2 : any ->(null) : null +>f2 : U +>(null) : any +>null : any /** * @param {U} _p */ set f3(_p) {} ->f3 : any ->_p : any +>f3 : U +>_p : U /** * @param {T} a * @param {U} b */ constructor(a, b) {} ->a : any ->b : any +>a : T +>b : U /** * @type {string} */ static staticField; ->staticField : any +>staticField : string // @readonly is currently unsupported, it seems - included here just in case that changes /** @@ -105,7 +107,7 @@ export class E { * @readonly */ static staticReadonlyField; ->staticReadonlyField : any +>staticReadonlyField : string static staticInitializedField = 12; >staticInitializedField : number @@ -136,29 +138,29 @@ export class E { * @param {string} _p */ static set s3(_p) {} ->s3 : any ->_p : any +>s3 : string +>_p : string } /** * @template T,U */ export class F { ->F : F +>F : F /** * @type {T & U} */ field; ->field : any +>field : T & U /** * @param {T} a * @param {U} b */ constructor(a, b) {} ->a : any ->b : any +>a : T +>b : U /** * @template A,B @@ -166,13 +168,13 @@ export class F { * @param {B} b */ static create(a, b) { return new F(a, b); } ->create : (a: any, b: any) => F ->a : any ->b : any ->new F(a, b) : F +>create : (a: A, b: B) => F +>a : A +>b : B +>new F(a, b) : F >F : typeof F ->a : any ->b : any +>a : A +>b : B } class G {} @@ -254,25 +256,25 @@ export class M extends null { * @template T */ export class N extends L { ->N : N +>N : N >L : L /** * @param {T} param */ constructor(param) { ->param : any +>param : T super(); >super() : void >super : typeof L this.another = param; ->this.another = param : any +>this.another = param : T >this.another : any >this : this >another : any ->param : any +>param : T } } @@ -281,32 +283,33 @@ export class N extends L { * @extends {N} */ export class O extends N { ->O : O ->N : N +>O : O +>N : typeof N /** * @param {U} param */ constructor(param) { ->param : any +>param : U super(param); >super(param) : void ->super : typeof N ->param : any +>super : any +>param : U this.another2 = param; ->this.another2 = param : any +>this.another2 = param : U >this.another2 : any >this : this >another2 : any ->param : any +>param : U } } var x = /** @type {*} */(null); >x : any ->(null) : null +>(null) : any +>null : any export class VariableBase extends x {} >VariableBase : VariableBase diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.types index d9f0e168db..9365514b93 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.types @@ -74,7 +74,7 @@ export class MyClass { * @param {typeof TopLevelSym | typeof InnerSym} _p */ constructor(_p = InnerSym) { ->_p : symbol +>_p : unique symbol | unique symbol >InnerSym : unique symbol // switch on _p diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.types index b9e91dd72e..968cb61dbf 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.types @@ -24,8 +24,9 @@ export default class Foo { >Foo : default a = /** @type {Foo} */(null); ->a : any ->(null) : null +>a : default +>(null) : default +>null : default }; export const X = Foo; @@ -45,8 +46,9 @@ class Bar extends Fab { >Fab : default x = /** @type {Bar} */(null); ->x : any ->(null) : null +>x : Bar +>(null) : Bar +>null : Bar } export default Bar; >Bar : Bar diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt new file mode 100644 index 0000000000..7312ed2c66 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt @@ -0,0 +1,63 @@ +index.js(23,12): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? +index.js(24,12): error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? +index.js(25,12): error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? +index.js(34,16): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? + + +==== index.js (4 errors) ==== + /** @enum {string} */ + export const Target = { + START: "start", + MIDDLE: "middle", + END: "end", + /** @type {number} */ + OK_I_GUESS: 2 + } + /** @enum number */ + export const Second = { + OK: 1, + /** @type {number} */ + FINE: 2, + } + /** @enum {function(number): number} */ + export const Fs = { + ADD1: n => n + 1, + ID: n => n, + SUB1: n => n - 1 + } + + /** + * @param {Target} t + ~~~~~~ +!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? + * @param {Second} s + ~~~~~~ +!!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? + * @param {Fs} f + ~~ +!!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? + */ + export function consume(t,s,f) { + /** @type {string} */ + var str = t + /** @type {number} */ + var num = s + /** @type {(n: number) => number} */ + var fun = f + /** @type {Target} */ + ~~~~~~ +!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? + var v = Target.START + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums + } + /** @param {string} s */ + export function ff(s) { + // element access with arbitrary string is an error only with noImplicitAny + if (!Target[s]) { + return null + } + else { + return Target[s] + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.types index 98ede7df05..3bb4eed24e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.types @@ -21,6 +21,7 @@ export const Target = { /** @type {number} */ OK_I_GUESS: 2 >OK_I_GUESS : number +>2 : number >2 : 2 } /** @enum number */ @@ -35,6 +36,7 @@ export const Second = { /** @type {number} */ FINE: 2, >FINE : number +>2 : number >2 : 2 } /** @enum {function(number): number} */ @@ -71,49 +73,49 @@ export const Fs = { * @param {Fs} f */ export function consume(t,s,f) { ->consume : (t: any, s: any, f: any) => void ->t : any ->s : any ->f : any +>consume : (t: Target, s: Second, f: Fs) => void +>t : Target +>s : Second +>f : Fs /** @type {string} */ var str = t ->str : any ->t : any +>str : string +>t : Target /** @type {number} */ var num = s ->num : any ->s : any +>num : number +>s : Second /** @type {(n: number) => number} */ var fun = f ->fun : any ->f : any +>fun : (n: number) => number +>f : Fs /** @type {Target} */ var v = Target.START ->v : string +>v : Target >Target.START : string >Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } >START : string v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums >v = 'something else' : "something else" ->v : string +>v : Target >'something else' : "something else" } /** @param {string} s */ export function ff(s) { ->ff : (s: any) => any ->s : any +>ff : (s: string) => any +>s : string // element access with arbitrary string is an error only with noImplicitAny if (!Target[s]) { >!Target[s] : boolean >Target[s] : any >Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } ->s : any +>s : string return null } @@ -121,7 +123,7 @@ export function ff(s) { return Target[s] >Target[s] : any >Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } ->s : any +>s : string } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.types index 794c743867..a2ae5632d8 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.types @@ -13,15 +13,15 @@ module.exports = class Thing { * @param {number} p */ constructor(p) { ->p : any +>p : number this.t = 12 + p; ->this.t = 12 + p : any +>this.t = 12 + p : number >this.t : any >this : this >t : any ->12 + p : any +>12 + p : number >12 : 12 ->p : any +>p : number } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.types index 7c5d44494f..5974c5c456 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.types @@ -12,15 +12,15 @@ module.exports = class { * @param {number} p */ constructor(p) { ->p : any +>p : number this.t = 12 + p; ->this.t = 12 + p : any +>this.t = 12 + p : number >this.t : any >this : this >t : any ->12 + p : any +>12 + p : number >12 : 12 ->p : any +>p : number } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types index 6b40743fae..42c61e6f57 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types @@ -12,16 +12,16 @@ module.exports = class { * @param {number} p */ constructor(p) { ->p : any +>p : number this.t = 12 + p; ->this.t = 12 + p : any +>this.t = 12 + p : number >this.t : any >this : this >t : any ->12 + p : any +>12 + p : number >12 : 12 ->p : any +>p : number } } module.exports.Sub = class { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt index 6445eae929..fbb512e76b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt @@ -6,7 +6,9 @@ index.js(22,23): error TS2580: Cannot find name 'module'. Do you need to install index.js(31,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(32,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(32,58): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +index.js(36,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(41,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(46,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(51,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(53,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(54,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -16,7 +18,7 @@ index.js(57,54): error TS2580: Cannot find name 'module'. Do you need to install index.js(58,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 (16 errors) ==== +==== index.js (18 errors) ==== Object.defineProperty(module.exports, "a", { value: function a() {} }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -69,6 +71,8 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a * @param {{y: typeof module.exports.b}} b + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ function g(a, b) { return a.x && b.y(); @@ -81,6 +85,8 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a * @param {{y: typeof module.exports.b}} b + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ function hh(a, b) { return a.x && b.y(); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.symbols index 2af33397b3..c042f1a5a8 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.symbols @@ -91,8 +91,12 @@ function g(a, b) { >b : Symbol(b, Decl(index.js, 37, 13)) return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 34, 12)) >a : Symbol(a, Decl(index.js, 37, 11)) +>x : Symbol(x, Decl(index.js, 34, 12)) +>b.y : Symbol(y, Decl(index.js, 35, 12)) >b : Symbol(b, Decl(index.js, 37, 13)) +>y : Symbol(y, Decl(index.js, 35, 12)) } Object.defineProperty(module.exports, "g", { value: g }); >Object.defineProperty : Symbol(defineProperty, Decl(lib.es5.d.ts, --, --)) @@ -112,8 +116,12 @@ function hh(a, b) { >b : Symbol(b, Decl(index.js, 47, 14)) return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 44, 12)) >a : Symbol(a, Decl(index.js, 47, 12)) +>x : Symbol(x, Decl(index.js, 44, 12)) +>b.y : Symbol(y, Decl(index.js, 45, 12)) >b : Symbol(b, Decl(index.js, 47, 14)) +>y : Symbol(y, Decl(index.js, 45, 12)) } Object.defineProperty(module.exports, "h", { value: hh }); >Object.defineProperty : Symbol(defineProperty, Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.symbols.diff index a83909aa88..a07682c725 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.symbols.diff @@ -113,16 +113,8 @@ /** * @param {{x: string}} a -@@= skipped -37, +22 lines =@@ - >b : Symbol(b, Decl(index.js, 37, 13)) - - return a.x && b.y(); -->a.x : Symbol(x, Decl(index.js, 34, 12)) - >a : Symbol(a, Decl(index.js, 37, 11)) -->x : Symbol(x, Decl(index.js, 34, 12)) -->b.y : Symbol(y, Decl(index.js, 35, 12)) - >b : Symbol(b, Decl(index.js, 37, 13)) -->y : Symbol(y, Decl(index.js, 35, 12)) +@@= skipped -45, +30 lines =@@ + >y : Symbol(y, Decl(index.js, 35, 12)) } Object.defineProperty(module.exports, "g", { value: g }); ->Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) @@ -137,16 +129,8 @@ >value : Symbol(value, Decl(index.js, 40, 44)) >g : Symbol(g, Decl(index.js, 31, 77)) -@@= skipped -29, +21 lines =@@ - >b : Symbol(b, Decl(index.js, 47, 14)) - - return a.x && b.y(); -->a.x : Symbol(x, Decl(index.js, 44, 12)) - >a : Symbol(a, Decl(index.js, 47, 12)) -->x : Symbol(x, Decl(index.js, 44, 12)) -->b.y : Symbol(y, Decl(index.js, 45, 12)) - >b : Symbol(b, Decl(index.js, 47, 14)) -->y : Symbol(y, Decl(index.js, 45, 12)) +@@= skipped -29, +25 lines =@@ + >y : Symbol(y, Decl(index.js, 45, 12)) } Object.defineProperty(module.exports, "h", { value: hh }); ->Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.types index d09542d31a..6006082d96 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.types @@ -50,10 +50,11 @@ Object.defineProperty(module.exports.b, "cat", { value: "cat" }); * @return {string} */ function d(a, b) { return /** @type {*} */(null); } ->d : (a: any, b: any) => any ->a : any ->b : any ->(null) : null +>d : (a: number, b: number) => string +>a : number +>b : number +>(null) : any +>null : any Object.defineProperty(module.exports, "d", { value: d }); >Object.defineProperty(module.exports, "d", { value: d }) : any @@ -64,9 +65,9 @@ Object.defineProperty(module.exports, "d", { value: d }); >module : any >exports : any >"d" : "d" ->{ value: d } : { value: (a: any, b: any) => any; } ->value : (a: any, b: any) => any ->d : (a: any, b: any) => any +>{ value: d } : { value: (a: number, b: number) => string; } +>value : (a: number, b: number) => string +>d : (a: number, b: number) => string /** @@ -76,10 +77,11 @@ Object.defineProperty(module.exports, "d", { value: d }); * @return {T & U} */ function e(a, b) { return /** @type {*} */(null); } ->e : (a: any, b: any) => any ->a : any ->b : any ->(null) : null +>e : (a: T, b: U) => T & U +>a : T +>b : U +>(null) : any +>null : any Object.defineProperty(module.exports, "e", { value: e }); >Object.defineProperty(module.exports, "e", { value: e }) : any @@ -90,20 +92,20 @@ Object.defineProperty(module.exports, "e", { value: e }); >module : any >exports : any >"e" : "e" ->{ value: e } : { value: (a: any, b: any) => any; } ->value : (a: any, b: any) => any ->e : (a: any, b: any) => any +>{ value: e } : { value: (a: T, b: U) => T & U; } +>value : (a: T, b: U) => T & U +>e : (a: T, b: U) => T & U /** * @template T * @param {T} a */ function f(a) { ->f : (a: any) => any ->a : any +>f : (a: T) => T +>a : T return a; ->a : any +>a : T } Object.defineProperty(module.exports, "f", { value: f }); >Object.defineProperty(module.exports, "f", { value: f }) : any @@ -114,9 +116,9 @@ Object.defineProperty(module.exports, "f", { value: f }); >module : any >exports : any >"f" : "f" ->{ value: f } : { value: (a: any) => any; } ->value : (a: any) => any ->f : (a: any) => any +>{ value: f } : { value: (a: T) => T; } +>value : (a: T) => T +>f : (a: T) => T Object.defineProperty(module.exports.f, "self", { value: module.exports.f }); >Object.defineProperty(module.exports.f, "self", { value: module.exports.f }) : any @@ -142,18 +144,18 @@ Object.defineProperty(module.exports.f, "self", { value: module.exports.f }); * @param {{y: typeof module.exports.b}} b */ function g(a, b) { ->g : (a: any, b: any) => any ->a : any ->b : any +>g : (a: { x: string; }, b: { y: any; }) => any +>a : { x: string; } +>b : { y: any; } return a.x && b.y(); >a.x && b.y() : any ->a.x : any ->a : any ->x : any +>a.x : string +>a : { x: string; } +>x : string >b.y() : any >b.y : any ->b : any +>b : { y: any; } >y : any } Object.defineProperty(module.exports, "g", { value: g }); @@ -165,9 +167,9 @@ Object.defineProperty(module.exports, "g", { value: g }); >module : any >exports : any >"g" : "g" ->{ value: g } : { value: (a: any, b: any) => any; } ->value : (a: any, b: any) => any ->g : (a: any, b: any) => any +>{ value: g } : { value: (a: { x: string; }, b: { y: any; }) => any; } +>value : (a: { x: string; }, b: { y: any; }) => any +>g : (a: { x: string; }, b: { y: any; }) => any /** @@ -175,18 +177,18 @@ Object.defineProperty(module.exports, "g", { value: g }); * @param {{y: typeof module.exports.b}} b */ function hh(a, b) { ->hh : (a: any, b: any) => any ->a : any ->b : any +>hh : (a: { x: string; }, b: { y: any; }) => any +>a : { x: string; } +>b : { y: any; } return a.x && b.y(); >a.x && b.y() : any ->a.x : any ->a : any ->x : any +>a.x : string +>a : { x: string; } +>x : string >b.y() : any >b.y : any ->b : any +>b : { y: any; } >y : any } Object.defineProperty(module.exports, "h", { value: hh }); @@ -198,9 +200,9 @@ Object.defineProperty(module.exports, "h", { value: hh }); >module : any >exports : any >"h" : "h" ->{ value: hh } : { value: (a: any, b: any) => any; } ->value : (a: any, b: any) => any ->hh : (a: any, b: any) => any +>{ value: hh } : { value: (a: { x: string; }, b: { y: any; }) => any; } +>value : (a: { x: string; }, b: { y: any; }) => any +>hh : (a: { x: string; }, b: { y: any; }) => any Object.defineProperty(module.exports, "i", { value: function i(){} }); >Object.defineProperty(module.exports, "i", { value: function i(){} }) : any diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt index d61c510933..e7e6110d7a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt @@ -1,5 +1,8 @@ +context.js(4,21): error TS2306: File 'timer.js' is not a module. +context.js(5,14): error TS1340: Module './hook' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./hook')'? context.js(34,14): error TS2350: Only a void function can be called with the 'new' keyword. context.js(48,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +hook.js(2,20): error TS1340: Module './context' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./context')'? hook.js(10,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. timer.js(7,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -14,9 +17,11 @@ timer.js(7,1): error TS2580: Cannot find name 'module'. Do you need to install t module.exports = Timer; ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== hook.js (1 errors) ==== +==== hook.js (2 errors) ==== /** * @typedef {(arg: import("./context")) => void} HookHandler + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './context' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./context')'? */ /** * @param {HookHandler} handle @@ -28,12 +33,16 @@ timer.js(7,1): error TS2580: Cannot find name 'module'. Do you need to install t ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== context.js (2 errors) ==== +==== context.js (4 errors) ==== /** * Imports * * @typedef {import("./timer")} Timer + ~~~~~~~~~ +!!! error TS2306: File 'timer.js' is not a module. * @typedef {import("./hook")} Hook + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './hook' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./hook')'? * @typedef {import("./hook").HookHandler} HookHandler */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types index 7afb8afe3a..3fc5508b7f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types @@ -5,22 +5,22 @@ * @param {number} timeout */ function Timer(timeout) { ->Timer : (timeout: any) => void ->timeout : any +>Timer : (timeout: number) => void +>timeout : number this.timeout = timeout; ->this.timeout = timeout : any +>this.timeout = timeout : number >this.timeout : any >this : any >timeout : any ->timeout : any +>timeout : number } module.exports = Timer; ->module.exports = Timer : (timeout: any) => void +>module.exports = Timer : (timeout: number) => void >module.exports : any >module : any >exports : any ->Timer : (timeout: any) => void +>Timer : (timeout: number) => void === hook.js === /** @@ -30,22 +30,22 @@ module.exports = Timer; * @param {HookHandler} handle */ function Hook(handle) { ->Hook : (handle: any) => void ->handle : any +>Hook : (handle: HookHandler) => void +>handle : HookHandler this.handle = handle; ->this.handle = handle : any +>this.handle = handle : HookHandler >this.handle : any >this : any >handle : any ->handle : any +>handle : HookHandler } module.exports = Hook; ->module.exports = Hook : (handle: any) => void +>module.exports = Hook : (handle: HookHandler) => void >module.exports : any >module : any >exports : any ->Hook : (handle: any) => void +>Hook : (handle: HookHandler) => void === context.js === /** @@ -80,20 +80,20 @@ module.exports = Hook; */ function Context(input) { ->Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } ->input : any +>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } +>input : Input if (!(this instanceof Context)) { >!(this instanceof Context) : boolean >(this instanceof Context) : boolean >this instanceof Context : boolean >this : any ->Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } +>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } return new Context(input) >new Context(input) : any ->Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } ->input : any +>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } +>input : Input } this.state = this.construct(input); >this.state = this.construct(input) : any @@ -104,14 +104,14 @@ function Context(input) { >this.construct : any >this : any >construct : any ->input : any +>input : Input } Context.prototype = { ->Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct: (input: any, handle?: () => any) => any; } ->Context.prototype : { construct: (input: any, handle?: () => any) => any; } ->Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } ->prototype : { construct: (input: any, handle?: () => any) => any; } ->{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct: (input: any, handle?: () => any) => any; } +>Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct: (input: Input, handle?: HookHandler) => State; } +>Context.prototype : { construct: (input: Input, handle?: HookHandler) => State; } +>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } +>prototype : { construct: (input: Input, handle?: HookHandler) => State; } +>{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct: (input: Input, handle?: HookHandler) => State; } /** * @param {Input} input @@ -119,21 +119,21 @@ Context.prototype = { * @returns {State} */ construct(input, handle = () => void 0) { ->construct : (input: any, handle?: () => any) => any ->input : any ->handle : () => any +>construct : (input: Input, handle?: HookHandler) => State +>input : Input +>handle : HookHandler >() => void 0 : () => any >void 0 : undefined >0 : 0 return input; ->input : any +>input : Input } } module.exports = Context; ->module.exports = Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } +>module.exports = Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } >module.exports : any >module : any >exports : any ->Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } +>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.types index cb4b7873be..981b176d05 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.types @@ -7,9 +7,9 @@ * @param {string} b */ export function foo(a, b) {} ->foo : (a: any, b: any) => void ->a : any ->b : any +>foo : (a: number, b: string) => void +>a : number +>b : string /** * Legacy - DO NOT USE @@ -23,18 +23,18 @@ export class Aleph { * @param {null} b */ constructor(a, b) { ->a : any ->b : any +>a : Aleph +>b : null /** * Field is always null */ this.field = b; ->this.field = b : any +>this.field = b : null >this.field : any >this : this >field : any ->b : any +>b : null } /** diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt index 4257e9ac23..cd9c5cdf28 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt @@ -1,3 +1,4 @@ +referencer.js(4,12): error TS2749: 'Point' refers to a value, but is being used as a type here. Did you mean 'typeof Point'? source.js(7,16): error TS2350: Only a void function can be called with the 'new' keyword. @@ -16,11 +17,13 @@ source.js(7,16): error TS2350: Only a void function can be called with the 'new' this.y = y; } -==== referencer.js (0 errors) ==== +==== referencer.js (1 errors) ==== import {Point} from "./source"; /** * @param {Point} p + ~~~~~ +!!! error TS2749: 'Point' refers to a value, but is being used as a type here. Did you mean 'typeof Point'? */ export function magnitude(p) { return Math.sqrt(p.x ** 2 + p.y ** 2); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.types index 4f75013fb3..8946c4eb88 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.types @@ -6,48 +6,48 @@ * @param {number} y */ export function Point(x, y) { ->Point : (x: any, y: any) => any ->x : any ->y : any +>Point : (x: number, y: number) => any +>x : number +>y : number if (!(this instanceof Point)) { >!(this instanceof Point) : boolean >(this instanceof Point) : boolean >this instanceof Point : boolean >this : any ->Point : (x: any, y: any) => any +>Point : (x: number, y: number) => any return new Point(x, y); >new Point(x, y) : any ->Point : (x: any, y: any) => any ->x : any ->y : any +>Point : (x: number, y: number) => any +>x : number +>y : number } this.x = x; ->this.x = x : any +>this.x = x : number >this.x : any >this : any >x : any ->x : any +>x : number this.y = y; ->this.y = y : any +>this.y = y : number >this.y : any >this : any >y : any ->y : any +>y : number } === referencer.js === import {Point} from "./source"; ->Point : (x: any, y: any) => any +>Point : (x: number, y: number) => any /** * @param {Point} p */ export function magnitude(p) { ->magnitude : (p: any) => number ->p : any +>magnitude : (p: Point) => number +>p : Point return Math.sqrt(p.x ** 2 + p.y ** 2); >Math.sqrt(p.x ** 2 + p.y ** 2) : number @@ -57,12 +57,12 @@ export function magnitude(p) { >p.x ** 2 + p.y ** 2 : number >p.x ** 2 : number >p.x : any ->p : any +>p : Point >x : any >2 : 2 >p.y ** 2 : number >p.y : any ->p : any +>p : Point >y : any >2 : 2 } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt index 3aedf38175..ab252908a8 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt @@ -1,8 +1,9 @@ referencer.js(3,23): error TS2350: Only a void function can be called with the 'new' keyword. +source.js(13,16): error TS2749: 'Vec' refers to a value, but is being used as a type here. Did you mean 'typeof Vec'? source.js(40,16): error TS2350: Only a void function can be called with the 'new' keyword. -==== source.js (1 errors) ==== +==== source.js (2 errors) ==== /** * @param {number} len */ @@ -16,6 +17,8 @@ source.js(40,16): error TS2350: Only a void function can be called with the 'new Vec.prototype = { /** * @param {Vec} other + ~~~ +!!! error TS2749: 'Vec' refers to a value, but is being used as a type here. Did you mean 'typeof Vec'? */ dot(other) { if (other.storage.length !== this.storage.length) { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.types index a9a07e2461..28bea0bb21 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.types @@ -5,8 +5,8 @@ * @param {number} len */ export function Vec(len) { ->Vec : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } ->len : any +>Vec : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } +>len : number /** * @type {number[]} @@ -18,28 +18,28 @@ export function Vec(len) { >storage : any >new Array(len) : any[] >Array : ArrayConstructor ->len : any +>len : number } 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: any) => number; magnitude: () => number; } ->Vec.prototype : { dot: (other: any) => number; magnitude: () => number; } ->Vec : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } ->prototype : { dot: (other: any) => number; magnitude: () => number; } ->{ /** * @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: any) => number; magnitude: () => number; } +>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; } +>Vec : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } +>prototype : { dot: (other: Vec) => number; magnitude: () => number; } +>{ /** * @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; } /** * @param {Vec} other */ dot(other) { ->dot : (other: any) => number ->other : any +>dot : (other: Vec) => number +>other : Vec if (other.storage.length !== this.storage.length) { >other.storage.length !== this.storage.length : boolean >other.storage.length : any >other.storage : any ->other : any +>other : Vec >storage : any >length : any >this.storage.length : any @@ -82,7 +82,7 @@ Vec.prototype = { >i : number >other.storage[i] : any >other.storage : any ->other : any +>other : Vec >storage : any >i : number } @@ -136,59 +136,59 @@ Vec.prototype = { * @param {number} y */ export function Point2D(x, y) { ->Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } ->x : any ->y : any +>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } +>x : number +>y : number if (!(this instanceof Point2D)) { >!(this instanceof Point2D) : boolean >(this instanceof Point2D) : boolean >this instanceof Point2D : boolean >this : any ->Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } +>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } return new Point2D(x, y); >new Point2D(x, y) : any ->Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } ->x : any ->y : any +>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } +>x : number +>y : number } Vec.call(this, 2); >Vec.call(this, 2) : any >Vec.call : (this: Function, thisArg: any, ...argArray: any[]) => any ->Vec : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } +>Vec : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } >call : (this: Function, thisArg: any, ...argArray: any[]) => any >this : any >2 : 2 this.x = x; ->this.x = x : any +>this.x = x : number >this.x : any >this : any >x : any ->x : any +>x : number this.y = y; ->this.y = y : any +>this.y = y : number >this.y : any >this : any >y : any ->y : any +>y : number } Point2D.prototype = { ->Point2D.prototype = { __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; } ->Point2D.prototype : { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; } ->Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } ->prototype : { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; } ->{ __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; } +>Point2D.prototype = { __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; } +>Point2D.prototype : { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; } +>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } +>prototype : { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; } +>{ __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; } __proto__: Vec, ->__proto__ : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } ->Vec : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } +>__proto__ : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } +>Vec : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } get x() { ->x : any +>x : number return this.storage[0]; >this.storage[0] : any @@ -202,21 +202,21 @@ Point2D.prototype = { * @param {number} x */ set x(x) { ->x : any ->x : any +>x : number +>x : number this.storage[0] = x; ->this.storage[0] = x : any +>this.storage[0] = x : number >this.storage[0] : any >this.storage : any >this : any >storage : any >0 : 0 ->x : any +>x : number }, get y() { ->y : any +>y : number return this.storage[1]; >this.storage[1] : any @@ -230,28 +230,28 @@ Point2D.prototype = { * @param {number} y */ set y(y) { ->y : any ->y : any +>y : number +>y : number this.storage[1] = y; ->this.storage[1] = y : any +>this.storage[1] = y : number >this.storage[1] : any >this.storage : any >this : any >storage : any >1 : 1 ->y : any +>y : number } }; === referencer.js === import {Point2D} from "./source"; ->Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } +>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } export const origin = new Point2D(0, 0); >origin : any >new Point2D(0, 0) : any ->Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } +>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } >0 : 0 >0 : 0 diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt new file mode 100644 index 0000000000..b5b272ad82 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt @@ -0,0 +1,71 @@ +index.js(38,21): error TS2349: This expression is not callable. + Type '{ y: ???; }' has no call signatures. +index.js(48,21): error TS2349: This expression is not callable. + Type '{ y: ???; }' has no call signatures. + + +==== index.js (2 errors) ==== + export function a() {} + + export function b() {} + b.cat = "cat"; + + export function c() {} + c.Cls = class {} + + /** + * @param {number} a + * @param {number} b + * @return {string} + */ + export function d(a, b) { return /** @type {*} */(null); } + + /** + * @template T,U + * @param {T} a + * @param {U} b + * @return {T & U} + */ + export function e(a, b) { return /** @type {*} */(null); } + + /** + * @template T + * @param {T} a + */ + export function f(a) { + return a; + } + f.self = f; + + /** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ + function g(a, b) { + return a.x && b.y(); + ~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type '{ y: ???; }' has no call signatures. + } + + export { g }; + + /** + * @param {{x: string}} a + * @param {{y: typeof b}} b + */ + function hh(a, b) { + return a.x && b.y(); + ~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type '{ y: ???; }' has no call signatures. + } + + export { hh as h }; + + export function i() {} + export { i as ii }; + + export { j as jj }; + export function j() {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.symbols index 4722a46367..7c366d06b6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.symbols @@ -68,8 +68,12 @@ function g(a, b) { >b : Symbol(b, Decl(index.js, 36, 13)) return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 33, 12)) >a : Symbol(a, Decl(index.js, 36, 11)) +>x : Symbol(x, Decl(index.js, 33, 12)) +>b.y : Symbol(y, Decl(index.js, 34, 12)) >b : Symbol(b, Decl(index.js, 36, 13)) +>y : Symbol(y, Decl(index.js, 34, 12)) } export { g }; @@ -85,8 +89,12 @@ function hh(a, b) { >b : Symbol(b, Decl(index.js, 46, 14)) return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 43, 12)) >a : Symbol(a, Decl(index.js, 46, 12)) +>x : Symbol(x, Decl(index.js, 43, 12)) +>b.y : Symbol(y, Decl(index.js, 44, 12)) >b : Symbol(b, Decl(index.js, 46, 14)) +>y : Symbol(y, Decl(index.js, 44, 12)) } export { hh as h }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.symbols.diff index 2035423afc..7b851080df 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.symbols.diff @@ -52,29 +52,3 @@ /** * @param {{x: string}} a -@@= skipped -22, +22 lines =@@ - >b : Symbol(b, Decl(index.js, 36, 13)) - - return a.x && b.y(); -->a.x : Symbol(x, Decl(index.js, 33, 12)) - >a : Symbol(a, Decl(index.js, 36, 11)) -->x : Symbol(x, Decl(index.js, 33, 12)) -->b.y : Symbol(y, Decl(index.js, 34, 12)) - >b : Symbol(b, Decl(index.js, 36, 13)) -->y : Symbol(y, Decl(index.js, 34, 12)) - } - - export { g }; -@@= skipped -21, +17 lines =@@ - >b : Symbol(b, Decl(index.js, 46, 14)) - - return a.x && b.y(); -->a.x : Symbol(x, Decl(index.js, 43, 12)) - >a : Symbol(a, Decl(index.js, 46, 12)) -->x : Symbol(x, Decl(index.js, 43, 12)) -->b.y : Symbol(y, Decl(index.js, 44, 12)) - >b : Symbol(b, Decl(index.js, 46, 14)) -->y : Symbol(y, Decl(index.js, 44, 12)) - } - - export { hh as h }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.types index b8521d732b..ad9acc5c28 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.types @@ -30,10 +30,11 @@ c.Cls = class {} * @return {string} */ export function d(a, b) { return /** @type {*} */(null); } ->d : (a: any, b: any) => any ->a : any ->b : any ->(null) : null +>d : (a: number, b: number) => string +>a : number +>b : number +>(null) : any +>null : any /** * @template T,U @@ -42,75 +43,76 @@ export function d(a, b) { return /** @type {*} */(null); } * @return {T & U} */ export function e(a, b) { return /** @type {*} */(null); } ->e : (a: any, b: any) => any ->a : any ->b : any ->(null) : null +>e : (a: T, b: U) => T & U +>a : T +>b : U +>(null) : any +>null : any /** * @template T * @param {T} a */ export function f(a) { ->f : { (a: any): any; self: ???; } ->a : any +>f : { (a: T): T; self: ???; } +>a : T return a; ->a : any +>a : T } f.self = f; ->f.self = f : { (a: any): any; self: ???; } ->f.self : { (a: any): any; self: ???; } ->f : { (a: any): any; self: ???; } ->self : { (a: any): any; self: ???; } ->f : { (a: any): any; self: ???; } +>f.self = f : { (a: T): T; self: ???; } +>f.self : { (a: T): T; self: ???; } +>f : { (a: T): T; self: ???; } +>self : { (a: T): T; self: ???; } +>f : { (a: T): T; self: ???; } /** * @param {{x: string}} a * @param {{y: typeof b}} b */ function g(a, b) { ->g : (a: any, b: any) => any ->a : any ->b : any +>g : (a: { x: string; }, b: { y: ???; }) => any +>a : { x: string; } +>b : { y: ???; } return a.x && b.y(); >a.x && b.y() : any ->a.x : any ->a : any ->x : any +>a.x : string +>a : { x: string; } +>x : string >b.y() : any ->b.y : any ->b : any ->y : any +>b.y : { y: ???; } +>b : { y: ???; } +>y : { y: ???; } } export { g }; ->g : (a: any, b: any) => any +>g : (a: { x: string; }, b: { y: ???; }) => any /** * @param {{x: string}} a * @param {{y: typeof b}} b */ function hh(a, b) { ->hh : (a: any, b: any) => any ->a : any ->b : any +>hh : (a: { x: string; }, b: { y: ???; }) => any +>a : { x: string; } +>b : { y: ???; } return a.x && b.y(); >a.x && b.y() : any ->a.x : any ->a : any ->x : any +>a.x : string +>a : { x: string; } +>x : string >b.y() : any ->b.y : any ->b : any ->y : any +>b.y : { y: ???; } +>b : { y: ???; } +>y : { y: ???; } } export { hh as h }; ->hh : (a: any, b: any) => any ->h : (a: any, b: any) => any +>hh : (a: { x: string; }, b: { y: ???; }) => any +>h : (a: { x: string; }, b: { y: ???; }) => any export function i() {} >i : () => void diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt index 11aee39fcc..263140ef38 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt @@ -8,7 +8,9 @@ index.js(22,1): error TS2580: Cannot find name 'module'. Do you need to install index.js(28,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. index.js(31,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. index.js(31,25): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +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(41,1): 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(51,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. index.js(53,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. index.js(54,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -18,7 +20,7 @@ index.js(57,21): error TS2580: Cannot find name 'module'. Do you need to install index.js(58,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== index.js (18 errors) ==== +==== index.js (20 errors) ==== module.exports.a = function a() {} ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -74,6 +76,8 @@ index.js(58,1): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a * @param {{y: typeof module.exports.b}} b + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ function g(a, b) { return a.x && b.y(); @@ -86,6 +90,8 @@ index.js(58,1): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a * @param {{y: typeof module.exports.b}} b + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ function hh(a, b) { return a.x && b.y(); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.symbols index 23c01b990e..2d71c847d6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.symbols @@ -58,8 +58,12 @@ function g(a, b) { >b : Symbol(b, Decl(index.js, 36, 13)) return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 33, 12)) >a : Symbol(a, Decl(index.js, 36, 11)) +>x : Symbol(x, Decl(index.js, 33, 12)) +>b.y : Symbol(y, Decl(index.js, 34, 12)) >b : Symbol(b, Decl(index.js, 36, 13)) +>y : Symbol(y, Decl(index.js, 34, 12)) } module.exports.g = g; @@ -75,8 +79,12 @@ function hh(a, b) { >b : Symbol(b, Decl(index.js, 46, 14)) return a.x && b.y(); +>a.x : Symbol(x, Decl(index.js, 43, 12)) >a : Symbol(a, Decl(index.js, 46, 12)) +>x : Symbol(x, Decl(index.js, 43, 12)) +>b.y : Symbol(y, Decl(index.js, 44, 12)) >b : Symbol(b, Decl(index.js, 46, 14)) +>y : Symbol(y, Decl(index.js, 44, 12)) } module.exports.h = hh; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.symbols.diff index 15a1c0b4c3..495b153c83 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.symbols.diff @@ -102,16 +102,7 @@ /** * @param {{x: string}} a -@@= skipped -23, +11 lines =@@ - >b : Symbol(b, Decl(index.js, 36, 13)) - - return a.x && b.y(); -->a.x : Symbol(x, Decl(index.js, 33, 12)) - >a : Symbol(a, Decl(index.js, 36, 11)) -->x : Symbol(x, Decl(index.js, 33, 12)) -->b.y : Symbol(y, Decl(index.js, 34, 12)) - >b : Symbol(b, Decl(index.js, 36, 13)) -->y : Symbol(y, Decl(index.js, 34, 12)) +@@= skipped -32, +20 lines =@@ } module.exports.g = g; @@ -123,16 +114,7 @@ >g : Symbol(g, Decl(index.js, 30, 41)) /** -@@= skipped -26, +17 lines =@@ - >b : Symbol(b, Decl(index.js, 46, 14)) - - return a.x && b.y(); -->a.x : Symbol(x, Decl(index.js, 43, 12)) - >a : Symbol(a, Decl(index.js, 46, 12)) -->x : Symbol(x, Decl(index.js, 43, 12)) -->b.y : Symbol(y, Decl(index.js, 44, 12)) - >b : Symbol(b, Decl(index.js, 46, 14)) -->y : Symbol(y, Decl(index.js, 44, 12)) +@@= skipped -26, +21 lines =@@ } module.exports.h = hh; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types index 0a57322ea0..12fca3dd8f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types @@ -69,7 +69,8 @@ module.exports.d = function d(a, b) { return /** @type {*} */(null); } >d : (a: any, b: any) => any >a : any >b : any ->(null) : null +>(null) : any +>null : any /** * @template T,U @@ -88,7 +89,8 @@ module.exports.e = function e(a, b) { return /** @type {*} */(null); } >e : (a: any, b: any) => any >a : any >b : any ->(null) : null +>(null) : any +>null : any /** * @template T @@ -128,58 +130,58 @@ module.exports.f.self = module.exports.f; * @param {{y: typeof module.exports.b}} b */ function g(a, b) { ->g : (a: any, b: any) => any ->a : any ->b : any +>g : (a: { x: string; }, b: { y: any; }) => any +>a : { x: string; } +>b : { y: any; } return a.x && b.y(); >a.x && b.y() : any ->a.x : any ->a : any ->x : any +>a.x : string +>a : { x: string; } +>x : string >b.y() : any >b.y : any ->b : any +>b : { y: any; } >y : any } module.exports.g = g; ->module.exports.g = g : (a: any, b: any) => any +>module.exports.g = g : (a: { x: string; }, b: { y: any; }) => any >module.exports.g : any >module.exports : any >module : any >exports : any >g : any ->g : (a: any, b: any) => any +>g : (a: { x: string; }, b: { y: any; }) => any /** * @param {{x: string}} a * @param {{y: typeof module.exports.b}} b */ function hh(a, b) { ->hh : (a: any, b: any) => any ->a : any ->b : any +>hh : (a: { x: string; }, b: { y: any; }) => any +>a : { x: string; } +>b : { y: any; } return a.x && b.y(); >a.x && b.y() : any ->a.x : any ->a : any ->x : any +>a.x : string +>a : { x: string; } +>x : string >b.y() : any >b.y : any ->b : any +>b : { y: any; } >y : any } module.exports.h = hh; ->module.exports.h = hh : (a: any, b: any) => any +>module.exports.h = hh : (a: { x: string; }, b: { y: any; }) => any >module.exports.h : any >module.exports : any >module : any >exports : any >h : any ->hh : (a: any, b: any) => any +>hh : (a: { x: string; }, b: { y: any; }) => any module.exports.i = function i() {} >module.exports.i = function i() {} : () => void diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.types index 573012044c..144f096884 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.types @@ -19,8 +19,8 @@ export class B { * @param {number} _arg */ set x(_arg) { ->x : any ->_arg : any +>x : number +>_arg : number } } @@ -73,14 +73,14 @@ Object.defineProperty(E.prototype, "x", { >E : typeof E >prototype : E >"x" : "x" ->{ /** * @param {number} _arg */ set(_arg) {}} : { set: (_arg: any) => void; } +>{ /** * @param {number} _arg */ set(_arg) {}} : { set: (_arg: number) => void; } /** * @param {number} _arg */ set(_arg) {} ->set : (_arg: any) => void ->_arg : any +>set : (_arg: number) => void +>_arg : number }); @@ -96,7 +96,7 @@ Object.defineProperty(F.prototype, "x", { >F : typeof F >prototype : F >"x" : "x" ->{ get() { return 12; }, /** * @param {number} _arg */ set(_arg) {}} : { get: () => number; set: (_arg: any) => void; } +>{ get() { return 12; }, /** * @param {number} _arg */ set(_arg) {}} : { get: () => number; set: (_arg: number) => void; } get() { >get : () => number @@ -109,8 +109,8 @@ Object.defineProperty(F.prototype, "x", { * @param {number} _arg */ set(_arg) {} ->set : (_arg: any) => void ->_arg : any +>set : (_arg: number) => void +>_arg : number }); @@ -126,14 +126,14 @@ Object.defineProperty(G.prototype, "x", { >G : typeof G >prototype : G >"x" : "x" ->{ /** * @param {number[]} args */ set(...args) {}} : { set: (v: any) => void; } +>{ /** * @param {number[]} args */ set(...args) {}} : { set: (...args: number[]) => void; } /** * @param {number[]} args */ set(...args) {} ->set : (v: any) => void ->args : [v: any] +>set : (...args: number[]) => void +>args : number[] }); @@ -169,15 +169,15 @@ Object.defineProperty(I.prototype, "x", { >I : typeof I >prototype : I >"x" : "x" ->{ /** * @param {number} v */ set: (v) => {}} : { set: (v: any) => void; } +>{ /** * @param {number} v */ set: (v) => {}} : { set: (v: number) => void; } /** * @param {number} v */ set: (v) => {} ->set : (v: any) => void ->(v) => {} : (v: any) => void ->v : any +>set : (v: number) => void +>(v) => {} : (v: number) => void +>v : number }); @@ -185,9 +185,9 @@ Object.defineProperty(I.prototype, "x", { * @param {number} v */ const jSetter = (v) => {} ->jSetter : (v: any) => void ->(v) => {} : (v: any) => void ->v : any +>jSetter : (v: number) => void +>(v) => {} : (v: number) => void +>v : number export class J {} >J : J @@ -201,11 +201,11 @@ Object.defineProperty(J.prototype, "x", { >J : typeof J >prototype : J >"x" : "x" ->{ set: jSetter} : { set: (v: any) => void; } +>{ set: jSetter} : { set: (v: number) => void; } set: jSetter ->set : (v: any) => void ->jSetter : (v: any) => void +>set : (v: number) => void +>jSetter : (v: number) => void }); @@ -213,17 +213,17 @@ Object.defineProperty(J.prototype, "x", { * @param {number} v */ const kSetter1 = (v) => {} ->kSetter1 : (v: any) => void ->(v) => {} : (v: any) => void ->v : any +>kSetter1 : (v: number) => void +>(v) => {} : (v: number) => void +>v : number /** * @param {number} v */ const kSetter2 = (v) => {} ->kSetter2 : (v: any) => void ->(v) => {} : (v: any) => void ->v : any +>kSetter2 : (v: number) => void +>(v) => {} : (v: number) => void +>v : number export class K {} >K : K @@ -237,17 +237,17 @@ Object.defineProperty(K.prototype, "x", { >K : typeof K >prototype : K >"x" : "x" ->{ set: Math.random() ? kSetter1 : kSetter2} : { set: (v: any) => void; } +>{ set: Math.random() ? kSetter1 : kSetter2} : { set: (v: number) => void; } set: Math.random() ? kSetter1 : kSetter2 ->set : (v: any) => void ->Math.random() ? kSetter1 : kSetter2 : (v: any) => void +>set : (v: number) => void +>Math.random() ? kSetter1 : kSetter2 : (v: number) => void >Math.random() : number >Math.random : () => number >Math : Math >random : () => number ->kSetter1 : (v: any) => void ->kSetter2 : (v: any) => void +>kSetter1 : (v: number) => void +>kSetter2 : (v: number) => void }); @@ -255,17 +255,17 @@ Object.defineProperty(K.prototype, "x", { * @param {number} v */ const lSetter1 = (v) => {} ->lSetter1 : (v: any) => void ->(v) => {} : (v: any) => void ->v : any +>lSetter1 : (v: number) => void +>(v) => {} : (v: number) => void +>v : number /** * @param {string} v */ const lSetter2 = (v) => {} ->lSetter2 : (v: any) => void ->(v) => {} : (v: any) => void ->v : any +>lSetter2 : (v: string) => void +>(v) => {} : (v: string) => void +>v : string export class L {} >L : L @@ -279,17 +279,17 @@ Object.defineProperty(L.prototype, "x", { >L : typeof L >prototype : L >"x" : "x" ->{ set: Math.random() ? lSetter1 : lSetter2} : { set: (v: any) => void; } +>{ set: Math.random() ? lSetter1 : lSetter2} : { set: ((v: number) => void) | ((v: string) => void); } set: Math.random() ? lSetter1 : lSetter2 ->set : (v: any) => void ->Math.random() ? lSetter1 : lSetter2 : (v: any) => void +>set : ((v: number) => void) | ((v: string) => void) +>Math.random() ? lSetter1 : lSetter2 : ((v: number) => void) | ((v: string) => void) >Math.random() : number >Math.random : () => number >Math : Math >random : () => number ->lSetter1 : (v: any) => void ->lSetter2 : (v: any) => void +>lSetter1 : (v: number) => void +>lSetter2 : (v: string) => void }); @@ -297,17 +297,17 @@ Object.defineProperty(L.prototype, "x", { * @param {number | boolean} v */ const mSetter1 = (v) => {} ->mSetter1 : (v: any) => void ->(v) => {} : (v: any) => void ->v : any +>mSetter1 : (v: number | boolean) => void +>(v) => {} : (v: number | boolean) => void +>v : number | boolean /** * @param {string | boolean} v */ const mSetter2 = (v) => {} ->mSetter2 : (v: any) => void ->(v) => {} : (v: any) => void ->v : any +>mSetter2 : (v: string | boolean) => void +>(v) => {} : (v: string | boolean) => void +>v : string | boolean export class M {} >M : M @@ -321,17 +321,17 @@ Object.defineProperty(M.prototype, "x", { >M : typeof M >prototype : M >"x" : "x" ->{ set: Math.random() ? mSetter1 : mSetter2} : { set: (v: any) => void; } +>{ set: Math.random() ? mSetter1 : mSetter2} : { set: ((v: number | boolean) => void) | ((v: string | boolean) => void); } set: Math.random() ? mSetter1 : mSetter2 ->set : (v: any) => void ->Math.random() ? mSetter1 : mSetter2 : (v: any) => void +>set : ((v: number | boolean) => void) | ((v: string | boolean) => void) +>Math.random() ? mSetter1 : mSetter2 : ((v: number | boolean) => void) | ((v: string | boolean) => void) >Math.random() : number >Math.random : () => number >Math : Math >random : () => number ->mSetter1 : (v: any) => void ->mSetter2 : (v: any) => void +>mSetter1 : (v: number | boolean) => void +>mSetter2 : (v: string | boolean) => void }); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt new file mode 100644 index 0000000000..339f44b69d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt @@ -0,0 +1,76 @@ +file.js(4,11): error TS2315: Type 'Object' is not generic. +file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. +file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. +file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. +file2.js(6,11): error TS2315: Type 'Object' is not generic. +file2.js(12,23): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. + + +==== file.js (5 errors) ==== + /** + * @namespace myTypes + * @global + * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + */ + const myTypes = { + // SOME PROPS HERE + }; + + /** @typedef {string|RegExp|Array} myTypes.typeA */ + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'myTypes'. + + /** + * @typedef myTypes.typeB + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'myTypes'. + * @property {myTypes.typeA} prop1 - Prop 1. + * @property {string} prop2 - Prop 2. + */ + + /** @typedef {myTypes.typeB|Function} myTypes.typeC */ + ~~~~~~~ +!!! error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'myTypes'. + + export {myTypes}; +==== file2.js (3 errors) ==== + import {myTypes} from './file.js'; + + /** + * @namespace testFnTypes + * @global + * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + */ + const testFnTypes = { + // SOME PROPS HERE + }; + + /** @typedef {boolean|myTypes.typeC} testFnTypes.input */ + ~~~~~~~ +!!! error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. + + /** + * @function testFn + * @description A test function. + * @param {testFnTypes.input} input - Input. + ~~~~~~~~~~~ +!!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. + * @returns {number|null} Result. + */ + function testFn(input) { + if (typeof input === 'number') { + return 2 * input; + } else { + return null; + } + } + + export {testFn, testFnTypes}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols index 87592a7b6d..0c301bfa5c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols @@ -7,7 +7,7 @@ * @type {Object} */ const myTypes = { ->myTypes : Symbol(myTypes, Decl(file.js, 5, 5)) +>myTypes : Symbol(myTypes, Decl(file.js, 5, 5), Decl(file.js, 9, 4), Decl(file.js, 12, 3), Decl(file.js, 17, 4)) // SOME PROPS HERE }; @@ -23,7 +23,7 @@ const myTypes = { /** @typedef {myTypes.typeB|Function} myTypes.typeC */ export {myTypes}; ->myTypes : Symbol(myTypes, Decl(file.js, 19, 8)) +>myTypes : Symbol(myTypes, Decl(file.js, 9, 4), Decl(file.js, 19, 8)) === file2.js === import {myTypes} from './file.js'; @@ -35,7 +35,7 @@ import {myTypes} from './file.js'; * @type {Object} */ const testFnTypes = { ->testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5)) +>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5), Decl(file2.js, 11, 4)) // SOME PROPS HERE }; @@ -65,5 +65,5 @@ function testFn(input) { export {testFn, testFnTypes}; >testFn : Symbol(testFn, Decl(file2.js, 27, 8)) ->testFnTypes : Symbol(testFnTypes, Decl(file2.js, 27, 15)) +>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 11, 4), Decl(file2.js, 27, 15)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols.diff index 899803d93f..e5fd12a887 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols.diff @@ -5,7 +5,7 @@ */ const myTypes = { ->myTypes : Symbol(myTypes, Decl(file.js, 5, 5), Decl(file.js, 9, 50), Decl(file.js, 12, 12), Decl(file.js, 17, 38)) -+>myTypes : Symbol(myTypes, Decl(file.js, 5, 5)) ++>myTypes : Symbol(myTypes, Decl(file.js, 5, 5), Decl(file.js, 9, 4), Decl(file.js, 12, 3), Decl(file.js, 17, 4)) // SOME PROPS HERE }; @@ -14,7 +14,7 @@ export {myTypes}; ->myTypes : Symbol(myTypes, Decl(file.js, 19, 8), Decl(file.js, 9, 50), Decl(file.js, 12, 12), Decl(file.js, 17, 38)) -+>myTypes : Symbol(myTypes, Decl(file.js, 19, 8)) ++>myTypes : Symbol(myTypes, Decl(file.js, 9, 4), Decl(file.js, 19, 8)) === file2.js === import {myTypes} from './file.js'; @@ -23,7 +23,7 @@ */ const testFnTypes = { ->testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5), Decl(file2.js, 11, 37)) -+>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5)) ++>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5), Decl(file2.js, 11, 4)) // SOME PROPS HERE }; @@ -32,5 +32,5 @@ export {testFn, testFnTypes}; >testFn : Symbol(testFn, Decl(file2.js, 27, 8)) ->testFnTypes : Symbol(testFnTypes, Decl(file2.js, 27, 15), Decl(file2.js, 11, 37)) -+>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 27, 15)) ++>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 11, 4), Decl(file2.js, 27, 15)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.types index 1a0e70cabf..3ecfd6cb66 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.types @@ -7,7 +7,7 @@ * @type {Object} */ const myTypes = { ->myTypes : {} +>myTypes : any >{ // SOME PROPS HERE} : {} // SOME PROPS HERE @@ -24,11 +24,11 @@ const myTypes = { /** @typedef {myTypes.typeB|Function} myTypes.typeC */ export {myTypes}; ->myTypes : {} +>myTypes : any === file2.js === import {myTypes} from './file.js'; ->myTypes : {} +>myTypes : any /** * @namespace testFnTypes @@ -36,7 +36,7 @@ import {myTypes} from './file.js'; * @type {Object} */ const testFnTypes = { ->testFnTypes : {} +>testFnTypes : any >{ // SOME PROPS HERE} : {} // SOME PROPS HERE @@ -51,13 +51,13 @@ const testFnTypes = { * @returns {number|null} Result. */ function testFn(input) { ->testFn : (input: any) => number ->input : any +>testFn : (input: input) => number +>input : input if (typeof input === 'number') { >typeof input === 'number' : boolean >typeof input : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->input : any +>input : input >'number' : "number" return 2 * input; @@ -71,6 +71,6 @@ function testFn(input) { } export {testFn, testFnTypes}; ->testFn : (input: any) => number ->testFnTypes : {} +>testFn : (input: input) => number +>testFnTypes : any diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt index 927a6ecac4..f3c038d0f7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt @@ -1,8 +1,11 @@ file2.js(1,19): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +file2.js(6,11): error TS2315: Type 'Object' is not generic. +file2.js(12,23): error TS2503: Cannot find namespace 'myTypes'. +file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. file2.js(28,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== file2.js (2 errors) ==== +==== file2.js (5 errors) ==== const {myTypes} = require('./file.js'); ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -11,17 +14,23 @@ file2.js(28,1): error TS2580: Cannot find name 'module'. Do you need to install * @namespace testFnTypes * @global * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. */ const testFnTypes = { // SOME PROPS HERE }; /** @typedef {boolean|myTypes.typeC} testFnTypes.input */ + ~~~~~~~ +!!! error TS2503: Cannot find namespace 'myTypes'. /** * @function testFn * @description A test function. * @param {testFnTypes.input} input - Input. + ~~~~~~~~~~~ +!!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. * @returns {number|null} Result. */ function testFn(input) { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols index af5a591be3..2ee8b34843 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols @@ -10,7 +10,7 @@ const {myTypes} = require('./file.js'); * @type {Object} */ const testFnTypes = { ->testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5)) +>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5), Decl(file2.js, 11, 4)) // SOME PROPS HERE }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff index e980ea1876..2dac9e6ef4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff @@ -14,7 +14,7 @@ */ const testFnTypes = { ->testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5), Decl(file2.js, 11, 37)) -+>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5)) ++>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 7, 5), Decl(file2.js, 11, 4)) // SOME PROPS HERE }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types index bbdde03d12..f3b4df0bf2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types @@ -13,7 +13,7 @@ const {myTypes} = require('./file.js'); * @type {Object} */ const testFnTypes = { ->testFnTypes : {} +>testFnTypes : any >{ // SOME PROPS HERE} : {} // SOME PROPS HERE @@ -28,13 +28,13 @@ const testFnTypes = { * @returns {number|null} Result. */ function testFn(input) { ->testFn : (input: any) => number ->input : any +>testFn : (input: input) => number +>input : input if (typeof input === 'number') { >typeof input === 'number' : boolean >typeof input : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->input : any +>input : input >'number' : "number" return 2 * input; @@ -48,11 +48,11 @@ function testFn(input) { } module.exports = {testFn, testFnTypes}; ->module.exports = {testFn, testFnTypes} : { testFn: (input: any) => number; testFnTypes: {}; } +>module.exports = {testFn, testFnTypes} : { testFn: (input: input) => number; testFnTypes: any; } >module.exports : any >module : any >exports : any ->{testFn, testFnTypes} : { testFn: (input: any) => number; testFnTypes: {}; } ->testFn : (input: any) => number ->testFnTypes : {} +>{testFn, testFnTypes} : { testFn: (input: input) => number; testFnTypes: any; } +>testFn : (input: input) => number +>testFnTypes : any diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt new file mode 100644 index 0000000000..8634dc2259 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt @@ -0,0 +1,14 @@ +file.js(2,29): error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. + + +==== file.js (1 errors) ==== + import { dummy } from './mod1' + /** @type {import('./mod1').Dotted.Name} - should work */ + ~~~~~~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. + var dot2 + +==== mod1.js (0 errors) ==== + /** @typedef {number} Dotted.Name */ + export var dummy = 1 + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.types index aff1e11ef1..c066349aef 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.types @@ -23,16 +23,16 @@ module.exports = x; === index.js === /** @type {(typeof import("./folder/mod1"))[]} */ const items = [{x: 12}]; ->items : { x: number; }[] +>items : typeof import("folder/mod1")[] >[{x: 12}] : { x: number; }[] >{x: 12} : { x: number; } >x : number >12 : 12 module.exports = items; ->module.exports = items : { x: number; }[] +>module.exports = items : typeof import("folder/mod1")[] >module.exports : any >module : any >exports : any ->items : { x: number; }[] +>items : typeof import("folder/mod1")[] diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt new file mode 100644 index 0000000000..38ff884b7d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt @@ -0,0 +1,60 @@ +index.js(5,12): error TS2304: Cannot find name 'Void'. +index.js(6,12): error TS2304: Cannot find name 'Undefined'. +index.js(7,12): error TS2304: Cannot find name 'Null'. +index.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +index.js(11,12): error TS2552: Cannot find name 'array'. Did you mean 'Array'? +index.js(12,12): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? +index.js(13,12): error TS2315: Type 'Object' is not generic. +index.js(30,12): error TS2749: 'event' refers to a value, but is being used as a type here. Did you mean 'typeof event'? + + +==== index.js (8 errors) ==== + // these are recognized as TS concepts by the checker + /** @type {String} */const a = ""; + /** @type {Number} */const b = 0; + /** @type {Boolean} */const c = true; + /** @type {Void} */const d = undefined; + ~~~~ +!!! error TS2304: Cannot find name 'Void'. + /** @type {Undefined} */const e = undefined; + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'Undefined'. + /** @type {Null} */const f = null; + ~~~~ +!!! error TS2304: Cannot find name 'Null'. + + /** @type {Function} */const g = () => void 0; + /** @type {function} */const h = () => void 0; + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + /** @type {array} */const i = []; + ~~~~~ +!!! error TS2552: Cannot find name 'array'. Did you mean 'Array'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Array' is declared here. + /** @type {promise} */const j = Promise.resolve(0); + ~~~~~~~ +!!! error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? +!!! related TS2728 lib.es2015.promise.d.ts:--:--: 'Promise' is declared here. + /** @type {Object} */const k = {x: "x"}; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + + + // these are not recognized as anything and should just be lookup failures + // ignore the errors to try to ensure they're emitted as `any` in declaration emit + // @ts-ignore + /** @type {class} */const l = true; + // @ts-ignore + /** @type {bool} */const m = true; + // @ts-ignore + /** @type {int} */const n = true; + // @ts-ignore + /** @type {float} */const o = true; + // @ts-ignore + /** @type {integer} */const p = true; + + // or, in the case of `event` likely erroneously refers to the type of the global Event object + /** @type {event} */const q = undefined; + ~~~~~ +!!! error TS2749: 'event' refers to a value, but is being used as a type here. Did you mean 'typeof event'? \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.types index 2f40433de1..28e870e0c7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.types @@ -3,46 +3,46 @@ === index.js === // these are recognized as TS concepts by the checker /** @type {String} */const a = ""; ->a : "" +>a : String >"" : "" /** @type {Number} */const b = 0; ->b : 0 +>b : Number >0 : 0 /** @type {Boolean} */const c = true; ->c : true +>c : Boolean >true : true /** @type {Void} */const d = undefined; ->d : undefined +>d : Void >undefined : undefined /** @type {Undefined} */const e = undefined; ->e : undefined +>e : Undefined >undefined : undefined /** @type {Null} */const f = null; ->f : null +>f : Null /** @type {Function} */const g = () => void 0; ->g : () => undefined +>g : Function >() => void 0 : () => undefined >void 0 : undefined >0 : 0 /** @type {function} */const h = () => void 0; ->h : () => undefined +>h : function >() => void 0 : () => undefined >void 0 : undefined >0 : 0 /** @type {array} */const i = []; ->i : never[] +>i : array >[] : never[] /** @type {promise} */const j = Promise.resolve(0); ->j : Promise +>j : promise >Promise.resolve(0) : Promise >Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } >Promise : PromiseConstructor @@ -50,7 +50,7 @@ >0 : 0 /** @type {Object} */const k = {x: "x"}; ->k : { x: string; } +>k : any >{x: "x"} : { x: string; } >x : string >"x" : "x" @@ -60,31 +60,31 @@ // ignore the errors to try to ensure they're emitted as `any` in declaration emit // @ts-ignore /** @type {class} */const l = true; ->l : true +>l : class >true : true // @ts-ignore /** @type {bool} */const m = true; ->m : true +>m : bool >true : true // @ts-ignore /** @type {int} */const n = true; ->n : true +>n : int >true : true // @ts-ignore /** @type {float} */const o = true; ->o : true +>o : float >true : true // @ts-ignore /** @type {integer} */const p = true; ->p : true +>p : integer >true : true // or, in the case of `event` likely erroneously refers to the type of the global Event object /** @type {event} */const q = undefined; ->q : undefined +>q : event >undefined : undefined diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.errors.txt new file mode 100644 index 0000000000..d4557d9119 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.errors.txt @@ -0,0 +1,17 @@ +file.js(2,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). +file.js(6,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). + + +==== file.js (2 errors) ==== + /** + * @param {Array} x + ~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). + */ + function x(x) {} + /** + * @param {Promise} x + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + */ + function y(x) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.errors.txt new file mode 100644 index 0000000000..809ccf10b2 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.errors.txt @@ -0,0 +1,38 @@ +file.js(2,13): error TS2314: Generic type 'T[]' requires 1 type argument(s). +file.js(12,14): error TS2314: Generic type 'T[]' requires 1 type argument(s). +file.js(12,19): error TS8020: JSDoc types can only be used inside documentation comments. +file.js(12,20): error TS1099: Type argument list cannot be empty. +file.js(18,14): error TS2314: Generic type 'Promise' requires 1 type argument(s). + + +==== file.js (5 errors) ==== + /** + * @param {Array=} y desc + ~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). + */ + function x(y) { } + + // @ts-ignore + /** @param {function (Array)} func Invoked + */ + function y(func) { return; } + + /** + * @return {(Array.<> | null)} list of devices + ~~~~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + ~~ +!!! error TS1099: Type argument list cannot be empty. + */ + function z() { return null ;} + + /** + * + * @return {?Promise} A promise + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + */ + function w() { return null; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.types index 7f6d87d961..d93c648b87 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.types @@ -5,7 +5,7 @@ * @param {Array=} y desc */ function x(y) { } ->x : (y: any) => void +>x : (y?: any) => void >y : any // @ts-ignore diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt new file mode 100644 index 0000000000..30a9f935a7 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt @@ -0,0 +1,19 @@ +index.js(9,11): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + +==== index.js (1 errors) ==== + /** + * @module A + */ + class A {} + + + /** + * Target element + * @type {module:A} + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ + export let el = null; + + export default A; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.types index 84dd46ae3a..80523f88f9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.types @@ -13,7 +13,7 @@ class A {} * @type {module:A} */ export let el = null; ->el : any +>el : module export default A; >A : A diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt new file mode 100644 index 0000000000..6874eb5fa6 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt @@ -0,0 +1,33 @@ +file.js(7,26): error TS8020: JSDoc types can only be used inside documentation comments. +file.js(20,26): error TS8020: JSDoc types can only be used inside documentation comments. + + +==== file.js (2 errors) ==== + class X { + /** + * Cancels the request, sending a cancellation to the other party + * @param {Object} error __auto_generated__ + * @param {string?} error.reason the error reason to send the cancellation with + * @param {string?} error.code the error code to send the cancellation with + * @returns {Promise.<*>} resolves when the event has been sent. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + */ + async cancel({reason, code}) {} + } + + class Y { + /** + * Cancels the request, sending a cancellation to the other party + * @param {Object} error __auto_generated__ + * @param {string?} error.reason the error reason to send the cancellation with + * @param {Object} error.suberr + * @param {string?} error.suberr.reason the error reason to send the cancellation with + * @param {string?} error.suberr.code the error code to send the cancellation with + * @returns {Promise.<*>} resolves when the event has been sent. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + */ + async cancel({reason, suberr}) {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.types index 1d4d04d185..5a1dd2d22e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.types @@ -12,7 +12,7 @@ class X { * @returns {Promise.<*>} resolves when the event has been sent. */ async cancel({reason, code}) {} ->cancel : (__0: { code: any; reason: any; }) => Promise +>cancel : (__0: { code: any; reason: any; }) => Promise >reason : any >code : any } @@ -30,7 +30,7 @@ class Y { * @returns {Promise.<*>} resolves when the event has been sent. */ async cancel({reason, suberr}) {} ->cancel : (__0: { reason: any; suberr: any; }) => Promise +>cancel : (__0: { reason: any; suberr: any; }) => Promise >reason : any >suberr : any } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.types index 03d234dfe0..4e6a7ad504 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.types @@ -12,7 +12,7 @@ * @returns {number} */ function foo({ a, b, c }) { ->foo : (__0: { a: any; b: any; c: any; }) => any +>foo : (__0: { a: any; b: any; c: any; }) => number >a : any >b : any >c : any diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.types index 2118e4d8d4..e2b0f903d3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.types @@ -12,7 +12,7 @@ * @returns {number} */ function foo({ a, b, c }) { ->foo : (__0: { a: any; b: any; c: any; }) => any +>foo : (__0: { a: any; b: any; c: any; }) => number >a : any >b : any >c : any diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt index f19f51ad05..df03f90c0b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt @@ -1,4 +1,5 @@ base.js(11,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +file.js(1,22): error TS2306: File 'base.js' is not a module. ==== base.js (1 errors) ==== @@ -16,8 +17,10 @@ base.js(11,1): error TS2580: Cannot find name 'module'. Do you need to install t ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== file.js (0 errors) ==== +==== file.js (1 errors) ==== /** @typedef {import('./base')} BaseFactory */ + ~~~~~~~~ +!!! error TS2306: File 'base.js' is not a module. /** * @callback BaseFactoryFactory * @param {import('./base')} factory diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt index ad61ed984b..73a374df92 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt @@ -1,4 +1,5 @@ base.js(11,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +file.js(1,29): error TS2306: File 'base.js' is not a module. ==== base.js (1 errors) ==== @@ -16,8 +17,10 @@ base.js(11,1): error TS2580: Cannot find name 'module'. Do you need to install t ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== file.js (0 errors) ==== +==== file.js (1 errors) ==== /** @typedef {typeof import('./base')} BaseFactory */ + ~~~~~~~~ +!!! error TS2306: File 'base.js' is not a module. /** * diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.symbols index 1e05a5747d..189fc58e87 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.symbols @@ -70,9 +70,9 @@ const TabbedShowLayout = () => { }; TabbedShowLayout.defaultProps = { ->TabbedShowLayout.defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents2.jsx, 10, 2)) +>TabbedShowLayout.defaultProps : Symbol(defaultProps, Decl(react16.d.ts, 410, 46)) >TabbedShowLayout : Symbol(TabbedShowLayout, Decl(jsDeclarationsReactComponents2.jsx, 4, 5)) ->defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents2.jsx, 10, 2)) +>defaultProps : Symbol(defaultProps, Decl(react16.d.ts, 410, 46)) tabs: "default value" >tabs : Symbol(tabs, Decl(jsDeclarationsReactComponents2.jsx, 12, 33)) @@ -106,9 +106,9 @@ const TabbedShowLayout = () => { }; TabbedShowLayout.defaultProps = { ->TabbedShowLayout.defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 10, 2)) +>TabbedShowLayout.defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 2, 11)) >TabbedShowLayout : Symbol(TabbedShowLayout, Decl(jsDeclarationsReactComponents3.jsx, 4, 5)) ->defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 10, 2)) +>defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 2, 11)) tabs: "default value" >tabs : Symbol(tabs, Decl(jsDeclarationsReactComponents3.jsx, 12, 33)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.symbols.diff index 6561864aa2..4c285386c6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.symbols.diff @@ -79,9 +79,9 @@ ->TabbedShowLayout.defaultProps : Symbol(React.StatelessComponent.defaultProps, Decl(react16.d.ts, 410, 46)) ->TabbedShowLayout : Symbol(TabbedShowLayout, Decl(jsDeclarationsReactComponents2.jsx, 4, 5), Decl(jsDeclarationsReactComponents2.jsx, 10, 2)) ->defaultProps : Symbol(React.StatelessComponent.defaultProps, Decl(react16.d.ts, 410, 46)) -+>TabbedShowLayout.defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents2.jsx, 10, 2)) ++>TabbedShowLayout.defaultProps : Symbol(defaultProps, Decl(react16.d.ts, 410, 46)) +>TabbedShowLayout : Symbol(TabbedShowLayout, Decl(jsDeclarationsReactComponents2.jsx, 4, 5)) -+>defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents2.jsx, 10, 2)) ++>defaultProps : Symbol(defaultProps, Decl(react16.d.ts, 410, 46)) tabs: "default value" >tabs : Symbol(tabs, Decl(jsDeclarationsReactComponents2.jsx, 12, 33)) @@ -117,15 +117,12 @@ }; TabbedShowLayout.defaultProps = { -->TabbedShowLayout.defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 2, 11)) + >TabbedShowLayout.defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 2, 11)) ->TabbedShowLayout : Symbol(TabbedShowLayout, Decl(jsDeclarationsReactComponents3.jsx, 4, 5), Decl(jsDeclarationsReactComponents3.jsx, 10, 2)) -->defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 2, 11)) -+>TabbedShowLayout.defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 10, 2)) +>TabbedShowLayout : Symbol(TabbedShowLayout, Decl(jsDeclarationsReactComponents3.jsx, 4, 5)) -+>defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 10, 2)) + >defaultProps : Symbol(defaultProps, Decl(jsDeclarationsReactComponents3.jsx, 2, 11)) tabs: "default value" - >tabs : Symbol(tabs, Decl(jsDeclarationsReactComponents3.jsx, 12, 33)) @@= skipped -26, +26 lines =@@ }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.types index 3f293ebdcb..aa5470a481 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.types @@ -62,7 +62,7 @@ import React from "react"; * @type {React.SFC} */ const TabbedShowLayout = () => { ->TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } +>TabbedShowLayout : SFC<{}> >() => { return (

ok
);} : { (): Element; defaultProps: { tabs: string; }; } return ( @@ -83,9 +83,9 @@ const TabbedShowLayout = () => { TabbedShowLayout.defaultProps = { >TabbedShowLayout.defaultProps = { tabs: "default value"} : { tabs: string; } ->TabbedShowLayout.defaultProps : { tabs: string; } ->TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } ->defaultProps : { tabs: string; } +>TabbedShowLayout.defaultProps : Partial<{}> | undefined +>TabbedShowLayout : SFC<{}> +>defaultProps : Partial<{}> | undefined >{ tabs: "default value"} : { tabs: string; } tabs: "default value" @@ -95,7 +95,7 @@ TabbedShowLayout.defaultProps = { }; export default TabbedShowLayout; ->TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } +>TabbedShowLayout : SFC<{}> === jsDeclarationsReactComponents3.jsx === import React from "react"; @@ -105,7 +105,7 @@ import React from "react"; * @type {{defaultProps: {tabs: string}} & ((props?: {elem: string}) => JSX.Element)} */ const TabbedShowLayout = () => { ->TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } +>TabbedShowLayout : { defaultProps: { tabs: string; }; } & ((props?: { elem: string; } | undefined) => Element) >() => { return (
ok
);} : { (): Element; defaultProps: { tabs: string; }; } return ( @@ -127,7 +127,7 @@ const TabbedShowLayout = () => { TabbedShowLayout.defaultProps = { >TabbedShowLayout.defaultProps = { tabs: "default value"} : { tabs: string; } >TabbedShowLayout.defaultProps : { tabs: string; } ->TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } +>TabbedShowLayout : { defaultProps: { tabs: string; }; } & ((props?: { elem: string; } | undefined) => Element) >defaultProps : { tabs: string; } >{ tabs: "default value"} : { tabs: string; } @@ -138,7 +138,7 @@ TabbedShowLayout.defaultProps = { }; export default TabbedShowLayout; ->TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } +>TabbedShowLayout : { defaultProps: { tabs: string; }; } & ((props?: { elem: string; } | undefined) => Element) === jsDeclarationsReactComponents4.jsx === import React from "react"; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt new file mode 100644 index 0000000000..42bdb51664 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt @@ -0,0 +1,41 @@ +index.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +index.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +index.js(22,12): error TS2315: Type 'Object' is not generic. +index.js(22,18): error TS8020: JSDoc types can only be used inside documentation comments. + + +==== index.js (4 errors) ==== + /** @type {?} */ + export const a = null; + + /** @type {*} */ + export const b = null; + + /** @type {string?} */ + export const c = null; + + /** @type {string=} */ + export const d = null; + + /** @type {string!} */ + export const e = null; + + /** @type {function(string, number): object} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + export const f = null; + + /** @type {function(new: object, string, number)} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + export const g = null; + + /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + export const h = null; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types index ebe72681c5..9ec66ea875 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types @@ -11,23 +11,23 @@ export const b = null; /** @type {string?} */ export const c = null; ->c : any +>c : string /** @type {string=} */ export const d = null; ->d : any +>d : string /** @type {string!} */ export const e = null; ->e : any +>e : string /** @type {function(string, number): object} */ export const f = null; ->f : any +>f : function /** @type {function(new: object, string, number)} */ export const g = null; ->g : any +>g : function /** @type {Object.} */ export const h = null; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt index 53d61cac2b..e605616373 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt @@ -1,14 +1,8 @@ -index.js(83,9): error TS7032: Property 'p1' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -index.js(83,12): error TS7006: Parameter 'value' implicitly has an 'any' type. -index.js(88,9): error TS7032: Property 'p2' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -index.js(88,12): error TS7006: Parameter 'value' implicitly has an 'any' type. -index.js(93,9): error TS7032: Property 'p3' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -index.js(93,12): error TS7006: Parameter 'value' implicitly has an 'any' type. -index.js(98,9): error TS7032: Property 'p4' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -index.js(98,12): error TS7006: Parameter 'value' implicitly has an 'any' type. +index.js(45,17): error TS1051: A 'set' accessor cannot have an optional parameter. +index.js(83,17): error TS1051: A 'set' accessor cannot have an optional parameter. -==== index.js (8 errors) ==== +==== index.js (2 errors) ==== class С1 { /** @type {string=} */ p1 = undefined; @@ -54,6 +48,8 @@ index.js(98,12): error TS7006: Parameter 'value' implicitly has an 'any' type. /** @param {string=} value */ set p1(value) { + +!!! error TS1051: A 'set' accessor cannot have an optional parameter. this.p1 = value; } @@ -92,37 +88,23 @@ index.js(98,12): error TS7006: Parameter 'value' implicitly has an 'any' type. class С4 { /** @param {string=} value */ set p1(value) { - ~~ -!!! error TS7032: Property 'p1' implicitly has type 'any', because its set accessor lacks a parameter type annotation. - ~~~~~ -!!! error TS7006: Parameter 'value' implicitly has an 'any' type. + +!!! error TS1051: A 'set' accessor cannot have an optional parameter. this.p1 = value; } /** @param {string | undefined} value */ set p2(value) { - ~~ -!!! error TS7032: Property 'p2' implicitly has type 'any', because its set accessor lacks a parameter type annotation. - ~~~~~ -!!! error TS7006: Parameter 'value' implicitly has an 'any' type. this.p2 = value; } /** @param {?string} value */ set p3(value) { - ~~ -!!! error TS7032: Property 'p3' implicitly has type 'any', because its set accessor lacks a parameter type annotation. - ~~~~~ -!!! error TS7006: Parameter 'value' implicitly has an 'any' type. this.p3 = value; } /** @param {string | null} value */ set p4(value) { - ~~ -!!! error TS7032: Property 'p4' implicitly has type 'any', because its set accessor lacks a parameter type annotation. - ~~~~~ -!!! error TS7006: Parameter 'value' implicitly has an 'any' type. this.p4 = value; } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.types index 1e04c16e23..ba682b2010 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.types @@ -6,21 +6,21 @@ class С1 { /** @type {string=} */ p1 = undefined; ->p1 : undefined +>p1 : string | undefined >undefined : undefined /** @type {string | undefined} */ p2 = undefined; ->p2 : undefined +>p2 : string | undefined >undefined : undefined /** @type {?string} */ p3 = null; ->p3 : null +>p3 : string | null /** @type {string | null} */ p4 = null; ->p4 : null +>p4 : string | null } class С2 { @@ -63,7 +63,7 @@ class С3 { /** @type {string=} */ get p1() { ->p1 : undefined +>p1 : string | undefined return undefined; >undefined : undefined @@ -71,20 +71,20 @@ class С3 { /** @param {string=} value */ set p1(value) { ->p1 : undefined ->value : undefined +>p1 : string | undefined +>value : string | undefined this.p1 = value; ->this.p1 = value : undefined ->this.p1 : undefined +>this.p1 = value : string | undefined +>this.p1 : string | undefined >this : this ->p1 : undefined ->value : undefined +>p1 : string | undefined +>value : string | undefined } /** @type {string | undefined} */ get p2() { ->p2 : undefined +>p2 : string | undefined return undefined; >undefined : undefined @@ -92,55 +92,55 @@ class С3 { /** @param {string | undefined} value */ set p2(value) { ->p2 : undefined ->value : undefined +>p2 : string | undefined +>value : string | undefined this.p2 = value; ->this.p2 = value : undefined ->this.p2 : undefined +>this.p2 = value : string | undefined +>this.p2 : string | undefined >this : this ->p2 : undefined ->value : undefined +>p2 : string | undefined +>value : string | undefined } /** @type {?string} */ get p3() { ->p3 : null +>p3 : string | null return null; } /** @param {?string} value */ set p3(value) { ->p3 : null ->value : null +>p3 : string | null +>value : string | null this.p3 = value; ->this.p3 = value : null ->this.p3 : null +>this.p3 = value : string | null +>this.p3 : string | null >this : this ->p3 : null ->value : null +>p3 : string | null +>value : string | null } /** @type {string | null} */ get p4() { ->p4 : null +>p4 : string | null return null; } /** @param {string | null} value */ set p4(value) { ->p4 : null ->value : null +>p4 : string | null +>value : string | null this.p4 = value; ->this.p4 = value : null ->this.p4 : null +>this.p4 = value : string | null +>this.p4 : string | null >this : this ->p4 : null ->value : null +>p4 : string | null +>value : string | null } } @@ -150,54 +150,54 @@ class С4 { /** @param {string=} value */ set p1(value) { ->p1 : any ->value : any +>p1 : string | undefined +>value : string | undefined this.p1 = value; ->this.p1 = value : any ->this.p1 : any +>this.p1 = value : string | undefined +>this.p1 : string | undefined >this : this ->p1 : any ->value : any +>p1 : string | undefined +>value : string | undefined } /** @param {string | undefined} value */ set p2(value) { ->p2 : any ->value : any +>p2 : string | undefined +>value : string | undefined this.p2 = value; ->this.p2 = value : any ->this.p2 : any +>this.p2 = value : string | undefined +>this.p2 : string | undefined >this : this ->p2 : any ->value : any +>p2 : string | undefined +>value : string | undefined } /** @param {?string} value */ set p3(value) { ->p3 : any ->value : any +>p3 : string | null +>value : string | null this.p3 = value; ->this.p3 = value : any ->this.p3 : any +>this.p3 = value : string | null +>this.p3 : string | null >this : this ->p3 : any ->value : any +>p3 : string | null +>value : string | null } /** @param {string | null} value */ set p4(value) { ->p4 : any ->value : any +>p4 : string | null +>value : string | null this.p4 = value; ->this.p4 = value : any ->this.p4 : any +>this.p4 = value : string | null +>this.p4 : string | null >this : this ->p4 : any ->value : any +>p4 : string | null +>value : string | null } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.types index 9c3811023f..d3328c449a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.types @@ -9,8 +9,8 @@ export class Super { * @param {string} secondArg */ constructor(firstArg, secondArg) { } ->firstArg : any ->secondArg : any +>firstArg : string +>secondArg : string } export class Sub extends Super { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.types index d3486e1930..b81b70e809 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.types @@ -38,15 +38,15 @@ export {}; // flag file as module * @returns {SomeType} */ function doTheThing(x) { ->doTheThing : (x: any) => { x: string; } ->x : any +>doTheThing : (x: number) => SomeType +>x : number return {x: ""+x}; >{x: ""+x} : { x: string; } >x : string >""+x : string >"" : "" ->x : any +>x : number } class ExportedThing { >ExportedThing : ExportedThing @@ -56,14 +56,14 @@ class ExportedThing { >"ok" : "ok" } module.exports = { ->module.exports = { doTheThing, ExportedThing,} : { doTheThing: (x: any) => { x: string; }; ExportedThing: typeof ExportedThing; } +>module.exports = { doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } >module.exports : any >module : any >exports : any ->{ doTheThing, ExportedThing,} : { doTheThing: (x: any) => { x: string; }; ExportedThing: typeof ExportedThing; } +>{ doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } doTheThing, ->doTheThing : (x: any) => { x: string; } +>doTheThing : (x: number) => SomeType ExportedThing, >ExportedThing : typeof ExportedThing diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.types index 3c99b2bc50..99b586db29 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.types @@ -14,13 +14,13 @@ export = items; === index.js === /** @type {typeof import("/some-mod")} */ const items = []; ->items : any[] +>items : Item[] >[] : undefined[] module.exports = items; ->module.exports = items : any[] +>module.exports = items : Item[] >module.exports : any >module : any >exports : any ->items : any[] +>items : Item[] diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt index c077de5eb6..0add975d32 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt @@ -1,4 +1,5 @@ conn.js(11,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +usage.js(2,14): error TS1340: Module './conn' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./conn')'? usage.js(10,14): error TS2339: Property 'connItem' does not exist on type 'Wrap'. usage.js(12,14): error TS2339: Property 'another' does not exist on type 'Wrap'. usage.js(16,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -19,9 +20,11 @@ usage.js(16,1): error TS2580: Cannot find name 'module'. Do you need to install ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== usage.js (3 errors) ==== +==== usage.js (4 errors) ==== /** * @typedef {import("./conn")} Conn + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './conn' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./conn')'? */ class Wrap { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt index a662678d78..48fc6a2824 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt @@ -1,31 +1,26 @@ -LazySet.js(5,7): error TS2451: Cannot redeclare block-scoped variable 'LazySet'. LazySet.js(13,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -index.js(1,7): error TS2451: Cannot redeclare block-scoped variable 'LazySet'. index.js(1,17): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +index.js(3,12): error TS2749: 'LazySet' refers to a value, but is being used as a type here. Did you mean 'typeof LazySet'? ==== index.js (2 errors) ==== const LazySet = require("./LazySet"); - ~~~~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'LazySet'. -!!! related TS6203 LazySet.js:5:7: 'LazySet' was also declared here. ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @type {LazySet} */ + ~~~~~~~ +!!! error TS2749: 'LazySet' refers to a value, but is being used as a type here. Did you mean 'typeof LazySet'? const stringSet = undefined; stringSet.addAll(stringSet); -==== LazySet.js (2 errors) ==== +==== LazySet.js (1 errors) ==== // Comment out this JSDoc, and note that the errors index.js go away. /** * @typedef {Object} SomeObject */ class LazySet { - ~~~~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'LazySet'. -!!! related TS6203 index.js:1:7: 'LazySet' was also declared here. /** * @param {LazySet} iterable */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.symbols index e450a3836b..b792c9fb28 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.symbols @@ -37,5 +37,5 @@ class LazySet { } module.exports = LazySet; ->LazySet : Symbol(LazySet, Decl(index.js, 0, 5)) +>LazySet : Symbol(LazySet, Decl(LazySet.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.symbols.diff index 0fd3b215f7..f0002b54f6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.symbols.diff @@ -41,6 +41,5 @@ ->module.exports : Symbol(module.exports, Decl(LazySet.js, 0, 0)) ->module : Symbol(export=, Decl(LazySet.js, 10, 1)) ->exports : Symbol(export=, Decl(LazySet.js, 10, 1)) -->LazySet : Symbol(LazySet, Decl(LazySet.js, 0, 0)) -+>LazySet : Symbol(LazySet, Decl(index.js, 0, 5)) + >LazySet : Symbol(LazySet, Decl(LazySet.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.types index 0c30209717..d00f82d698 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.types @@ -9,15 +9,15 @@ const LazySet = require("./LazySet"); /** @type {LazySet} */ const stringSet = undefined; ->stringSet : any +>stringSet : LazySet >undefined : undefined stringSet.addAll(stringSet); >stringSet.addAll(stringSet) : any >stringSet.addAll : any ->stringSet : any +>stringSet : LazySet >addAll : any ->stringSet : any +>stringSet : LazySet === LazySet.js === @@ -32,8 +32,8 @@ class LazySet { * @param {LazySet} iterable */ addAll(iterable) {} ->addAll : (iterable: any) => void ->iterable : any +>addAll : (iterable: LazySet) => void +>iterable : LazySet [Symbol.iterator]() {} >[Symbol.iterator] : () => void @@ -43,9 +43,9 @@ class LazySet { } module.exports = LazySet; ->module.exports = LazySet : any +>module.exports = LazySet : typeof LazySet >module.exports : any >module : any >exports : any ->LazySet : any +>LazySet : typeof LazySet diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.types index 76beedfbe5..f0d37471f2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.types @@ -16,23 +16,23 @@ let id = 0 * @returns {Promise} */ const send = handlers => new Promise((resolve, reject) => { ->send : (handlers: any) => Promise ->handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : (handlers: any) => Promise ->handlers : any ->new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : Promise +>send : (handlers: { [id: string]: [Function, Function]; }) => Promise +>handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : (handlers: { [id: string]: [Function, Function]; }) => Promise +>handlers : { [id: string]: [Function, Function]; } +>new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : Promise >Promise : PromiseConstructor ->(resolve, reject) => { handlers[++id] = [resolve, reject]} : (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void ->resolve : (value: unknown) => void +>(resolve, reject) => { handlers[++id] = [resolve, reject]} : (resolve: (value: any) => void, reject: (reason?: any) => void) => void +>resolve : (value: any) => void >reject : (reason?: any) => void handlers[++id] = [resolve, reject] ->handlers[++id] = [resolve, reject] : ((value: unknown) => void)[] ->handlers[++id] : any ->handlers : any +>handlers[++id] = [resolve, reject] : [(value: any) => void, (reason?: any) => void] +>handlers[++id] : [Function, Function] +>handlers : { [id: string]: [Function, Function]; } >++id : number >id : number ->[resolve, reject] : ((value: unknown) => void)[] ->resolve : (value: unknown) => void +>[resolve, reject] : [(value: any) => void, (reason?: any) => void] +>resolve : (value: any) => void >reject : (reason?: any) => void }) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt index 871a4cb6f7..26e7eee074 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt @@ -1,13 +1,16 @@ index.js(1,39): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +index.js(3,22): error TS2307: Cannot find module './module.js' or its corresponding type declarations. index.js(21,1): 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 (3 errors) ==== const {taskGroups, taskNameToGroup} = require('./module.js'); ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @typedef {import('./module.js').TaskGroup} TaskGroup */ + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './module.js' or its corresponding type declarations. /** * @typedef TaskNode diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types index f6ff1ad6bf..e63e30c6b2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types @@ -27,7 +27,7 @@ class MainThreadTasks { */ constructor(x, y){} >x : any ->y : any +>y : TaskNode } module.exports = MainThreadTasks; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt new file mode 100644 index 0000000000..4903c8be4b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt @@ -0,0 +1,23 @@ +b.js(2,28): error TS2694: Namespace '"a"' has no exported member 'WithSymbol'. +b.js(3,26): error TS2694: Namespace '"a"' has no exported member 'WithSymbol'. + + +==== a.js (0 errors) ==== + export const kSymbol = Symbol("my-symbol"); + + /** + * @typedef {{[kSymbol]: true}} WithSymbol + */ +==== b.js (2 errors) ==== + /** + * @returns {import('./a').WithSymbol} + ~~~~~~~~~~ +!!! error TS2694: Namespace '"a"' has no exported member 'WithSymbol'. + * @param {import('./a').WithSymbol} value + ~~~~~~~~~~ +!!! error TS2694: Namespace '"a"' has no exported member 'WithSymbol'. + */ + export function b(value) { + return value; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.types b/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.types index 737e775ad2..5591a1a997 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.types @@ -8,9 +8,9 @@ if (false) { * @param {string} s */ const x = function (s) { ->x : (s: any) => void ->function (s) { } : (s: any) => void ->s : any +>x : (s: string) => void +>function (s) { } : (s: string) => void +>s : string }; } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt index e67b0151cb..38388986e6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt @@ -1,7 +1,15 @@ +foo.js(20,54): error TS2339: Property 'foo' does not exist on type 'unknown'. +foo.js(21,54): error TS2339: Property 'foo' does not exist on type 'unknown'. +foo.js(22,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. +foo.js(23,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. foo.js(35,7): error TS2492: Cannot redeclare identifier 'err' in catch clause. +foo.js(46,45): error TS2339: Property 'x' does not exist on type '{}'. +foo.js(47,45): error TS2339: Property 'x' does not exist on type '{}'. +foo.js(48,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. +foo.js(49,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. -==== foo.js (1 errors) ==== +==== foo.js (9 errors) ==== /** * @typedef {any} Any */ @@ -22,9 +30,17 @@ foo.js(35,7): error TS2492: Cannot redeclare identifier 'err' in catch clause. try { } catch (/** @type {unknown} */ err) { console.log(err); } // should be OK try { } catch (/** @type {Unknown} */ err) { console.log(err); } // should be OK try { } catch (/** @type {unknown} */ err) { err.foo; } // error in the body + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'unknown'. try { } catch (/** @type {Unknown} */ err) { err.foo; } // error in the body + ~~~ +!!! error TS2339: Property 'foo' does not exist on type 'unknown'. try { } catch (/** @type {Error} */ err) { } // error in the type + ~~~~~ +!!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. try { } catch (/** @type {object} */ err) { } // error in the type + ~~~~~~ +!!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. try { console.log(); } // @ts-ignore @@ -50,8 +66,16 @@ foo.js(35,7): error TS2492: Cannot redeclare identifier 'err' in catch clause. try { } catch (/** @type {any} */ { x }) { x.foo; } // should be OK try { } catch (/** @type {Any} */ { x }) { x.foo;} // should be OK try { } catch (/** @type {unknown} */ { x }) { console.log(x); } // error in the destructure + ~ +!!! error TS2339: Property 'x' does not exist on type '{}'. try { } catch (/** @type {Unknown} */ { x }) { console.log(x); } // error in the destructure + ~ +!!! error TS2339: Property 'x' does not exist on type '{}'. try { } catch (/** @type {Error} */ { x }) { } // error in the type + ~~~~~ +!!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. try { } catch (/** @type {object} */ { x }) { } // error in the type + ~~~~~~ +!!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.types b/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.types index 70f5280760..242800d865 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.types @@ -22,10 +22,10 @@ function fn() { >err : any try { } catch (/** @type {unknown} */ err) { } // should be OK ->err : any +>err : unknown try { } catch (/** @type {Unknown} */ err) { } // should be OK ->err : any +>err : unknown try { } catch (err) { err.foo; } // should be OK >err : any @@ -46,31 +46,31 @@ function fn() { >foo : any try { } catch (/** @type {unknown} */ err) { console.log(err); } // should be OK ->err : any +>err : unknown >console.log(err) : void >console.log : (...data: any[]) => void >console : Console >log : (...data: any[]) => void ->err : any +>err : unknown try { } catch (/** @type {Unknown} */ err) { console.log(err); } // should be OK ->err : any +>err : unknown >console.log(err) : void >console.log : (...data: any[]) => void >console : Console >log : (...data: any[]) => void ->err : any +>err : unknown try { } catch (/** @type {unknown} */ err) { err.foo; } // error in the body ->err : any +>err : unknown >err.foo : any ->err : any +>err : unknown >foo : any try { } catch (/** @type {Unknown} */ err) { err.foo; } // error in the body ->err : any +>err : unknown >err.foo : any ->err : any +>err : unknown >foo : any try { } catch (/** @type {Error} */ err) { } // error in the type @@ -107,7 +107,7 @@ function fn() { /** @type {string} */ let err; ->err : any +>err : string } try { } catch (err) { @@ -115,7 +115,7 @@ function fn() { /** @type {boolean} */ var err; ->err : any +>err : boolean } try { } catch ({ x }) { } // should be OK diff --git a/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt index fe2d62bae0..0ecef16650 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt @@ -1,4 +1,4 @@ -jsdocConstructorFunctionTypeReference.js(10,36): error TS7006: Parameter 'state' implicitly has an 'any' type. +jsdocConstructorFunctionTypeReference.js(8,12): error TS2749: 'Validator' refers to a value, but is being used as a type here. Did you mean 'typeof Validator'? ==== jsdocConstructorFunctionTypeReference.js (1 errors) ==== @@ -10,10 +10,10 @@ jsdocConstructorFunctionTypeReference.js(10,36): error TS7006: Parameter 'state' /** * @param {Validator} state + ~~~~~~~~~ +!!! error TS2749: 'Validator' refers to a value, but is being used as a type here. Did you mean 'typeof Validator'? */ var validateRegExpFlags = function(state) { - ~~~~~ -!!! error TS7006: Parameter 'state' implicitly has an 'any' type. return state.flags }; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.types b/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.types index 08173d3720..71e17e4733 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.types @@ -28,13 +28,13 @@ Validator.prototype.num = 12 * @param {Validator} state */ var validateRegExpFlags = function(state) { ->validateRegExpFlags : (state: any) => any ->function(state) { return state.flags} : (state: any) => any ->state : any +>validateRegExpFlags : (state: Validator) => any +>function(state) { return state.flags} : (state: Validator) => any +>state : Validator return state.flags >state.flags : any ->state : any +>state : Validator >flags : any }; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt index bbc81a1df4..47d91d1ee9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt @@ -1,20 +1,24 @@ +functions.js(3,13): error TS2552: Cannot find name 'function'. Did you mean 'Function'? functions.js(5,14): error TS7006: Parameter 'c' implicitly has an 'any' type. functions.js(9,23): error TS7006: Parameter 'n' implicitly has an 'any' type. +functions.js(13,13): error TS2552: Cannot find name 'function'. Did you mean 'Function'? functions.js(15,14): error TS7006: Parameter 'c' implicitly has an 'any' type. -functions.js(21,17): error TS7006: Parameter 'n' implicitly has an 'any' type. functions.js(22,14): error TS2339: Property 'length' does not exist on type 'C'. +functions.js(30,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? functions.js(31,19): error TS7006: Parameter 'ab' implicitly has an 'any' type. functions.js(31,23): error TS7006: Parameter 'onetwo' implicitly has an 'any' type. -functions.js(38,12): error TS7006: Parameter 'n' implicitly has an 'any' type. +functions.js(49,13): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? functions.js(51,26): error TS7006: Parameter 'dref' implicitly has an 'any' type. -functions.js(60,18): error TS7006: Parameter 'n' implicitly has an 'any' type. functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. -==== functions.js (11 errors) ==== +==== functions.js (12 errors) ==== /** * @param {function(this: string, number): number} c is just passing on through * @return {function(this: string, number): number} + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. */ function id1(c) { ~ @@ -29,6 +33,9 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ /** * @param {function(new: { length: number }, number): number} c is just passing on through * @return {function(new: { length: number }, number): number} + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. */ function id2(c) { ~ @@ -39,8 +46,6 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ class C { /** @param {number} n */ constructor(n) { - ~ -!!! error TS7006: Parameter 'n' implicitly has an 'any' type. this.length = n; ~~~~~~ !!! error TS2339: Property 'length' does not exist on type 'C'. @@ -52,6 +57,9 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ z.length; /** @type {function ("a" | "b", 1 | 2): 3 | 4} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. var f = function (ab, onetwo) { return ab === "a" ? 3 : 4; } ~~ !!! error TS7006: Parameter 'ab' implicitly has an 'any' type. @@ -64,8 +72,6 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ * @param {number} n */ function D(n) { - ~ -!!! error TS7006: Parameter 'n' implicitly has an 'any' type. this.length = n; } @@ -77,6 +83,8 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ /** * @param {function(new: D, number)} dref * @return {D} + ~ +!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? */ var construct = function(dref) { return new dref(33); } ~~~~ @@ -90,8 +98,6 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ * @param {number} n */ var E = function(n) { - ~ -!!! error TS7006: Parameter 'n' implicitly has an 'any' type. this.not_length_on_purpose = n; }; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.types b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.types index ef73f9235a..c58ccc8fdc 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.types @@ -6,7 +6,7 @@ * @return {function(this: string, number): number} */ function id1(c) { ->id1 : (c: any) => any +>id1 : (c: any) => function >c : any return c @@ -14,9 +14,9 @@ function id1(c) { } var x = id1(function (n) { return this.length + n }); ->x : any ->id1(function (n) { return this.length + n }) : any ->id1 : (c: any) => any +>x : function +>id1(function (n) { return this.length + n }) : function +>id1 : (c: any) => function >function (n) { return this.length + n } : (n: any) => any >n : any >this.length + n : any @@ -30,7 +30,7 @@ var x = id1(function (n) { return this.length + n }); * @return {function(new: { length: number }, number): number} */ function id2(c) { ->id2 : (c: any) => any +>id2 : (c: any) => function >c : any return c @@ -42,27 +42,27 @@ class C { /** @param {number} n */ constructor(n) { ->n : any +>n : number this.length = n; ->this.length = n : any +>this.length = n : number >this.length : any >this : this >length : any ->n : any +>n : number } } var y = id2(C); ->y : any ->id2(C) : any ->id2 : (c: any) => any +>y : function +>id2(C) : function +>id2 : (c: any) => function >C : typeof C var z = new y(12); >z : any >new y(12) : any ->y : any +>y : function >12 : 12 z.length; @@ -72,7 +72,7 @@ z.length; /** @type {function ("a" | "b", 1 | 2): 3 | 4} */ var f = function (ab, onetwo) { return ab === "a" ? 3 : 4; } ->f : (ab: any, onetwo: any) => 3 | 4 +>f : function >function (ab, onetwo) { return ab === "a" ? 3 : 4; } : (ab: any, onetwo: any) => 3 | 4 >ab : any >onetwo : any @@ -89,27 +89,27 @@ var f = function (ab, onetwo) { return ab === "a" ? 3 : 4; } * @param {number} n */ function D(n) { ->D : (n: any) => void ->n : any +>D : (n: number) => void +>n : number this.length = n; ->this.length = n : any +>this.length = n : number >this.length : any >this : any >length : any ->n : any +>n : number } var y2 = id2(D); ->y2 : any ->id2(D) : any ->id2 : (c: any) => any ->D : (n: any) => void +>y2 : function +>id2(D) : function +>id2 : (c: any) => function +>D : (n: number) => void var z2 = new y2(33); >z2 : any >new y2(33) : any ->y2 : any +>y2 : function >33 : 33 z2.length; @@ -123,22 +123,22 @@ z2.length; * @return {D} */ var construct = function(dref) { return new dref(33); } ->construct : (dref: any) => any ->function(dref) { return new dref(33); } : (dref: any) => any +>construct : (dref: any) => D +>function(dref) { return new dref(33); } : (dref: any) => D >dref : any >new dref(33) : any >dref : any >33 : 33 var z3 = construct(D); ->z3 : any ->construct(D) : any ->construct : (dref: any) => any ->D : (n: any) => void +>z3 : D +>construct(D) : D +>construct : (dref: any) => D +>D : (n: number) => void z3.length; >z3.length : any ->z3 : any +>z3 : D >length : any @@ -147,25 +147,25 @@ z3.length; * @param {number} n */ var E = function(n) { ->E : (n: any) => void ->function(n) { this.not_length_on_purpose = n;} : (n: any) => void ->n : any +>E : (n: number) => void +>function(n) { this.not_length_on_purpose = n;} : (n: number) => void +>n : number this.not_length_on_purpose = n; ->this.not_length_on_purpose = n : any +>this.not_length_on_purpose = n : number >this.not_length_on_purpose : any >this : any >not_length_on_purpose : any ->n : any +>n : number }; var y3 = id2(E); ->y3 : any ->id2(E) : any ->id2 : (c: any) => any ->E : (n: any) => void +>y3 : function +>id2(E) : function +>id2 : (c: any) => function +>E : (n: number) => void // Repro from #39229 diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.types b/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.types index b203944689..e0d94ab856 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.types @@ -6,7 +6,7 @@ class A { /** @return {number} */ method() { throw new Error(); } ->method : () => void +>method : () => number >new Error() : Error >Error : ErrorConstructor } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportType.errors.txt new file mode 100644 index 0000000000..b203c22a1c --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportType.errors.txt @@ -0,0 +1,33 @@ +use.js(2,22): error TS2307: Cannot find module './mod1' or its corresponding type declarations. +use.js(8,12): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? + + +==== use.js (2 errors) ==== + /// + /** @typedef {import("./mod1")} C + ~~~~~~~~ +!!! error TS2307: Cannot find module './mod1' or its corresponding type declarations. + * @type {C} */ + var c; + c.chunk; + + const D = require("./mod1"); + /** @type {D} */ + ~ +!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? + var d; + d.chunk; + +==== types.d.ts (0 errors) ==== + declare function require(name: string): any; + declare var exports: any; + declare var module: { exports: any }; +==== mod1.js (0 errors) ==== + /// + class Chunk { + constructor() { + this.chunk = 1; + } + } + module.exports = Chunk; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportType.types b/testdata/baselines/reference/submodule/conformance/jsdocImportType.types index ecc408657b..b8e71d9b26 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportType.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportType.types @@ -20,11 +20,11 @@ const D = require("./mod1"); /** @type {D} */ var d; ->d : any +>d : D d.chunk; >d.chunk : any ->d : any +>d : D >chunk : any === types.d.ts === diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportType2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportType2.errors.txt new file mode 100644 index 0000000000..c05368aaf8 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportType2.errors.txt @@ -0,0 +1,32 @@ +use.js(2,22): error TS2307: Cannot find module './mod1' or its corresponding type declarations. +use.js(8,12): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? + + +==== use.js (2 errors) ==== + /// + /** @typedef {import("./mod1")} C + ~~~~~~~~ +!!! error TS2307: Cannot find module './mod1' or its corresponding type declarations. + * @type {C} */ + var c; + c.chunk; + + const D = require("./mod1"); + /** @type {D} */ + ~ +!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? + var d; + d.chunk; + +==== types.d.ts (0 errors) ==== + declare function require(name: string): any; + declare var exports: any; + declare var module: { exports: any }; +==== mod1.js (0 errors) ==== + /// + module.exports = class Chunk { + constructor() { + this.chunk = 1; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportType2.types b/testdata/baselines/reference/submodule/conformance/jsdocImportType2.types index 50ce547859..68968909e1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportType2.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportType2.types @@ -20,11 +20,11 @@ const D = require("./mod1"); /** @type {D} */ var d; ->d : any +>d : D d.chunk; >d.chunk : any ->d : any +>d : D >chunk : any === types.d.ts === diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt index 679391ceef..5555cf2cf6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt @@ -1,4 +1,5 @@ mod1.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +test.js(1,22): error TS2306: File 'mod1.js' is not a module. ==== mod1.js (1 errors) ==== @@ -9,8 +10,10 @@ mod1.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install ty ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -==== test.js (0 errors) ==== +==== test.js (1 errors) ==== /** @typedef {import('./mod1').C} X */ + ~~~~~~~~ +!!! error TS2306: File 'mod1.js' is not a module. /** @param {X} c */ function demo(c) { c.s diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt new file mode 100644 index 0000000000..7cfc65e1df --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt @@ -0,0 +1,17 @@ +test.js(1,13): error TS1340: Module './ex' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./ex')'? + + +==== ex.d.ts (0 errors) ==== + declare var config: { + fix: boolean + } + export = config; + +==== test.js (1 errors) ==== + /** @param {import('./ex')} a */ + ~~~~~~~~~~~~~~ +!!! error TS1340: Module './ex' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./ex')'? + function demo(a) { + a.fix + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt new file mode 100644 index 0000000000..b5f2e2a2bf --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt @@ -0,0 +1,14 @@ +test.js(1,13): error TS1340: Module './ex' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./ex')'? + + +==== ex.d.ts (0 errors) ==== + export var config: {} + +==== test.js (1 errors) ==== + /** @param {import('./ex')} a */ + ~~~~~~~~~~~~~~ +!!! error TS1340: Module './ex' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./ex')'? + function demo(a) { + a.config + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt new file mode 100644 index 0000000000..84a4804709 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt @@ -0,0 +1,12 @@ +a.js(1,26): error TS2694: Namespace '"b"' has no exported member 'FOO'. + + +==== b.js (0 errors) ==== + export const FOO = "foo"; + +==== a.js (1 errors) ==== + /** @type {import('./b').FOO} */ + ~~~ +!!! error TS2694: Namespace '"b"' has no exported member 'FOO'. + let x; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt new file mode 100644 index 0000000000..0572ee15d8 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt @@ -0,0 +1,39 @@ +indices.js(1,12): error TS2315: Type 'Object' is not generic. +indices.js(1,18): error TS8020: JSDoc types can only be used inside documentation comments. +indices.js(3,12): error TS2315: Type 'Object' is not generic. +indices.js(3,18): error TS8020: JSDoc types can only be used inside documentation comments. +indices.js(5,12): error TS2315: Type 'Object' is not generic. +indices.js(5,18): error TS8020: JSDoc types can only be used inside documentation comments. +indices.js(7,13): error TS2315: Type 'Object' is not generic. +indices.js(7,19): error TS8020: JSDoc types can only be used inside documentation comments. + + +==== indices.js (8 errors) ==== + /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + var o1; + /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + var o2; + /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + var o3; + /** @param {Object.} o */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + function f(o) { + o.foo = 1; // error + o.bar = false; // ok + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocLiteral.types b/testdata/baselines/reference/submodule/conformance/jsdocLiteral.types index ad8279a6fb..9420cd1887 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocLiteral.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocLiteral.types @@ -9,24 +9,24 @@ * @param {12 | true | 'str'} p5 */ function f(p1, p2, p3, p4, p5) { ->f : (p1: any, p2: any, p3: any, p4: any, p5: any) => string ->p1 : any ->p2 : any ->p3 : any ->p4 : any ->p5 : any +>f : (p1: "literal", p2: "literal", p3: "literal" | "other", p4: number | "literal", p5: "str" | 12 | true) => string +>p1 : "literal" +>p2 : "literal" +>p3 : "literal" | "other" +>p4 : number | "literal" +>p5 : "str" | 12 | true return p1 + p2 + p3 + p4 + p5 + '.'; >p1 + p2 + p3 + p4 + p5 + '.' : string ->p1 + p2 + p3 + p4 + p5 : any ->p1 + p2 + p3 + p4 : any ->p1 + p2 + p3 : any ->p1 + p2 : any ->p1 : any ->p2 : any ->p3 : any ->p4 : any ->p5 : any +>p1 + p2 + p3 + p4 + p5 : string +>p1 + p2 + p3 + p4 : string +>p1 + p2 + p3 : string +>p1 + p2 : string +>p1 : "literal" +>p2 : "literal" +>p3 : "literal" | "other" +>p4 : number | "literal" +>p5 : "str" | 12 | true >'.' : "." } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.types b/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.types index 226c7093b9..2a8baa91ff 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.types @@ -8,9 +8,9 @@ * @returns {void} nothing */ function f(p1, p2, p3) { ->f : (p1: any, p2: any, p3: any) => void ->p1 : any ->p2 : any ->p3 : any +>f : (p1: never, p2: undefined, p3: null) => void +>p1 : never +>p2 : undefined +>p3 : null } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt index 9246cf7e70..c0a05d7652 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt @@ -1,8 +1,11 @@ +jsdocOuterTypeParameters1.js(1,14): error TS2304: Cannot find name 'T'. jsdocOuterTypeParameters1.js(7,35): error TS2339: Property 'foo' does not exist on type 'Bar'. -==== jsdocOuterTypeParameters1.js (1 errors) ==== +==== jsdocOuterTypeParameters1.js (2 errors) ==== /** @return {T} */ + ~ +!!! error TS2304: Cannot find name 'T'. const dedupingMixin = function(mixin) {}; /** @template {T} */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.types b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.types index 1e0de37aed..3909401472 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.types @@ -3,15 +3,15 @@ === jsdocOuterTypeParameters1.js === /** @return {T} */ const dedupingMixin = function(mixin) {}; ->dedupingMixin : (mixin: any) => void ->function(mixin) {} : (mixin: any) => void +>dedupingMixin : (mixin: any) => T +>function(mixin) {} : (mixin: any) => T >mixin : any /** @template {T} */ const PropertyAccessors = dedupingMixin(() => { ->PropertyAccessors : void ->dedupingMixin(() => { class Bar { static bar() { this.prototype.foo(); } }}) : void ->dedupingMixin : (mixin: any) => void +>PropertyAccessors : T +>dedupingMixin(() => { class Bar { static bar() { this.prototype.foo(); } }}) : T +>dedupingMixin : (mixin: any) => T >() => { class Bar { static bar() { this.prototype.foo(); } }} : () => void class Bar { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt index f48b72dc8a..f78e45da6b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt @@ -1,8 +1,11 @@ +jsdocOuterTypeParameters1.js(1,14): error TS2304: Cannot find name 'T'. jsdocOuterTypeParameters1.js(7,35): error TS2339: Property 'foo' does not exist on type 'Bar'. -==== jsdocOuterTypeParameters1.js (1 errors) ==== +==== jsdocOuterTypeParameters1.js (2 errors) ==== /** @return {T} */ + ~ +!!! error TS2304: Cannot find name 'T'. const dedupingMixin = function(mixin) {}; /** @template T */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.types b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.types index ceb322ad3f..8089797bf0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.types @@ -3,15 +3,15 @@ === jsdocOuterTypeParameters1.js === /** @return {T} */ const dedupingMixin = function(mixin) {}; ->dedupingMixin : (mixin: any) => void ->function(mixin) {} : (mixin: any) => void +>dedupingMixin : (mixin: any) => T +>function(mixin) {} : (mixin: any) => T >mixin : any /** @template T */ const PropertyAccessors = dedupingMixin(() => { ->PropertyAccessors : void ->dedupingMixin(() => { class Bar { static bar() { this.prototype.foo(); } }}) : void ->dedupingMixin : (mixin: any) => void +>PropertyAccessors : T +>dedupingMixin(() => { class Bar { static bar() { this.prototype.foo(); } }}) : T +>dedupingMixin : (mixin: any) => T >() => { class Bar { static bar() { this.prototype.foo(); } }} : () => void class Bar { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.types b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.types index 83f0c93f72..fb37e4caac 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.types @@ -10,13 +10,13 @@ class A { * @returns {boolean} */ foo (a) { ->foo : (a: any) => a is string ->a : any +>foo : (a: string | number) => boolean +>a : string | number return typeof a === 'string' >typeof a === 'string' : boolean >typeof a : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->a : any +>a : string | number >'string' : "string" } bar () { @@ -36,15 +36,15 @@ class B extends A { * @returns {boolean} */ foo (a) { ->foo : (a: any) => a is string ->a : any +>foo : (a: string | number) => boolean +>a : string | number return super.foo(a) >super.foo(a) : boolean ->super.foo : (a: any) => a is string +>super.foo : (a: string | number) => boolean >super : A ->foo : (a: any) => a is string ->a : any +>foo : (a: string | number) => boolean +>a : string | number } bar () { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.types b/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.types index 3e8043a4b1..54335d1106 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.types @@ -7,10 +7,10 @@ * @param {string} x */ function good1({a, b}, x) {} ->good1 : (__0: { a: any; b: any; }, x: any) => void +>good1 : (__0: { a: any; b: any; }, x: string) => void >a : any >b : any ->x : any +>x : string /** * @param {{a: string, b: string}} obj @@ -29,11 +29,11 @@ function good2({a, b}, {c, d}) {} * @param {string} y */ function good3(x, {a, b}, y) {} ->good3 : (x: any, __1: { a: any; b: any; }, y: any) => void ->x : any +>good3 : (x: number, __1: { a: any; b: any; }, y: string) => void +>x : number >a : any >b : any ->y : any +>y : string /** * @param {{a: string, b: string}} obj @@ -51,10 +51,10 @@ function good4({a, b}) {} * @param {string} x */ function good5({a, b}, x) {} ->good5 : (__0: { a: any; b: any; }, x: any) => void +>good5 : (__0: { a: any; b: any; }, x: string) => void >a : any >b : any ->x : any +>x : string /** * @param {Object} obj @@ -79,11 +79,11 @@ function good6({a, b}, {c, d}) {} * @param {string} y */ function good7(x, {a, b}, y) {} ->good7 : (x: any, __1: { a: any; b: any; }, y: any) => void ->x : any +>good7 : (x: number, __1: { a: any; b: any; }, y: string) => void +>x : number >a : any >b : any ->y : any +>y : string /** * @param {Object} obj @@ -118,8 +118,8 @@ function good9({ a }) { * @param {string} x */ function bad1(x, {a, b}) {} ->bad1 : (x: any, __1: { a: any; b: any; }) => void ->x : any +>bad1 : (x: string, __1: { a: any; b: any; }) => void +>x : string >a : any >b : any diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt deleted file mode 100644 index 45327cca41..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt +++ /dev/null @@ -1,93 +0,0 @@ -0.js(5,17): error TS7006: Parameter 'notSpecial' implicitly has an 'any' type. -0.js(17,15): error TS7006: Parameter 'opts1' implicitly has an 'any' type. -0.js(28,52): error TS7006: Parameter 'opts2' implicitly has an 'any' type. -0.js(38,15): error TS7006: Parameter 'opts3' implicitly has an 'any' type. -0.js(50,15): error TS7006: Parameter 'opts4' implicitly has an 'any' type. -0.js(66,15): error TS7006: Parameter 'opts5' implicitly has an 'any' type. - - -==== 0.js (6 errors) ==== - /** - * @param {Object} notSpecial - * @param {string} unrelated - not actually related because it's not notSpecial.unrelated - */ - function normal(notSpecial) { - ~~~~~~~~~~ -!!! error TS7006: Parameter 'notSpecial' implicitly has an 'any' type. - notSpecial; // should just be 'Object' - } - normal(12); - - /** - * @param {Object} opts1 doc1 - * @param {string} opts1.x doc2 - * @param {string=} opts1.y doc3 - * @param {string} [opts1.z] doc4 - * @param {string} [opts1.w="hi"] doc5 - */ - function foo1(opts1) { - ~~~~~ -!!! error TS7006: Parameter 'opts1' implicitly has an 'any' type. - opts1.x; - } - - foo1({x: 'abc'}); - - /** - * @param {Object[]} opts2 - * @param {string} opts2[].anotherX - * @param {string=} opts2[].anotherY - */ - function foo2(/** @param opts2 bad idea theatre! */opts2) { - ~~~~~ -!!! error TS7006: Parameter 'opts2' implicitly has an 'any' type. - opts2[0].anotherX; - } - - foo2([{anotherX: "world"}]); - - /** - * @param {object} opts3 - * @param {string} opts3.x - */ - function foo3(opts3) { - ~~~~~ -!!! error TS7006: Parameter 'opts3' implicitly has an 'any' type. - opts3.x; - } - foo3({x: 'abc'}); - - /** - * @param {object[]} opts4 - * @param {string} opts4[].x - * @param {string=} opts4[].y - * @param {string} [opts4[].z] - * @param {string} [opts4[].w="hi"] - */ - function foo4(opts4) { - ~~~~~ -!!! error TS7006: Parameter 'opts4' implicitly has an 'any' type. - opts4[0].x; - } - - foo4([{ x: 'hi' }]); - - /** - * @param {object[]} opts5 - Let's test out some multiple nesting levels - * @param {string} opts5[].help - (This one is just normal) - * @param {object} opts5[].what - Look at us go! Here's the first nest! - * @param {string} opts5[].what.a - (Another normal one) - * @param {Object[]} opts5[].what.bad - Now we're nesting inside a nested type - * @param {string} opts5[].what.bad[].idea - I don't think you can get back out of this level... - * @param {boolean} opts5[].what.bad[].oh - Oh ... that's how you do it. - * @param {number} opts5[].unnest - Here we are almost all the way back at the beginning. - */ - function foo5(opts5) { - ~~~~~ -!!! error TS7006: Parameter 'opts5' implicitly has an 'any' type. - opts5[0].what.bad[0].idea; - opts5[0].unnest; - } - - foo5([{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }]); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.types b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.types index 24ff356ae2..470a8300aa 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.types @@ -6,15 +6,15 @@ * @param {string} unrelated - not actually related because it's not notSpecial.unrelated */ function normal(notSpecial) { ->normal : (notSpecial: any) => void ->notSpecial : any +>normal : (notSpecial: Object) => void +>notSpecial : Object notSpecial; // should just be 'Object' ->notSpecial : any +>notSpecial : Object } normal(12); >normal(12) : void ->normal : (notSpecial: any) => void +>normal : (notSpecial: Object) => void >12 : 12 /** diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt index a6fc714600..4a853ebcdf 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt @@ -1,17 +1,14 @@ -a.js(5,12): error TS7006: Parameter 'args' implicitly has an 'any' type. -a.js(5,18): error TS7006: Parameter 'bwarg' implicitly has an 'any' type. +a.js(5,18): error TS1016: A required parameter cannot follow an optional parameter. -==== a.js (2 errors) ==== +==== a.js (1 errors) ==== /** * @param {string=} `args` * @param `bwarg` {?number?} */ function f(args, bwarg) { - ~~~~ -!!! error TS7006: Parameter 'args' implicitly has an 'any' type. ~~~~~ -!!! error TS7006: Parameter 'bwarg' implicitly has an 'any' type. +!!! error TS1016: A required parameter cannot follow an optional parameter. } ==== ts.ts (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.types b/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.types index d5e4bea0c0..f714bf0844 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.types @@ -6,9 +6,9 @@ * @param `bwarg` {?number?} */ function f(args, bwarg) { ->f : (args: any, bwarg: any) => void ->args : any ->bwarg : any +>f : (args: string | undefined, bwarg: number | null) => void +>args : string | undefined +>bwarg : number | null } === ts.ts === diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt index ff761ca257..4d4beab51f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt @@ -1,7 +1,8 @@ a.js(3,12): error TS7006: Parameter 'callback' implicitly has an 'any' type. +a.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== // from bcryptjs /** @param {function(...[*])} callback */ function g(callback) { @@ -12,6 +13,9 @@ a.js(3,12): error TS7006: Parameter 'callback' implicitly has an 'any' type. /** * @type {!function(...number):string} + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. * @inner */ var stringFromCharCode = String.fromCharCode; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.types b/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.types index 39f2689475..f310e7ed1e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.types @@ -23,7 +23,7 @@ function g(callback) { * @inner */ var stringFromCharCode = String.fromCharCode; ->stringFromCharCode : (...codes: number[]) => string +>stringFromCharCode : function >String.fromCharCode : (...codes: number[]) => string >String : StringConstructor >fromCharCode : (...codes: number[]) => string diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt index 5fc557919c..ff420a46d1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt @@ -1,9 +1,13 @@ +paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? paren.js(2,10): error TS7006: Parameter 's' implicitly has an 'any' type. paren.js(2,13): error TS7006: Parameter 'id' implicitly has an 'any' type. -==== paren.js (2 errors) ==== +==== paren.js (3 errors) ==== /** @type {function((string), function((string)): string): string} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. var x = (s, id) => id(s) ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.types b/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.types index 3582d5fcb2..83cf505482 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.types @@ -3,7 +3,7 @@ === paren.js === /** @type {function((string), function((string)): string): string} */ var x = (s, id) => id(s) ->x : (s: any, id: any) => any +>x : function >(s, id) => id(s) : (s: any, id: any) => any >s : any >id : any diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.errors.txt deleted file mode 100644 index 84afda44f4..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -jsdocParseMatchingBackticks.js(12,19): error TS7006: Parameter 'x' implicitly has an 'any' type. -jsdocParseMatchingBackticks.js(12,22): error TS7006: Parameter 'y' implicitly has an 'any' type. -jsdocParseMatchingBackticks.js(12,25): error TS7006: Parameter 'z' implicitly has an 'any' type. -jsdocParseMatchingBackticks.js(12,28): error TS7006: Parameter 'alpha' implicitly has an 'any' type. -jsdocParseMatchingBackticks.js(12,35): error TS7006: Parameter 'beta' implicitly has an 'any' type. -jsdocParseMatchingBackticks.js(12,41): error TS7006: Parameter 'gamma' implicitly has an 'any' type. - - -==== jsdocParseMatchingBackticks.js (6 errors) ==== - /** - * `@param` initial at-param is OK in title comment - * @param {string} x hi there `@param` - * @param {string} y hi there `@ * param - * this is the margin - * so we'll drop everything before it - `@param` @param {string} z hello??? - * `@param` @param {string} alpha hello??? - * `@ * param` @param {string} beta hello??? - * @param {string} gamma - */ - export function f(x, y, z, alpha, beta, gamma) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'y' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'z' implicitly has an 'any' type. - ~~~~~ -!!! error TS7006: Parameter 'alpha' implicitly has an 'any' type. - ~~~~ -!!! error TS7006: Parameter 'beta' implicitly has an 'any' type. - ~~~~~ -!!! error TS7006: Parameter 'gamma' implicitly has an 'any' type. - return x + y + z + alpha + beta + gamma - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.types b/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.types index 3bbdcd9b06..b7835c0c6d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.types @@ -13,25 +13,25 @@ * @param {string} gamma */ export function f(x, y, z, alpha, beta, gamma) { ->f : (x: any, y: any, z: any, alpha: any, beta: any, gamma: any) => any ->x : any ->y : any ->z : any ->alpha : any ->beta : any ->gamma : any +>f : (x: string, y: string, z: string, alpha: string, beta: string, gamma: string) => string +>x : string +>y : string +>z : string +>alpha : string +>beta : string +>gamma : string return x + y + z + alpha + beta + gamma ->x + y + z + alpha + beta + gamma : any ->x + y + z + alpha + beta : any ->x + y + z + alpha : any ->x + y + z : any ->x + y : any ->x : any ->y : any ->z : any ->alpha : any ->beta : any ->gamma : any +>x + y + z + alpha + beta + gamma : string +>x + y + z + alpha + beta : string +>x + y + z + alpha : string +>x + y + z : string +>x + y : string +>x : string +>y : string +>z : string +>alpha : string +>beta : string +>gamma : string } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt index 8b239e96fe..89b948713c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt @@ -1,8 +1,12 @@ +paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? paren.js(2,9): error TS7006: Parameter 's' implicitly has an 'any' type. -==== paren.js (1 errors) ==== +==== paren.js (2 errors) ==== /** @type {function((string)): string} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. var x = s => s.toString() ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.types b/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.types index fe3b681113..c3576d3ded 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.types @@ -3,7 +3,7 @@ === paren.js === /** @type {function((string)): string} */ var x = s => s.toString() ->x : (s: any) => any +>x : function >s => s.toString() : (s: any) => any >s : any >s.toString() : any diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt index 0f3224b30b..0774af10ea 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt @@ -1,13 +1,16 @@ -a.js(3,12): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. +a.js(3,12): error TS2370: A rest parameter must be of an array type. +a.js(3,19): error TS1047: A rest parameter cannot be optional. a.js(12,14): error TS7006: Parameter 'f' implicitly has an 'any' type. -==== a.js (2 errors) ==== +==== a.js (3 errors) ==== /** @param {...*=} args @return {*=} */ function f(...args) { ~~~~~~~ -!!! error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. +!!! error TS2370: A rest parameter must be of an array type. + +!!! error TS1047: A rest parameter cannot be optional. return null } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.types b/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.types index 0e7aa5b915..b48d0f1ee8 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.types @@ -4,8 +4,8 @@ /** @param {...*=} args @return {*=} */ function f(...args) { ->f : (...args: any[]) => null ->args : any[] +>f : (...args: any[] | undefined) => any +>args : any[] | undefined return null } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt index e810256bc6..e683fb2f2d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt @@ -1,5 +1,5 @@ -a.js(2,12): error TS7006: Parameter 'a' implicitly has an 'any' type. -a.js(7,1): error TS2554: Expected 1 arguments, but got 0. +a.js(4,5): error TS2322: Type 'null' is not assignable to type 'number | undefined'. +a.js(8,3): error TS2345: Argument of type 'null' is not assignable to parameter of type 'number | undefined'. a.js(13,12): error TS7006: Parameter 'a' implicitly has an 'any' type. a.js(18,1): error TS2554: Expected 1 arguments, but got 0. @@ -7,17 +7,16 @@ a.js(18,1): error TS2554: Expected 1 arguments, but got 0. ==== a.js (4 errors) ==== /** @param {number=} a */ function f(a) { - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. a = 1 a = null // should not be allowed + ~ +!!! error TS2322: Type 'null' is not assignable to type 'number | undefined'. a = undefined } f() - ~ -!!! error TS2554: Expected 1 arguments, but got 0. -!!! related TS6210 a.js:2:12: An argument for 'a' was not provided. f(null) // should not be allowed + ~~~~ +!!! error TS2345: Argument of type 'null' is not assignable to parameter of type 'number | undefined'. f(undefined) f(1) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.types b/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.types index a3e62a9313..4c487015fd 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.types @@ -3,39 +3,39 @@ === a.js === /** @param {number=} a */ function f(a) { ->f : (a: any) => void ->a : any +>f : (a?: number | undefined) => void +>a : number | undefined a = 1 >a = 1 : 1 ->a : any +>a : number | undefined >1 : 1 a = null // should not be allowed >a = null : null ->a : any +>a : number | undefined a = undefined >a = undefined : undefined ->a : any +>a : number | undefined >undefined : undefined } f() >f() : void ->f : (a: any) => void +>f : (a?: number | undefined) => void f(null) // should not be allowed >f(null) : void ->f : (a: any) => void +>f : (a?: number | undefined) => void f(undefined) >f(undefined) : void ->f : (a: any) => void +>f : (a?: number | undefined) => void >undefined : undefined f(1) >f(1) : void ->f : (a: any) => void +>f : (a?: number | undefined) => void >1 : 1 /** @param {???!?number?=} a */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt index 20fd08e846..eb8c66517a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt @@ -1,21 +1,15 @@ prefixPostfix.js(18,12): error TS7006: Parameter 'x' implicitly has an 'any' type. -prefixPostfix.js(18,15): error TS7006: Parameter 'y' implicitly has an 'any' type. prefixPostfix.js(18,18): error TS7006: Parameter 'z' implicitly has an 'any' type. prefixPostfix.js(18,21): error TS7006: Parameter 'a' implicitly has an 'any' type. -prefixPostfix.js(18,24): error TS7006: Parameter 'b' implicitly has an 'any' type. prefixPostfix.js(18,27): error TS7006: Parameter 'c' implicitly has an 'any' type. -prefixPostfix.js(18,30): error TS7006: Parameter 'e' implicitly has an 'any' type. prefixPostfix.js(18,33): error TS7006: Parameter 'f' implicitly has an 'any' type. prefixPostfix.js(18,36): error TS7006: Parameter 'g' implicitly has an 'any' type. prefixPostfix.js(18,39): error TS7006: Parameter 'h' implicitly has an 'any' type. -prefixPostfix.js(18,42): error TS7006: Parameter 'i' implicitly has an 'any' type. prefixPostfix.js(18,45): error TS7006: Parameter 'j' implicitly has an 'any' type. prefixPostfix.js(18,48): error TS7006: Parameter 'k' implicitly has an 'any' type. -prefixPostfix.js(18,51): error TS7006: Parameter 'l' implicitly has an 'any' type. -prefixPostfix.js(18,54): error TS7006: Parameter 'm' implicitly has an 'any' type. -==== prefixPostfix.js (15 errors) ==== +==== prefixPostfix.js (9 errors) ==== /** * @param {number![]} x - number[] * @param {!number[]} y - number[] @@ -36,33 +30,21 @@ prefixPostfix.js(18,54): error TS7006: Parameter 'm' implicitly has an 'any' typ function f(x, y, z, a, b, c, e, f, g, h, i, j, k, l, m) { ~ !!! error TS7006: Parameter 'x' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'y' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'z' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'c' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'e' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'f' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'g' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'h' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'i' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'j' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'k' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'l' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'm' implicitly has an 'any' type. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.types b/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.types index 584275c4b6..17030fe29f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.types @@ -19,21 +19,21 @@ * @param {[number, number?]} m - [number, (number | undefined)?] */ function f(x, y, z, a, b, c, e, f, g, h, i, j, k, l, m) { ->f : (x: any, y: any, z: any, a: any, b: any, c: any, e: any, f: any, g: any, h: any, i: any, j: any, k: any, l: any, m: any) => void +>f : (x: any, y: number[], z: any, a: any, b: number[] | null, c: any, e: (number | null)[], f: any, g: any, h: any, i: number[][], j: any, k: any, l: true, m: [number, (number | undefined)?]) => void >x : any ->y : any +>y : number[] >z : any >a : any ->b : any +>b : number[] | null >c : any ->e : any +>e : (number | null)[] >f : any >g : any >h : any ->i : any +>i : number[][] >j : any >k : any ->l : any ->m : any +>l : true +>m : [number, (number | undefined)?] } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt new file mode 100644 index 0000000000..d6c7a99ac5 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt @@ -0,0 +1,11 @@ +jsdocPrivateName1.js(3,5): error TS2322: Type 'number' is not assignable to type 'boolean'. + + +==== jsdocPrivateName1.js (1 errors) ==== + class A { + /** @type {boolean} some number value */ + #foo = 3 // Error because not assignable to boolean + ~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.types b/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.types index 4c83a9466f..a361284063 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.types @@ -6,7 +6,7 @@ class A { /** @type {boolean} some number value */ #foo = 3 // Error because not assignable to boolean ->#foo : number +>#foo : boolean >3 : 3 } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt index fa5f1759a3..1648125f5e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt @@ -1,12 +1,16 @@ +returns.js(5,5): error TS2322: Type 'number' is not assignable to type 'string'. +returns.js(12,5): error TS2322: Type 'number' is not assignable to type 'string'. returns.js(19,12): error TS2872: This kind of expression is always truthy. -==== returns.js (1 errors) ==== +==== returns.js (3 errors) ==== /** * @returns {string} This comment is not currently exposed */ function f() { return 5; + ~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. } /** @@ -14,6 +18,8 @@ returns.js(19,12): error TS2872: This kind of expression is always truthy. */ function f1() { return 5; + ~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. } /** diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.types b/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.types index 250bad9456..e6c327cbb4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.types @@ -5,7 +5,7 @@ * @returns {string} This comment is not currently exposed */ function f() { ->f : () => number +>f : () => string return 5; >5 : 5 @@ -15,7 +15,7 @@ function f() { * @returns {string=} This comment is not currently exposed */ function f1() { ->f1 : () => number +>f1 : () => string return 5; >5 : 5 @@ -25,7 +25,7 @@ function f1() { * @returns {string|number} This comment is not currently exposed */ function f2() { ->f2 : () => "hello" | 5 +>f2 : () => string | number return 5 || "hello"; >5 || "hello" : "hello" | 5 diff --git a/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.errors.txt deleted file mode 100644 index 0ef255da33..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.errors.txt +++ /dev/null @@ -1,63 +0,0 @@ -jsdocSignatureOnReturnedFunction.js(7,13): error TS7006: Parameter 'a' implicitly has an 'any' type. -jsdocSignatureOnReturnedFunction.js(7,16): error TS7006: Parameter 'b' implicitly has an 'any' type. -jsdocSignatureOnReturnedFunction.js(18,22): error TS7006: Parameter 'a' implicitly has an 'any' type. -jsdocSignatureOnReturnedFunction.js(18,25): error TS7006: Parameter 'b' implicitly has an 'any' type. -jsdocSignatureOnReturnedFunction.js(25,13): error TS7006: Parameter 'a' implicitly has an 'any' type. -jsdocSignatureOnReturnedFunction.js(25,16): error TS7006: Parameter 'b' implicitly has an 'any' type. -jsdocSignatureOnReturnedFunction.js(32,22): error TS7006: Parameter 'a' implicitly has an 'any' type. -jsdocSignatureOnReturnedFunction.js(32,25): error TS7006: Parameter 'b' implicitly has an 'any' type. - - -==== jsdocSignatureOnReturnedFunction.js (8 errors) ==== - function f1() { - /** - * @param {number} a - * @param {number} b - * @returns {number} - */ - return (a, b) => { - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. - return a + b; - } - } - - function f2() { - /** - * @param {number} a - * @param {number} b - * @returns {number} - */ - return function (a, b){ - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. - return a + b; - } - } - - function f3() { - /** @type {(a: number, b: number) => number} */ - return (a, b) => { - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. - return a + b; - } - } - - function f4() { - /** @type {(a: number, b: number) => number} */ - return function (a, b){ - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. - return a + b; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.types b/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.types index 7499e38dde..d496efe380 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.types @@ -2,7 +2,7 @@ === jsdocSignatureOnReturnedFunction.js === function f1() { ->f1 : () => (a: any, b: any) => any +>f1 : () => (a: number, b: number) => number /** * @param {number} a @@ -10,19 +10,19 @@ function f1() { * @returns {number} */ return (a, b) => { ->(a, b) => { return a + b; } : (a: any, b: any) => any ->a : any ->b : any +>(a, b) => { return a + b; } : (a: number, b: number) => number +>a : number +>b : number return a + b; ->a + b : any ->a : any ->b : any +>a + b : number +>a : number +>b : number } } function f2() { ->f2 : () => (a: any, b: any) => any +>f2 : () => (a: number, b: number) => number /** * @param {number} a @@ -30,46 +30,48 @@ function f2() { * @returns {number} */ return function (a, b){ ->function (a, b){ return a + b; } : (a: any, b: any) => any ->a : any ->b : any +>function (a, b){ return a + b; } : (a: number, b: number) => number +>a : number +>b : number return a + b; ->a + b : any ->a : any ->b : any +>a + b : number +>a : number +>b : number } } function f3() { ->f3 : () => (a: any, b: any) => any +>f3 : () => (a: number, b: number) => number /** @type {(a: number, b: number) => number} */ return (a, b) => { ->(a, b) => { return a + b; } : (a: any, b: any) => any ->a : any ->b : any +>(a, b) => { return a + b; } : (a: number, b: number) => number +>(a, b) => { return a + b; } : (a: number, b: number) => number +>a : number +>b : number return a + b; ->a + b : any ->a : any ->b : any +>a + b : number +>a : number +>b : number } } function f4() { ->f4 : () => (a: any, b: any) => any +>f4 : () => (a: number, b: number) => number /** @type {(a: number, b: number) => number} */ return function (a, b){ ->function (a, b){ return a + b; } : (a: any, b: any) => any ->a : any ->b : any +>function (a, b){ return a + b; } : (a: number, b: number) => number +>function (a, b){ return a + b; } : (a: number, b: number) => number +>a : number +>b : number return a + b; ->a + b : any ->a : any ->b : any +>a + b : number +>a : number +>b : number } } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt index ec71f9db75..82d9a6ba3a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt @@ -1,6 +1,6 @@ -templateTagOnClasses.js(10,14): error TS2339: Property 'a' does not exist on type 'Foo'. -templateTagOnClasses.js(25,3): error TS2339: Property 'a' does not exist on type 'Foo'. -templateTagOnClasses.js(25,9): error TS2339: Property 'a' does not exist on type 'Foo'. +templateTagOnClasses.js(10,14): error TS2339: Property 'a' does not exist on type 'Foo'. +templateTagOnClasses.js(25,3): error TS2339: Property 'a' does not exist on type 'Foo'. +templateTagOnClasses.js(25,9): error TS2339: Property 'a' does not exist on type 'Foo'. ==== templateTagOnClasses.js (3 errors) ==== @@ -15,7 +15,7 @@ templateTagOnClasses.js(25,9): error TS2339: Property 'a' does not exist on type constructor (x) { this.a = x ~ -!!! error TS2339: Property 'a' does not exist on type 'Foo'. +!!! error TS2339: Property 'a' does not exist on type 'Foo'. } /** * @@ -32,7 +32,7 @@ templateTagOnClasses.js(25,9): error TS2339: Property 'a' does not exist on type var g = new Foo(false) f.a = g.a ~ -!!! error TS2339: Property 'a' does not exist on type 'Foo'. +!!! error TS2339: Property 'a' does not exist on type 'Foo'. ~ -!!! error TS2339: Property 'a' does not exist on type 'Foo'. +!!! error TS2339: Property 'a' does not exist on type 'Foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.types index 4b11f84bab..34bdf98718 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.types @@ -7,19 +7,19 @@ */ /** @template T */ class Foo { ->Foo : Foo +>Foo : Foo /** @typedef {(t: T) => T} Id2 */ /** @param {T} x */ constructor (x) { ->x : any +>x : T this.a = x ->this.a = x : any +>this.a = x : T >this.a : any >this : this >a : any ->x : any +>x : T } /** * @@ -29,37 +29,37 @@ class Foo { * @return {T} */ foo(x, y, alpha) { ->foo : (x: any, y: any, alpha: any) => any ->x : any ->y : any ->alpha : any +>foo : (x: T, y: (t: T) => T, alpha: (t: T) => T) => T +>x : T +>y : (t: T) => T +>alpha : (t: T) => T return alpha(y(x)) ->alpha(y(x)) : any ->alpha : any ->y(x) : any ->y : any ->x : any +>alpha(y(x)) : T +>alpha : (t: T) => T +>y(x) : T +>y : (t: T) => T +>x : T } } var f = new Foo(1) ->f : Foo ->new Foo(1) : Foo +>f : Foo +>new Foo(1) : Foo >Foo : typeof Foo >1 : 1 var g = new Foo(false) ->g : Foo ->new Foo(false) : Foo +>g : Foo +>new Foo(false) : Foo >Foo : typeof Foo >false : false f.a = g.a >f.a = g.a : any >f.a : any ->f : Foo +>f : Foo >a : any >g.a : any ->g : Foo +>g : Foo >a : any diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.types index 785fa91765..e3e64c3c17 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.types @@ -10,8 +10,8 @@ * @template T */ function Zet(t) { ->Zet : (t: any) => void ->t : any +>Zet : (t: T) => void +>t : T /** @type {T} */ this.u @@ -20,11 +20,11 @@ function Zet(t) { >u : any this.t = t ->this.t = t : any +>this.t = t : T >this.t : any >this : any >t : any ->t : any +>t : T } /** * @param {T} v @@ -34,7 +34,7 @@ Zet.prototype.add = function(v, id) { >Zet.prototype.add = function(v, id) { this.u = v || this.t return id(this.u)} : (v: any, id: any) => any >Zet.prototype.add : any >Zet.prototype : any ->Zet : (t: any) => void +>Zet : (t: T) => void >prototype : any >add : any >function(v, id) { this.u = v || this.t return id(this.u)} : (v: any, id: any) => any @@ -62,7 +62,7 @@ Zet.prototype.add = function(v, id) { var z = new Zet(1) >z : any >new Zet(1) : any ->Zet : (t: any) => void +>Zet : (t: T) => void >1 : 1 z.t = 2 diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.types index e7dd5794a9..6248d2cc34 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.types @@ -6,8 +6,8 @@ * @template T */ function Zet(t) { ->Zet : (t: any) => void ->t : any +>Zet : (t: T) => void +>t : T /** @type {T} */ this.u @@ -16,11 +16,11 @@ function Zet(t) { >u : any this.t = t ->this.t = t : any +>this.t = t : T >this.t : any >this : any >t : any ->t : any +>t : T } /** * @param {T} v @@ -31,7 +31,7 @@ Zet.prototype.add = function(v, o) { >Zet.prototype.add = function(v, o) { this.u = v || o.nested return this.u} : (v: any, o: any) => any >Zet.prototype.add : any >Zet.prototype : any ->Zet : (t: any) => void +>Zet : (t: T) => void >prototype : any >add : any >function(v, o) { this.u = v || o.nested return this.u} : (v: any, o: any) => any @@ -57,7 +57,7 @@ Zet.prototype.add = function(v, o) { var z = new Zet(1) >z : any >new Zet(1) : any ->Zet : (t: any) => void +>Zet : (t: T) => void >1 : 1 z.t = 2 @@ -76,7 +76,7 @@ z.u = false /** @type {number} */ let answer = z.add(3, { nested: 4 }) ->answer : any +>answer : number >z.add(3, { nested: 4 }) : any >z.add : any >z : any @@ -93,7 +93,7 @@ let answer = z.add(3, { nested: 4 }) */ /** @type {A} */ const options = { value: null }; ->options : { value: any; } +>options : A >{ value: null } : { value: null; } >value : null diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt index 9078b6efa4..b60487ba5b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt @@ -1,8 +1,9 @@ +forgot.js(13,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? forgot.js(23,1): error TS2322: Type '(keyframes: Keyframe[] | PropertyIndexedKeyframes) => void' is not assignable to type '(keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions) => Animation'. Type 'void' is not assignable to type 'Animation'. -==== forgot.js (1 errors) ==== +==== forgot.js (2 errors) ==== /** * @param {T} a * @template T @@ -16,6 +17,9 @@ forgot.js(23,1): error TS2322: Type '(keyframes: Keyframe[] | PropertyIndexedKey * @param {T} a * @template T * @returns {function(): T} + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. */ function g(a) { return () => a diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.types index 913255d202..7ad6085463 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.types @@ -6,18 +6,18 @@ * @template T */ function f(a) { ->f : (a: any) => () => any ->a : any +>f : (a: T) => () => T +>a : T return () => a ->() => a : () => any ->a : any +>() => a : () => T +>a : T } let n = f(1)() ->n : any ->f(1)() : any ->f(1) : () => any ->f : (a: any) => () => any +>n : number +>f(1)() : number +>f(1) : () => number +>f : (a: T) => () => T >1 : 1 /** @@ -26,18 +26,18 @@ let n = f(1)() * @returns {function(): T} */ function g(a) { ->g : (a: any) => () => any ->a : any +>g : (a: T) => function +>a : T return () => a ->() => a : () => any ->a : any +>() => a : () => T +>a : T } let s = g('hi')() >s : any >g('hi')() : any ->g('hi') : () => any ->g : (a: any) => () => any +>g('hi') : function +>g : (a: T) => function >'hi' : "hi" /** diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.types index 4f4362f8e4..1827468150 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.types @@ -2,8 +2,8 @@ === github17339.js === var obj = { ->obj : { x: (a: any) => any; } ->{ /** * @template T * @param {T} a * @returns {T} */ x: function (a) { return a; },} : { x: (a: any) => any; } +>obj : { x: (a: T) => T; } +>{ /** * @template T * @param {T} a * @returns {T} */ x: function (a) { return a; },} : { x: (a: T) => T; } /** * @template T @@ -11,12 +11,12 @@ var obj = { * @returns {T} */ x: function (a) { ->x : (a: any) => any ->function (a) { return a; } : (a: any) => any ->a : any +>x : (a: T) => T +>function (a) { return a; } : (a: T) => T +>a : T return a; ->a : any +>a : T }, }; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt new file mode 100644 index 0000000000..f503b09c3b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt @@ -0,0 +1,37 @@ +a.js(21,3): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. + + +==== a.js (1 errors) ==== + /** + * @template {{ a: number, b: string }} T,U A Comment + * @template {{ c: boolean }} V uh ... are comments even supported?? + * @template W + * @template X That last one had no comment + * @param {T} t + * @param {U} u + * @param {V} v + * @param {W} w + * @param {X} x + * @return {W | X} + */ + function f(t, u, v, w, x) { + if(t.a + t.b.length > u.a - u.b.length && v.c) { + return w; + } + return x; + } + + f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); + f({ a: 12 }, undefined, undefined, 101, 'nope'); + ~~~~~~~~~~ +!!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. +!!! related TS2728 a.js:2:28: 'b' is declared here. + + /** + * @template {NoLongerAllowed} + * @template T preceding line's syntax is no longer allowed + * @param {T} x + */ + function g(x) { } + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols index ce3017dca3..4488412bdb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols @@ -22,11 +22,25 @@ function f(t, u, v, w, x) { >x : Symbol(x, Decl(a.js, 12, 22)) if(t.a + t.b.length > u.a - u.b.length && v.c) { +>t.a : Symbol(a, Decl(a.js, 1, 15)) >t : Symbol(t, Decl(a.js, 12, 11)) +>a : Symbol(a, Decl(a.js, 1, 15)) +>t.b.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) +>t.b : Symbol(b, Decl(a.js, 1, 26)) >t : Symbol(t, Decl(a.js, 12, 11)) +>b : Symbol(b, Decl(a.js, 1, 26)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) +>u.a : Symbol(a, Decl(a.js, 1, 15)) >u : Symbol(u, Decl(a.js, 12, 13)) +>a : Symbol(a, Decl(a.js, 1, 15)) +>u.b.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) +>u.b : Symbol(b, Decl(a.js, 1, 26)) >u : Symbol(u, Decl(a.js, 12, 13)) +>b : Symbol(b, Decl(a.js, 1, 26)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) +>v.c : Symbol(c, Decl(a.js, 2, 15)) >v : Symbol(v, Decl(a.js, 12, 16)) +>c : Symbol(c, Decl(a.js, 2, 15)) return w; >w : Symbol(w, Decl(a.js, 12, 19)) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols.diff index 57d785ee2f..29cb4c4712 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols.diff @@ -1,22 +1,24 @@ --- old.jsdocTemplateTag3.symbols +++ new.jsdocTemplateTag3.symbols -@@= skipped -21, +21 lines =@@ - >x : Symbol(x, Decl(a.js, 12, 22)) - - if(t.a + t.b.length > u.a - u.b.length && v.c) { -->t.a : Symbol(a, Decl(a.js, 1, 15)) +@@= skipped -24, +24 lines =@@ + >t.a : Symbol(a, Decl(a.js, 1, 15)) >t : Symbol(t, Decl(a.js, 12, 11)) -->a : Symbol(a, Decl(a.js, 1, 15)) + >a : Symbol(a, Decl(a.js, 1, 15)) ->t.b.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) -->t.b : Symbol(b, Decl(a.js, 1, 26)) ++>t.b.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) + >t.b : Symbol(b, Decl(a.js, 1, 26)) >t : Symbol(t, Decl(a.js, 12, 11)) -->b : Symbol(b, Decl(a.js, 1, 26)) + >b : Symbol(b, Decl(a.js, 1, 26)) ->length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) ++>u.a : Symbol(a, Decl(a.js, 1, 15)) >u : Symbol(u, Decl(a.js, 12, 13)) ++>a : Symbol(a, Decl(a.js, 1, 15)) ++>u.b.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) ++>u.b : Symbol(b, Decl(a.js, 1, 26)) >u : Symbol(u, Decl(a.js, 12, 13)) -->v.c : Symbol(c, Decl(a.js, 2, 15)) ++>b : Symbol(b, Decl(a.js, 1, 26)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) + >v.c : Symbol(c, Decl(a.js, 2, 15)) >v : Symbol(v, Decl(a.js, 12, 16)) -->c : Symbol(c, Decl(a.js, 2, 15)) - - return w; - >w : Symbol(w, Decl(a.js, 12, 19)) + >c : Symbol(c, Decl(a.js, 2, 15)) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.types index bf35076edb..5d9b438876 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.types @@ -14,48 +14,48 @@ * @return {W | X} */ function f(t, u, v, w, x) { ->f : (t: any, u: any, v: any, w: any, x: any) => any ->t : any ->u : any ->v : any ->w : any ->x : any +>f : (t: T, u: U, v: V, w: W, x: X) => W | X +>t : T +>u : U +>v : V +>w : W +>x : X if(t.a + t.b.length > u.a - u.b.length && v.c) { ->t.a + t.b.length > u.a - u.b.length && v.c : any +>t.a + t.b.length > u.a - u.b.length && v.c : boolean >t.a + t.b.length > u.a - u.b.length : boolean ->t.a + t.b.length : any ->t.a : any ->t : any ->a : any ->t.b.length : any ->t.b : any ->t : any ->b : any ->length : any +>t.a + t.b.length : number +>t.a : number +>t : T +>a : number +>t.b.length : number +>t.b : string +>t : T +>b : string +>length : number >u.a - u.b.length : number ->u.a : any ->u : any ->a : any ->u.b.length : any ->u.b : any ->u : any ->b : any ->length : any ->v.c : any ->v : any ->c : any +>u.a : number +>u : U +>a : number +>u.b.length : number +>u.b : string +>u : U +>b : string +>length : number +>v.c : boolean +>v : V +>c : boolean return w; ->w : any +>w : W } return x; ->x : any +>x : X } f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); ->f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope') : any ->f : (t: any, u: any, v: any, w: any, x: any) => any +>f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope') : "nope" | 101 +>f : (t: T, u: U, v: V, w: W, x: X) => W | X >{ a: 12, b: 'hi', c: null } : { a: number; b: string; c: null; } >a : number >12 : 12 @@ -63,8 +63,8 @@ f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101 >'hi' : "hi" >c : null >undefined : undefined ->{ c: false, d: 12, b: undefined } : { c: boolean; d: number; b: undefined; } ->c : boolean +>{ c: false, d: 12, b: undefined } : { c: false; d: number; b: undefined; } +>c : false >false : false >d : number >12 : 12 @@ -74,8 +74,8 @@ f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101 >'nope' : "nope" f({ a: 12 }, undefined, undefined, 101, 'nope'); ->f({ a: 12 }, undefined, undefined, 101, 'nope') : any ->f : (t: any, u: any, v: any, w: any, x: any) => any +>f({ a: 12 }, undefined, undefined, 101, 'nope') : "nope" | 101 +>f : (t: T, u: U, v: V, w: W, x: X) => W | X >{ a: 12 } : { a: number; } >a : number >12 : 12 @@ -90,7 +90,7 @@ f({ a: 12 }, undefined, undefined, 101, 'nope'); * @param {T} x */ function g(x) { } ->g : (x: any) => void ->x : any +>g : (x: T) => void +>x : T diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.types index 78ce5cb9d5..21efece73b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.types @@ -8,7 +8,7 @@ * @template V */ function Multimap() { ->Multimap : () => void +>Multimap : () => void /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; @@ -28,7 +28,7 @@ Multimap.prototype.get = function (key) { >Multimap.prototype.get = function (key) { return this._map[key + ''];} : (key: any) => any >Multimap.prototype.get : any >Multimap.prototype : any ->Multimap : () => void +>Multimap : () => void >prototype : any >get : any >function (key) { return this._map[key + ''];} : (key: any) => any @@ -51,8 +51,8 @@ Multimap.prototype.get = function (key) { * @template V */ var Multimap2 = function() { ->Multimap2 : () => void ->function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : () => void +>Multimap2 : () => void +>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : () => void /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; @@ -72,7 +72,7 @@ Multimap2.prototype.get = function (key) { >Multimap2.prototype.get = function (key) { return this._map[key + ''];} : (key: any) => any >Multimap2.prototype.get : any >Multimap2.prototype : any ->Multimap2 : () => void +>Multimap2 : () => void >prototype : any >get : any >function (key) { return this._map[key + ''];} : (key: any) => any diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt index ec88758a45..3327c8ae09 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt @@ -1,16 +1,18 @@ a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -a.js(17,5): error TS7023: 'get' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -a.js(17,9): error TS7006: Parameter 'key' implicitly has an 'any' type. -a.js(18,21): error TS2339: Property '_map' does not exist on type '{ get: (key: any) => any; }'. +a.js(14,16): error TS2304: Cannot find name 'K'. +a.js(15,18): error TS2304: Cannot find name 'V'. +a.js(18,21): error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. a.js(30,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -a.js(38,19): error TS7006: Parameter 'key' implicitly has an 'any' type. +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(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(60,9): error TS7006: Parameter 'key' implicitly has an 'any' type. +a.js(57,16): error TS2304: Cannot find name 'K'. +a.js(58,18): error TS2304: Cannot find name 'V'. -==== a.js (10 errors) ==== +==== a.js (12 errors) ==== /** * Should work for function declarations * @constructor @@ -27,16 +29,16 @@ a.js(60,9): error TS7006: Parameter 'key' implicitly has an 'any' type. Multimap.prototype = { /** * @param {K} key the key ok + ~ +!!! error TS2304: Cannot find name 'K'. * @returns {V} the value ok + ~ +!!! error TS2304: Cannot find name 'V'. */ get(key) { - ~~~ -!!! error TS7023: 'get' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. - ~~~ -!!! error TS7006: Parameter 'key' implicitly has an 'any' type. return this._map[key + '']; ~~~~ -!!! error TS2339: Property '_map' does not exist on type '{ get: (key: any) => any; }'. +!!! error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. } } @@ -56,11 +58,13 @@ a.js(60,9): error TS7006: Parameter 'key' implicitly has an 'any' type. Multimap2.prototype = { /** * @param {K} key the key ok + ~ +!!! error TS2304: Cannot find name 'K'. * @returns {V} the value ok + ~ +!!! error TS2304: Cannot find name 'V'. */ get: function(key) { - ~~~ -!!! error TS7006: Parameter 'key' implicitly has an 'any' type. return this._map[key + '']; } } @@ -86,11 +90,13 @@ a.js(60,9): error TS7006: Parameter 'key' implicitly has an 'any' type. !!! error TS2339: Property 'Multimap3' does not exist on type '{}'. /** * @param {K} key the key ok + ~ +!!! error TS2304: Cannot find name 'K'. * @returns {V} the value ok + ~ +!!! error TS2304: Cannot find name 'V'. */ get(key) { - ~~~ -!!! error TS7006: Parameter 'key' implicitly has an 'any' type. return this._map[key + '']; } } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.types index 928925bb55..345d3bf137 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.types @@ -8,7 +8,7 @@ * @template V */ function Multimap() { ->Multimap : { (): void; prototype: { get: (key: any) => any; }; } +>Multimap : { (): void; prototype: { get: (key: K) => V; }; } /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; @@ -21,27 +21,27 @@ function Multimap() { }; Multimap.prototype = { ->Multimap.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } ->Multimap.prototype : { get: (key: any) => any; } ->Multimap : { (): void; prototype: { get: (key: any) => any; }; } ->prototype : { get: (key: any) => any; } ->{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } +>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; } +>Multimap : { (): void; prototype: { get: (key: K) => V; }; } +>prototype : { get: (key: K) => V; } +>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: K) => V; } /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { ->get : (key: any) => any ->key : any +>get : (key: K) => V +>key : K return this._map[key + '']; >this._map[key + ''] : any >this._map : any ->this : { get: (key: any) => any; } +>this : { get: (key: K) => V; } >_map : any >key + '' : string ->key : any +>key : K >'' : "" } } @@ -53,8 +53,8 @@ Multimap.prototype = { * @template V */ var Multimap2 = function() { ->Multimap2 : () => void ->function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : () => void +>Multimap2 : () => void +>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : () => void /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; @@ -67,20 +67,20 @@ var Multimap2 = function() { }; Multimap2.prototype = { ->Multimap2.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: any) => any; } +>Multimap2.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: K) => V; } >Multimap2.prototype : any ->Multimap2 : () => void +>Multimap2 : () => void >prototype : any ->{ /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: any) => any; } +>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: K) => V; } /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { ->get : (key: any) => any ->function(key) { return this._map[key + '']; } : (key: any) => any ->key : any +>get : (key: K) => V +>function(key) { return this._map[key + '']; } : (key: K) => V +>key : K return this._map[key + '']; >this._map[key + ''] : any @@ -88,7 +88,7 @@ Multimap2.prototype = { >this : any >_map : any >key + '' : string ->key : any +>key : K >'' : "" } } @@ -121,21 +121,21 @@ Ns.Multimap3 = function() { }; Ns.Multimap3.prototype = { ->Ns.Multimap3.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } +>Ns.Multimap3.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: K) => V; } >Ns.Multimap3.prototype : any >Ns.Multimap3 : any >Ns : {} >Multimap3 : any >prototype : any ->{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } +>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: K) => V; } /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { ->get : (key: any) => any ->key : any +>get : (key: K) => V +>key : K return this._map[key + '']; >this._map[key + ''] : any @@ -143,7 +143,7 @@ Ns.Multimap3.prototype = { >this : any >_map : any >key + '' : string ->key : any +>key : K >'' : "" } } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt deleted file mode 100644 index da3c62e1ff..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt +++ /dev/null @@ -1,115 +0,0 @@ -a.js(6,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -a.js(18,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -a.js(30,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -a.js(41,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -a.js(52,13): error TS7006: Parameter 'obj' implicitly has an 'any' type. -a.js(65,17): error TS7006: Parameter 'x' implicitly has an 'any' type. -a.js(71,9): error TS7006: Parameter 'x' implicitly has an 'any' type. -a.js(84,13): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. - - -==== a.js (8 errors) ==== - /** - * @template const T - * @param {T} x - * @returns {T} - */ - function f1(x) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - return x; - } - const t1 = f1("a"); - const t2 = f1(["a", ["b", "c"]]); - const t3 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); - - /** - * @template const T, U - * @param {T} x - * @returns {T} - */ - function f2(x) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - return x; - }; - const t4 = f2('a'); - const t5 = f2(['a', ['b', 'c']]); - const t6 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); - - /** - * @template const T - * @param {T} x - * @returns {T[]} - */ - function f3(x) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - return [x]; - } - const t7 = f3("hello"); - const t8 = f3("hello"); - - /** - * @template const T - * @param {[T, T]} x - * @returns {T} - */ - function f4(x) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - return x[0]; - } - const t9 = f4([[1, "x"], [2, "y"]]); - const t10 = f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]); - - /** - * @template const T - * @param {{ x: T, y: T}} obj - * @returns {T} - */ - function f5(obj) { - ~~~ -!!! error TS7006: Parameter 'obj' implicitly has an 'any' type. - return obj.x; - } - const t11 = f5({ x: [1, "x"], y: [2, "y"] }); - const t12 = f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }); - - /** - * @template const T - */ - class C { - /** - * @param {T} x - */ - constructor(x) {} - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - - /** - * @template const U - * @param {U} x - */ - foo(x) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - return x; - } - } - - const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); - const t14 = t13.foo(["a", ["b", "c"]]); - - /** - * @template {readonly unknown[]} const T - * @param {T} args - * @returns {T} - */ - function f6(...args) { - ~~~~~~~ -!!! error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. - return args; - } - const t15 = f6(1, 'b', { a: 1, b: 'x' }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.symbols b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.symbols index e885cba37e..ab292c55c2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.symbols @@ -89,6 +89,7 @@ function f4(x) { return x[0]; >x : Symbol(x, Decl(a.js, 40, 12)) +>0 : Symbol(0) } const t9 = f4([[1, "x"], [2, "y"]]); >t9 : Symbol(t9, Decl(a.js, 43, 5)) @@ -112,7 +113,9 @@ function f5(obj) { >obj : Symbol(obj, Decl(a.js, 51, 12)) return obj.x; +>obj.x : Symbol(x, Decl(a.js, 48, 12)) >obj : Symbol(obj, Decl(a.js, 51, 12)) +>x : Symbol(x, Decl(a.js, 48, 12)) } const t11 = f5({ x: [1, "x"], y: [2, "y"] }); >t11 : Symbol(t11, Decl(a.js, 54, 5)) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.symbols.diff index 78d72ec4b2..c00aee2b03 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.symbols.diff @@ -1,24 +1,6 @@ --- old.jsdocTemplateTag6.symbols +++ new.jsdocTemplateTag6.symbols -@@= skipped -88, +88 lines =@@ - - return x[0]; - >x : Symbol(x, Decl(a.js, 40, 12)) -->0 : Symbol(0) - } - const t9 = f4([[1, "x"], [2, "y"]]); - >t9 : Symbol(t9, Decl(a.js, 43, 5)) -@@= skipped -24, +23 lines =@@ - >obj : Symbol(obj, Decl(a.js, 51, 12)) - - return obj.x; -->obj.x : Symbol(x, Decl(a.js, 48, 12)) - >obj : Symbol(obj, Decl(a.js, 51, 12)) -->x : Symbol(x, Decl(a.js, 48, 12)) - } - const t11 = f5({ x: [1, "x"], y: [2, "y"] }); - >t11 : Symbol(t11, Decl(a.js, 54, 5)) -@@= skipped -37, +35 lines =@@ +@@= skipped -149, +149 lines =@@ * @param {U} x */ foo(x) { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.types index b439a702d9..c1916c5cf0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.types @@ -7,44 +7,44 @@ * @returns {T} */ function f1(x) { ->f1 : (x: any) => any ->x : any +>f1 : (x: T) => T +>x : T return x; ->x : any +>x : T } const t1 = f1("a"); ->t1 : any ->f1("a") : any ->f1 : (x: any) => any +>t1 : "a" +>f1("a") : "a" +>f1 : (x: T) => T >"a" : "a" const t2 = f1(["a", ["b", "c"]]); ->t2 : any ->f1(["a", ["b", "c"]]) : any ->f1 : (x: any) => any ->["a", ["b", "c"]] : (string | string[])[] +>t2 : readonly ["a", readonly ["b", "c"]] +>f1(["a", ["b", "c"]]) : readonly ["a", readonly ["b", "c"]] +>f1 : (x: T) => T +>["a", ["b", "c"]] : ["a", ["b", "c"]] >"a" : "a" ->["b", "c"] : string[] +>["b", "c"] : ["b", "c"] >"b" : "b" >"c" : "c" const t3 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); ->t3 : any ->f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : any ->f1 : (x: any) => any ->{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: number; b: string; d: (string | number | boolean | { f: string; })[]; } ->a : number +>t3 : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } +>f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } +>f1 : (x: T) => T +>{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: 1; b: "c"; d: ["e", 2, true, { f: "g"; }]; } +>a : 1 >1 : 1 ->b : string +>b : "c" >"c" : "c" ->d : (string | number | boolean | { f: string; })[] ->["e", 2, true, { f: "g" }] : (string | number | boolean | { f: string; })[] +>d : ["e", 2, true, { f: "g"; }] +>["e", 2, true, { f: "g" }] : ["e", 2, true, { f: "g"; }] >"e" : "e" >2 : 2 >true : true ->{ f: "g" } : { f: string; } ->f : string +>{ f: "g" } : { f: "g"; } +>f : "g" >"g" : "g" /** @@ -53,45 +53,45 @@ const t3 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); * @returns {T} */ function f2(x) { ->f2 : (x: any) => any ->x : any +>f2 : (x: T) => T +>x : T return x; ->x : any +>x : T }; const t4 = f2('a'); ->t4 : any ->f2('a') : any ->f2 : (x: any) => any +>t4 : "a" +>f2('a') : "a" +>f2 : (x: T) => T >'a' : "a" const t5 = f2(['a', ['b', 'c']]); ->t5 : any ->f2(['a', ['b', 'c']]) : any ->f2 : (x: any) => any ->['a', ['b', 'c']] : (string | string[])[] +>t5 : readonly ["a", readonly ["b", "c"]] +>f2(['a', ['b', 'c']]) : readonly ["a", readonly ["b", "c"]] +>f2 : (x: T) => T +>['a', ['b', 'c']] : ["a", ["b", "c"]] >'a' : "a" ->['b', 'c'] : string[] +>['b', 'c'] : ["b", "c"] >'b' : "b" >'c' : "c" const t6 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); ->t6 : any ->f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : any ->f2 : (x: any) => any ->{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: number; b: string; d: (string | number | boolean | { f: string; })[]; } ->a : number +>t6 : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } +>f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } +>f2 : (x: T) => T +>{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: 1; b: "c"; d: ["e", 2, true, { f: "g"; }]; } +>a : 1 >1 : 1 ->b : string +>b : "c" >"c" : "c" ->d : (string | number | boolean | { f: string; })[] ->["e", 2, true, { f: "g" }] : (string | number | boolean | { f: string; })[] +>d : ["e", 2, true, { f: "g"; }] +>["e", 2, true, { f: "g" }] : ["e", 2, true, { f: "g"; }] >"e" : "e" >2 : 2 >true : true ->{ f: "g" } : { f: string; } ->f : string +>{ f: "g" } : { f: "g"; } +>f : "g" >"g" : "g" /** @@ -100,23 +100,23 @@ const t6 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); * @returns {T[]} */ function f3(x) { ->f3 : (x: any) => any[] ->x : any +>f3 : (x: T) => T[] +>x : T return [x]; ->[x] : any[] ->x : any +>[x] : T[] +>x : T } const t7 = f3("hello"); ->t7 : any[] ->f3("hello") : any[] ->f3 : (x: any) => any[] +>t7 : "hello"[] +>f3("hello") : "hello"[] +>f3 : (x: T) => T[] >"hello" : "hello" const t8 = f3("hello"); ->t8 : any[] ->f3("hello") : any[] ->f3 : (x: any) => any[] +>t8 : "hello"[] +>f3("hello") : "hello"[] +>f3 : (x: T) => T[] >"hello" : "hello" /** @@ -125,40 +125,40 @@ const t8 = f3("hello"); * @returns {T} */ function f4(x) { ->f4 : (x: any) => any ->x : any +>f4 : (x: [T, T]) => T +>x : [T, T] return x[0]; ->x[0] : any ->x : any +>x[0] : T +>x : [T, T] >0 : 0 } const t9 = f4([[1, "x"], [2, "y"]]); ->t9 : any ->f4([[1, "x"], [2, "y"]]) : any ->f4 : (x: any) => any ->[[1, "x"], [2, "y"]] : (string | number)[][] ->[1, "x"] : (string | number)[] +>t9 : readonly [1, "x"] | readonly [2, "y"] +>f4([[1, "x"], [2, "y"]]) : readonly [1, "x"] | readonly [2, "y"] +>f4 : (x: [T, T]) => T +>[[1, "x"], [2, "y"]] : [[1, "x"], [2, "y"]] +>[1, "x"] : [1, "x"] >1 : 1 >"x" : "x" ->[2, "y"] : (string | number)[] +>[2, "y"] : [2, "y"] >2 : 2 >"y" : "y" const t10 = f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]); ->t10 : any ->f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]) : any ->f4 : (x: any) => any ->[{ a: 1, b: "x" }, { a: 2, b: "y" }] : { a: number; b: string; }[] ->{ a: 1, b: "x" } : { a: number; b: string; } ->a : number +>t10 : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } +>f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]) : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } +>f4 : (x: [T, T]) => T +>[{ a: 1, b: "x" }, { a: 2, b: "y" }] : [{ a: 1; b: "x"; }, { a: 2; b: "y"; }] +>{ a: 1, b: "x" } : { a: 1; b: "x"; } +>a : 1 >1 : 1 ->b : string +>b : "x" >"x" : "x" ->{ a: 2, b: "y" } : { a: number; b: string; } ->a : number +>{ a: 2, b: "y" } : { a: 2; b: "y"; } +>a : 2 >2 : 2 ->b : string +>b : "y" >"y" : "y" /** @@ -167,98 +167,98 @@ const t10 = f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]); * @returns {T} */ function f5(obj) { ->f5 : (obj: any) => any ->obj : any +>f5 : (obj: { x: T; y: T; }) => T +>obj : { x: T; y: T; } return obj.x; ->obj.x : any ->obj : any ->x : any +>obj.x : T +>obj : { x: T; y: T; } +>x : T } const t11 = f5({ x: [1, "x"], y: [2, "y"] }); ->t11 : any ->f5({ x: [1, "x"], y: [2, "y"] }) : any ->f5 : (obj: any) => any ->{ x: [1, "x"], y: [2, "y"] } : { x: (string | number)[]; y: (string | number)[]; } ->x : (string | number)[] ->[1, "x"] : (string | number)[] +>t11 : readonly [1, "x"] | readonly [2, "y"] +>f5({ x: [1, "x"], y: [2, "y"] }) : readonly [1, "x"] | readonly [2, "y"] +>f5 : (obj: { x: T; y: T; }) => T +>{ x: [1, "x"], y: [2, "y"] } : { x: [1, "x"]; y: [2, "y"]; } +>x : [1, "x"] +>[1, "x"] : [1, "x"] >1 : 1 >"x" : "x" ->y : (string | number)[] ->[2, "y"] : (string | number)[] +>y : [2, "y"] +>[2, "y"] : [2, "y"] >2 : 2 >"y" : "y" const t12 = f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }); ->t12 : any ->f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }) : any ->f5 : (obj: any) => any ->{ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } } : { x: { a: number; b: string; }; y: { a: number; b: string; }; } ->x : { a: number; b: string; } ->{ a: 1, b: "x" } : { a: number; b: string; } ->a : number +>t12 : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } +>f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }) : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } +>f5 : (obj: { x: T; y: T; }) => T +>{ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } } : { x: { a: 1; b: "x"; }; y: { a: 2; b: "y"; }; } +>x : { a: 1; b: "x"; } +>{ a: 1, b: "x" } : { a: 1; b: "x"; } +>a : 1 >1 : 1 ->b : string +>b : "x" >"x" : "x" ->y : { a: number; b: string; } ->{ a: 2, b: "y" } : { a: number; b: string; } ->a : number +>y : { a: 2; b: "y"; } +>{ a: 2, b: "y" } : { a: 2; b: "y"; } +>a : 2 >2 : 2 ->b : string +>b : "y" >"y" : "y" /** * @template const T */ class C { ->C : C +>C : C /** * @param {T} x */ constructor(x) {} ->x : any +>x : T /** * @template const U * @param {U} x */ foo(x) { ->foo : (x: any) => any ->x : any +>foo : (x: U) => U +>x : U return x; ->x : any +>x : U } } const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); ->t13 : C ->new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : C +>t13 : C<{ readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; }> +>new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : C<{ readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; }> >C : typeof C ->{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: number; b: string; d: (string | number | boolean | { f: string; })[]; } ->a : number +>{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: 1; b: "c"; d: ["e", 2, true, { f: "g"; }]; } +>a : 1 >1 : 1 ->b : string +>b : "c" >"c" : "c" ->d : (string | number | boolean | { f: string; })[] ->["e", 2, true, { f: "g" }] : (string | number | boolean | { f: string; })[] +>d : ["e", 2, true, { f: "g"; }] +>["e", 2, true, { f: "g" }] : ["e", 2, true, { f: "g"; }] >"e" : "e" >2 : 2 >true : true ->{ f: "g" } : { f: string; } ->f : string +>{ f: "g" } : { f: "g"; } +>f : "g" >"g" : "g" const t14 = t13.foo(["a", ["b", "c"]]); ->t14 : any ->t13.foo(["a", ["b", "c"]]) : any ->t13.foo : (x: any) => any ->t13 : C ->foo : (x: any) => any ->["a", ["b", "c"]] : (string | string[])[] +>t14 : readonly ["a", readonly ["b", "c"]] +>t13.foo(["a", ["b", "c"]]) : readonly ["a", readonly ["b", "c"]] +>t13.foo : (x: U) => U +>t13 : C<{ readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; }> +>foo : (x: U) => U +>["a", ["b", "c"]] : ["a", ["b", "c"]] >"a" : "a" ->["b", "c"] : string[] +>["b", "c"] : ["b", "c"] >"b" : "b" >"c" : "c" @@ -268,21 +268,21 @@ const t14 = t13.foo(["a", ["b", "c"]]); * @returns {T} */ function f6(...args) { ->f6 : (...args: any[]) => any[] ->args : any[] +>f6 : (...args: T) => T +>args : T return args; ->args : any[] +>args : T } const t15 = f6(1, 'b', { a: 1, b: 'x' }); ->t15 : any[] ->f6(1, 'b', { a: 1, b: 'x' }) : any[] ->f6 : (...args: any[]) => any[] +>t15 : readonly [1, "b", { readonly a: 1; readonly b: "x"; }] +>f6(1, 'b', { a: 1, b: 'x' }) : readonly [1, "b", { readonly a: 1; readonly b: "x"; }] +>f6 : (...args: T) => T >1 : 1 >'b' : "b" ->{ a: 1, b: 'x' } : { a: number; b: string; } ->a : number +>{ a: 1, b: 'x' } : { a: 1; b: "x"; } +>a : 1 >1 : 1 ->b : string +>b : "x" >'x' : "x" diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt index f0d82db191..6d5770242e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt @@ -1,9 +1,12 @@ -a.js(16,12): error TS7006: Parameter 'x' implicitly has an 'any' type. +a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== /** * @template const T + ~~~~~ +!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class * @typedef {[T]} X */ @@ -14,12 +17,12 @@ a.js(16,12): error TS7006: Parameter 'x' implicitly has an 'any' type. /** * @template private T + ~~~~~~~ +!!! error TS1273: 'private' modifier cannot appear on a type parameter * @param {T} x * @returns {T} */ function f(x) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. return x; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.types index a1eca4340e..7a49d72b4a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.types @@ -10,7 +10,7 @@ * @template const T */ class C { } ->C : C +>C : C /** * @template private T @@ -18,10 +18,10 @@ class C { } * @returns {T} */ function f(x) { ->f : (x: any) => any ->x : any +>f : (x: T) => T +>x : T return x; ->x : any +>x : T } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt index 55ac7a5647..348848a9e7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt @@ -1,22 +1,26 @@ -a.js(17,1): error TS2322: Type '{ x: string; }' is not assignable to type '{ x: number; }'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type 'number'. -a.js(18,1): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. - Types of property 'x' are incompatible. - Type 'number' is not assignable to type 'string'. +a.js(2,14): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias +a.js(18,1): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. + Type 'unknown' is not assignable to type 'string'. +a.js(21,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias a.js(29,33): error TS7006: Parameter 'x' implicitly has an 'any' type. a.js(34,31): error TS7006: Parameter 'x' implicitly has an 'any' type. +a.js(36,1): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. + Type 'unknown' is not assignable to type 'string'. +a.js(40,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias a.js(48,29): error TS7006: Parameter 'x' implicitly has an 'any' type. a.js(53,27): error TS7006: Parameter 'x' implicitly has an 'any' type. -a.js(56,1): error TS2322: Type '{ f: (x: any) => void; }' is not assignable to type '{ f: (x: any) => string; }'. - The types returned by 'f(...)' are incompatible between these types. - Type 'void' is not assignable to type 'string'. -a.js(62,12): error TS7006: Parameter 'x' implicitly has an 'any' type. +a.js(55,1): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. + Type 'unknown' is not assignable to type 'string'. +a.js(56,1): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. + Type 'unknown' is not assignable to type 'string'. +a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias -==== a.js (8 errors) ==== +==== a.js (12 errors) ==== /** * @template out T + ~~~ +!!! error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Covariant * @property {T} x */ @@ -32,18 +36,15 @@ a.js(62,12): error TS7006: Parameter 'x' implicitly has an 'any' type. let sub_covariant = { x: '' }; super_covariant = sub_covariant; - ~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ x: string; }' is not assignable to type '{ x: number; }'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. sub_covariant = super_covariant; // Error ~~~~~~~~~~~~~ -!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. /** * @template in T + ~~ +!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Contravariant * @property {(x: T) => void} f */ @@ -63,10 +64,15 @@ a.js(62,12): error TS7006: Parameter 'x' implicitly has an 'any' type. !!! error TS7006: Parameter 'x' implicitly has an 'any' type. super_contravariant = sub_contravariant; // Error + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. sub_contravariant = super_contravariant; /** * @template in out T + ~~ +!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Invariant * @property {(x: T) => T} f */ @@ -86,17 +92,19 @@ a.js(62,12): error TS7006: Parameter 'x' implicitly has an 'any' type. !!! error TS7006: Parameter 'x' implicitly has an 'any' type. super_invariant = sub_invariant; // Error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. sub_invariant = super_invariant; // Error ~~~~~~~~~~~~~ -!!! error TS2322: Type '{ f: (x: any) => void; }' is not assignable to type '{ f: (x: any) => string; }'. -!!! error TS2322: The types returned by 'f(...)' are incompatible between these types. -!!! error TS2322: Type 'void' is not assignable to type 'string'. +!!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +!!! error TS2322: Type 'unknown' is not assignable to type 'string'. /** * @template in T + ~~ +!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @param {T} x */ function f(x) {} - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.types index f194e5d4d7..87dbc6fdee 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.types @@ -11,7 +11,7 @@ * @type {Covariant} */ let super_covariant = { x: 1 }; ->super_covariant : { x: number; } +>super_covariant : Covariant >{ x: 1 } : { x: number; } >x : number >1 : 1 @@ -20,20 +20,20 @@ let super_covariant = { x: 1 }; * @type {Covariant} */ let sub_covariant = { x: '' }; ->sub_covariant : { x: string; } +>sub_covariant : Covariant >{ x: '' } : { x: string; } >x : string >'' : "" super_covariant = sub_covariant; ->super_covariant = sub_covariant : { x: string; } ->super_covariant : { x: number; } ->sub_covariant : { x: string; } +>super_covariant = sub_covariant : Covariant +>super_covariant : Covariant +>sub_covariant : Covariant sub_covariant = super_covariant; // Error ->sub_covariant = super_covariant : { x: number; } ->sub_covariant : { x: string; } ->super_covariant : { x: number; } +>sub_covariant = super_covariant : Covariant +>sub_covariant : Covariant +>super_covariant : Covariant /** * @template in T @@ -45,7 +45,7 @@ sub_covariant = super_covariant; // Error * @type {Contravariant} */ let super_contravariant = { f: (x) => {} }; ->super_contravariant : { f: (x: any) => void; } +>super_contravariant : Contravariant >{ f: (x) => {} } : { f: (x: any) => void; } >f : (x: any) => void >(x) => {} : (x: any) => void @@ -55,21 +55,21 @@ let super_contravariant = { f: (x) => {} }; * @type {Contravariant} */ let sub_contravariant = { f: (x) => {} }; ->sub_contravariant : { f: (x: any) => void; } +>sub_contravariant : Contravariant >{ f: (x) => {} } : { f: (x: any) => void; } >f : (x: any) => void >(x) => {} : (x: any) => void >x : any super_contravariant = sub_contravariant; // Error ->super_contravariant = sub_contravariant : { f: (x: any) => void; } ->super_contravariant : { f: (x: any) => void; } ->sub_contravariant : { f: (x: any) => void; } +>super_contravariant = sub_contravariant : Contravariant +>super_contravariant : Contravariant +>sub_contravariant : Contravariant sub_contravariant = super_contravariant; ->sub_contravariant = super_contravariant : { f: (x: any) => void; } ->sub_contravariant : { f: (x: any) => void; } ->super_contravariant : { f: (x: any) => void; } +>sub_contravariant = super_contravariant : Contravariant +>sub_contravariant : Contravariant +>super_contravariant : Contravariant /** * @template in out T @@ -81,7 +81,7 @@ sub_contravariant = super_contravariant; * @type {Invariant} */ let super_invariant = { f: (x) => {} }; ->super_invariant : { f: (x: any) => void; } +>super_invariant : Invariant >{ f: (x) => {} } : { f: (x: any) => void; } >f : (x: any) => void >(x) => {} : (x: any) => void @@ -91,7 +91,7 @@ let super_invariant = { f: (x) => {} }; * @type {Invariant} */ let sub_invariant = { f: (x) => { return "" } }; ->sub_invariant : { f: (x: any) => string; } +>sub_invariant : Invariant >{ f: (x) => { return "" } } : { f: (x: any) => string; } >f : (x: any) => string >(x) => { return "" } : (x: any) => string @@ -99,20 +99,20 @@ let sub_invariant = { f: (x) => { return "" } }; >"" : "" super_invariant = sub_invariant; // Error ->super_invariant = sub_invariant : { f: (x: any) => string; } ->super_invariant : { f: (x: any) => void; } ->sub_invariant : { f: (x: any) => string; } +>super_invariant = sub_invariant : Invariant +>super_invariant : Invariant +>sub_invariant : Invariant sub_invariant = super_invariant; // Error ->sub_invariant = super_invariant : { f: (x: any) => void; } ->sub_invariant : { f: (x: any) => string; } ->super_invariant : { f: (x: any) => void; } +>sub_invariant = super_invariant : Invariant +>sub_invariant : Invariant +>super_invariant : Invariant /** * @template in T * @param {T} x */ function f(x) {} ->f : (x: any) => void ->x : any +>f : (x: T) => void +>x : T diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt new file mode 100644 index 0000000000..3e6ab1d570 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt @@ -0,0 +1,90 @@ +file.js(3,15): error TS2304: Cannot find name 'T'. +file.js(33,14): error TS2706: Required type parameters may not follow optional type parameters. +file.js(38,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. +file.js(45,17): error TS2304: Cannot find name 'T'. +file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. +file.js(60,17): error TS2304: Cannot find name 'U'. +file.js(61,17): error TS2304: Cannot find name 'T'. + + +==== file.js (7 errors) ==== + /** + * @template {string | number} [T=string] - ok: defaults are permitted + * @typedef {[T]} A + ~ +!!! error TS2304: Cannot find name 'T'. + */ + + /** @type {A} */ // ok, default for `T` in `A` is `string` + const aDefault1 = [""]; + /** @type {A} */ // error: `number` is not assignable to string` + const aDefault2 = [0]; + /** @type {A} */ // ok, `T` is provided for `A` + const aString = [""]; + /** @type {A} */ // ok, `T` is provided for `A` + const aNumber = [0]; + + /** + * @template T + * @template [U=T] - ok: default can reference earlier type parameter + * @typedef {[T, U]} B + */ + + /** + * @template {string | number} [T] - error: default requires an `=type` + * @typedef {[T]} C + */ + + /** + * @template {string | number} [T=] - error: default requires a `type` + * @typedef {[T]} D + */ + + /** + * @template {string | number} [T=string] + * @template U - error: Required type parameters cannot follow optional type parameters + ~ +!!! error TS2706: Required type parameters may not follow optional type parameters. + * @typedef {[T, U]} E + */ + + /** + * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. + ~ +!!! error TS2744: Type parameter defaults can only reference previously declared type parameters. + * @template [U=T] + * @typedef {[T, U]} G + */ + + /** + * @template T + * @template [U=T] - ok: default can reference earlier type parameter + ~ +!!! error TS2304: Cannot find name 'T'. + * @param {T} a + * @param {U} b + */ + function f1(a, b) {} + + /** + * @template {string | number} [T=string] + * @template U - error: Required type parameters cannot follow optional type parameters + ~ +!!! error TS2706: Required type parameters may not follow optional type parameters. + * @param {T} a + * @param {U} b + */ + function f2(a, b) {} + + /** + * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. + ~ +!!! error TS2304: Cannot find name 'U'. + * @template [U=T] + ~ +!!! error TS2304: Cannot find name 'T'. + * @param {T} a + * @param {U} b + */ + function f3(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types index 841f1a4dea..c191b65f31 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types @@ -8,26 +8,26 @@ /** @type {A} */ // ok, default for `T` in `A` is `string` const aDefault1 = [""]; ->aDefault1 : string[] ->[""] : string[] +>aDefault1 : [T] +>[""] : [string] >"" : "" /** @type {A} */ // error: `number` is not assignable to string` const aDefault2 = [0]; ->aDefault2 : number[] ->[0] : number[] +>aDefault2 : [T] +>[0] : [number] >0 : 0 /** @type {A} */ // ok, `T` is provided for `A` const aString = [""]; ->aString : string[] ->[""] : string[] +>aString : [T] +>[""] : [string] >"" : "" /** @type {A} */ // ok, `T` is provided for `A` const aNumber = [0]; ->aNumber : number[] ->[0] : number[] +>aNumber : [T] +>[0] : [number] >0 : 0 /** @@ -65,9 +65,9 @@ const aNumber = [0]; * @param {U} b */ function f1(a, b) {} ->f1 : (a: any, b: any) => void ->a : any ->b : any +>f1 : (a: T, b: U) => void +>a : T +>b : U /** * @template {string | number} [T=string] @@ -76,9 +76,9 @@ function f1(a, b) {} * @param {U} b */ function f2(a, b) {} ->f2 : (a: any, b: any) => void ->a : any ->b : any +>f2 : (a: T, b: U) => void +>a : T +>b : U /** * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. @@ -87,7 +87,7 @@ function f2(a, b) {} * @param {U} b */ function f3(a, b) {} ->f3 : (a: any, b: any) => void ->a : any ->b : any +>f3 : (a: T, b: U) => void +>a : T +>b : U diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt new file mode 100644 index 0000000000..5aa1f20558 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt @@ -0,0 +1,22 @@ +file.js(3,21): error TS2304: Cannot find name 'T'. +file.js(4,14): error TS2304: Cannot find name 'T'. +file.js(4,16): error TS2304: Cannot find name 'K'. + + +==== file.js (3 errors) ==== + /** + * @template T + * @template {keyof T} K + ~ +!!! error TS2304: Cannot find name 'T'. + * @typedef {T[K]} Foo + ~ +!!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS2304: Cannot find name 'K'. + */ + + const x = { a: 1 }; + + /** @type {Foo} */ + const y = "a"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.types index 1579d9800d..5d05ab34ac 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.types @@ -15,6 +15,6 @@ const x = { a: 1 }; /** @type {Foo} */ const y = "a"; ->y : "a" +>y : T >"a" : "a" diff --git a/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt new file mode 100644 index 0000000000..94ee1d5f47 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt @@ -0,0 +1,50 @@ +/a.js(3,10): error TS2339: Property 'test' does not exist on type 'Foo'. +/a.js(13,10): error TS2339: Property 'test' does not exist on type 'Foo'. +/a.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + +==== /types.d.ts (0 errors) ==== + export interface Foo { + foo: () => void; + } + + export type M = (this: Foo) => void; + +==== /a.js (3 errors) ==== + /** @type {import('./types').M} */ + export const f1 = function() { + this.test(); + ~~~~ +!!! error TS2339: Property 'test' does not exist on type 'Foo'. + } + + /** @type {import('./types').M} */ + export function f2() { + this.test(); + } + + /** @type {(this: import('./types').Foo) => void} */ + export const f3 = function() { + this.test(); + ~~~~ +!!! error TS2339: Property 'test' does not exist on type 'Foo'. + } + + /** @type {(this: import('./types').Foo) => void} */ + export function f4() { + this.test(); + } + + /** @type {function(this: import('./types').Foo): void} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + export const f5 = function() { + this.test(); + } + + /** @type {function(this: import('./types').Foo): void} */ + export function f6() { + this.test(); + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocThisType.symbols b/testdata/baselines/reference/submodule/conformance/jsdocThisType.symbols index 308da31e12..f9fd5bc328 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocThisType.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsdocThisType.symbols @@ -19,6 +19,7 @@ export const f1 = function() { >f1 : Symbol(f1, Decl(a.js, 1, 12)) this.test(); +>this : Symbol(this, Decl(types.d.ts, 4, 17)) } /** @type {import('./types').M} */ @@ -33,6 +34,7 @@ export const f3 = function() { >f3 : Symbol(f3, Decl(a.js, 11, 12)) this.test(); +>this : Symbol(this, Decl(a.js, 10, 12)) } /** @type {(this: import('./types').Foo) => void} */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocThisType.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsdocThisType.symbols.diff index c988aae3fa..9b62092c66 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocThisType.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocThisType.symbols.diff @@ -9,15 +9,7 @@ } export type M = (this: Foo) => void; -@@= skipped -14, +14 lines =@@ - >f1 : Symbol(f1, Decl(a.js, 1, 12)) - - this.test(); -->this : Symbol(this, Decl(types.d.ts, 4, 17)) - } - - /** @type {import('./types').M} */ -@@= skipped -8, +7 lines =@@ +@@= skipped -22, +22 lines =@@ >f2 : Symbol(f2, Decl(a.js, 3, 1)) this.test(); @@ -25,15 +17,7 @@ } /** @type {(this: import('./types').Foo) => void} */ -@@= skipped -8, +7 lines =@@ - >f3 : Symbol(f3, Decl(a.js, 11, 12)) - - this.test(); -->this : Symbol(this, Decl(a.js, 10, 12)) - } - - /** @type {(this: import('./types').Foo) => void} */ -@@= skipped -8, +7 lines =@@ +@@= skipped -16, +15 lines =@@ >f4 : Symbol(f4, Decl(a.js, 13, 1)) this.test(); diff --git a/testdata/baselines/reference/submodule/conformance/jsdocThisType.types b/testdata/baselines/reference/submodule/conformance/jsdocThisType.types index 2596e8b37d..9ae04bcca9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocThisType.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocThisType.types @@ -13,13 +13,13 @@ export type M = (this: Foo) => void; === /a.js === /** @type {import('./types').M} */ export const f1 = function() { ->f1 : () => void ->function() { this.test();} : () => void +>f1 : M +>function() { this.test();} : (this: Foo) => void this.test(); >this.test() : any >this.test : any ->this : any +>this : Foo >test : any } @@ -36,13 +36,13 @@ export function f2() { /** @type {(this: import('./types').Foo) => void} */ export const f3 = function() { ->f3 : () => void ->function() { this.test();} : () => void +>f3 : (this: Foo) => void +>function() { this.test();} : (this: Foo) => void this.test(); >this.test() : any >this.test : any ->this : any +>this : Foo >test : any } @@ -59,7 +59,7 @@ export function f4() { /** @type {function(this: import('./types').Foo): void} */ export const f5 = function() { ->f5 : () => void +>f5 : function >function() { this.test();} : () => void this.test(); diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt new file mode 100644 index 0000000000..be8a7c7817 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt @@ -0,0 +1,17 @@ +index.js(1,12): error TS2304: Cannot find name 'AnyEffect'. +index.js(3,12): error TS2304: Cannot find name 'Third'. + + +==== dtsEquivalent.js (0 errors) ==== + /** @typedef {{[k: string]: any}} AnyEffect */ + /** @typedef {number} Third */ +==== index.js (2 errors) ==== + /** @type {AnyEffect} */ + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'AnyEffect'. + let b; + /** @type {Third} */ + ~~~~~ +!!! error TS2304: Cannot find name 'Third'. + let c; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.types index 43c7280932..d3c40ce2ed 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.types @@ -7,9 +7,9 @@ === index.js === /** @type {AnyEffect} */ let b; ->b : any +>b : AnyEffect /** @type {Third} */ let c; ->c : any +>c : Third diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt index 4bd269ce21..4b1d9f2cb3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt @@ -1,12 +1,15 @@ bug27342.js(1,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +bug27342.js(3,11): error TS2304: Cannot find name 'exports'. -==== bug27342.js (1 errors) ==== +==== bug27342.js (2 errors) ==== module.exports = {} ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** * @type {exports} + ~~~~~~~ +!!! error TS2304: Cannot find name 'exports'. */ var x diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.types index 7824eedfab..541485d3a9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.types @@ -12,6 +12,6 @@ module.exports = {} * @type {exports} */ var x ->x : any +>x : exports diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt index e7cbf8fc04..a7f7b62b4e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt @@ -1,8 +1,10 @@ jsdocTypeReferenceToImport.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`. jsdocTypeReferenceToImport.js(2,11): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +jsdocTypeReferenceToImport.js(3,12): error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? +jsdocTypeReferenceToImport.js(8,12): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? -==== jsdocTypeReferenceToImport.js (2 errors) ==== +==== jsdocTypeReferenceToImport.js (4 errors) ==== const C = require('./ex').C; ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -10,11 +12,15 @@ jsdocTypeReferenceToImport.js(2,11): error TS2580: Cannot find name 'require'. D ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @type {C} c */ + ~ +!!! error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? var c = new C() c.start c.end /** @type {D} c */ + ~ +!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? var d = new D() d.start d.end diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.types index c544827ab4..1250d4da7e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.types @@ -19,34 +19,34 @@ const D = require('./ex')?.C; /** @type {C} c */ var c = new C() ->c : any +>c : C >new C() : any >C : any c.start >c.start : any ->c : any +>c : C >start : any c.end >c.end : any ->c : any +>c : C >end : any /** @type {D} c */ var d = new D() ->d : any +>d : D >new D() : any >D : any d.start >d.start : any ->d : any +>d : D >start : any d.end >d.end : any ->d : any +>d : D >end : any === ex.d.ts === diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.types index 09304d9d02..1536a69a39 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.types @@ -20,13 +20,13 @@ module.exports = function MC() { /** @type {any} */ var x = {} ->x : {} +>x : any >{} : {} return new MW(x); >new MW(x) : any >MW : any ->x : {} +>x : any }; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt index 87c84ddade..a820680442 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt @@ -1,10 +1,13 @@ +jsdocTypeReferenceToMergedClass.js(2,12): error TS2503: Cannot find namespace 'Workspace'. jsdocTypeReferenceToMergedClass.js(6,11): error TS2339: Property 'Project' does not exist on type '{}'. jsdocTypeReferenceToMergedClass.js(7,11): error TS2339: Property 'Project' does not exist on type '{}'. -==== jsdocTypeReferenceToMergedClass.js (2 errors) ==== +==== jsdocTypeReferenceToMergedClass.js (3 errors) ==== var Workspace = {} /** @type {Workspace.Project} */ + ~~~~~~~~~ +!!! error TS2503: Cannot find namespace 'Workspace'. var p; p.isServiceProject() diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.types index 1fe6e733a2..785994e30f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.types @@ -7,12 +7,12 @@ var Workspace = {} /** @type {Workspace.Project} */ var p; ->p : any +>p : Project p.isServiceProject() >p.isServiceProject() : any >p.isServiceProject : any ->p : any +>p : Project >isServiceProject : any Workspace.Project = function wp() { } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt new file mode 100644 index 0000000000..bee4d86738 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt @@ -0,0 +1,11 @@ +foo.js(1,13): error TS2749: 'Image' refers to a value, but is being used as a type here. Did you mean 'typeof Image'? + + +==== foo.js (1 errors) ==== + /** @param {Image} image */ + ~~~~~ +!!! error TS2749: 'Image' refers to a value, but is being used as a type here. Did you mean 'typeof Image'? + function process(image) { + return new image(1, 1) + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.types index 3d0eab1009..4a2961cc36 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.types @@ -3,12 +3,12 @@ === foo.js === /** @param {Image} image */ function process(image) { ->process : (image: any) => any ->image : any +>process : (image: Image) => any +>image : Image return new image(1, 1) >new image(1, 1) : any ->image : any +>image : Image >1 : 1 >1 : 1 } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.types index b75db888d1..b70447a0bb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.types @@ -3,7 +3,7 @@ === bug25097.js === /** @type {C | null} */ const c = null ->c : any +>c : C class C { >C : C diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt index a7741d6821..399860b673 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt @@ -1,26 +1,18 @@ -b.ts(1,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'S' must be of type 'any', but here has type 'string'. -b.ts(2,5): error TS2403: Subsequent variable declarations must have the same type. Variable 's' must be of type 'any', but here has type 'string'. -b.ts(3,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'N' must be of type 'any', but here has type 'number'. -b.ts(4,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'n' must be of type 'any', but here has type 'number'. -b.ts(5,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'B' must be of type 'any', but here has type 'boolean'. -b.ts(6,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'any', but here has type 'boolean'. -b.ts(7,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'V' must be of type 'any', but here has type 'void'. -b.ts(8,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'v' must be of type 'any', but here has type 'void'. -b.ts(9,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'U' must be of type 'any', but here has type 'undefined'. -b.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'u' must be of type 'any', but here has type 'undefined'. -b.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'Nl' must be of type 'any', but here has type 'null'. -b.ts(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'nl' must be of type 'any', but here has type 'null'. -b.ts(13,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'A' must be of type 'any', but here has type 'any[]'. -b.ts(14,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'any[]'. -b.ts(15,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'P' must be of type 'any', but here has type 'Promise'. -b.ts(16,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'any', but here has type 'Promise'. -b.ts(17,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'nullable' must be of type 'any', but here has type 'number | null'. -b.ts(20,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'Func' must be of type 'any', but here has type 'Function'. -b.ts(21,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type 'any', but here has type '(s: string) => number'. -b.ts(22,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'ctor' must be of type 'any', but here has type 'new (s: string) => { s: string; }'. +a.js(19,12): error TS2304: Cannot find name 'Void'. +a.js(25,12): error TS2304: Cannot find name 'Undefined'. +a.js(31,12): error TS2304: Cannot find name 'Null'. +a.js(37,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). +a.js(40,12): error TS2552: Cannot find name 'array'. Did you mean 'Array'? +a.js(43,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). +a.js(46,12): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? +b.ts(1,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'S' must be of type 'String', but here has type 'string'. +b.ts(3,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'N' must be of type 'Number', but here has type 'number'. +b.ts(5,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'B' must be of type 'Boolean', but here has type 'boolean'. +b.ts(18,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'Obj' must be of type 'Object', but here has type 'any'. +b.ts(19,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'obj' must be of type 'object', but here has type 'any'. -==== a.js (0 errors) ==== +==== a.js (7 errors) ==== /** @type {String} */ var S; @@ -40,33 +32,48 @@ b.ts(22,5): error TS2403: Subsequent variable declarations must have the same ty var b; /** @type {Void} */ + ~~~~ +!!! error TS2304: Cannot find name 'Void'. var V; /** @type {void} */ var v; /** @type {Undefined} */ + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'Undefined'. var U; /** @type {undefined} */ var u; /** @type {Null} */ + ~~~~ +!!! error TS2304: Cannot find name 'Null'. var Nl; /** @type {null} */ var nl; /** @type {Array} */ + ~~~~~ +!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). var A; /** @type {array} */ + ~~~~~ +!!! error TS2552: Cannot find name 'array'. Did you mean 'Array'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Array' is declared here. var a; /** @type {Promise} */ + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). var P; /** @type {promise} */ + ~~~~~~~ +!!! error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? var p; /** @type {?number} */ @@ -87,87 +94,42 @@ b.ts(22,5): error TS2403: Subsequent variable declarations must have the same ty /** @type {new (s: string) => { s: string }} */ var ctor; -==== b.ts (20 errors) ==== +==== b.ts (5 errors) ==== var S: string; ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'S' must be of type 'any', but here has type 'string'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'S' must be of type 'String', but here has type 'string'. !!! related TS6203 a.js:2:5: 'S' was also declared here. var s: string; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 's' must be of type 'any', but here has type 'string'. -!!! related TS6203 a.js:5:5: 's' was also declared here. var N: number; ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'N' must be of type 'any', but here has type 'number'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'N' must be of type 'Number', but here has type 'number'. !!! related TS6203 a.js:8:5: 'N' was also declared here. var n: number - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'n' must be of type 'any', but here has type 'number'. -!!! related TS6203 a.js:11:5: 'n' was also declared here. var B: boolean; ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'B' must be of type 'any', but here has type 'boolean'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'B' must be of type 'Boolean', but here has type 'boolean'. !!! related TS6203 a.js:14:5: 'B' was also declared here. var b: boolean; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'any', but here has type 'boolean'. -!!! related TS6203 a.js:17:5: 'b' was also declared here. var V :void; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'V' must be of type 'any', but here has type 'void'. -!!! related TS6203 a.js:20:5: 'V' was also declared here. var v: void; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'v' must be of type 'any', but here has type 'void'. -!!! related TS6203 a.js:23:5: 'v' was also declared here. var U: undefined; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'U' must be of type 'any', but here has type 'undefined'. -!!! related TS6203 a.js:26:5: 'U' was also declared here. var u: undefined; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'u' must be of type 'any', but here has type 'undefined'. -!!! related TS6203 a.js:29:5: 'u' was also declared here. var Nl: null; - ~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Nl' must be of type 'any', but here has type 'null'. -!!! related TS6203 a.js:32:5: 'Nl' was also declared here. var nl: null; - ~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'nl' must be of type 'any', but here has type 'null'. -!!! related TS6203 a.js:35:5: 'nl' was also declared here. var A: any[]; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'A' must be of type 'any', but here has type 'any[]'. -!!! related TS6203 a.js:38:5: 'A' was also declared here. var a: any[]; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'any[]'. -!!! related TS6203 a.js:41:5: 'a' was also declared here. var P: Promise; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'P' must be of type 'any', but here has type 'Promise'. -!!! related TS6203 a.js:44:5: 'P' was also declared here. var p: Promise; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'any', but here has type 'Promise'. -!!! related TS6203 a.js:47:5: 'p' was also declared here. var nullable: number | null; - ~~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'nullable' must be of type 'any', but here has type 'number | null'. -!!! related TS6203 a.js:50:5: 'nullable' was also declared here. var Obj: any; + ~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Obj' must be of type 'Object', but here has type 'any'. +!!! related TS6203 a.js:53:5: 'Obj' was also declared here. var obj: any; + ~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'obj' must be of type 'object', but here has type 'any'. +!!! related TS6203 a.js:56:5: 'obj' was also declared here. var Func: Function; - ~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Func' must be of type 'any', but here has type 'Function'. -!!! related TS6203 a.js:59:5: 'Func' was also declared here. var f: (s: string) => number; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type 'any', but here has type '(s: string) => number'. -!!! related TS6203 a.js:62:5: 'f' was also declared here. var ctor: new (s: string) => { s: string }; - ~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'ctor' must be of type 'any', but here has type 'new (s: string) => { s: string; }'. -!!! related TS6203 a.js:65:5: 'ctor' was also declared here. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.types index fcf3d57cf5..612c3866a0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.types @@ -3,51 +3,51 @@ === a.js === /** @type {String} */ var S; ->S : any +>S : String /** @type {string} */ var s; ->s : any +>s : string /** @type {Number} */ var N; ->N : any +>N : Number /** @type {number} */ var n; ->n : any +>n : number /** @type {Boolean} */ var B; ->B : any +>B : Boolean /** @type {boolean} */ var b; ->b : any +>b : boolean /** @type {Void} */ var V; ->V : any +>V : Void /** @type {void} */ var v; ->v : any +>v : void /** @type {Undefined} */ var U; ->U : any +>U : Undefined /** @type {undefined} */ var u; ->u : any +>u : undefined /** @type {Null} */ var Nl; ->Nl : any +>Nl : Null /** @type {null} */ var nl; ->nl : any +>nl : null /** @type {Array} */ var A; @@ -55,7 +55,7 @@ var A; /** @type {array} */ var a; ->a : any +>a : array /** @type {Promise} */ var P; @@ -63,99 +63,99 @@ var P; /** @type {promise} */ var p; ->p : any +>p : promise /** @type {?number} */ var nullable; ->nullable : any +>nullable : number | null /** @type {Object} */ var Obj; ->Obj : any +>Obj : Object /** @type {object} */ var obj; ->obj : any +>obj : object /** @type {Function} */ var Func; ->Func : any +>Func : Function /** @type {(s: string) => number} */ var f; ->f : any +>f : (s: string) => number /** @type {new (s: string) => { s: string }} */ var ctor; ->ctor : any +>ctor : new (s: string) => { s: string; } === b.ts === var S: string; ->S : any +>S : String var s: string; ->s : any +>s : string var N: number; ->N : any +>N : Number var n: number ->n : any +>n : number var B: boolean; ->B : any +>B : Boolean var b: boolean; ->b : any +>b : boolean var V :void; ->V : any +>V : Void var v: void; ->v : any +>v : void var U: undefined; ->U : any +>U : Undefined var u: undefined; ->u : any +>u : undefined var Nl: null; ->Nl : any +>Nl : Null var nl: null; ->nl : any +>nl : null var A: any[]; >A : any var a: any[]; ->a : any +>a : array var P: Promise; >P : any var p: Promise; ->p : any +>p : promise var nullable: number | null; ->nullable : any +>nullable : number | null var Obj: any; ->Obj : any +>Obj : Object var obj: any; ->obj : any +>obj : object var Func: Function; ->Func : any +>Func : Function var f: (s: string) => number; ->f : any +>f : (s: string) => number >s : string var ctor: new (s: string) => { s: string }; ->ctor : any +>ctor : new (s: string) => { s: string; } >s : string >s : string diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt index 2cad807110..2cac730ae2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt @@ -1,26 +1,24 @@ -b.js(2,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'W' must be of type 'string', but here has type 'number'. -b.js(4,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'W' must be of type 'string', but here has type 'number'. -b.js(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'string'. -b.js(13,5): error TS2403: Subsequent variable declarations must have the same type. Variable 's' must be of type 'any', but here has type 'string'. +b.js(4,31): 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. b.js(17,14): error TS2339: Property 'p' does not exist on type 'SomeBase'. b.js(23,14): error TS2339: Property 'x' does not exist on type 'SomeDerived'. b.js(28,14): error TS2339: Property 'q' does not exist on type 'SomeOther'. +b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. +b.js(66,38): error TS2454: Variable 'numOrStr' is used before being assigned. +b.js(67,2): error TS2322: Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. +b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. ==== a.ts (0 errors) ==== var W: string; -==== b.js (7 errors) ==== +==== b.js (8 errors) ==== // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'W' must be of type 'string', but here has type 'number'. -!!! related TS6203 a.ts:1:5: 'W' was also declared here. var W = /** @type {string} */(4); // Error - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'W' must be of type 'string', but here has type 'number'. -!!! related TS6203 a.ts:1:5: 'W' was also declared here. + ~ +!!! 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. /** @type {*} */ var a; @@ -29,13 +27,7 @@ b.js(28,14): error TS2339: Property 'q' does not exist on type 'SomeOther'. var s; var a = /** @type {*} */("" + 4); - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'string'. -!!! related TS6203 b.js:7:5: 'a' was also declared here. var s = "" + /** @type {*} */(4); - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 's' must be of type 'any', but here has type 'string'. -!!! related TS6203 b.js:10:5: 's' was also declared here. class SomeBase { constructor() { @@ -95,7 +87,16 @@ b.js(28,14): error TS2339: Property 'q' does not exist on type 'SomeOther'. /** @type {string} */ var str; if(/** @type {numOrStr is string} */(numOrStr === undefined)) { // Error + ~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + ~~~~~~~~ +!!! error TS2454: Variable 'numOrStr' is used before being assigned. str = numOrStr; // Error, no narrowing occurred + ~~~ +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + ~~~~~~~~ +!!! error TS2454: Variable 'numOrStr' is used before being assigned. } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types index 0cb37af450..8ae90144ab 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types @@ -8,13 +8,16 @@ var W: string; // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); >W : string ->(/** @type {*} */ (4)) : 4 ->(4) : 4 +>(/** @type {*} */ (4)) : string +>(4) : string +>(4) : any +>4 : any >4 : 4 var W = /** @type {string} */(4); // Error >W : string ->(4) : 4 +>(4) : string +>4 : string >4 : 4 /** @type {*} */ @@ -23,20 +26,22 @@ var a; /** @type {string} */ var s; ->s : any +>s : string var a = /** @type {*} */("" + 4); >a : any ->("" + 4) : string +>("" + 4) : any +>"" + 4 : any >"" + 4 : string >"" : "" >4 : 4 var s = "" + /** @type {*} */(4); ->s : any +>s : string >"" + /** @type {*} */(4) : string >"" : "" ->(4) : 4 +>(4) : any +>4 : any >4 : 4 class SomeBase { @@ -115,9 +120,10 @@ var someFakeClass = new SomeFakeClass(); >SomeFakeClass : () => void someBase = /** @type {SomeBase} */(someDerived); ->someBase = /** @type {SomeBase} */(someDerived) : SomeDerived +>someBase = /** @type {SomeBase} */(someDerived) : SomeBase >someBase : SomeBase ->(someDerived) : SomeDerived +>(someDerived) : SomeBase +>someDerived : SomeBase >someDerived : SomeDerived someBase = /** @type {SomeBase} */(someBase); @@ -125,11 +131,13 @@ someBase = /** @type {SomeBase} */(someBase); >someBase : SomeBase >(someBase) : SomeBase >someBase : SomeBase +>someBase : SomeBase someBase = /** @type {SomeBase} */(someOther); // Error ->someBase = /** @type {SomeBase} */(someOther) : SomeOther +>someBase = /** @type {SomeBase} */(someOther) : SomeBase >someBase : SomeBase ->(someOther) : SomeOther +>(someOther) : SomeBase +>someOther : SomeBase >someOther : SomeOther someDerived = /** @type {SomeDerived} */(someDerived); @@ -137,29 +145,34 @@ someDerived = /** @type {SomeDerived} */(someDerived); >someDerived : SomeDerived >(someDerived) : SomeDerived >someDerived : SomeDerived +>someDerived : SomeDerived someDerived = /** @type {SomeDerived} */(someBase); ->someDerived = /** @type {SomeDerived} */(someBase) : SomeBase +>someDerived = /** @type {SomeDerived} */(someBase) : SomeDerived >someDerived : SomeDerived ->(someBase) : SomeBase +>(someBase) : SomeDerived +>someBase : SomeDerived >someBase : SomeBase someDerived = /** @type {SomeDerived} */(someOther); // Error ->someDerived = /** @type {SomeDerived} */(someOther) : SomeOther +>someDerived = /** @type {SomeDerived} */(someOther) : SomeDerived >someDerived : SomeDerived ->(someOther) : SomeOther +>(someOther) : SomeDerived +>someOther : SomeDerived >someOther : SomeOther someOther = /** @type {SomeOther} */(someDerived); // Error ->someOther = /** @type {SomeOther} */(someDerived) : SomeDerived +>someOther = /** @type {SomeOther} */(someDerived) : SomeOther >someOther : SomeOther ->(someDerived) : SomeDerived +>(someDerived) : SomeOther +>someDerived : SomeOther >someDerived : SomeDerived someOther = /** @type {SomeOther} */(someBase); // Error ->someOther = /** @type {SomeOther} */(someBase) : SomeBase +>someOther = /** @type {SomeOther} */(someBase) : SomeOther >someOther : SomeOther ->(someBase) : SomeBase +>(someBase) : SomeOther +>someBase : SomeOther >someBase : SomeBase someOther = /** @type {SomeOther} */(someOther); @@ -167,6 +180,7 @@ someOther = /** @type {SomeOther} */(someOther); >someOther : SomeOther >(someOther) : SomeOther >someOther : SomeOther +>someOther : SomeOther someFakeClass = someBase; >someFakeClass = someBase : SomeBase @@ -184,45 +198,49 @@ someBase = someFakeClass; // Error >someFakeClass : any someBase = /** @type {SomeBase} */(someFakeClass); ->someBase = /** @type {SomeBase} */(someFakeClass) : any +>someBase = /** @type {SomeBase} */(someFakeClass) : SomeBase >someBase : SomeBase ->(someFakeClass) : any +>(someFakeClass) : SomeBase +>someFakeClass : SomeBase >someFakeClass : any // Type assertion cannot be a type-predicate type /** @type {number | string} */ var numOrStr; ->numOrStr : any +>numOrStr : string | number /** @type {string} */ var str; ->str : any +>str : string if(/** @type {numOrStr is string} */(numOrStr === undefined)) { // Error >(numOrStr === undefined) : boolean >numOrStr === undefined : boolean ->numOrStr : any +>numOrStr === undefined : boolean +>numOrStr : string | number >undefined : undefined str = numOrStr; // Error, no narrowing occurred ->str = numOrStr : any ->str : any ->numOrStr : any +>str = numOrStr : string | number +>str : string +>numOrStr : string | number } var asConst1 = /** @type {const} */(1); ->asConst1 : number +>asConst1 : 1 >(1) : 1 >1 : 1 +>1 : 1 var asConst2 = /** @type {const} */({ ->asConst2 : { x: number; } ->({ x: 1}) : { x: number; } ->{ x: 1} : { x: number; } +>asConst2 : { readonly x: 1; } +>({ x: 1}) : { readonly x: 1; } +>{ x: 1} : { readonly x: 1; } +>{ x: 1} : { readonly x: 1; } x: 1 ->x : number +>x : 1 >1 : 1 }); diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt index 6d33f5168c..4b79a3d468 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt @@ -1,9 +1,13 @@ +a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? a.js(2,12): error TS7006: Parameter 'value' implicitly has an 'any' type. a.js(6,12): error TS7006: Parameter 's' implicitly has an 'any' type. -==== a.js (2 errors) ==== +==== a.js (3 errors) ==== /** @type {function(string): void} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. const f = (value) => { ~~~~~ !!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.types index 03ebe0a901..fc9b78da8e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.types @@ -3,7 +3,7 @@ === a.js === /** @type {function(string): void} */ const f = (value) => { ->f : (value: any) => void +>f : function >(value) => { value = 1 // should error} : (value: any) => void >value : any diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt index f6915b7f41..96a1ffda77 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt @@ -1,13 +1,16 @@ +a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? a.js(2,12): error TS7006: Parameter 'value' implicitly has an 'any' type. a.js(5,12): error TS7006: Parameter 's' implicitly has an 'any' type. a.js(8,12): error TS7006: Parameter 's' implicitly has an 'any' type. -a.js(11,1): error TS2554: Expected 1 arguments, but got 0. a.js(12,1): error TS2554: Expected 1 arguments, but got 0. a.js(13,1): error TS2554: Expected 1 arguments, but got 0. ==== a.js (6 errors) ==== /** @type {function(string): void} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. const f = (value) => { ~~~~~ !!! error TS7006: Parameter 'value' implicitly has an 'any' type. @@ -24,9 +27,6 @@ a.js(13,1): error TS2554: Expected 1 arguments, but got 0. } f() // should error - ~ -!!! error TS2554: Expected 1 arguments, but got 0. -!!! related TS6210 a.js:2:12: An argument for 'value' was not provided. g() // should error ~ !!! error TS2554: Expected 1 arguments, but got 0. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.types index 9d88dc7b3c..9c3065edcb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.types @@ -3,7 +3,7 @@ === a.js === /** @type {function(string): void} */ const f = (value) => { ->f : (value: any) => void +>f : function >(value) => {} : (value: any) => void >value : any @@ -20,8 +20,8 @@ function h(s) { } f() // should error ->f() : void ->f : (value: any) => void +>f() : any +>f : function g() // should error >g() : void diff --git a/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.types b/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.types index 51baa75342..f53bb4b55f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.types @@ -3,8 +3,8 @@ === foo.js === /** @type {boolean} */ var /** @type {string} */ x, ->x : any +>x : string /** @type {number} */ y; ->y : any +>y : number diff --git a/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt new file mode 100644 index 0000000000..908bca4dda --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt @@ -0,0 +1,15 @@ +a.js(2,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + +==== a.js (1 errors) ==== + /** + * @type {function(boolean, string, ...*):void} + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + */ + const foo = function (a, b, ...r) { }; + +==== b.ts (0 errors) ==== + foo(false, ''); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.types b/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.types index aa93e280e2..55ec62eca7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.types @@ -5,7 +5,7 @@ * @type {function(boolean, string, ...*):void} */ const foo = function (a, b, ...r) { }; ->foo : (a: any, b: any, ...r: any[]) => void +>foo : function >function (a, b, ...r) { } : (a: any, b: any, ...r: any[]) => void >a : any >b : any @@ -13,8 +13,8 @@ const foo = function (a, b, ...r) { }; === b.ts === foo(false, ''); ->foo(false, '') : void ->foo : (a: any, b: any, ...r: any[]) => void +>foo(false, '') : any +>foo : function >false : false >'' : "" diff --git a/testdata/baselines/reference/submodule/conformance/linkTagEmit1.types b/testdata/baselines/reference/submodule/conformance/linkTagEmit1.types index bb442e5264..567ff79cd7 100644 --- a/testdata/baselines/reference/submodule/conformance/linkTagEmit1.types +++ b/testdata/baselines/reference/submodule/conformance/linkTagEmit1.types @@ -19,12 +19,12 @@ declare namespace NS { * @param {number} integer {@link Z} */ function computeCommonSourceDirectoryOfFilenames(integer) { ->computeCommonSourceDirectoryOfFilenames : (integer: any) => any ->integer : any +>computeCommonSourceDirectoryOfFilenames : (integer: number) => number +>integer : number return integer + 1 // pls pls pls ->integer + 1 : any ->integer : any +>integer + 1 : number +>integer : number >1 : 1 } diff --git a/testdata/baselines/reference/submodule/conformance/malformedTags.types b/testdata/baselines/reference/submodule/conformance/malformedTags.types index 93bde05262..d8a66740cf 100644 --- a/testdata/baselines/reference/submodule/conformance/malformedTags.types +++ b/testdata/baselines/reference/submodule/conformance/malformedTags.types @@ -7,7 +7,7 @@ * @type Function */ var isArray = Array.isArray; ->isArray : (arg: any) => arg is any[] +>isArray : Function >Array.isArray : (arg: any) => arg is any[] >Array : ArrayConstructor >isArray : (arg: any) => arg is any[] diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.types b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.types index 30c84713e9..9d5dbdd72a 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.types @@ -6,34 +6,34 @@ class C { /** @param {number} x */ constructor(x) { ->x : any +>x : number this.x = x ->this.x = x : any +>this.x = x : number >this.x : any >this : this >x : any ->x : any +>x : number this.exports = [x] ->this.exports = [x] : any[] +>this.exports = [x] : number[] >this.exports : any >this : this >exports : any ->[x] : any[] ->x : any +>[x] : number[] +>x : number } /** @param {number} y */ m(y) { ->m : (y: any) => any ->y : any +>m : (y: number) => any +>y : number return this.x + y >this.x + y : any >this.x : any >this : this >x : any ->y : any +>y : number } } function exec() { diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt index 54d6efa7f4..bc5363672c 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt @@ -1,17 +1,29 @@ -index.ts(2,15): error TS2306: File 'mod.js' is not a module. -index.ts(3,15): error TS2306: File 'mod.js' is not a module. -index.ts(4,15): error TS2306: File 'mod.js' is not a module. -index.ts(5,15): error TS2306: File 'mod.js' is not a module. -index.ts(6,15): error TS2306: File 'mod.js' is not a module. -index.ts(7,15): error TS2306: File 'mod.js' is not a module. -index.ts(8,15): error TS2306: File 'mod.js' is not a module. -index.ts(14,22): error TS2306: File 'mod.js' is not a module. -index.ts(15,22): error TS2306: File 'mod.js' is not a module. -index.ts(16,22): error TS2306: File 'mod.js' is not a module. -index.ts(17,22): error TS2306: File 'mod.js' is not a module. -index.ts(18,22): error TS2306: File 'mod.js' is not a module. -index.ts(19,22): error TS2306: File 'mod.js' is not a module. -index.ts(20,22): error TS2306: File 'mod.js' is not a module. +index.ts(2,24): error TS2694: Namespace '"mod"' has no exported member 'Thing'. +index.ts(3,24): error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. +index.ts(4,24): error TS2694: Namespace '"mod"' has no exported member 'foo'. +index.ts(5,24): error TS2694: Namespace '"mod"' has no exported member 'qux'. +index.ts(6,24): error TS2694: Namespace '"mod"' has no exported member 'baz'. +index.ts(8,24): error TS2694: Namespace '"mod"' has no exported member 'literal'. +index.ts(14,31): error TS2694: Namespace '"mod"' has no exported member 'Thing'. +index.ts(15,31): error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. +index.ts(16,31): error TS2694: Namespace '"mod"' has no exported member 'foo'. +index.ts(17,31): error TS2694: Namespace '"mod"' has no exported member 'qux'. +index.ts(18,31): error TS2694: Namespace '"mod"' has no exported member 'baz'. +index.ts(19,31): error TS2694: Namespace '"mod"' has no exported member 'buz'. +index.ts(20,31): error TS2694: Namespace '"mod"' has no exported member 'literal'. +main.js(2,28): error TS2694: Namespace '"mod"' has no exported member 'Thing'. +main.js(3,28): error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. +main.js(4,28): error TS2694: Namespace '"mod"' has no exported member 'foo'. +main.js(5,28): error TS2694: Namespace '"mod"' has no exported member 'qux'. +main.js(6,28): error TS2694: Namespace '"mod"' has no exported member 'baz'. +main.js(8,28): error TS2694: Namespace '"mod"' has no exported member 'literal'. +main.js(15,35): error TS2694: Namespace '"mod"' has no exported member 'Thing'. +main.js(16,35): error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. +main.js(17,35): error TS2694: Namespace '"mod"' has no exported member 'foo'. +main.js(18,35): error TS2694: Namespace '"mod"' has no exported member 'qux'. +main.js(19,35): error TS2694: Namespace '"mod"' has no exported member 'baz'. +main.js(20,35): error TS2694: Namespace '"mod"' has no exported member 'buz'. +main.js(21,35): error TS2694: Namespace '"mod"' has no exported member 'literal'. mod.js(6,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -31,15 +43,27 @@ mod.js(6,1): error TS2580: Cannot find name 'module'. Do you need to install typ baz() { return 5 }, literal: "", } -==== main.js (0 errors) ==== +==== main.js (13 errors) ==== /** * @param {import("./mod").Thing} a + ~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'Thing'. * @param {import("./mod").AnotherThing} b + ~~~~~~~~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. * @param {import("./mod").foo} c + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'foo'. * @param {import("./mod").qux} d + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'qux'. * @param {import("./mod").baz} e + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'baz'. * @param {import("./mod").buz} f * @param {import("./mod").literal} g + ~~~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'literal'. */ function jstypes(a, b, c, d, e, f, g) { return a.x + b.y + c() + d() + e() + f() + g.length @@ -47,66 +71,78 @@ mod.js(6,1): error TS2580: Cannot find name 'module'. Do you need to install typ /** * @param {typeof import("./mod").Thing} a + ~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'Thing'. * @param {typeof import("./mod").AnotherThing} b + ~~~~~~~~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. * @param {typeof import("./mod").foo} c + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'foo'. * @param {typeof import("./mod").qux} d + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'qux'. * @param {typeof import("./mod").baz} e + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'baz'. * @param {typeof import("./mod").buz} f + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'buz'. * @param {typeof import("./mod").literal} g + ~~~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'literal'. */ function jsvalues(a, b, c, d, e, f, g) { return a.length + b.length + c() + d() + e() + f() + g.length } -==== index.ts (14 errors) ==== +==== index.ts (13 errors) ==== function types( a: import('./mod').Thing, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'Thing'. b: import('./mod').AnotherThing, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~~~~~~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. c: import('./mod').foo, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'foo'. d: import('./mod').qux, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'qux'. e: import('./mod').baz, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'baz'. f: import('./mod').buz, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. g: import('./mod').literal, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'literal'. ) { return a.x + b.y + c() + d() + e() + f() + g.length } function values( a: typeof import('./mod').Thing, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'Thing'. b: typeof import('./mod').AnotherThing, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~~~~~~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. c: typeof import('./mod').foo, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'foo'. d: typeof import('./mod').qux, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'qux'. e: typeof import('./mod').baz, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'baz'. f: typeof import('./mod').buz, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'buz'. g: typeof import('./mod').literal, - ~~~~~~~ -!!! error TS2306: File 'mod.js' is not a module. + ~~~~~~~ +!!! error TS2694: Namespace '"mod"' has no exported member 'literal'. ) { return a.length + b.length + c() + d() + e() + f() + g.length } diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols index 2b7400dd6c..318be9ed2b 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols @@ -116,6 +116,7 @@ function types( f: import('./mod').buz, >f : Symbol(f, Decl(index.ts, 5, 27)) +>buz : Symbol(buz, Decl(mod.js, 4, 4)) g: import('./mod').literal, >g : Symbol(g, Decl(index.ts, 6, 27)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff index 65b0a77627..cf0b78e146 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff @@ -65,15 +65,7 @@ } === index.ts === -@@= skipped -36, +30 lines =@@ - - f: import('./mod').buz, - >f : Symbol(f, Decl(index.ts, 5, 27)) -->buz : Symbol(buz, Decl(mod.js, 4, 4)) - - g: import('./mod').literal, - >g : Symbol(g, Decl(index.ts, 6, 27)) -@@= skipped -21, +20 lines =@@ +@@= skipped -57, +51 lines =@@ a: typeof import('./mod').Thing, >a : Symbol(a, Decl(index.ts, 12, 16)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types index 75020c101b..fcde31ff62 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types @@ -59,13 +59,13 @@ module.exports = { * @param {import("./mod").literal} g */ function jstypes(a, b, c, d, e, f, g) { ->jstypes : (a: any, b: any, c: any, d: any, e: any, f: any, g: any) => any +>jstypes : (a: any, b: any, c: any, d: any, e: any, f: () => number, g: any) => any >a : any >b : any >c : any >d : any >e : any ->f : any +>f : () => number >g : any return a.x + b.y + c() + d() + e() + f() + g.length @@ -87,8 +87,8 @@ function jstypes(a, b, c, d, e, f, g) { >d : any >e() : any >e : any ->f() : any ->f : any +>f() : number +>f : () => number >g.length : any >g : any >length : any @@ -141,7 +141,7 @@ function jsvalues(a, b, c, d, e, f, g) { === index.ts === function types( ->types : (a: any, b: any, c: any, d: any, e: any, f: any, g: any) => any +>types : (a: any, b: any, c: any, d: any, e: any, f: () => number, g: any) => any a: import('./mod').Thing, >a : any @@ -159,7 +159,7 @@ function types( >e : any f: import('./mod').buz, ->f : any +>f : () => number g: import('./mod').literal, >g : any @@ -184,8 +184,8 @@ function types( >d : any >e() : any >e : any ->f() : any ->f : any +>f() : number +>f : () => number >g.length : any >g : any >length : any diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.types b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.types index 6ba5c1ee31..ea97d76e1d 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.types @@ -77,18 +77,18 @@ var classic = new s.Classic() /** @param {s.n.K} c @param {s.Classic} classic */ function f(c, classic) { ->f : (c: any, classic: any) => void ->c : any ->classic : any +>f : (c: K, classic: Classic) => void +>c : K +>classic : Classic c.x >c.x : any ->c : any +>c : K >x : any classic.p >classic.p : any ->classic : any +>classic : Classic >p : any } diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment2.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment2.errors.txt deleted file mode 100644 index 1472224b4d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment2.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -file1.js(9,12): error TS7006: Parameter 'type' implicitly has an 'any' type. -file1.js(9,18): error TS7006: Parameter 'ctor' implicitly has an 'any' type. -file1.js(9,24): error TS7006: Parameter 'exports' implicitly has an 'any' type. - - -==== file1.js (3 errors) ==== - // this file _should_ be a global file - var GlobalThing = { x: 12 }; - - /** - * @param {*} type - * @param {*} ctor - * @param {*} exports - */ - function f(type, ctor, exports) { - ~~~~ -!!! error TS7006: Parameter 'type' implicitly has an 'any' type. - ~~~~ -!!! error TS7006: Parameter 'ctor' implicitly has an 'any' type. - ~~~~~~~ -!!! error TS7006: Parameter 'exports' implicitly has an 'any' type. - if (typeof exports !== "undefined") { - exports["AST_" + type] = ctor; - } - } - -==== ref.js (0 errors) ==== - GlobalThing.x - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/noAssertForUnparseableTypedefs.errors.txt b/testdata/baselines/reference/submodule/conformance/noAssertForUnparseableTypedefs.errors.txt index 6f70960c4a..e71c8f9b2d 100644 --- a/testdata/baselines/reference/submodule/conformance/noAssertForUnparseableTypedefs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/noAssertForUnparseableTypedefs.errors.txt @@ -1,8 +1,11 @@ +bug26693.js(1,15): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. bug26693.js(2,22): error TS2307: Cannot find module 'nope' or its corresponding type declarations. -==== bug26693.js (1 errors) ==== +==== bug26693.js (2 errors) ==== /** @typedef {module:locale} hi */ + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. import { nope } from 'nope'; ~~~~~~ !!! error TS2307: Cannot find module 'nope' or its corresponding type declarations. diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt new file mode 100644 index 0000000000..c9b3fb4a96 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt @@ -0,0 +1,50 @@ +overloadTag1.js(26,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. + + +==== overloadTag1.js (1 errors) ==== + /** + * @overload + * @param {number} a + * @param {number} b + * @returns {number} + * + * @overload + * @param {string} a + * @param {boolean} b + * @returns {string} + * + * @param {string | number} a + * @param {string | number} b + * @returns {string | number} + */ + export function overloaded(a,b) { + if (typeof a === "string" && typeof b === "string") { + return a + b; + } else if (typeof a === "number" && typeof b === "number") { + return a + b; + } + throw new Error("Invalid arguments"); + } + var o1 = overloaded(1,2) + var o2 = overloaded("zero", "one") + var o3 = overloaded("a",false) + ~~~~~ +!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. + + /** + * @overload + * @param {number} a + * @param {number} b + * @returns {number} + * + * @overload + * @param {string} a + * @param {boolean} b + * @returns {string} + */ + export function uncheckedInternally(a, b) { + return a + b; + } + uncheckedInternally(1,2) + uncheckedInternally("zero", "one") + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag1.types b/testdata/baselines/reference/submodule/conformance/overloadTag1.types index 8738361a21..da3231b55a 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag1.types +++ b/testdata/baselines/reference/submodule/conformance/overloadTag1.types @@ -17,19 +17,19 @@ * @returns {string | number} */ export function overloaded(a,b) { ->overloaded : (a: any, b: any) => string | number ->a : any ->b : any +>overloaded : (a: string | number, b: string | number) => string | number +>a : string | number +>b : string | number if (typeof a === "string" && typeof b === "string") { >typeof a === "string" && typeof b === "string" : boolean >typeof a === "string" : boolean >typeof a : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->a : any +>a : string | number >"string" : "string" >typeof b === "string" : boolean >typeof b : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->b : any +>b : string | number >"string" : "string" return a + b; @@ -41,11 +41,11 @@ export function overloaded(a,b) { >typeof a === "number" && typeof b === "number" : boolean >typeof a === "number" : boolean >typeof a : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->a : any +>a : string | number >"number" : "number" >typeof b === "number" : boolean >typeof b : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->b : any +>b : string | number >"number" : "number" return a + b; @@ -61,21 +61,21 @@ export function overloaded(a,b) { var o1 = overloaded(1,2) >o1 : string | number >overloaded(1,2) : string | number ->overloaded : (a: any, b: any) => string | number +>overloaded : (a: string | number, b: string | number) => string | number >1 : 1 >2 : 2 var o2 = overloaded("zero", "one") >o2 : string | number >overloaded("zero", "one") : string | number ->overloaded : (a: any, b: any) => string | number +>overloaded : (a: string | number, b: string | number) => string | number >"zero" : "zero" >"one" : "one" var o3 = overloaded("a",false) >o3 : string | number >overloaded("a",false) : string | number ->overloaded : (a: any, b: any) => string | number +>overloaded : (a: string | number, b: string | number) => string | number >"a" : "a" >false : false diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt index 3588aacd02..eb5e2e1931 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt @@ -1,11 +1,10 @@ -overloadTag2.js(25,17): error TS7006: Parameter 'a' implicitly has an 'any' type. overloadTag2.js(25,20): error TS7006: Parameter 'b' implicitly has an 'any' type. overloadTag2.js(30,9): error TS2554: Expected 2 arguments, but got 0. overloadTag2.js(31,9): error TS2554: Expected 2 arguments, but got 1. overloadTag2.js(32,9): error TS2554: Expected 2 arguments, but got 1. -==== overloadTag2.js (5 errors) ==== +==== overloadTag2.js (4 errors) ==== export class Foo { #a = true ? 1 : "1" #b @@ -31,8 +30,6 @@ overloadTag2.js(32,9): error TS2554: Expected 2 arguments, but got 1. * @param {number | string} a */ constructor(a, b) { - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'b' implicitly has an 'any' type. this.#a = a diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag2.types b/testdata/baselines/reference/submodule/conformance/overloadTag2.types index 4ece744a70..a4d987da70 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag2.types +++ b/testdata/baselines/reference/submodule/conformance/overloadTag2.types @@ -35,14 +35,14 @@ export class Foo { * @param {number | string} a */ constructor(a, b) { ->a : any +>a : string | number >b : any this.#a = a ->this.#a = a : any +>this.#a = a : string | number >this.#a : string | number >this : this ->a : any +>a : string | number this.#b = b >this.#b = b : any diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt deleted file mode 100644 index ddded0d6da..0000000000 --- a/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt +++ /dev/null @@ -1,26 +0,0 @@ -/a.js(14,9): error TS7006: Parameter 'value' implicitly has an 'any' type. - - -==== /a.js (1 errors) ==== - /** - * @template T - */ - export class Foo { - /** - * @constructor - * @overload - */ - constructor() { } - - /** - * @param {T} value - */ - bar(value) { } - ~~~~~ -!!! error TS7006: Parameter 'value' implicitly has an 'any' type. - } - - /** @type {Foo} */ - let foo; - foo = new Foo(); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag3.types b/testdata/baselines/reference/submodule/conformance/overloadTag3.types index 72c9b5f33b..1f7db75036 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag3.types +++ b/testdata/baselines/reference/submodule/conformance/overloadTag3.types @@ -5,7 +5,7 @@ * @template T */ export class Foo { ->Foo : Foo +>Foo : Foo /** * @constructor @@ -17,17 +17,17 @@ export class Foo { * @param {T} value */ bar(value) { } ->bar : (value: any) => void ->value : any +>bar : (value: T) => void +>value : T } /** @type {Foo} */ let foo; ->foo : any +>foo : Foo foo = new Foo(); ->foo = new Foo() : Foo ->foo : any ->new Foo() : Foo +>foo = new Foo() : Foo +>foo : Foo +>new Foo() : Foo >Foo : typeof Foo diff --git a/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.errors.txt deleted file mode 100644 index e49c5e7f6f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.errors.txt +++ /dev/null @@ -1,32 +0,0 @@ -a.js(6,12): error TS7006: Parameter 'p' implicitly has an 'any' type. -a.js(6,15): error TS7006: Parameter 'q' implicitly has an 'any' type. -a.js(6,18): error TS7006: Parameter 'r' implicitly has an 'any' type. -a.js(13,1): error TS2554: Expected 3 arguments, but got 0. - - -==== a.js (4 errors) ==== - /** - * @param {number} [p] - * @param {number=} q - * @param {number} [r=101] - */ - function f(p, q, r) { - ~ -!!! error TS7006: Parameter 'p' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'q' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'r' implicitly has an 'any' type. - p = undefined - q = undefined - // note that, unlike TS, JSDOC [r=101] retains | undefined because - // there's no code emitted to get rid of it. - r = undefined - } - f() - ~ -!!! error TS2554: Expected 3 arguments, but got 0. -!!! related TS6210 a.js:6:12: An argument for 'p' was not provided. - f(undefined, undefined, undefined) - f(1, 2, 3) - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.types b/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.types index 6ae6930d0a..d0cc84ac6a 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.types +++ b/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.types @@ -7,42 +7,42 @@ * @param {number} [r=101] */ function f(p, q, r) { ->f : (p: any, q: any, r: any) => void ->p : any ->q : any ->r : any +>f : (p?: number | undefined, q?: number | undefined, r?: number | undefined) => void +>p : number | undefined +>q : number | undefined +>r : number | undefined p = undefined >p = undefined : undefined ->p : any +>p : number | undefined >undefined : undefined q = undefined >q = undefined : undefined ->q : any +>q : number | undefined >undefined : undefined // note that, unlike TS, JSDOC [r=101] retains | undefined because // there's no code emitted to get rid of it. r = undefined >r = undefined : undefined ->r : any +>r : number | undefined >undefined : undefined } f() >f() : void ->f : (p: any, q: any, r: any) => void +>f : (p?: number | undefined, q?: number | undefined, r?: number | undefined) => void f(undefined, undefined, undefined) >f(undefined, undefined, undefined) : void ->f : (p: any, q: any, r: any) => void +>f : (p?: number | undefined, q?: number | undefined, r?: number | undefined) => void >undefined : undefined >undefined : undefined >undefined : undefined f(1, 2, 3) >f(1, 2, 3) : void ->f : (p: any, q: any, r: any) => void +>f : (p?: number | undefined, q?: number | undefined, r?: number | undefined) => void >1 : 1 >2 : 2 >3 : 3 diff --git a/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt new file mode 100644 index 0000000000..5d76f62a2f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt @@ -0,0 +1,13 @@ +paramTagNestedWithoutTopLevelObject3.js(6,16): error TS2339: Property 'bar' does not exist on type 'object'. + + +==== paramTagNestedWithoutTopLevelObject3.js (1 errors) ==== + /** + * @param {object} xyz + * @param {number} xyz.bar.p + */ + function g(xyz) { + return xyz.bar.p; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'object'. + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.types b/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.types index 6863a2531b..6c0bf1240f 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.types +++ b/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.types @@ -6,13 +6,13 @@ * @param {number} xyz.bar.p */ function g(xyz) { ->g : (xyz: any) => any ->xyz : any +>g : (xyz: object) => any +>xyz : object return xyz.bar.p; >xyz.bar.p : any >xyz.bar : any ->xyz : any +>xyz : object >bar : any >p : any } diff --git a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt new file mode 100644 index 0000000000..992effe5ec --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt @@ -0,0 +1,16 @@ +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.types b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.types index ac9c0da985..6fc6473131 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.types +++ b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.types @@ -7,22 +7,22 @@ * @param {{[K in keyof T]: (value: T[K]) => void }} b */ function f(a, b) { ->f : (a: any, b: any) => void ->a : any ->b : any +>f : (a: T, b: { [K in keyof T]: (value: T[K]) => void; }) => void +>a : T +>b : { [K in keyof T]: (value: T[K]) => void; } } f({ x: 42 }, { x(param) { param.toFixed() } }); >f({ x: 42 }, { x(param) { param.toFixed() } }) : void ->f : (a: any, b: any) => void +>f : (a: T, b: { [K in keyof T]: (value: T[K]) => void; }) => void >{ x: 42 } : { x: number; } >x : number >42 : 42 ->{ x(param) { param.toFixed() } } : { x: (param: any) => void; } ->x : (param: any) => void ->param : any +>{ x(param) { param.toFixed() } } : { x: (param: K) => void; } +>x : (param: K) => void +>param : K >param.toFixed() : any >param.toFixed : any ->param : any +>param : K >toFixed : any diff --git a/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt index a888f24270..bc43cc7750 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt @@ -1,12 +1,9 @@ bad.js(9,14): error TS7006: Parameter 'x' implicitly has an 'any' type. bad.js(9,17): error TS7006: Parameter 'y' implicitly has an 'any' type. bad.js(9,20): error TS7006: Parameter 'z' implicitly has an 'any' type. -good.js(9,15): error TS7006: Parameter 'x' implicitly has an 'any' type. -good.js(9,18): error TS7006: Parameter 'y' implicitly has an 'any' type. -good.js(9,21): error TS7006: Parameter 'z' implicitly has an 'any' type. -==== good.js (3 errors) ==== +==== good.js (0 errors) ==== /** * @param * {number} x Arg x. @@ -16,12 +13,6 @@ good.js(9,21): error TS7006: Parameter 'z' implicitly has an 'any' type. * Arg z. */ function good(x, y, z) { - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'y' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'z' implicitly has an 'any' type. } good(1, 2, 3) diff --git a/testdata/baselines/reference/submodule/conformance/paramTagWrapping.types b/testdata/baselines/reference/submodule/conformance/paramTagWrapping.types index 28649e313b..dacf722c05 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagWrapping.types +++ b/testdata/baselines/reference/submodule/conformance/paramTagWrapping.types @@ -10,15 +10,15 @@ * Arg z. */ function good(x, y, z) { ->good : (x: any, y: any, z: any) => void ->x : any ->y : any ->z : any +>good : (x: number, y: number, z: number) => void +>x : number +>y : number +>z : number } good(1, 2, 3) >good(1, 2, 3) : void ->good : (x: any, y: any, z: any) => void +>good : (x: number, y: number, z: number) => void >1 : 1 >2 : 2 >3 : 3 diff --git a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt new file mode 100644 index 0000000000..ccc2bc954c --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt @@ -0,0 +1,58 @@ +propertiesOfGenericConstructorFunctions.js(14,12): error TS2749: 'Multimap' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap'? + + +==== propertiesOfGenericConstructorFunctions.js (1 errors) ==== + /** + * @template {string} K + * @template V + * @param {string} ik + * @param {V} iv + */ + function Multimap(ik, iv) { + /** @type {{ [s: string]: V }} */ + this._map = {}; + // without type annotation + this._map2 = { [ik]: iv }; + }; + + /** @type {Multimap<"a" | "b", number>} with type annotation */ + ~~~~~~~~ +!!! error TS2749: 'Multimap' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap'? + const map = new Multimap("a", 1); + // without type annotation + const map2 = new Multimap("m", 2); + + /** @type {number} */ + var n = map._map['hi'] + /** @type {number} */ + var n = map._map2['hi'] + /** @type {number} */ + var n = map2._map['hi'] + /** @type {number} */ + var n = map._map2['hi'] + + /** + * @class + * @template T + * @param {T} t + */ + function Cp(t) { + this.x = 1 + this.y = t + } + Cp.prototype = { + m1() { return this.x }, + m2() { this.z = this.x + 1; return this.y } + } + var cp = new Cp(1) + + /** @type {number} */ + var n = cp.x + /** @type {number} */ + var n = cp.y + /** @type {number} */ + var n = cp.m1() + /** @type {number} */ + var n = cp.m2() + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.types b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.types index a124bc6d44..ac0d1e4700 100644 --- a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.types +++ b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.types @@ -8,9 +8,9 @@ * @param {V} iv */ function Multimap(ik, iv) { ->Multimap : (ik: any, iv: any) => void ->ik : any ->iv : any +>Multimap : (ik: string, iv: V) => void +>ik : string +>iv : V /** @type {{ [s: string]: V }} */ this._map = {}; @@ -22,22 +22,22 @@ function Multimap(ik, iv) { // without type annotation this._map2 = { [ik]: iv }; ->this._map2 = { [ik]: iv } : { [x: number]: any; } +>this._map2 = { [ik]: iv } : { [x: string]: V; } >this._map2 : any >this : any >_map2 : any ->{ [ik]: iv } : { [x: number]: any; } ->[ik] : any ->ik : any ->iv : any +>{ [ik]: iv } : { [x: string]: V; } +>[ik] : V +>ik : string +>iv : V }; /** @type {Multimap<"a" | "b", number>} with type annotation */ const map = new Multimap("a", 1); ->map : any +>map : Multimap<"a" | "b", number> >new Multimap("a", 1) : any ->Multimap : (ik: any, iv: any) => void +>Multimap : (ik: string, iv: V) => void >"a" : "a" >1 : 1 @@ -45,31 +45,31 @@ const map = new Multimap("a", 1); const map2 = new Multimap("m", 2); >map2 : any >new Multimap("m", 2) : any ->Multimap : (ik: any, iv: any) => void +>Multimap : (ik: string, iv: V) => void >"m" : "m" >2 : 2 /** @type {number} */ var n = map._map['hi'] ->n : any +>n : number >map._map['hi'] : any >map._map : any ->map : any +>map : Multimap<"a" | "b", number> >_map : any >'hi' : "hi" /** @type {number} */ var n = map._map2['hi'] ->n : any +>n : number >map._map2['hi'] : any >map._map2 : any ->map : any +>map : Multimap<"a" | "b", number> >_map2 : any >'hi' : "hi" /** @type {number} */ var n = map2._map['hi'] ->n : any +>n : number >map2._map['hi'] : any >map2._map : any >map2 : any @@ -78,10 +78,10 @@ var n = map2._map['hi'] /** @type {number} */ var n = map._map2['hi'] ->n : any +>n : number >map._map2['hi'] : any >map._map2 : any ->map : any +>map : Multimap<"a" | "b", number> >_map2 : any >'hi' : "hi" @@ -91,8 +91,8 @@ var n = map._map2['hi'] * @param {T} t */ function Cp(t) { ->Cp : { (t: any): void; prototype: { m1: () => any; m2: () => any; }; } ->t : any +>Cp : { (t: T): void; prototype: { m1: () => any; m2: () => any; }; } +>t : T this.x = 1 >this.x = 1 : 1 @@ -102,16 +102,16 @@ function Cp(t) { >1 : 1 this.y = t ->this.y = t : any +>this.y = t : T >this.y : any >this : any >y : any ->t : any +>t : T } Cp.prototype = { >Cp.prototype = { m1() { return this.x }, m2() { this.z = this.x + 1; return this.y }} : { m1: () => any; m2: () => any; } >Cp.prototype : { m1: () => any; m2: () => any; } ->Cp : { (t: any): void; prototype: { m1: () => any; m2: () => any; }; } +>Cp : { (t: T): void; prototype: { m1: () => any; m2: () => any; }; } >prototype : { m1: () => any; m2: () => any; } >{ m1() { return this.x }, m2() { this.z = this.x + 1; return this.y }} : { m1: () => any; m2: () => any; } @@ -139,26 +139,26 @@ Cp.prototype = { var cp = new Cp(1) >cp : any >new Cp(1) : any ->Cp : { (t: any): void; prototype: { m1: () => any; m2: () => any; }; } +>Cp : { (t: T): void; prototype: { m1: () => any; m2: () => any; }; } >1 : 1 /** @type {number} */ var n = cp.x ->n : any +>n : number >cp.x : any >cp : any >x : any /** @type {number} */ var n = cp.y ->n : any +>n : number >cp.y : any >cp : any >y : any /** @type {number} */ var n = cp.m1() ->n : any +>n : number >cp.m1() : any >cp.m1 : any >cp : any @@ -166,7 +166,7 @@ var n = cp.m1() /** @type {number} */ var n = cp.m2() ->n : any +>n : number >cp.m2() : any >cp.m2 : any >cp : any diff --git a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.symbols b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.symbols index dfe5811ad4..f0708a96c2 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.symbols +++ b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.symbols @@ -6,9 +6,9 @@ export const inlined = () => true >inlined : Symbol(inlined, Decl(propertyAssignmentUseParentType2.js, 1, 12)) inlined.nuo = 789 ->inlined.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 1, 33)) +>inlined.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 0, 25)) >inlined : Symbol(inlined, Decl(propertyAssignmentUseParentType2.js, 1, 12)) ->nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 1, 33)) +>nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 0, 25)) /** @type {{ (): boolean; nuo: 789 }} */ export const duplicated = () => true @@ -16,9 +16,9 @@ export const duplicated = () => true /** @type {789} */ duplicated.nuo = 789 ->duplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 5, 36)) +>duplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 4, 25)) >duplicated : Symbol(duplicated, Decl(propertyAssignmentUseParentType2.js, 5, 12)) ->nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 5, 36)) +>nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 4, 25)) /** @type {{ (): boolean; nuo: 789 }} */ export const conflictingDuplicated = () => true @@ -26,7 +26,7 @@ export const conflictingDuplicated = () => true /** @type {1000} */ conflictingDuplicated.nuo = 789 ->conflictingDuplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 10, 47)) +>conflictingDuplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 9, 25)) >conflictingDuplicated : Symbol(conflictingDuplicated, Decl(propertyAssignmentUseParentType2.js, 10, 12)) ->nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 10, 47)) +>nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 9, 25)) diff --git a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.symbols.diff b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.symbols.diff index 4060d524e3..4bc4b1c28b 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.symbols.diff @@ -8,12 +8,10 @@ +>inlined : Symbol(inlined, Decl(propertyAssignmentUseParentType2.js, 1, 12)) inlined.nuo = 789 -->inlined.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 0, 25)) + >inlined.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 0, 25)) ->inlined : Symbol(inlined, Decl(propertyAssignmentUseParentType2.js, 1, 12), Decl(propertyAssignmentUseParentType2.js, 1, 33)) -->nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 0, 25)) -+>inlined.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 1, 33)) +>inlined : Symbol(inlined, Decl(propertyAssignmentUseParentType2.js, 1, 12)) -+>nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 1, 33)) + >nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 0, 25)) /** @type {{ (): boolean; nuo: 789 }} */ export const duplicated = () => true @@ -22,12 +20,10 @@ /** @type {789} */ duplicated.nuo = 789 -->duplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 4, 25)) + >duplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 4, 25)) ->duplicated : Symbol(duplicated, Decl(propertyAssignmentUseParentType2.js, 5, 12), Decl(propertyAssignmentUseParentType2.js, 5, 36)) -->nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 4, 25)) -+>duplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 5, 36)) +>duplicated : Symbol(duplicated, Decl(propertyAssignmentUseParentType2.js, 5, 12)) -+>nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 5, 36)) + >nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 4, 25)) /** @type {{ (): boolean; nuo: 789 }} */ export const conflictingDuplicated = () => true @@ -36,10 +32,8 @@ /** @type {1000} */ conflictingDuplicated.nuo = 789 -->conflictingDuplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 9, 25)) + >conflictingDuplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 9, 25)) ->conflictingDuplicated : Symbol(conflictingDuplicated, Decl(propertyAssignmentUseParentType2.js, 10, 12), Decl(propertyAssignmentUseParentType2.js, 10, 47)) -->nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 9, 25)) -+>conflictingDuplicated.nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 10, 47)) +>conflictingDuplicated : Symbol(conflictingDuplicated, Decl(propertyAssignmentUseParentType2.js, 10, 12)) -+>nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 10, 47)) + >nuo : Symbol(nuo, Decl(propertyAssignmentUseParentType2.js, 9, 25)) diff --git a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.types b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.types index 54a0b6710d..d46c4f4998 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.types +++ b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.types @@ -3,42 +3,42 @@ === propertyAssignmentUseParentType2.js === /** @type {{ (): boolean; nuo: 789 }} */ export const inlined = () => true ->inlined : { (): boolean; nuo: number; } ->() => true : { (): boolean; nuo: number; } +>inlined : { (): boolean; nuo: 789; } +>() => true : { (): true; nuo: 789; } >true : true inlined.nuo = 789 >inlined.nuo = 789 : 789 ->inlined.nuo : number ->inlined : { (): boolean; nuo: number; } ->nuo : number +>inlined.nuo : 789 +>inlined : { (): boolean; nuo: 789; } +>nuo : 789 >789 : 789 /** @type {{ (): boolean; nuo: 789 }} */ export const duplicated = () => true ->duplicated : { (): boolean; nuo: number; } ->() => true : { (): boolean; nuo: number; } +>duplicated : { (): boolean; nuo: 789; } +>() => true : { (): true; nuo: 789; } >true : true /** @type {789} */ duplicated.nuo = 789 >duplicated.nuo = 789 : 789 ->duplicated.nuo : number ->duplicated : { (): boolean; nuo: number; } ->nuo : number +>duplicated.nuo : 789 +>duplicated : { (): boolean; nuo: 789; } +>nuo : 789 >789 : 789 /** @type {{ (): boolean; nuo: 789 }} */ export const conflictingDuplicated = () => true ->conflictingDuplicated : { (): boolean; nuo: number; } ->() => true : { (): boolean; nuo: number; } +>conflictingDuplicated : { (): boolean; nuo: 789; } +>() => true : { (): true; nuo: 789; } >true : true /** @type {1000} */ conflictingDuplicated.nuo = 789 >conflictingDuplicated.nuo = 789 : 789 ->conflictingDuplicated.nuo : number ->conflictingDuplicated : { (): boolean; nuo: number; } ->nuo : number +>conflictingDuplicated.nuo : 789 +>conflictingDuplicated : { (): boolean; nuo: 789; } +>nuo : 789 >789 : 789 diff --git a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt index 2ac8d5ec6b..29eab95b99 100644 --- a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt @@ -1,3 +1,5 @@ +other.js(2,11): error TS2503: Cannot find namespace 'Ns'. +other.js(7,11): error TS2503: Cannot find namespace 'Ns'. prototypePropertyAssignmentMergeAcrossFiles2.js(2,4): error TS2339: Property 'One' does not exist on type '{}'. prototypePropertyAssignmentMergeAcrossFiles2.js(3,4): error TS2339: Property 'Two' does not exist on type '{}'. prototypePropertyAssignmentMergeAcrossFiles2.js(5,4): error TS2339: Property 'One' does not exist on type '{}'. @@ -23,14 +25,18 @@ prototypePropertyAssignmentMergeAcrossFiles2.js(8,4): error TS2339: Property 'Tw !!! error TS2339: Property 'Two' does not exist on type '{}'. } -==== other.js (0 errors) ==== +==== other.js (2 errors) ==== /** * @type {Ns.One} + ~~ +!!! error TS2503: Cannot find namespace 'Ns'. */ var one; one.wat; /** * @type {Ns.Two} + ~~ +!!! error TS2503: Cannot find namespace 'Ns'. */ var two; two.wat; diff --git a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.types b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.types index 70342f12e8..e174c55c41 100644 --- a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.types +++ b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.types @@ -47,21 +47,21 @@ Ns.Two.prototype = { * @type {Ns.One} */ var one; ->one : any +>one : One one.wat; >one.wat : any ->one : any +>one : One >wat : any /** * @type {Ns.Two} */ var two; ->two : any +>two : Two two.wat; >two.wat : any ->two : any +>two : Two >wat : any diff --git a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt new file mode 100644 index 0000000000..fcf4d43ce1 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt @@ -0,0 +1,21 @@ +prototypePropertyAssignmentMergedTypeReference.js(7,22): error TS2749: 'f' refers to a value, but is being used as a type here. Did you mean 'typeof f'? +prototypePropertyAssignmentMergedTypeReference.js(8,5): error TS2322: Type '() => number' is not assignable to type 'new () => f'. + Type '() => number' provides no match for the signature 'new (): f'. + + +==== prototypePropertyAssignmentMergedTypeReference.js (2 errors) ==== + var f = function() { + return 12; + }; + + f.prototype.a = "a"; + + /** @type {new () => f} */ + ~ +!!! error TS2749: 'f' refers to a value, but is being used as a type here. Did you mean 'typeof f'? + var x = f; + ~ +!!! error TS2322: Type '() => number' is not assignable to type 'new () => f'. +!!! error TS2322: Type '() => number' provides no match for the signature 'new (): f'. + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.types b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.types index 4280178c41..00bc5dad5a 100644 --- a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.types +++ b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.types @@ -21,7 +21,7 @@ f.prototype.a = "a"; /** @type {new () => f} */ var x = f; ->x : () => number +>x : new () => f >f : () => number diff --git a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt new file mode 100644 index 0000000000..af20fbb5f1 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt @@ -0,0 +1,64 @@ +bug39372.js(1,36): error TS2456: Type alias 'JsonArray' circularly references itself. +bug39372.js(3,88): error TS2456: Type alias 'Json' circularly references itself. +bug39372.js(9,17): error TS2304: Cannot find name 'T'. +bug39372.js(9,32): error TS2304: Cannot find name 'T'. +bug39372.js(12,17): error TS2304: Cannot find name 'T'. +bug39372.js(14,10): error TS2304: Cannot find name 'T'. +bug39372.js(14,55): error TS2304: Cannot find name 'T'. +bug39372.js(18,15): error TS2304: Cannot find name 'T'. +bug39372.js(19,5): error TS2304: Cannot find name 'T'. +bug39372.js(20,19): error TS2304: Cannot find name 'T'. +bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (??? & ???)[]; }; $O: { [x: string]: { $$?: Record; } & (??? | ??? & ???); }; $$?: Record; } & ???; }'. + Type '{}' is missing the following properties from type '{ $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; }': $A, $O + + +==== bug39372.js (11 errors) ==== + /** @typedef {ReadonlyArray} JsonArray */ + ~~~~~~~~~ +!!! error TS2456: Type alias 'JsonArray' circularly references itself. + /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ + /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ + ~~~~ +!!! error TS2456: Type alias 'Json' circularly references itself. + + /** + * @template T + * @typedef {{ + $A: { + [K in keyof T]?: XMLObject[] + ~ +!!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS2304: Cannot find name 'T'. + }, + $O: { + [K in keyof T]?: { + ~ +!!! error TS2304: Cannot find name 'T'. + $$?: Record + } & (T[K] extends string ? {$:string} : XMLObject) + ~ +!!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS2304: Cannot find name 'T'. + }, + $$?: Record, + } & { + [K in keyof T]?: ( + ~ +!!! error TS2304: Cannot find name 'T'. + T[K] extends string ? string + ~ +!!! error TS2304: Cannot find name 'T'. + : XMLObject + ~ +!!! error TS2304: Cannot find name 'T'. + ) + }} XMLObject */ + + /** @type {XMLObject<{foo:string}>} */ + const p = {}; + ~ +!!! error TS2322: Type '{}' is not assignable to type '{ $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (??? & ???)[]; }; $O: { [x: string]: { $$?: Record; } & (??? | ??? & ???); }; $$?: Record; } & ???; }'. +!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; }': $A, $O + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types index d9bc2172ac..fd81757bb2 100644 --- a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types +++ b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types @@ -26,6 +26,6 @@ /** @type {XMLObject<{foo:string}>} */ const p = {}; ->p : {} +>p : { $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (??? & ???)[]; }; $O: { [x: string]: { $$?: Record; } & (??? | ??? & ???); }; $$?: Record; } & ???; } >{} : {} diff --git a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt index 3b7364ece6..d052558419 100644 --- a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt @@ -1,8 +1,10 @@ bug25127.js(3,14): error TS2339: Property 'c' does not exist on type 'Entry'. bug25127.js(15,14): error TS2339: Property 'd' does not exist on type 'Group'. +bug25127.js(27,41): error TS2339: Property 'c' does not exist on type 'Entry'. +bug25127.js(27,51): error TS2339: Property 'd' does not exist on type 'Group'. -==== bug25127.js (2 errors) ==== +==== bug25127.js (4 errors) ==== class Entry { constructor() { this.c = 1 @@ -34,6 +36,10 @@ bug25127.js(15,14): error TS2339: Property 'd' does not exist on type 'Group'. /** @param {Entry | Group} chunk */ function f(chunk) { let x = chunk.isInit(chunk) ? chunk.c : chunk.d + ~ +!!! error TS2339: Property 'c' does not exist on type 'Entry'. + ~ +!!! error TS2339: Property 'd' does not exist on type 'Group'. return x } diff --git a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.symbols b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.symbols index 15303022d0..62dda0ebe8 100644 --- a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.symbols +++ b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.symbols @@ -44,7 +44,9 @@ function f(chunk) { let x = chunk.isInit(chunk) ? chunk.c : chunk.d >x : Symbol(x, Decl(bug25127.js, 26, 7)) +>chunk.isInit : Symbol(isInit, Decl(bug25127.js, 3, 5), Decl(bug25127.js, 15, 5)) >chunk : Symbol(chunk, Decl(bug25127.js, 25, 11)) +>isInit : Symbol(isInit, Decl(bug25127.js, 3, 5), Decl(bug25127.js, 15, 5)) >chunk : Symbol(chunk, Decl(bug25127.js, 25, 11)) >chunk : Symbol(chunk, Decl(bug25127.js, 25, 11)) >chunk : Symbol(chunk, Decl(bug25127.js, 25, 11)) diff --git a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.symbols.diff b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.symbols.diff index 954ef40c70..1d4c21c5a9 100644 --- a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.symbols.diff @@ -36,13 +36,9 @@ >x : Symbol(x, Decl(bug25127.js, 20, 11)) return false -@@= skipped -22, +20 lines =@@ - - let x = chunk.isInit(chunk) ? chunk.c : chunk.d - >x : Symbol(x, Decl(bug25127.js, 26, 7)) -->chunk.isInit : Symbol(isInit, Decl(bug25127.js, 3, 5), Decl(bug25127.js, 15, 5)) +@@= skipped -26, +24 lines =@@ >chunk : Symbol(chunk, Decl(bug25127.js, 25, 11)) -->isInit : Symbol(isInit, Decl(bug25127.js, 3, 5), Decl(bug25127.js, 15, 5)) + >isInit : Symbol(isInit, Decl(bug25127.js, 3, 5), Decl(bug25127.js, 15, 5)) >chunk : Symbol(chunk, Decl(bug25127.js, 25, 11)) ->chunk.c : Symbol(Entry.c, Decl(bug25127.js, 1, 19)) >chunk : Symbol(chunk, Decl(bug25127.js, 25, 11)) diff --git a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.types b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.types index e7f1e04775..09933f5301 100644 --- a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.types +++ b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.types @@ -17,7 +17,7 @@ class Entry { * @return {this is Entry} */ isInit(x) { ->isInit : (x: any) => boolean +>isInit : (x: any) => this is Entry >x : any return true @@ -40,7 +40,7 @@ class Group { * @return {false} */ isInit(x) { ->isInit : (x: any) => boolean +>isInit : (x: any) => false >x : any return false @@ -49,22 +49,22 @@ class Group { } /** @param {Entry | Group} chunk */ function f(chunk) { ->f : (chunk: any) => any ->chunk : any +>f : (chunk: Entry | Group) => any +>chunk : Entry | Group let x = chunk.isInit(chunk) ? chunk.c : chunk.d >x : any >chunk.isInit(chunk) ? chunk.c : chunk.d : any ->chunk.isInit(chunk) : any ->chunk.isInit : any ->chunk : any ->isInit : any ->chunk : any +>chunk.isInit(chunk) : boolean +>chunk.isInit : ((x: any) => this is Entry) | ((x: any) => false) +>chunk : Entry | Group +>isInit : ((x: any) => this is Entry) | ((x: any) => false) +>chunk : Entry | Group >chunk.c : any ->chunk : any +>chunk : Entry >c : any >chunk.d : any ->chunk : any +>chunk : Group >d : any return x @@ -88,13 +88,13 @@ function isBoolean(value) { /** @param {boolean | number} val */ function foo(val) { ->foo : (val: any) => void ->val : any +>foo : (val: number | boolean) => void +>val : number | boolean if (isBoolean(val)) { >isBoolean(val) : boolean >isBoolean : (value: any) => value is boolean ->val : any +>val : number | boolean val; >val : boolean @@ -118,13 +118,13 @@ function isNumber(x) { return typeof x === "number" } /** @param {unknown} x */ function g(x) { ->g : (x: any) => void ->x : any +>g : (x: unknown) => void +>x : unknown if (isNumber(x)) { >isNumber(x) : boolean >isNumber : (x: any) => x is number ->x : any +>x : unknown x * 2; >x * 2 : number diff --git a/testdata/baselines/reference/submodule/conformance/syntaxErrors.types b/testdata/baselines/reference/submodule/conformance/syntaxErrors.types index cd06fcf234..52e43cddb3 100644 --- a/testdata/baselines/reference/submodule/conformance/syntaxErrors.types +++ b/testdata/baselines/reference/submodule/conformance/syntaxErrors.types @@ -11,10 +11,10 @@ declare class C { t: T } // @ts-ignore /** @param {C.} skipped */ function f(x, y, skipped) { ->f : (x: any, y: any, skipped: any) => any +>f : (x: any, y: any, skipped: C) => any >x : any >y : any ->skipped : any +>skipped : C return x.t + y.t; >x.t + y.t : any @@ -28,7 +28,7 @@ function f(x, y, skipped) { var x = f({ t: 1000 }, { t: 3000 }, { t: 5000 }); >x : any >f({ t: 1000 }, { t: 3000 }, { t: 5000 }) : any ->f : (x: any, y: any, skipped: any) => any +>f : (x: any, y: any, skipped: C) => any >{ t: 1000 } : { t: number; } >t : number >1000 : 1000 diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt index 051bb37540..3675effd28 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt @@ -1,8 +1,9 @@ +templateInsideCallback.js(15,11): error TS2304: Cannot find name 'Call'. +templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. templateInsideCallback.js(17,18): error TS7006: Parameter 'x' implicitly has an 'any' type. -templateInsideCallback.js(47,18): error TS7006: Parameter 'array' implicitly has an 'any' type. -==== templateInsideCallback.js (2 errors) ==== +==== templateInsideCallback.js (3 errors) ==== /** * @typedef Oops * @template T @@ -18,6 +19,10 @@ templateInsideCallback.js(47,18): error TS7006: Parameter 'array' implicitly has /** * @template T * @type {Call} + ~~~~ +!!! error TS2304: Cannot find name 'Call'. + ~ +!!! error TS2304: Cannot find name 'T'. */ const identity = x => x; ~ @@ -52,8 +57,6 @@ templateInsideCallback.js(47,18): error TS7006: Parameter 'array' implicitly has * @returns {unknown[]} */ function flatMap(array, iterable = identity) { - ~~~~~ -!!! error TS7006: Parameter 'array' implicitly has an 'any' type. /** @type {unknown[]} */ const result = []; for (let i = 0; i < array.length; i += 1) { diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.symbols b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.symbols index b387bc8c65..15ac0e4570 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.symbols +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.symbols @@ -63,7 +63,9 @@ function flatMap(array, iterable = identity) { for (let i = 0; i < array.length; i += 1) { >i : Symbol(i, Decl(templateInsideCallback.js, 49, 10)) >i : Symbol(i, Decl(templateInsideCallback.js, 49, 10)) +>array.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >array : Symbol(array, Decl(templateInsideCallback.js, 46, 17)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >i : Symbol(i, Decl(templateInsideCallback.js, 49, 10)) result.push(.../** @type {unknown[]} */(iterable(array[i]))); diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.symbols.diff b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.symbols.diff index 5534d73105..5e0b33b705 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.symbols.diff @@ -5,8 +5,10 @@ >i : Symbol(i, Decl(templateInsideCallback.js, 49, 10)) >i : Symbol(i, Decl(templateInsideCallback.js, 49, 10)) ->array.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) ++>array.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >array : Symbol(array, Decl(templateInsideCallback.js, 46, 17)) ->length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >i : Symbol(i, Decl(templateInsideCallback.js, 49, 10)) result.push(.../** @type {unknown[]} */(iterable(array[i]))); diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types index 60c05a7b25..cd3fad61e8 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types @@ -18,8 +18,8 @@ * @type {Call} */ const identity = x => x; ->identity : (x: any) => any ->x => x : (x: any) => any +>identity : Call +>x => x : (x: any) => any >x : any >x : any @@ -52,14 +52,14 @@ const identity = x => x; * @returns {unknown[]} */ function flatMap(array, iterable = identity) { ->flatMap : (array: any, iterable?: (x: any) => any) => any[] ->array : any ->iterable : (x: any) => any ->identity : (x: any) => any +>flatMap : (array: unknown[], iterable?: (x: unknown) => unknown) => unknown[] +>array : unknown[] +>iterable : (x: unknown) => unknown +>identity : Call /** @type {unknown[]} */ const result = []; ->result : any[] +>result : unknown[] >[] : never[] for (let i = 0; i < array.length; i += 1) { @@ -67,27 +67,28 @@ function flatMap(array, iterable = identity) { >0 : 0 >i < array.length : boolean >i : number ->array.length : any ->array : any ->length : any +>array.length : number +>array : unknown[] +>length : number >i += 1 : number >i : number >1 : 1 result.push(.../** @type {unknown[]} */(iterable(array[i]))); >result.push(.../** @type {unknown[]} */(iterable(array[i]))) : number ->result.push : (...items: any[]) => number ->result : any[] ->push : (...items: any[]) => number ->.../** @type {unknown[]} */(iterable(array[i])) : any ->(iterable(array[i])) : any ->iterable(array[i]) : any ->iterable : (x: any) => any ->array[i] : any ->array : any +>result.push : (...items: unknown[]) => number +>result : unknown[] +>push : (...items: unknown[]) => number +>.../** @type {unknown[]} */(iterable(array[i])) : unknown +>(iterable(array[i])) : unknown[] +>iterable(array[i]) : unknown[] +>iterable(array[i]) : unknown +>iterable : (x: unknown) => unknown +>array[i] : unknown +>array : unknown[] >i : number } return result; ->result : any[] +>result : unknown[] } diff --git a/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.types b/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.types index e1c5cc7591..c2d9c2495b 100644 --- a/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.types +++ b/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.types @@ -8,14 +8,14 @@ export class Element { * @returns {String} */ get textContent() { ->textContent : string +>textContent : String return '' >'' : "" } set textContent(x) {} ->textContent : string ->x : string +>textContent : String +>x : String cloneNode() { return this} >cloneNode : () => this @@ -30,19 +30,19 @@ export class TextElement extends HTMLElement { >HTMLElement : HTMLElement get innerHTML() { return this.textContent; } ->innerHTML : string ->this.textContent : string +>innerHTML : String +>this.textContent : String >this : this ->textContent : string +>textContent : String set innerHTML(html) { this.textContent = html; } ->innerHTML : string ->html : string ->this.textContent = html : string ->this.textContent : string +>innerHTML : String +>html : String +>this.textContent = html : String +>this.textContent : String >this : this ->textContent : string ->html : string +>textContent : String +>html : String toString() { >toString : () => void diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt index 7614b6986c..97c3329beb 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt @@ -1,15 +1,12 @@ -a.js(5,12): error TS7006: Parameter 's' implicitly has an 'any' type. a.js(6,12): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -==== a.js (2 errors) ==== +==== a.js (1 errors) ==== /** @this {{ n: number }} Mount Holyoke Preparatory School * @param {string} s * @return {number} */ function f(s) { - ~ -!!! error TS7006: Parameter 's' implicitly has an 'any' type. return this.n + s.length ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.symbols b/testdata/baselines/reference/submodule/conformance/thisTag1.symbols index 13f51a6f5c..123d62d3cd 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag1.symbols +++ b/testdata/baselines/reference/submodule/conformance/thisTag1.symbols @@ -10,7 +10,9 @@ function f(s) { >s : Symbol(s, Decl(a.js, 4, 11)) return this.n + s.length +>s.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(a.js, 4, 11)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) } const o = { diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.symbols.diff b/testdata/baselines/reference/submodule/conformance/thisTag1.symbols.diff index 50e7f941ca..2c28611217 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag1.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/thisTag1.symbols.diff @@ -8,8 +8,10 @@ ->this : Symbol(this) ->n : Symbol(n, Decl(a.js, 0, 12)) ->s.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ++>s.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(a.js, 4, 11)) ->length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) } const o = { diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.types b/testdata/baselines/reference/submodule/conformance/thisTag1.types index 8b5ae4145d..9643db11d1 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag1.types +++ b/testdata/baselines/reference/submodule/conformance/thisTag1.types @@ -6,34 +6,34 @@ * @return {number} */ function f(s) { ->f : (s: any) => any ->s : any +>f : (s: string) => number +>s : string return this.n + s.length >this.n + s.length : any >this.n : any >this : any >n : any ->s.length : any ->s : any ->length : any +>s.length : number +>s : string +>length : number } const o = { ->o : { f: (s: any) => any; n: number; } ->{ f, n: 1} : { f: (s: any) => any; n: number; } +>o : { f: (s: string) => number; n: number; } +>{ f, n: 1} : { f: (s: string) => number; n: number; } f, ->f : (s: any) => any +>f : (s: string) => number n: 1 >n : number >1 : 1 } o.f('hi') ->o.f('hi') : any ->o.f : (s: any) => any ->o : { f: (s: any) => any; n: number; } ->f : (s: any) => any +>o.f('hi') : number +>o.f : (s: string) => number +>o : { f: (s: string) => number; n: number; } +>f : (s: string) => number >'hi' : "hi" diff --git a/testdata/baselines/reference/submodule/conformance/thisTag3.types b/testdata/baselines/reference/submodule/conformance/thisTag3.types index ba47264596..7a0779ce9c 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag3.types +++ b/testdata/baselines/reference/submodule/conformance/thisTag3.types @@ -13,15 +13,15 @@ class C { * @param {string} a */ p = (a) => this.fn("" + a); ->p : (a: any) => any ->(a) => this.fn("" + a) : (a: any) => any ->a : any +>p : (a: string) => any +>(a) => this.fn("" + a) : (a: string) => any +>a : string >this.fn("" + a) : any >this.fn : any >this : this >fn : any >"" + a : string >"" : "" ->a : any +>a : string } diff --git a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt new file mode 100644 index 0000000000..0961be452d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt @@ -0,0 +1,61 @@ +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 (4 errors) ==== + /** + * @class + * @template T + * @param {T} t + */ + function Cp(t) { + /** @type {this} */ + this.dit = this + this.y = t + /** @return {this} */ + this.m3 = () => this + } + + Cp.prototype = { + /** @return {this} */ + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + m4() { + this.z = this.y; return this + } + } + + /** + * @class + * @template T + * @param {T} t + */ + function Cpp(t) { + this.y = t + } + /** @return {this} */ + Cpp.prototype.m2 = function () { + this.z = this.y; return this + } + + var cp = new Cp(1) + var cpp = new Cpp(2) + cp.dit + + /** @type {Cpp} */ + ~~~ +!!! error TS2749: 'Cpp' refers to a value, but is being used as a type here. Did you mean 'typeof Cpp'? + var cppn = cpp.m2() + + /** @type {Cp} */ + ~~ +!!! error TS2749: 'Cp' refers to a value, but is being used as a type here. Did you mean 'typeof Cp'? + var cpn = cp.m3() + /** @type {Cp} */ + ~~ +!!! error TS2749: 'Cp' refers to a value, but is being used as a type here. Did you mean 'typeof Cp'? + var cpn = cp.m4() + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.types b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.types index bbb36e1abf..2af7c44ddc 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.types +++ b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.types @@ -7,8 +7,8 @@ * @param {T} t */ function Cp(t) { ->Cp : { (t: any): void; prototype: { m4: () => any; }; } ->t : any +>Cp : { (t: T): void; prototype: { m4: () => any; }; } +>t : T /** @type {this} */ this.dit = this @@ -19,11 +19,11 @@ function Cp(t) { >this : any this.y = t ->this.y = t : any +>this.y = t : T >this.y : any >this : any >y : any ->t : any +>t : T /** @return {this} */ this.m3 = () => this @@ -38,7 +38,7 @@ function Cp(t) { Cp.prototype = { >Cp.prototype = { /** @return {this} */ m4() { this.z = this.y; return this }} : { m4: () => any; } >Cp.prototype : { m4: () => any; } ->Cp : { (t: any): void; prototype: { m4: () => any; }; } +>Cp : { (t: T): void; prototype: { m4: () => any; }; } >prototype : { m4: () => any; } >{ /** @return {this} */ m4() { this.z = this.y; return this }} : { m4: () => any; } @@ -64,22 +64,22 @@ Cp.prototype = { * @param {T} t */ function Cpp(t) { ->Cpp : (t: any) => void ->t : any +>Cpp : (t: T) => void +>t : T this.y = t ->this.y = t : any +>this.y = t : T >this.y : any >this : any >y : any ->t : any +>t : T } /** @return {this} */ Cpp.prototype.m2 = function () { >Cpp.prototype.m2 = function () { this.z = this.y; return this} : () => any >Cpp.prototype.m2 : any >Cpp.prototype : any ->Cpp : (t: any) => void +>Cpp : (t: T) => void >prototype : any >m2 : any >function () { this.z = this.y; return this} : () => any @@ -98,13 +98,13 @@ Cpp.prototype.m2 = function () { var cp = new Cp(1) >cp : any >new Cp(1) : any ->Cp : { (t: any): void; prototype: { m4: () => any; }; } +>Cp : { (t: T): void; prototype: { m4: () => any; }; } >1 : 1 var cpp = new Cpp(2) >cpp : any >new Cpp(2) : any ->Cpp : (t: any) => void +>Cpp : (t: T) => void >2 : 2 cp.dit @@ -114,7 +114,7 @@ cp.dit /** @type {Cpp} */ var cppn = cpp.m2() ->cppn : any +>cppn : Cpp >cpp.m2() : any >cpp.m2 : any >cpp : any @@ -122,7 +122,7 @@ var cppn = cpp.m2() /** @type {Cp} */ var cpn = cp.m3() ->cpn : any +>cpn : Cp >cp.m3() : any >cp.m3 : any >cp : any @@ -130,7 +130,7 @@ var cpn = cp.m3() /** @type {Cp} */ var cpn = cp.m4() ->cpn : any +>cpn : Cp >cp.m4() : any >cp.m4 : any >cp : any diff --git a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt deleted file mode 100644 index 8f168eb7af..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -bug25926.js(4,14): error TS2339: Property 'b' does not exist on type '{ a: () => void; }'. -bug25926.js(4,18): error TS7006: Parameter 'n' implicitly has an 'any' type. -bug25926.js(11,14): error TS2339: Property 'e' does not exist on type '{ d: () => void; }'. -bug25926.js(11,23): error TS2339: Property 'f' does not exist on type '{ d: () => void; }'. -bug25926.js(11,27): error TS7006: Parameter 'm' implicitly has an 'any' type. -bug25926.js(11,37): error TS2339: Property 'g' does not exist on type '{ d: () => void; }'. - - -==== bug25926.js (6 errors) ==== - /** @type {{ a(): void; b?(n: number): number; }} */ - const o1 = { - a() { - this.b = n => n; - ~ -!!! error TS2339: Property 'b' does not exist on type '{ a: () => void; }'. - ~ -!!! error TS7006: Parameter 'n' implicitly has an 'any' type. - } - }; - - /** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ - const o2 = { - d() { - this.e = this.f = m => this.g || m; - ~ -!!! error TS2339: Property 'e' does not exist on type '{ d: () => void; }'. - ~ -!!! error TS2339: Property 'f' does not exist on type '{ d: () => void; }'. - ~ -!!! error TS7006: Parameter 'm' implicitly has an 'any' type. - ~ -!!! error TS2339: Property 'g' does not exist on type '{ d: () => void; }'. - } - }; - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols index 65c25f84b3..4400ed3a9c 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols +++ b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols @@ -9,7 +9,9 @@ const o1 = { >a : Symbol(a, Decl(bug25926.js, 1, 12)) this.b = n => n; ->this : Symbol((Anonymous type), Decl(bug25926.js, 1, 10)) +>this.b : Symbol(b, Decl(bug25926.js, 0, 23)) +>this : Symbol((Anonymous 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)) } @@ -23,10 +25,16 @@ const o2 = { >d : Symbol(d, Decl(bug25926.js, 8, 12)) this.e = this.f = m => this.g || m; ->this : Symbol((Anonymous type), Decl(bug25926.js, 8, 10)) ->this : Symbol((Anonymous type), Decl(bug25926.js, 8, 10)) +>this.e : Symbol(e, Decl(bug25926.js, 7, 23)) +>this : Symbol((Anonymous 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((Anonymous type), Decl(bug25926.js, 7, 11)) +>f : Symbol(f, Decl(bug25926.js, 7, 46)) >m : Symbol(m, Decl(bug25926.js, 10, 25)) ->this : Symbol((Anonymous type), Decl(bug25926.js, 8, 10)) +>this.g : Symbol(g, Decl(bug25926.js, 7, 69)) +>this : Symbol((Anonymous 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 0a94aae360..f39477cc81 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.symbols.diff @@ -1,33 +1,33 @@ --- old.typeFromContextualThisType.symbols +++ new.typeFromContextualThisType.symbols -@@= skipped -8, +8 lines =@@ - >a : Symbol(a, Decl(bug25926.js, 1, 12)) +@@= skipped -9, +9 lines =@@ this.b = n => n; -->this.b : Symbol(b, Decl(bug25926.js, 0, 23)) + >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((Anonymous type), Decl(bug25926.js, 1, 10)) ++>this : Symbol((Anonymous 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)) } -@@= skipped -16, +14 lines =@@ - >d : Symbol(d, Decl(bug25926.js, 8, 12)) +@@= skipped -16, +16 lines =@@ this.e = this.f = m => this.g || m; -->this.e : Symbol(e, Decl(bug25926.js, 7, 23)) + >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.f : Symbol(f, Decl(bug25926.js, 7, 46)) ++>this : Symbol((Anonymous 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((Anonymous type), Decl(bug25926.js, 8, 10)) -+>this : Symbol((Anonymous type), Decl(bug25926.js, 8, 10)) ++>this : Symbol((Anonymous 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.g : Symbol(g, Decl(bug25926.js, 7, 69)) ->this : Symbol(__type, Decl(bug25926.js, 7, 11)) -->g : Symbol(g, Decl(bug25926.js, 7, 69)) -+>this : Symbol((Anonymous type), Decl(bug25926.js, 8, 10)) ++>this : Symbol((Anonymous 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.types b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.types index 4231bc2eea..50cfe60739 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.types @@ -3,47 +3,47 @@ === bug25926.js === /** @type {{ a(): void; b?(n: number): number; }} */ const o1 = { ->o1 : { a: () => void; } +>o1 : { a: () => void; b?: ((n: number) => number) | undefined; } >{ a() { this.b = n => n; }} : { a: () => void; } a() { >a : () => void this.b = n => n; ->this.b = n => n : (n: any) => any ->this.b : any ->this : { a: () => void; } ->b : any ->n => n : (n: any) => any ->n : any ->n : any +>this.b = n => n : (n: number) => number +>this.b : ((n: number) => number) | undefined +>this : { a: () => void; b?: ((n: number) => number) | undefined; } +>b : ((n: number) => number) | undefined +>n => n : (n: number) => number +>n : number +>n : number } }; /** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ const o2 = { ->o2 : { d: () => void; } +>o2 : { d: () => void; e?: ((n: number) => number) | undefined; f?: ((n: number) => number) | undefined; g?: number | undefined; } >{ d() { this.e = this.f = m => this.g || m; }} : { d: () => void; } d() { >d : () => void this.e = this.f = m => this.g || m; ->this.e = this.f = m => this.g || m : (m: any) => any ->this.e : any ->this : { d: () => void; } ->e : any ->this.f = m => this.g || m : (m: any) => any ->this.f : any ->this : { d: () => void; } ->f : any ->m => this.g || m : (m: any) => any ->m : any ->this.g || m : any ->this.g : any ->this : { d: () => void; } ->g : any ->m : any +>this.e = this.f = m => this.g || m : (m: number) => number +>this.e : ((n: number) => number) | undefined +>this : { d: () => void; e?: ((n: number) => number) | undefined; f?: ((n: number) => number) | undefined; g?: number | undefined; } +>e : ((n: number) => number) | undefined +>this.f = m => this.g || m : (m: number) => number +>this.f : ((n: number) => number) | undefined +>this : { d: () => void; e?: ((n: number) => number) | undefined; f?: ((n: number) => number) | undefined; g?: number | undefined; } +>f : ((n: number) => number) | undefined +>m => this.g || m : (m: number) => number +>m : number +>this.g || m : number +>this.g : number | undefined +>this : { d: () => void; e?: ((n: number) => number) | undefined; f?: ((n: number) => number) | undefined; g?: number | undefined; } +>g : number | undefined +>m : number } }; diff --git a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt index 2e2365b572..ecf3829086 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt @@ -1,17 +1,15 @@ a.js(7,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -a.js(22,5): error TS7034: Variable 'n' implicitly has type 'any' in some locations where its type cannot be determined. -a.js(25,26): error TS7005: Variable 'n' implicitly has an 'any' type. a.js(27,5): error TS2322: Type 'undefined' is not assignable to type 'null'. a.js(29,5): error TS2322: Type '1' is not assignable to type 'null'. a.js(30,5): error TS2322: Type 'true' is not assignable to type 'null'. a.js(31,5): error TS2322: Type '{}' is not assignable to type 'null'. a.js(32,5): error TS2322: Type '"ok"' is not assignable to type 'null'. +a.js(37,5): error TS2322: Type 'string' is not assignable to type 'number'. a.js(40,12): error TS2345: Argument of type '1' is not assignable to parameter of type 'never'. a.js(41,12): error TS2345: Argument of type '"ok"' is not assignable to parameter of type 'never'. -a.js(56,17): error TS7006: Parameter 'v' implicitly has an 'any' type. -==== a.js (11 errors) ==== +==== a.js (9 errors) ==== function A () { // should get any on this-assignments in constructor this.unknown = null @@ -36,13 +34,9 @@ a.js(56,17): error TS7006: Parameter 'v' implicitly has an 'any' type. /** @type {number | undefined} */ var n; - ~ -!!! error TS7034: Variable 'n' implicitly has type 'any' in some locations where its type cannot be determined. // should get any on parameter initialisers function f(a = null, b = n, l = []) { - ~ -!!! error TS7005: Variable 'n' implicitly has an 'any' type. // a should be null in strict mode a = undefined ~ @@ -65,6 +59,8 @@ a.js(56,17): error TS7006: Parameter 'v' implicitly has an 'any' type. b = 1 b = undefined b = 'error' + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. // l should be any[] l.push(1) @@ -88,8 +84,6 @@ a.js(56,17): error TS7006: Parameter 'v' implicitly has an 'any' type. /** @type {(v: unknown) => v is undefined} */ const isUndef = v => v === undefined; - ~ -!!! error TS7006: Parameter 'v' implicitly has an 'any' type. const e = [1, undefined]; // should be undefined[] diff --git a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.types b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.types index 9d0d60d503..dbcb1afd01 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.types @@ -124,14 +124,14 @@ a.empty.push('hi') /** @type {number | undefined} */ var n; ->n : any +>n : number | undefined // should get any on parameter initialisers function f(a = null, b = n, l = []) { ->f : (a?: null, b?: any, l?: never[]) => void +>f : (a?: null, b?: number | undefined, l?: never[]) => void >a : null ->b : any ->n : any +>b : number | undefined +>n : number | undefined >l : never[] >[] : never[] @@ -168,17 +168,17 @@ function f(a = null, b = n, l = []) { // b should be number | undefined, not any b = 1 >b = 1 : 1 ->b : any +>b : number | undefined >1 : 1 b = undefined >b = undefined : undefined ->b : any +>b : number | undefined >undefined : undefined b = 'error' >b = 'error' : "error" ->b : any +>b : number | undefined >'error' : "error" // l should be any[] @@ -240,11 +240,11 @@ l.push('ok') /** @type {(v: unknown) => v is undefined} */ const isUndef = v => v === undefined; ->isUndef : (v: any) => boolean ->v => v === undefined : (v: any) => boolean ->v : any +>isUndef : (v: unknown) => v is undefined +>v => v === undefined : (v: unknown) => v is undefined +>v : unknown >v === undefined : boolean ->v : any +>v : unknown >undefined : undefined const e = [1, undefined]; @@ -255,10 +255,10 @@ const e = [1, undefined]; // should be undefined[] const g = e.filter(isUndef); ->g : (number | undefined)[] ->e.filter(isUndef) : (number | undefined)[] +>g : undefined[] +>e.filter(isUndef) : undefined[] >e.filter : { (predicate: (value: number | undefined, index: number, array: (number | undefined)[]) => value is S, thisArg?: any): S[]; (predicate: (value: number | undefined, index: number, array: (number | undefined)[]) => unknown, thisArg?: any): (number | undefined)[]; } >e : (number | undefined)[] >filter : { (predicate: (value: number | undefined, index: number, array: (number | undefined)[]) => value is S, thisArg?: any): S[]; (predicate: (value: number | undefined, index: number, array: (number | undefined)[]) => unknown, thisArg?: any): (number | undefined)[]; } ->isUndef : (v: any) => boolean +>isUndef : (v: unknown) => v is undefined diff --git a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt index 7fc773fa28..58532b712f 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt @@ -1,21 +1,16 @@ -a.js(2,5): error TS7034: Variable 'n' implicitly has type 'any' in some locations where its type cannot be determined. a.js(5,12): error TS7006: Parameter 'a' implicitly has an 'any' type. -a.js(5,26): error TS7005: Variable 'n' implicitly has an 'any' type. a.js(5,29): error TS7006: Parameter 'l' implicitly has an 'any[]' type. +a.js(17,5): error TS2322: Type 'string' is not assignable to type 'number'. -==== a.js (4 errors) ==== +==== a.js (3 errors) ==== /** @type {number | undefined} */ var n; - ~ -!!! error TS7034: Variable 'n' implicitly has type 'any' in some locations where its type cannot be determined. // should get any on parameter initialisers function f(a = null, b = n, l = []) { ~~~~~~~~ !!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7005: Variable 'n' implicitly has an 'any' type. ~~~~~~ !!! error TS7006: Parameter 'l' implicitly has an 'any[]' type. // a should be any @@ -30,6 +25,8 @@ a.js(5,29): error TS7006: Parameter 'l' implicitly has an 'any[]' type. b = 1 b = undefined b = 'error' + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. // l should be any[] l.push(1) diff --git a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.types b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.types index 86a5e073c4..960829fc27 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.types @@ -3,14 +3,14 @@ === a.js === /** @type {number | undefined} */ var n; ->n : any +>n : number // should get any on parameter initialisers function f(a = null, b = n, l = []) { ->f : (a?: any, b?: any, l?: any[]) => void +>f : (a?: any, b?: number, l?: any[]) => void >a : any ->b : any ->n : any +>b : number +>n : number >l : any[] >[] : undefined[] @@ -47,17 +47,17 @@ function f(a = null, b = n, l = []) { // b should be number | undefined, not any b = 1 >b = 1 : 1 ->b : any +>b : number >1 : 1 b = undefined >b = undefined : undefined ->b : any +>b : number >undefined : undefined b = 'error' >b = 'error' : "error" ->b : any +>b : number >'error' : "error" // l should be any[] diff --git a/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt index acff5629e9..631f5be936 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt @@ -1,6 +1,14 @@ +a.js(3,13): error TS2749: 'A' refers to a value, but is being used as a type here. Did you mean 'typeof A'? b-ext.js(3,14): error TS2339: Property 'x' does not exist on type 'B'. +b.js(3,13): error TS2749: 'B' refers to a value, but is being used as a type here. Did you mean 'typeof B'? +c.js(3,13): error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? +d.js(3,13): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? e-ext.js(3,14): error TS2339: Property 'x' does not exist on type 'E'. +e.js(3,13): error TS2749: 'E' refers to a value, but is being used as a type here. Did you mean 'typeof E'? +f.js(5,13): error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? +g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? h.js(3,14): error TS2339: Property 'x' does not exist on type 'H'. +h.js(8,19): error TS2339: Property 'x' does not exist on type 'H'. ==== node.d.ts (0 errors) ==== @@ -12,10 +20,12 @@ h.js(3,14): error TS2339: Property 'x' does not exist on type 'H'. this.x = 1; }; -==== a.js (0 errors) ==== +==== a.js (1 errors) ==== const { A } = require("./a-ext"); /** @param {A} p */ + ~ +!!! error TS2749: 'A' refers to a value, but is being used as a type here. Did you mean 'typeof A'? function a(p) { p.x; } ==== b-ext.js (1 errors) ==== @@ -27,10 +37,12 @@ h.js(3,14): error TS2339: Property 'x' does not exist on type 'H'. } }; -==== b.js (0 errors) ==== +==== b.js (1 errors) ==== const { B } = require("./b-ext"); /** @param {B} p */ + ~ +!!! error TS2749: 'B' refers to a value, but is being used as a type here. Did you mean 'typeof B'? function b(p) { p.x; } ==== c-ext.js (0 errors) ==== @@ -38,10 +50,12 @@ h.js(3,14): error TS2339: Property 'x' does not exist on type 'H'. this.x = 1; } -==== c.js (0 errors) ==== +==== c.js (1 errors) ==== const { C } = require("./c-ext"); /** @param {C} p */ + ~ +!!! error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? function c(p) { p.x; } ==== d-ext.js (0 errors) ==== @@ -49,10 +63,12 @@ h.js(3,14): error TS2339: Property 'x' does not exist on type 'H'. this.x = 1; }; -==== d.js (0 errors) ==== +==== d.js (1 errors) ==== const { D } = require("./d-ext"); /** @param {D} p */ + ~ +!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? function d(p) { p.x; } ==== e-ext.js (1 errors) ==== @@ -64,29 +80,35 @@ h.js(3,14): error TS2339: Property 'x' does not exist on type 'H'. } } -==== e.js (0 errors) ==== +==== e.js (1 errors) ==== const { E } = require("./e-ext"); /** @param {E} p */ + ~ +!!! error TS2749: 'E' refers to a value, but is being used as a type here. Did you mean 'typeof E'? function e(p) { p.x; } -==== f.js (0 errors) ==== +==== f.js (1 errors) ==== var F = function () { this.x = 1; }; /** @param {F} p */ + ~ +!!! error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? function f(p) { p.x; } -==== g.js (0 errors) ==== +==== g.js (1 errors) ==== function G() { this.x = 1; } /** @param {G} p */ + ~ +!!! error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? function g(p) { p.x; } -==== h.js (1 errors) ==== +==== h.js (2 errors) ==== class H { constructor() { this.x = 1; @@ -96,4 +118,6 @@ h.js(3,14): error TS2339: Property 'x' does not exist on type 'H'. } /** @param {H} p */ - function h(p) { p.x; } \ No newline at end of file + function h(p) { p.x; } + ~ +!!! error TS2339: Property 'x' does not exist on type 'H'. \ 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 8aeaa9daa3..ebf78ebb4f 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.types @@ -35,10 +35,10 @@ const { A } = require("./a-ext"); /** @param {A} p */ function a(p) { p.x; } ->a : (p: any) => void ->p : any +>a : (p: A) => void +>p : A >p.x : any ->p : any +>p : A >x : any === b-ext.js === @@ -68,10 +68,10 @@ const { B } = require("./b-ext"); /** @param {B} p */ function b(p) { p.x; } ->b : (p: any) => void ->p : any +>b : (p: B) => void +>p : B >p.x : any ->p : any +>p : B >x : any === c-ext.js === @@ -95,10 +95,10 @@ const { C } = require("./c-ext"); /** @param {C} p */ function c(p) { p.x; } ->c : (p: any) => void ->p : any +>c : (p: C) => void +>p : C >p.x : any ->p : any +>p : C >x : any === d-ext.js === @@ -124,10 +124,10 @@ const { D } = require("./d-ext"); /** @param {D} p */ function d(p) { p.x; } ->d : (p: any) => void ->p : any +>d : (p: D) => void +>p : D >p.x : any ->p : any +>p : D >x : any === e-ext.js === @@ -153,10 +153,10 @@ const { E } = require("./e-ext"); /** @param {E} p */ function e(p) { p.x; } ->e : (p: any) => void ->p : any +>e : (p: E) => void +>p : E >p.x : any ->p : any +>p : E >x : any === f.js === @@ -175,10 +175,10 @@ var F = function () { /** @param {F} p */ function f(p) { p.x; } ->f : (p: any) => void ->p : any +>f : (p: F) => void +>p : F >p.x : any ->p : any +>p : F >x : any === g.js === @@ -195,10 +195,10 @@ function G() { /** @param {G} p */ function g(p) { p.x; } ->g : (p: any) => void ->p : any +>g : (p: G) => void +>p : G >p.x : any ->p : any +>p : G >x : any === h.js === @@ -217,9 +217,9 @@ class H { /** @param {H} p */ function h(p) { p.x; } ->h : (p: any) => void ->p : any +>h : (p: H) => void +>p : H >p.x : any ->p : any +>p : H >x : any diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.types b/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.types index add27511ea..3957ca0f84 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.types @@ -8,28 +8,28 @@ class C { /** @type {{ foo?: string } | undefined } */ #a; ->#a : any +>#a : { foo?: string; } /** @type {{ foo?: string } | undefined } */ #b; ->#b : any +>#b : { foo?: string; } m() { >m : () => void const a = this.#a || {}; ->a : any ->this.#a || {} : any ->this.#a : any +>a : { foo?: string; } +>this.#a || {} : { foo?: string; } +>this.#a : { foo?: string; } >this : this >{} : {} this.#b = this.#b || {}; ->this.#b = this.#b || {} : any ->this.#b : any +>this.#b = this.#b || {} : { foo?: string; } +>this.#b : { foo?: string; } >this : this ->this.#b || {} : any ->this.#b : any +>this.#b || {} : { foo?: string; } +>this.#b : { foo?: string; } >this : this >{} : {} } diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt index 47fe9440fb..7a0891aa8f 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt @@ -1,7 +1,9 @@ a.js(4,7): error TS2339: Property 'Inner' does not exist on type 'typeof O'. +a.js(8,12): error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? +a.js(11,12): error TS2503: Cannot find namespace 'Outer'. -==== a.js (1 errors) ==== +==== a.js (3 errors) ==== var Outer = class O { m(x, y) { } } @@ -12,9 +14,13 @@ a.js(4,7): error TS2339: Property 'Inner' does not exist on type 'typeof O'. } /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? var si si.m /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var oi oi.n diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.types index a8bfcd05dd..0b589e5d68 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.types @@ -27,20 +27,20 @@ Outer.Inner = class I { } /** @type {Outer} */ var si ->si : any +>si : Outer si.m >si.m : any ->si : any +>si : Outer >m : any /** @type {Outer.Inner} */ var oi ->oi : any +>oi : Inner oi.n >oi.n : any ->oi : any +>oi : Inner >n : any diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt index 579073d8b0..12557bce5a 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt @@ -1,3 +1,4 @@ +main.js(4,12): error TS2503: Cannot find namespace 'Outer'. someview.js(10,14): error TS2339: Property 'y' does not exist on type 'Inner'. @@ -39,11 +40,13 @@ someview.js(10,14): error TS2339: Property 'y' does not exist on type 'Inner'. }; return Application; })(); -==== main.js (0 errors) ==== +==== main.js (1 errors) ==== var app = new Outer.app.Application(); var inner = new Outer.app.Inner(); inner.y; /** @type {Outer.app.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var x; x.y; Outer.app.statische(101); // Infinity, duh diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.types index 14169a295b..67ced614c7 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.types @@ -158,11 +158,11 @@ inner.y; /** @type {Outer.app.Inner} */ var x; ->x : any +>x : Inner x.y; >x.y : any ->x : any +>x : Inner >y : any Outer.app.statische(101); // Infinity, duh diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.errors.txt index 9726ce6c15..4c083f927a 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.errors.txt @@ -1,3 +1,4 @@ +main.js(4,12): error TS2503: Cannot find namespace 'Outer'. someview.js(10,14): error TS2339: Property 'y' does not exist on type 'Inner'. @@ -39,11 +40,13 @@ someview.js(10,14): error TS2339: Property 'y' does not exist on type 'Inner'. }; return Application; })(); -==== main.js (0 errors) ==== +==== main.js (1 errors) ==== var app = new Outer.app.Application(); var inner = new Outer.app.Inner(); inner.y; /** @type {Outer.app.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var x; x.y; Outer.app.statische(101); // Infinity, duh diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.types index f829a19665..ddca325660 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.types @@ -158,11 +158,11 @@ inner.y; /** @type {Outer.app.Inner} */ var x; ->x : any +>x : Inner x.y; >x.y : any ->x : any +>x : Inner >y : any Outer.app.statische(101); // Infinity, duh diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt index dc608b527e..aa43d4abec 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt @@ -1,3 +1,4 @@ +use.js(1,12): error TS2503: Cannot find namespace 'Outer'. use.js(5,22): error TS2339: Property 'Inner' does not exist on type '{}'. work.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. work.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. @@ -17,8 +18,10 @@ work.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. m() { } } -==== use.js (1 errors) ==== +==== use.js (2 errors) ==== /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var inner inner.x inner.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.types index 2b5bc0f7a6..a1c65551f3 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.types @@ -33,17 +33,17 @@ Outer.Inner.prototype = { === use.js === /** @type {Outer.Inner} */ var inner ->inner : any +>inner : Inner inner.x >inner.x : any ->inner : any +>inner : Inner >x : any inner.m() >inner.m() : any >inner.m : any ->inner : any +>inner : Inner >m : any var inno = new Outer.Inner() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt index 9a82edb3d4..fb4921e205 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt @@ -1,9 +1,10 @@ a.js(3,7): error TS2339: Property 'Inner' does not exist on type '{}'. a.js(5,14): error TS2339: Property 'x' does not exist on type 'Inner'. +a.js(10,12): error TS2503: Cannot find namespace 'Outer'. a.js(14,22): error TS2339: Property 'Inner' does not exist on type '{}'. -==== a.js (3 errors) ==== +==== a.js (4 errors) ==== var Outer = {}; Outer.Inner = class { @@ -18,6 +19,8 @@ a.js(14,22): error TS2339: Property 'Inner' does not exist on type '{}'. } /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var inner inner.x inner.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.types index 3eb8086081..e7fe47d659 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.types @@ -26,17 +26,17 @@ Outer.Inner = class { /** @type {Outer.Inner} */ var inner ->inner : any +>inner : Inner inner.x >inner.x : any ->inner : any +>inner : Inner >x : any inner.m() >inner.m() : any >inner.m : any ->inner : any +>inner : Inner >m : any var inno = new Outer.Inner() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt index 05184f45d8..c54db8a4a9 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt @@ -1,9 +1,10 @@ a.js(3,7): error TS2339: Property 'Inner' does not exist on type '{}'. a.js(4,7): error TS2339: Property 'Inner' does not exist on type '{}'. +a.js(9,12): error TS2503: Cannot find namespace 'Outer'. a.js(13,22): error TS2339: Property 'Inner' does not exist on type '{}'. -==== a.js (3 errors) ==== +==== a.js (4 errors) ==== var Outer = {}; Outer.Inner = function () {} @@ -17,6 +18,8 @@ a.js(13,22): error TS2339: Property 'Inner' does not exist on type '{}'. } /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var inner inner.x inner.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.types index af6a82e71d..68b7a9b039 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.types @@ -31,17 +31,17 @@ Outer.Inner.prototype = { /** @type {Outer.Inner} */ var inner ->inner : any +>inner : Inner inner.x >inner.x : any ->inner : any +>inner : Inner >x : any inner.m() >inner.m() : any >inner.m : any ->inner : any +>inner : Inner >m : any var inno = new Outer.Inner() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt index 477e317e0e..8cb50e996a 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt @@ -1,7 +1,9 @@ a.js(6,14): error TS2339: Property 'x' does not exist on type 'I'. +a.js(9,12): error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? +a.js(12,12): error TS2503: Cannot find namespace 'Outer'. -==== a.js (1 errors) ==== +==== a.js (3 errors) ==== function Outer() { this.y = 2 } @@ -13,9 +15,13 @@ a.js(6,14): error TS2339: Property 'x' does not exist on type 'I'. } } /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? var ok ok.y /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var oc oc.x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.types index a5ed2732a2..5d2d486285 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.types @@ -30,19 +30,19 @@ Outer.Inner = class I { } /** @type {Outer} */ var ok ->ok : any +>ok : Outer ok.y >ok.y : any ->ok : any +>ok : Outer >y : any /** @type {Outer.Inner} */ var oc ->oc : any +>oc : Inner oc.x >oc.x : any ->oc : any +>oc : Inner >x : any diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt index d4e17911fb..4de02a5a06 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt @@ -1,9 +1,10 @@ def.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. usage.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. usage.js(5,19): error TS2339: Property 'Inner' does not exist on type '{}'. +usage.js(7,12): error TS2503: Cannot find namespace 'Outer'. -==== usage.js (2 errors) ==== +==== usage.js (3 errors) ==== // note that usage is first in the compilation Outer.Inner.Message = function() { ~~~~~ @@ -15,6 +16,8 @@ usage.js(5,19): error TS2339: Property 'Inner' does not exist on type '{}'. !!! error TS2339: Property 'Inner' does not exist on type '{}'. y.name /** @type {Outer.Inner} should be instance type, not static type */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var x; x.name diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.types index 171a756889..3f23cf8e7e 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.types @@ -27,11 +27,11 @@ y.name /** @type {Outer.Inner} should be instance type, not static type */ var x; ->x : any +>x : Inner x.name >x.name : any ->x : any +>x : Inner >name : any === def.js === diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt index e9e2972b40..f02f8f9f4d 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt @@ -1,8 +1,10 @@ a.js(4,7): error TS2339: Property 'Inner' does not exist on type '() => void'. a.js(6,14): error TS2339: Property 'x' does not exist on type 'I'. +a.js(9,12): error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? +a.js(12,12): error TS2503: Cannot find namespace 'Outer'. -==== a.js (2 errors) ==== +==== a.js (4 errors) ==== var Outer = function O() { this.y = 2 } @@ -16,9 +18,13 @@ a.js(6,14): error TS2339: Property 'x' does not exist on type 'I'. } } /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? var ja ja.y /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var da da.x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.types index 3528450433..66b50f5dd7 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.types @@ -32,19 +32,19 @@ Outer.Inner = class I { } /** @type {Outer} */ var ja ->ja : any +>ja : Outer ja.y >ja.y : any ->ja : any +>ja : Outer >y : any /** @type {Outer.Inner} */ var da ->da : any +>da : Inner da.x >da.x : any ->da : any +>da : Inner >x : any diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt index 08e085ad62..13dca3e156 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt @@ -1,3 +1,4 @@ +bug26877.js(1,13): error TS2503: Cannot find namespace 'Emu'. bug26877.js(4,23): error TS2339: Property 'D' does not exist on type '{}'. bug26877.js(5,19): error TS2339: Property 'D' does not exist on type '{}'. bug26877.js(7,5): error TS2339: Property 'D' does not exist on type '{}'. @@ -5,8 +6,10 @@ bug26877.js(9,14): error TS2339: Property '_model' does not exist on type 'D'. second.js(3,5): error TS2339: Property 'D' does not exist on type '{}'. -==== bug26877.js (4 errors) ==== +==== bug26877.js (5 errors) ==== /** @param {Emu.D} x */ + ~~~ +!!! error TS2503: Cannot find namespace 'Emu'. function ollKorrect(x) { x._model const y = new Emu.D() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.types index 6265d58c28..1bac114802 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.types @@ -3,12 +3,12 @@ === bug26877.js === /** @param {Emu.D} x */ function ollKorrect(x) { ->ollKorrect : (x: any) => void ->x : any +>ollKorrect : (x: D) => void +>x : D x._model >x._model : any ->x : any +>x : D >_model : any const y = new Emu.D() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt index 91587b0f27..3b644b682e 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt @@ -1,13 +1,15 @@ a.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. a.js(4,14): error TS2339: Property 'y' does not exist on type 'Inner'. +a.js(8,12): error TS2503: Cannot find namespace 'Outer'. a.js(11,23): error TS2339: Property 'Inner' does not exist on type '{}'. +b.js(1,12): error TS2503: Cannot find namespace 'Outer'. b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. ==== def.js (0 errors) ==== var Outer = {}; -==== a.js (3 errors) ==== +==== a.js (4 errors) ==== Outer.Inner = class { ~~~~~ !!! error TS2339: Property 'Inner' does not exist on type '{}'. @@ -20,6 +22,8 @@ b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. } /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var local local.y var inner = new Outer.Inner() @@ -27,8 +31,10 @@ b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. !!! error TS2339: Property 'Inner' does not exist on type '{}'. inner.y -==== b.js (1 errors) ==== +==== b.js (2 errors) ==== /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. var x x.y var z = new Outer.Inner() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.types index b11991982b..a431f9b7a0 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.types @@ -26,11 +26,11 @@ Outer.Inner = class { /** @type {Outer.Inner} */ var local ->local : any +>local : Inner local.y >local.y : any ->local : any +>local : Inner >y : any var inner = new Outer.Inner() @@ -48,11 +48,11 @@ inner.y === b.js === /** @type {Outer.Inner} */ var x ->x : any +>x : Inner x.y >x.y : any ->x : any +>x : Inner >y : any var z = new Outer.Inner() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.errors.txt new file mode 100644 index 0000000000..9e6a8111a7 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.errors.txt @@ -0,0 +1,14 @@ +typeFromPropertyAssignment40.js(5,12): error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? + + +==== typeFromPropertyAssignment40.js (1 errors) ==== + function Outer() { + var self = this + self.y = 2 + } + /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? + var ok + ok.y + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.types index 023749cf32..27e564b678 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.types @@ -17,10 +17,10 @@ function Outer() { } /** @type {Outer} */ var ok ->ok : any +>ok : Outer ok.y >ok.y : any ->ok : any +>ok : Outer >y : any diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt new file mode 100644 index 0000000000..d247630d9d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt @@ -0,0 +1,18 @@ +b.js(3,12): error TS2503: Cannot find namespace 'MC'. + + +==== a.js (0 errors) ==== + export default function MyClass() { + } + MyClass.bar = class C { + } + MyClass.bar + +==== b.js (1 errors) ==== + import MC from './a' + MC.bar + /** @type {MC.bar} */ + ~~ +!!! error TS2503: Cannot find namespace 'MC'. + var x + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.types index 2a85aeab2e..11fbaadbd0 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.types @@ -28,5 +28,5 @@ MC.bar /** @type {MC.bar} */ var x ->x : any +>x : bar diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt index 1798238608..48dce5754d 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt @@ -1,6 +1,7 @@ a.js(1,7): error TS2339: Property 'Inner' does not exist on type 'typeof Outer'. a.js(5,7): error TS2339: Property 'i' does not exist on type 'typeof Outer'. b.js(1,18): error TS2339: Property 'i' does not exist on type 'typeof Outer'. +b.js(3,13): error TS2702: 'Outer' only refers to a type, but is being used as a namespace here. ==== def.js (0 errors) ==== @@ -17,12 +18,14 @@ b.js(1,18): error TS2339: Property 'i' does not exist on type 'typeof Outer'. ~ !!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. -==== b.js (1 errors) ==== +==== b.js (2 errors) ==== var msgs = Outer.i.messages() ~ !!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. /** @param {Outer.Inner} inner */ + ~~~~~ +!!! error TS2702: 'Outer' only refers to a type, but is being used as a namespace here. function x(inner) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.types index c4180f9437..46c6709826 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.types @@ -35,7 +35,7 @@ var msgs = Outer.i.messages() /** @param {Outer.Inner} inner */ function x(inner) { ->x : (inner: any) => void ->inner : any +>x : (inner: Inner) => void +>inner : Inner } diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt index 594bf0fd6f..c10ea07ed6 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt @@ -3,9 +3,10 @@ index.js(2,8): error TS2339: Property 'Object' does not exist on type '{}'. index.js(2,37): error TS2339: Property 'Item' does not exist on type '{}'. index.js(4,11): error TS2339: Property 'Object' does not exist on type '{}'. index.js(4,41): error TS2339: Property 'Object' does not exist on type '{}'. +index.js(6,12): error TS2503: Cannot find namespace 'Workspace'. -==== index.js (5 errors) ==== +==== index.js (6 errors) ==== First.Item = class I {} ~~~~ !!! error TS2339: Property 'Item' does not exist on type '{}'. @@ -22,6 +23,8 @@ index.js(4,41): error TS2339: Property 'Object' does not exist on type '{}'. !!! error TS2339: Property 'Object' does not exist on type '{}'. /** @type {Workspace.Object} */ + ~~~~~~~~~ +!!! error TS2503: Cannot find namespace 'Workspace'. var am; ==== roots.js (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.types b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.types index 5c4d2e8157..4c65eed0ab 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.types @@ -31,7 +31,7 @@ Workspace.Object = class extends Common.Object {} /** @type {Workspace.Object} */ var am; ->am : any +>am : Object === roots.js === var First = {}; diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt index e43f5a5ed7..03f06755e4 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt @@ -1,11 +1,10 @@ bug26885.js(2,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -bug26885.js(10,5): error TS7023: 'get' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -bug26885.js(10,9): error TS7006: Parameter 'key' implicitly has an 'any' type. -bug26885.js(11,21): error TS2339: Property '_map' does not exist on type '{ get: (key: any) => any; }'. +bug26885.js(11,21): error TS2339: Property '_map' does not exist on type '{ get: (key: string) => number; }'. +bug26885.js(15,12): error TS2749: 'Multimap3' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap3'? bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -==== bug26885.js (5 errors) ==== +==== bug26885.js (4 errors) ==== function Multimap3() { this._map = {}; ~~~~ @@ -18,17 +17,15 @@ bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a constru * @returns {number} the value ok */ get(key) { - ~~~ -!!! error TS7023: 'get' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. - ~~~ -!!! error TS7006: Parameter 'key' implicitly has an 'any' type. return this._map[key + '']; ~~~~ -!!! error TS2339: Property '_map' does not exist on type '{ get: (key: any) => any; }'. +!!! error TS2339: Property '_map' does not exist on type '{ get: (key: string) => number; }'. } } /** @type {Multimap3} */ + ~~~~~~~~~ +!!! error TS2749: 'Multimap3' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap3'? const map = new Multimap3(); ~~~~~~~~~~~~~~~ !!! error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.types b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.types index ec8abf02a3..86ee9d157f 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.types @@ -2,7 +2,7 @@ === bug26885.js === function Multimap3() { ->Multimap3 : { (): void; prototype: { get: (key: any) => any; }; } +>Multimap3 : { (): void; prototype: { get: (key: string) => number; }; } this._map = {}; >this._map = {} : {} @@ -14,42 +14,42 @@ function Multimap3() { }; Multimap3.prototype = { ->Multimap3.prototype = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } ->Multimap3.prototype : { get: (key: any) => any; } ->Multimap3 : { (): void; prototype: { get: (key: any) => any; }; } ->prototype : { get: (key: any) => any; } ->{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } +>Multimap3.prototype = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: string) => number; } +>Multimap3.prototype : { get: (key: string) => number; } +>Multimap3 : { (): void; prototype: { get: (key: string) => number; }; } +>prototype : { get: (key: string) => number; } +>{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: string) => number; } /** * @param {string} key * @returns {number} the value ok */ get(key) { ->get : (key: any) => any ->key : any +>get : (key: string) => number +>key : string return this._map[key + '']; >this._map[key + ''] : any >this._map : any ->this : { get: (key: any) => any; } +>this : { get: (key: string) => number; } >_map : any >key + '' : string ->key : any +>key : string >'' : "" } } /** @type {Multimap3} */ const map = new Multimap3(); ->map : any +>map : Multimap3 >new Multimap3() : any ->Multimap3 : { (): void; prototype: { get: (key: any) => any; }; } +>Multimap3 : { (): void; prototype: { get: (key: string) => number; }; } const n = map.get('hi') >n : any >map.get('hi') : any >map.get : any ->map : any +>map : Multimap3 >get : any >'hi' : "hi" diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.types b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.types index 11631672a8..23acb0371f 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.types +++ b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.types @@ -2,7 +2,7 @@ === a.js === function Multimap4() { ->Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } +>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } this._map = {}; >this._map = {} : {} @@ -14,19 +14,19 @@ function Multimap4() { }; Multimap4["prototype"] = { ->Multimap4["prototype"] = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } ->Multimap4["prototype"] : { get: (key: any) => any; } ->Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } +>Multimap4["prototype"] = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: string) => number; } +>Multimap4["prototype"] : { get: (key: string) => number; } +>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } >"prototype" : "prototype" ->{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } +>{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: string) => number; } /** * @param {string} key * @returns {number} the value ok */ get(key) { ->get : (key: any) => any ->key : any +>get : (key: string) => number +>key : string return this._map[key + '']; >this._map[key + ''] : any @@ -34,7 +34,7 @@ Multimap4["prototype"] = { >this : any >_map : any >key + '' : string ->key : any +>key : string >'' : "" } }; @@ -42,8 +42,8 @@ Multimap4["prototype"] = { Multimap4["prototype"]["add-on"] = function() {}; >Multimap4["prototype"]["add-on"] = function() {} : () => void >Multimap4["prototype"]["add-on"] : any ->Multimap4["prototype"] : { get: (key: any) => any; } ->Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } +>Multimap4["prototype"] : { get: (key: string) => number; } +>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } >"prototype" : "prototype" >"add-on" : "add-on" >function() {} : () => void @@ -51,8 +51,8 @@ Multimap4["prototype"]["add-on"] = function() {}; Multimap4["prototype"]["addon"] = function() {}; >Multimap4["prototype"]["addon"] = function() {} : () => void >Multimap4["prototype"]["addon"] : any ->Multimap4["prototype"] : { get: (key: any) => any; } ->Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } +>Multimap4["prototype"] : { get: (key: string) => number; } +>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } >"prototype" : "prototype" >"addon" : "addon" >function() {} : () => void @@ -60,8 +60,8 @@ Multimap4["prototype"]["addon"] = function() {}; Multimap4["prototype"]["__underscores__"] = function() {}; >Multimap4["prototype"]["__underscores__"] = function() {} : () => void >Multimap4["prototype"]["__underscores__"] : any ->Multimap4["prototype"] : { get: (key: any) => any; } ->Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } +>Multimap4["prototype"] : { get: (key: string) => number; } +>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } >"prototype" : "prototype" >"__underscores__" : "__underscores__" >function() {} : () => void @@ -69,7 +69,7 @@ Multimap4["prototype"]["__underscores__"] = function() {}; const map4 = new Multimap4(); >map4 : any >new Multimap4() : any ->Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } +>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } map4.get(""); >map4.get("") : any diff --git a/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt b/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt new file mode 100644 index 0000000000..b8f89f9c63 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt @@ -0,0 +1,11 @@ +a.js(3,12): error TS2503: Cannot find namespace 'ns'. + + +==== a.js (1 errors) ==== + // #22973 + var ns = (function() {})(); + /** @type {ns.NotFound} */ + ~~ +!!! error TS2503: Cannot find namespace 'ns'. + var crash; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.types b/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.types index 96858aef83..b9280c03ce 100644 --- a/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.types +++ b/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.types @@ -10,5 +10,5 @@ var ns = (function() {})(); /** @type {ns.NotFound} */ var crash; ->crash : any +>crash : NotFound diff --git a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt new file mode 100644 index 0000000000..71b0b2cce5 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt @@ -0,0 +1,14 @@ +typeTagNoErasure.js(1,39): error TS2304: Cannot find name 'T'. + + +==== typeTagNoErasure.js (1 errors) ==== + /** @template T @typedef {(data: T1) => T1} Test */ + ~ +!!! error TS2304: Cannot find name 'T'. + + /** @type {Test} */ + const test = dibbity => dibbity + + test(1) // ok, T=1 + test('hi') // error, T=number + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types index ccb3f5d161..ef248f206c 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types +++ b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types @@ -5,18 +5,18 @@ /** @type {Test} */ const test = dibbity => dibbity ->test : (dibbity: any) => any ->dibbity => dibbity : (dibbity: any) => any ->dibbity : any ->dibbity : any +>test : (data: T1) => T1 +>dibbity => dibbity : (dibbity: T1) => T1 +>dibbity : T1 +>dibbity : T1 test(1) // ok, T=1 ->test(1) : any ->test : (dibbity: any) => any +>test(1) : 1 +>test : (data: T1) => T1 >1 : 1 test('hi') // error, T=number ->test('hi') : any ->test : (dibbity: any) => any +>test('hi') : "hi" +>test : (data: T1) => T1 >'hi' : "hi" diff --git a/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.types b/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.types index 9ff1f2e75d..4b523d5efb 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.types +++ b/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.types @@ -20,15 +20,15 @@ inJs(1); // lints error. Why? /**@type {IFn}*/ const inJsArrow = (j) => { ->inJsArrow : (j: any) => any ->(j) => { return j;} : (j: any) => any ->j : any +>inJsArrow : IFn +>(j) => { return j;} : (j: T) => T +>j : T return j; ->j : any +>j : T } inJsArrow(2); // no error gets linted as expected ->inJsArrow(2) : any ->inJsArrow : (j: any) => any +>inJsArrow(2) : 2 +>inJsArrow : IFn >2 : 2 diff --git a/testdata/baselines/reference/submodule/conformance/typeTagOnPropertyAssignment.types b/testdata/baselines/reference/submodule/conformance/typeTagOnPropertyAssignment.types index 2a4bb163c7..7766f435ed 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagOnPropertyAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/typeTagOnPropertyAssignment.types @@ -2,30 +2,32 @@ === typeTagOnPropertyAssignment.js === const o = { ->o : { a: string; n: () => string; } ->{ /** * @type {"a"} */ a: "a", /** @type {() => 'b'} */ n: () => 'b'} : { a: string; n: () => string; } +>o : { a: "a"; n: () => "b"; } +>{ /** * @type {"a"} */ a: "a", /** @type {() => 'b'} */ n: () => 'b'} : { a: "a"; n: () => "b"; } /** * @type {"a"} */ a: "a", ->a : string +>a : "a" +>"a" : "a" >"a" : "a" /** @type {() => 'b'} */ n: () => 'b' ->n : () => string ->() => 'b' : () => string +>n : () => "b" +>() => 'b' : () => "b" +>() => 'b' : () => "b" >'b' : "b" }; o.a ->o.a : string ->o : { a: string; n: () => string; } ->a : string +>o.a : "a" +>o : { a: "a"; n: () => "b"; } +>a : "a" o.n ->o.n : () => string ->o : { a: string; n: () => string; } ->n : () => string +>o.n : () => "b" +>o : { a: "a"; n: () => "b"; } +>n : () => "b" diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types index 03a0b5fd15..46ee7c4072 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types @@ -69,22 +69,22 @@ exports.C = function() { === use.js === /** @type {import('./mod1').Both} */ var both1 = { type: 'a', x: 1 }; ->both1 : { type: string; x: number; } ->{ type: 'a', x: 1 } : { type: string; x: number; } ->type : string +>both1 : { type: "a"; x: 1; } | { type: "b"; y: 1; } +>{ type: 'a', x: 1 } : { type: "a"; x: 1; } +>type : "a" >'a' : "a" ->x : number +>x : 1 >1 : 1 /** @type {import('./mod2').Both} */ var both2 = both1; ->both2 : { type: string; x: number; } ->both1 : { type: string; x: number; } +>both2 : Both +>both1 : { type: "a"; x: 1; } /** @type {import('./mod3').Both} */ var both3 = both2; ->both3 : { type: string; x: number; } ->both2 : { type: string; x: number; } +>both3 : { type: "a"; x: 1; } | { type: "b"; y: 1; } +>both2 : A diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt index bdbed02782..98a50caafd 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt @@ -1,13 +1,19 @@ use.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`. +use.js(2,19): error TS2307: Cannot find module './mod1.js' or its corresponding type declarations. +use.js(4,12): error TS2503: Cannot find namespace 'mod'. -==== use.js (1 errors) ==== +==== use.js (3 errors) ==== var mod = require('./mod1.js'); ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @type {import("./mod1.js").Baz} */ + ~~~~~~~~~~~ +!!! error TS2307: Cannot find module './mod1.js' or its corresponding type declarations. var b; /** @type {mod.Baz} */ + ~~~ +!!! error TS2503: Cannot find namespace 'mod'. var bb; var bbb = new mod.Baz(); diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types index 2b2b4ef2e0..053aa0751b 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types @@ -13,7 +13,7 @@ var b; /** @type {mod.Baz} */ var bb; ->bb : any +>bb : Baz var bbb = new mod.Baz(); >bbb : any diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule5.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule5.errors.txt deleted file mode 100644 index b48220e505..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule5.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -mod1.js:2:7 - error TS2451: Cannot redeclare block-scoped variable 'Bar'. - -2 class Bar {} -   ~~~ - - mod2.js:2:7 - 'Bar' was also declared here. - 2 const Bar = 3; -    ~~~ - -mod2.js:2:7 - error TS2451: Cannot redeclare block-scoped variable 'Bar'. - -2 const Bar = 3; -   ~~~ - - mod1.js:2:7 - 'Bar' was also declared here. - 2 class Bar {} -    ~~~ - - -==== mod1.js (1 errors) ==== - /** @typedef {number} Foo */ - class Bar {} - ~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'Bar'. -!!! related TS6203 mod2.js:2:7: 'Bar' was also declared here. - -==== mod2.js (1 errors) ==== - class Foo { } // should error - const Bar = 3; - ~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'Bar'. -!!! related TS6203 mod1.js:2:7: 'Bar' was also declared here. - -Found 2 errors in 2 files. - -Errors Files - 1 mod1.js:2 - 1 mod2.js:2 - diff --git a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt index 222260e5aa..5570c99ce3 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt @@ -1,22 +1,44 @@ +a.js(6,19): error TS2304: Cannot find name 'T'. +a.js(6,25): error TS2304: Cannot find name 'U'. +a.js(6,31): error TS2304: Cannot find name 'V'. +a.js(6,37): error TS2304: Cannot find name 'W'. +a.js(6,43): error TS2304: Cannot find name 'X'. +a.js(12,23): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. +a.js(15,12): error TS2314: Generic type 'Everything' requires 5 type argument(s). test.ts(1,23): error TS2304: Cannot find name 'Everything'. -==== a.js (0 errors) ==== +==== a.js (7 errors) ==== /** * @template {{ a: number, b: string }} T,U A Comment * @template {{ c: boolean }} V uh ... are comments even supported?? * @template W * @template X That last one had no comment * @typedef {{ t: T, u: U, v: V, w: W, x: X }} Everything + ~ +!!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS2304: Cannot find name 'U'. + ~ +!!! error TS2304: Cannot find name 'V'. + ~ +!!! error TS2304: Cannot find name 'W'. + ~ +!!! error TS2304: Cannot find name 'X'. */ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ var tuvwx; /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ + ~~~~~~~~~~~~~~ +!!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. +!!! related TS2728 a.js:2:28: 'b' is declared here. var wrong; /** @type {Everything<{ a: number }>} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2314: Generic type 'Everything' requires 5 type argument(s). var insufficient; ==== test.ts (1 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types index f06d56ac40..34308527f8 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types +++ b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types @@ -11,11 +11,11 @@ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ var tuvwx; ->tuvwx : any +>tuvwx : { t: T; u: U; v: V; w: W; x: X; } /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ var wrong; ->wrong : any +>wrong : { t: T; u: U; v: V; w: W; x: X; } /** @type {Everything<{ a: number }>} */ var insufficient; diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt index d0fafef40c..d6726678a1 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt @@ -2,26 +2,9 @@ typedefOnStatements.js(26,1): error TS1105: A 'break' statement can only be used typedefOnStatements.js(31,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. typedefOnStatements.js(33,1): error TS1101: 'with' statements are not allowed in strict mode. typedefOnStatements.js(33,1): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'. -typedefOnStatements.js(71,17): error TS7006: Parameter 'a' implicitly has an 'any' type. -typedefOnStatements.js(71,19): error TS7006: Parameter 'b' implicitly has an 'any' type. -typedefOnStatements.js(71,21): error TS7006: Parameter 'c' implicitly has an 'any' type. -typedefOnStatements.js(71,23): error TS7006: Parameter 'd' implicitly has an 'any' type. -typedefOnStatements.js(71,25): error TS7006: Parameter 'e' implicitly has an 'any' type. -typedefOnStatements.js(71,27): error TS7006: Parameter 'f' implicitly has an 'any' type. -typedefOnStatements.js(71,29): error TS7006: Parameter 'g' implicitly has an 'any' type. -typedefOnStatements.js(71,31): error TS7006: Parameter 'h' implicitly has an 'any' type. -typedefOnStatements.js(71,33): error TS7006: Parameter 'i' implicitly has an 'any' type. -typedefOnStatements.js(71,35): error TS7006: Parameter 'j' implicitly has an 'any' type. -typedefOnStatements.js(71,37): error TS7006: Parameter 'k' implicitly has an 'any' type. -typedefOnStatements.js(71,39): error TS7006: Parameter 'l' implicitly has an 'any' type. -typedefOnStatements.js(71,41): error TS7006: Parameter 'm' implicitly has an 'any' type. -typedefOnStatements.js(71,43): error TS7006: Parameter 'n' implicitly has an 'any' type. -typedefOnStatements.js(71,45): error TS7006: Parameter 'o' implicitly has an 'any' type. -typedefOnStatements.js(71,47): error TS7006: Parameter 'p' implicitly has an 'any' type. -typedefOnStatements.js(71,49): error TS7006: Parameter 'q' implicitly has an 'any' type. -==== typedefOnStatements.js (21 errors) ==== +==== typedefOnStatements.js (4 errors) ==== /** @typedef {{a: string}} A */ ; /** @typedef {{ b: string }} B */ @@ -101,40 +84,6 @@ typedefOnStatements.js(71,49): error TS7006: Parameter 'q' implicitly has an 'an * @param {Q} q */ function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) { - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'c' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'd' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'e' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'f' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'g' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'h' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'i' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'j' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'k' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'l' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'm' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'n' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'o' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'p' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'q' implicitly has an 'any' type. console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) /** @type {Alpha} */ var alpha = { alpha: "aleph" } diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.symbols b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.symbols index 236378c837..064c38f2eb 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.symbols +++ b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.symbols @@ -101,23 +101,57 @@ function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) { >console.log : Symbol(log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(log, Decl(lib.dom.d.ts, --, --)) +>a.a : Symbol(a, Decl(typedefOnStatements.js, 0, 15)) >a : Symbol(a, Decl(typedefOnStatements.js, 70, 16)) +>a : Symbol(a, Decl(typedefOnStatements.js, 0, 15)) +>b.b : Symbol(b, Decl(typedefOnStatements.js, 2, 15)) >b : Symbol(b, Decl(typedefOnStatements.js, 70, 18)) +>b : Symbol(b, Decl(typedefOnStatements.js, 2, 15)) +>c.c : Symbol(c, Decl(typedefOnStatements.js, 4, 15)) >c : Symbol(c, Decl(typedefOnStatements.js, 70, 20)) +>c : Symbol(c, Decl(typedefOnStatements.js, 4, 15)) +>d.d : Symbol(d, Decl(typedefOnStatements.js, 7, 15)) >d : Symbol(d, Decl(typedefOnStatements.js, 70, 22)) +>d : Symbol(d, Decl(typedefOnStatements.js, 7, 15)) +>e.e : Symbol(e, Decl(typedefOnStatements.js, 9, 15)) >e : Symbol(e, Decl(typedefOnStatements.js, 70, 24)) +>e : Symbol(e, Decl(typedefOnStatements.js, 9, 15)) +>f.f : Symbol(f, Decl(typedefOnStatements.js, 12, 15)) >f : Symbol(f, Decl(typedefOnStatements.js, 70, 26)) +>f : Symbol(f, Decl(typedefOnStatements.js, 12, 15)) +>g.g : Symbol(g, Decl(typedefOnStatements.js, 15, 15)) >g : Symbol(g, Decl(typedefOnStatements.js, 70, 28)) +>g : Symbol(g, Decl(typedefOnStatements.js, 15, 15)) +>h.h : Symbol(h, Decl(typedefOnStatements.js, 18, 15)) >h : Symbol(h, Decl(typedefOnStatements.js, 70, 30)) +>h : Symbol(h, Decl(typedefOnStatements.js, 18, 15)) +>i.i : Symbol(i, Decl(typedefOnStatements.js, 21, 15)) >i : Symbol(i, Decl(typedefOnStatements.js, 70, 32)) +>i : Symbol(i, Decl(typedefOnStatements.js, 21, 15)) +>j.j : Symbol(j, Decl(typedefOnStatements.js, 24, 15)) >j : Symbol(j, Decl(typedefOnStatements.js, 70, 34)) +>j : Symbol(j, Decl(typedefOnStatements.js, 24, 15)) +>k.k : Symbol(k, Decl(typedefOnStatements.js, 26, 15)) >k : Symbol(k, Decl(typedefOnStatements.js, 70, 36)) +>k : Symbol(k, Decl(typedefOnStatements.js, 26, 15)) +>l.l : Symbol(l, Decl(typedefOnStatements.js, 29, 15)) >l : Symbol(l, Decl(typedefOnStatements.js, 70, 38)) +>l : Symbol(l, Decl(typedefOnStatements.js, 29, 15)) +>m.m : Symbol(m, Decl(typedefOnStatements.js, 31, 15)) >m : Symbol(m, Decl(typedefOnStatements.js, 70, 40)) +>m : Symbol(m, Decl(typedefOnStatements.js, 31, 15)) +>n.n : Symbol(n, Decl(typedefOnStatements.js, 34, 15)) >n : Symbol(n, Decl(typedefOnStatements.js, 70, 42)) +>n : Symbol(n, Decl(typedefOnStatements.js, 34, 15)) +>o.o : Symbol(o, Decl(typedefOnStatements.js, 38, 15)) >o : Symbol(o, Decl(typedefOnStatements.js, 70, 44)) +>o : Symbol(o, Decl(typedefOnStatements.js, 38, 15)) +>p.p : Symbol(p, Decl(typedefOnStatements.js, 42, 15)) >p : Symbol(p, Decl(typedefOnStatements.js, 70, 46)) +>p : Symbol(p, Decl(typedefOnStatements.js, 42, 15)) +>q.q : Symbol(q, Decl(typedefOnStatements.js, 45, 15)) >q : Symbol(q, Decl(typedefOnStatements.js, 70, 48)) +>q : Symbol(q, Decl(typedefOnStatements.js, 45, 15)) /** @type {Alpha} */ var alpha = { alpha: "aleph" } diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.symbols.diff b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.symbols.diff index 9b47f706f4..d1989f8de3 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.symbols.diff @@ -8,58 +8,7 @@ +>console.log : Symbol(log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) ->log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) -->a.a : Symbol(a, Decl(typedefOnStatements.js, 0, 15)) +>log : Symbol(log, Decl(lib.dom.d.ts, --, --)) + >a.a : Symbol(a, Decl(typedefOnStatements.js, 0, 15)) >a : Symbol(a, Decl(typedefOnStatements.js, 70, 16)) -->a : Symbol(a, Decl(typedefOnStatements.js, 0, 15)) -->b.b : Symbol(b, Decl(typedefOnStatements.js, 2, 15)) - >b : Symbol(b, Decl(typedefOnStatements.js, 70, 18)) -->b : Symbol(b, Decl(typedefOnStatements.js, 2, 15)) -->c.c : Symbol(c, Decl(typedefOnStatements.js, 4, 15)) - >c : Symbol(c, Decl(typedefOnStatements.js, 70, 20)) -->c : Symbol(c, Decl(typedefOnStatements.js, 4, 15)) -->d.d : Symbol(d, Decl(typedefOnStatements.js, 7, 15)) - >d : Symbol(d, Decl(typedefOnStatements.js, 70, 22)) -->d : Symbol(d, Decl(typedefOnStatements.js, 7, 15)) -->e.e : Symbol(e, Decl(typedefOnStatements.js, 9, 15)) - >e : Symbol(e, Decl(typedefOnStatements.js, 70, 24)) -->e : Symbol(e, Decl(typedefOnStatements.js, 9, 15)) -->f.f : Symbol(f, Decl(typedefOnStatements.js, 12, 15)) - >f : Symbol(f, Decl(typedefOnStatements.js, 70, 26)) -->f : Symbol(f, Decl(typedefOnStatements.js, 12, 15)) -->g.g : Symbol(g, Decl(typedefOnStatements.js, 15, 15)) - >g : Symbol(g, Decl(typedefOnStatements.js, 70, 28)) -->g : Symbol(g, Decl(typedefOnStatements.js, 15, 15)) -->h.h : Symbol(h, Decl(typedefOnStatements.js, 18, 15)) - >h : Symbol(h, Decl(typedefOnStatements.js, 70, 30)) -->h : Symbol(h, Decl(typedefOnStatements.js, 18, 15)) -->i.i : Symbol(i, Decl(typedefOnStatements.js, 21, 15)) - >i : Symbol(i, Decl(typedefOnStatements.js, 70, 32)) -->i : Symbol(i, Decl(typedefOnStatements.js, 21, 15)) -->j.j : Symbol(j, Decl(typedefOnStatements.js, 24, 15)) - >j : Symbol(j, Decl(typedefOnStatements.js, 70, 34)) -->j : Symbol(j, Decl(typedefOnStatements.js, 24, 15)) -->k.k : Symbol(k, Decl(typedefOnStatements.js, 26, 15)) - >k : Symbol(k, Decl(typedefOnStatements.js, 70, 36)) -->k : Symbol(k, Decl(typedefOnStatements.js, 26, 15)) -->l.l : Symbol(l, Decl(typedefOnStatements.js, 29, 15)) - >l : Symbol(l, Decl(typedefOnStatements.js, 70, 38)) -->l : Symbol(l, Decl(typedefOnStatements.js, 29, 15)) -->m.m : Symbol(m, Decl(typedefOnStatements.js, 31, 15)) - >m : Symbol(m, Decl(typedefOnStatements.js, 70, 40)) -->m : Symbol(m, Decl(typedefOnStatements.js, 31, 15)) -->n.n : Symbol(n, Decl(typedefOnStatements.js, 34, 15)) - >n : Symbol(n, Decl(typedefOnStatements.js, 70, 42)) -->n : Symbol(n, Decl(typedefOnStatements.js, 34, 15)) -->o.o : Symbol(o, Decl(typedefOnStatements.js, 38, 15)) - >o : Symbol(o, Decl(typedefOnStatements.js, 70, 44)) -->o : Symbol(o, Decl(typedefOnStatements.js, 38, 15)) -->p.p : Symbol(p, Decl(typedefOnStatements.js, 42, 15)) - >p : Symbol(p, Decl(typedefOnStatements.js, 70, 46)) -->p : Symbol(p, Decl(typedefOnStatements.js, 42, 15)) -->q.q : Symbol(q, Decl(typedefOnStatements.js, 45, 15)) - >q : Symbol(q, Decl(typedefOnStatements.js, 70, 48)) -->q : Symbol(q, Decl(typedefOnStatements.js, 45, 15)) - - /** @type {Alpha} */ - var alpha = { alpha: "aleph" } + >a : Symbol(a, Decl(typedefOnStatements.js, 0, 15)) diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.types b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.types index 8ccf3222f4..bc0ab0707e 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.types +++ b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.types @@ -93,81 +93,81 @@ catch (e) { * @param {Q} q */ function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) { ->proof : (a: any, b: any, c: any, d: any, e: any, f: any, g: any, h: any, i: any, j: any, k: any, l: any, m: any, n: any, o: any, p: any, q: any) => void ->a : any ->b : any ->c : any ->d : any ->e : any ->f : any ->g : any ->h : any ->i : any ->j : any ->k : any ->l : any ->m : any ->n : any ->o : any ->p : any ->q : any +>proof : (a: { a: string; }, b: { b: string; }, c: { c: string; }, d: { d: string; }, e: { e: string; }, f: { f: string; }, g: { g: string; }, h: { h: string; }, i: { i: string; }, j: { j: string; }, k: { k: string; }, l: { l: string; }, m: { m: string; }, n: { n: string; }, o: { o: string; }, p: { p: string; }, q: { q: string; }) => void +>a : { a: string; } +>b : { b: string; } +>c : { c: string; } +>d : { d: string; } +>e : { e: string; } +>f : { f: string; } +>g : { g: string; } +>h : { h: string; } +>i : { i: string; } +>j : { j: string; } +>k : { k: string; } +>l : { l: string; } +>m : { m: string; } +>n : { n: string; } +>o : { o: string; } +>p : { p: string; } +>q : { q: string; } console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) >console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) : void >console.log : (...data: any[]) => void >console : Console >log : (...data: any[]) => void ->a.a : any ->a : any ->a : any ->b.b : any ->b : any ->b : any ->c.c : any ->c : any ->c : any ->d.d : any ->d : any ->d : any ->e.e : any ->e : any ->e : any ->f.f : any ->f : any ->f : any ->g.g : any ->g : any ->g : any ->h.h : any ->h : any ->h : any ->i.i : any ->i : any ->i : any ->j.j : any ->j : any ->j : any ->k.k : any ->k : any ->k : any ->l.l : any ->l : any ->l : any ->m.m : any ->m : any ->m : any ->n.n : any ->n : any ->n : any ->o.o : any ->o : any ->o : any ->p.p : any ->p : any ->p : any ->q.q : any ->q : any ->q : any +>a.a : string +>a : { a: string; } +>a : string +>b.b : string +>b : { b: string; } +>b : string +>c.c : string +>c : { c: string; } +>c : string +>d.d : string +>d : { d: string; } +>d : string +>e.e : string +>e : { e: string; } +>e : string +>f.f : string +>f : { f: string; } +>f : string +>g.g : string +>g : { g: string; } +>g : string +>h.h : string +>h : { h: string; } +>h : string +>i.i : string +>i : { i: string; } +>i : string +>j.j : string +>j : { j: string; } +>j : string +>k.k : string +>k : { k: string; } +>k : string +>l.l : string +>l : { l: string; } +>l : string +>m.m : string +>m : { m: string; } +>m : string +>n.n : string +>n : { n: string; } +>n : string +>o.o : string +>o : { o: string; } +>o : string +>p.p : string +>p : { p: string; } +>p : string +>q.q : string +>q : { q: string; } +>q : string /** @type {Alpha} */ var alpha = { alpha: "aleph" } diff --git a/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt new file mode 100644 index 0000000000..78efa2ed36 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt @@ -0,0 +1,21 @@ +typedefScope1.js(13,12): error TS2304: Cannot find name 'B'. + + +==== typedefScope1.js (1 errors) ==== + function B1() { + /** @typedef {number} B */ + /** @type {B} */ + var ok1 = 0; + } + + function B2() { + /** @typedef {string} B */ + /** @type {B} */ + var ok2 = 'hi'; + } + + /** @type {B} */ + ~ +!!! error TS2304: Cannot find name 'B'. + var notOK = 0; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefScope1.types b/testdata/baselines/reference/submodule/conformance/typedefScope1.types index e39fc7c9c4..5e0dd42260 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefScope1.types +++ b/testdata/baselines/reference/submodule/conformance/typedefScope1.types @@ -23,6 +23,6 @@ function B2() { /** @type {B} */ var notOK = 0; ->notOK : number +>notOK : B >0 : 0 diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt index b2014ce27d..ab86dff568 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt @@ -1,8 +1,13 @@ -typedefTagExtraneousProperty.js(8,3): error TS2339: Property 'ignoreMe' does not exist on type '{ bye: string; }'. +typedefTagExtraneousProperty.js(1,15): error TS2315: Type 'Object' is not generic. +typedefTagExtraneousProperty.js(1,21): error TS8020: JSDoc types can only be used inside documentation comments. -==== typedefTagExtraneousProperty.js (1 errors) ==== +==== typedefTagExtraneousProperty.js (2 errors) ==== /** @typedef {Object.} Mmap + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. * @property {string} ignoreMe - should be ignored */ @@ -10,7 +15,5 @@ typedefTagExtraneousProperty.js(8,3): error TS2339: Property 'ignoreMe' does not var y = { bye: "no" }; y y.ignoreMe = "ok but just because of the index signature" - ~~~~~~~~ -!!! error TS2339: Property 'ignoreMe' does not exist on type '{ bye: string; }'. y['hi'] = "yes" \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.types b/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.types index db359d3ed0..fc68b20720 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.types +++ b/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.types @@ -7,25 +7,25 @@ /** @type {Mmap} */ var y = { bye: "no" }; ->y : { bye: string; } +>y : any >{ bye: "no" } : { bye: string; } >bye : string >"no" : "no" y ->y : { bye: string; } +>y : any y.ignoreMe = "ok but just because of the index signature" >y.ignoreMe = "ok but just because of the index signature" : "ok but just because of the index signature" >y.ignoreMe : any ->y : { bye: string; } +>y : any >ignoreMe : any >"ok but just because of the index signature" : "ok but just because of the index signature" y['hi'] = "yes" >y['hi'] = "yes" : "yes" >y['hi'] : any ->y : { bye: string; } +>y : any >'hi' : "hi" >"yes" : "yes" diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagNested.symbols b/testdata/baselines/reference/submodule/conformance/typedefTagNested.symbols index d170655538..75da97d256 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagNested.symbols +++ b/testdata/baselines/reference/submodule/conformance/typedefTagNested.symbols @@ -55,17 +55,17 @@ var sala = { name: 'uppsala', not: 0, nested: "ok" }; >nested : Symbol(nested, Decl(a.js, 35, 37)) sala.name ->sala.name : Symbol(name, Decl(a.js, 35, 12)) +>sala.name : Symbol(name, Decl(a.js, 29, 3)) >sala : Symbol(sala, Decl(a.js, 35, 3)) ->name : Symbol(name, Decl(a.js, 35, 12)) +>name : Symbol(name, Decl(a.js, 29, 3)) sala.not ->sala.not : Symbol(not, Decl(a.js, 35, 29)) +>sala.not : Symbol(not, Decl(a.js, 30, 3)) >sala : Symbol(sala, Decl(a.js, 35, 3)) ->not : Symbol(not, Decl(a.js, 35, 29)) +>not : Symbol(not, Decl(a.js, 30, 3)) sala.nested ->sala.nested : Symbol(nested, Decl(a.js, 35, 37)) +>sala.nested : Symbol(nested, Decl(a.js, 31, 3)) >sala : Symbol(sala, Decl(a.js, 35, 3)) ->nested : Symbol(nested, Decl(a.js, 35, 37)) +>nested : Symbol(nested, Decl(a.js, 31, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagNested.symbols.diff b/testdata/baselines/reference/submodule/conformance/typedefTagNested.symbols.diff deleted file mode 100644 index f3c78345d8..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typedefTagNested.symbols.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.typedefTagNested.symbols -+++ new.typedefTagNested.symbols -@@= skipped -54, +54 lines =@@ - >nested : Symbol(nested, Decl(a.js, 35, 37)) - - sala.name -->sala.name : Symbol(name, Decl(a.js, 29, 3)) -+>sala.name : Symbol(name, Decl(a.js, 35, 12)) - >sala : Symbol(sala, Decl(a.js, 35, 3)) -->name : Symbol(name, Decl(a.js, 29, 3)) -+>name : Symbol(name, Decl(a.js, 35, 12)) - - sala.not -->sala.not : Symbol(not, Decl(a.js, 30, 3)) -+>sala.not : Symbol(not, Decl(a.js, 35, 29)) - >sala : Symbol(sala, Decl(a.js, 35, 3)) -->not : Symbol(not, Decl(a.js, 30, 3)) -+>not : Symbol(not, Decl(a.js, 35, 29)) - - sala.nested -->sala.nested : Symbol(nested, Decl(a.js, 31, 3)) -+>sala.nested : Symbol(nested, Decl(a.js, 35, 37)) - >sala : Symbol(sala, Decl(a.js, 35, 3)) -->nested : Symbol(nested, Decl(a.js, 31, 3)) -+>nested : Symbol(nested, Decl(a.js, 35, 37)) - diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagNested.types b/testdata/baselines/reference/submodule/conformance/typedefTagNested.types index bd7a914515..7077cb580a 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagNested.types +++ b/testdata/baselines/reference/submodule/conformance/typedefTagNested.types @@ -12,7 +12,7 @@ var ex; /** @type {App} */ const app = { ->app : { name: string; icons: { image32: string; image64: string; }; } +>app : App >{ name: 'name', icons: { image32: 'x.png', image64: 'y.png', }} : { name: string; icons: { image32: string; image64: string; }; } name: 'name', @@ -45,7 +45,7 @@ var intercessor = 1 /** @type {Opp} */ var mistake; ->mistake : any +>mistake : string /** @typedef {Object} Upp * @property {string} name @@ -55,7 +55,7 @@ var mistake; /** @type {Upp} */ var sala = { name: 'uppsala', not: 0, nested: "ok" }; ->sala : { name: string; not: number; nested: string; } +>sala : Upp >{ name: 'uppsala', not: 0, nested: "ok" } : { name: string; not: number; nested: string; } >name : string >'uppsala' : "uppsala" @@ -65,17 +65,17 @@ var sala = { name: 'uppsala', not: 0, nested: "ok" }; >"ok" : "ok" sala.name ->sala.name : string ->sala : { name: string; not: number; nested: string; } ->name : string +>sala.name : any +>sala : Upp +>name : any sala.not ->sala.not : number ->sala : { name: string; not: number; nested: string; } ->not : number +>sala.not : any +>sala : Upp +>not : any sala.nested ->sala.nested : string ->sala : { name: string; not: number; nested: string; } ->nested : string +>sala.nested : any +>sala : Upp +>nested : any diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt new file mode 100644 index 0000000000..8d39add592 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt @@ -0,0 +1,37 @@ +github20832.js(2,15): error TS2304: Cannot find name 'U'. +github20832.js(26,12): error TS2304: Cannot find name 'Cb'. + + +==== github20832.js (2 errors) ==== + // #20832 + /** @typedef {U} T - should be "error, can't find type named 'U' */ + ~ +!!! error TS2304: Cannot find name 'U'. + /** + * @template U + * @param {U} x + * @return {T} + */ + function f(x) { + return x; + } + + /** @type T - should be fine, since T will be any */ + const x = 3; + + /** + * @callback Cb + * @param {V} firstParam + */ + /** + * @template V + * @param {V} vvvvv + */ + function g(vvvvv) { + } + + /** @type {Cb} */ + ~~ +!!! error TS2304: Cannot find name 'Cb'. + const cb = x => {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.types b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.types index 612f378daa..7261c71574 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.types +++ b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.types @@ -9,16 +9,16 @@ * @return {T} */ function f(x) { ->f : (x: any) => any ->x : any +>f : (x: U) => U +>x : U return x; ->x : any +>x : U } /** @type T - should be fine, since T will be any */ const x = 3; ->x : 3 +>x : U >3 : 3 /** @@ -30,13 +30,13 @@ const x = 3; * @param {V} vvvvv */ function g(vvvvv) { ->g : (vvvvv: any) => void ->vvvvv : any +>g : (vvvvv: V) => void +>vvvvv : V } /** @type {Cb} */ const cb = x => {} ->cb : (x: any) => void +>cb : Cb >x => {} : (x: any) => void >x : any diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt new file mode 100644 index 0000000000..6b2506e05c --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt @@ -0,0 +1,151 @@ +mod1.js(2,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod1.js(9,12): error TS2304: Cannot find name 'Type1'. +mod3.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod3.js(10,12): error TS2304: Cannot find name 'StringOrNumber1'. +mod4.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. + + +==== mod1.js (2 errors) ==== + /** + * @typedef {function(string): boolean} + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + * Type1 + */ + + /** + * Tries to use a type whose name is on a different + * line than the typedef tag. + * @param {Type1} func The function to call. + ~~~~~ +!!! error TS2304: Cannot find name 'Type1'. + * @param {string} arg The argument to call it with. + * @returns {boolean} The return. + */ + function callIt(func, arg) { + return func(arg); + } + +==== mod2.js (0 errors) ==== + /** + * @typedef {{ + * num: number, + * str: string, + * boo: boolean + * }} Type2 + */ + + /** + * Makes use of a type with a multiline type expression. + * @param {Type2} obj The object. + * @returns {string|number} The return. + */ + function check(obj) { + return obj.boo ? obj.num : obj.str; + } + +==== mod3.js (2 errors) ==== + /** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, number): + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + * (string|number)} StringOrNumber1 + */ + + /** + * Makes use of a function type with a long signature. + * @param {StringOrNumber1} func The function. + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'StringOrNumber1'. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ + function use1(func, bool, str, num) { + return func(bool, str, num) + } + +==== mod4.js (2 errors) ==== + /** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + * number): + * (string|number)} StringOrNumber2 + */ + + /** + * Makes use of a function type with a long signature. + * @param {StringOrNumber2} func The function. + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'StringOrNumber2'. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. + * @returns {string|number} The return. + */ + function use2(func, bool, str, num) { + return func(bool, str, num) + } + +==== mod5.js (0 errors) ==== + /** + * @typedef {{ + * num: + * number, + * str: + * string, + * boo: + * boolean + * }} Type5 + */ + + /** + * Makes use of a type with a multiline type expression. + * @param {Type5} obj The object. + * @returns {string|number} The return. + */ + function check5(obj) { + return obj.boo ? obj.num : obj.str; + } + +==== mod6.js (0 errors) ==== + /** + * @typedef {{ + * foo: + * *, + * bar: + * * + * }} Type6 + */ + + /** + * Makes use of a type with a multiline type expression. + * @param {Type6} obj The object. + * @returns {*} The return. + */ + function check6(obj) { + return obj.foo; + } + + +==== mod7.js (0 errors) ==== + /** + Multiline type expressions in comments without leading * are not supported. + @typedef {{ + foo: + *, + bar: + * + }} Type7 + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.symbols b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.symbols index 655f4ebbb6..87f704a013 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.symbols +++ b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.symbols @@ -42,9 +42,15 @@ function check(obj) { >obj : Symbol(obj, Decl(mod2.js, 13, 15)) return obj.boo ? obj.num : obj.str; +>obj.boo : Symbol(boo, Decl(mod2.js, 3, 17)) >obj : Symbol(obj, Decl(mod2.js, 13, 15)) +>boo : Symbol(boo, Decl(mod2.js, 3, 17)) +>obj.num : Symbol(num, Decl(mod2.js, 1, 14)) >obj : Symbol(obj, Decl(mod2.js, 13, 15)) +>num : Symbol(num, Decl(mod2.js, 1, 14)) +>obj.str : Symbol(str, Decl(mod2.js, 2, 17)) >obj : Symbol(obj, Decl(mod2.js, 13, 15)) +>str : Symbol(str, Decl(mod2.js, 2, 17)) } === mod3.js === @@ -130,9 +136,15 @@ function check5(obj) { >obj : Symbol(obj, Decl(mod5.js, 16, 16)) return obj.boo ? obj.num : obj.str; +>obj.boo : Symbol(boo, Decl(mod5.js, 5, 12)) >obj : Symbol(obj, Decl(mod5.js, 16, 16)) +>boo : Symbol(boo, Decl(mod5.js, 5, 12)) +>obj.num : Symbol(num, Decl(mod5.js, 1, 14)) >obj : Symbol(obj, Decl(mod5.js, 16, 16)) +>num : Symbol(num, Decl(mod5.js, 1, 14)) +>obj.str : Symbol(str, Decl(mod5.js, 3, 12)) >obj : Symbol(obj, Decl(mod5.js, 16, 16)) +>str : Symbol(str, Decl(mod5.js, 3, 12)) } === mod6.js === @@ -155,7 +167,9 @@ function check6(obj) { >obj : Symbol(obj, Decl(mod6.js, 14, 16)) return obj.foo; +>obj.foo : Symbol(foo, Decl(mod6.js, 1, 14)) >obj : Symbol(obj, Decl(mod6.js, 14, 16)) +>foo : Symbol(foo, Decl(mod6.js, 1, 14)) } diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.symbols.diff b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.symbols.diff deleted file mode 100644 index d63c196fe1..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.symbols.diff +++ /dev/null @@ -1,44 +0,0 @@ ---- old.typedefTagWrapping.symbols -+++ new.typedefTagWrapping.symbols -@@= skipped -41, +41 lines =@@ - >obj : Symbol(obj, Decl(mod2.js, 13, 15)) - - return obj.boo ? obj.num : obj.str; -->obj.boo : Symbol(boo, Decl(mod2.js, 3, 17)) - >obj : Symbol(obj, Decl(mod2.js, 13, 15)) -->boo : Symbol(boo, Decl(mod2.js, 3, 17)) -->obj.num : Symbol(num, Decl(mod2.js, 1, 14)) - >obj : Symbol(obj, Decl(mod2.js, 13, 15)) -->num : Symbol(num, Decl(mod2.js, 1, 14)) -->obj.str : Symbol(str, Decl(mod2.js, 2, 17)) - >obj : Symbol(obj, Decl(mod2.js, 13, 15)) -->str : Symbol(str, Decl(mod2.js, 2, 17)) - } - - === mod3.js === -@@= skipped -94, +88 lines =@@ - >obj : Symbol(obj, Decl(mod5.js, 16, 16)) - - return obj.boo ? obj.num : obj.str; -->obj.boo : Symbol(boo, Decl(mod5.js, 5, 12)) - >obj : Symbol(obj, Decl(mod5.js, 16, 16)) -->boo : Symbol(boo, Decl(mod5.js, 5, 12)) -->obj.num : Symbol(num, Decl(mod5.js, 1, 14)) - >obj : Symbol(obj, Decl(mod5.js, 16, 16)) -->num : Symbol(num, Decl(mod5.js, 1, 14)) -->obj.str : Symbol(str, Decl(mod5.js, 3, 12)) - >obj : Symbol(obj, Decl(mod5.js, 16, 16)) -->str : Symbol(str, Decl(mod5.js, 3, 12)) - } - - === mod6.js === -@@= skipped -31, +25 lines =@@ - >obj : Symbol(obj, Decl(mod6.js, 14, 16)) - - return obj.foo; -->obj.foo : Symbol(foo, Decl(mod6.js, 1, 14)) - >obj : Symbol(obj, Decl(mod6.js, 14, 16)) -->foo : Symbol(foo, Decl(mod6.js, 1, 14)) - } - - diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.types b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.types index 57533db763..ebd2541cad 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.types +++ b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.types @@ -14,14 +14,14 @@ * @returns {boolean} The return. */ function callIt(func, arg) { ->callIt : (func: any, arg: any) => any ->func : any ->arg : any +>callIt : (func: Type1, arg: string) => boolean +>func : Type1 +>arg : string return func(arg); >func(arg) : any ->func : any ->arg : any +>func : Type1 +>arg : string } === mod2.js === @@ -39,20 +39,20 @@ function callIt(func, arg) { * @returns {string|number} The return. */ function check(obj) { ->check : (obj: any) => any ->obj : any +>check : (obj: Type2) => string | number +>obj : Type2 return obj.boo ? obj.num : obj.str; ->obj.boo ? obj.num : obj.str : any ->obj.boo : any ->obj : any ->boo : any ->obj.num : any ->obj : any ->num : any ->obj.str : any ->obj : any ->str : any +>obj.boo ? obj.num : obj.str : string | number +>obj.boo : boolean +>obj : Type2 +>boo : boolean +>obj.num : number +>obj : Type2 +>num : number +>obj.str : string +>obj : Type2 +>str : string } === mod3.js === @@ -72,18 +72,18 @@ function check(obj) { * @returns {string|number} The return. */ function use1(func, bool, str, num) { ->use1 : (func: any, bool: any, str: any, num: any) => any ->func : any ->bool : any ->str : any ->num : any +>use1 : (func: StringOrNumber1, bool: boolean, str: string, num: number) => string | number +>func : StringOrNumber1 +>bool : boolean +>str : string +>num : number return func(bool, str, num) >func(bool, str, num) : any ->func : any ->bool : any ->str : any ->num : any +>func : StringOrNumber1 +>bool : boolean +>str : string +>num : number } === mod4.js === @@ -104,18 +104,18 @@ function use1(func, bool, str, num) { * @returns {string|number} The return. */ function use2(func, bool, str, num) { ->use2 : (func: any, bool: any, str: any, num: any) => any ->func : any ->bool : any ->str : any ->num : any +>use2 : (func: StringOrNumber2, bool: boolean, str: string, num: number) => string | number +>func : StringOrNumber2 +>bool : boolean +>str : string +>num : number return func(bool, str, num) >func(bool, str, num) : any ->func : any ->bool : any ->str : any ->num : any +>func : StringOrNumber2 +>bool : boolean +>str : string +>num : number } === mod5.js === @@ -136,20 +136,20 @@ function use2(func, bool, str, num) { * @returns {string|number} The return. */ function check5(obj) { ->check5 : (obj: any) => any ->obj : any +>check5 : (obj: Type5) => string | number +>obj : Type5 return obj.boo ? obj.num : obj.str; ->obj.boo ? obj.num : obj.str : any ->obj.boo : any ->obj : any ->boo : any ->obj.num : any ->obj : any ->num : any ->obj.str : any ->obj : any ->str : any +>obj.boo ? obj.num : obj.str : string | number +>obj.boo : boolean +>obj : Type5 +>boo : boolean +>obj.num : number +>obj : Type5 +>num : number +>obj.str : string +>obj : Type5 +>str : string } === mod6.js === @@ -168,12 +168,12 @@ function check5(obj) { * @returns {*} The return. */ function check6(obj) { ->check6 : (obj: any) => any ->obj : any +>check6 : (obj: Type6) => any +>obj : Type6 return obj.foo; >obj.foo : any ->obj : any +>obj : Type6 >foo : any } diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt new file mode 100644 index 0000000000..2c2ac38279 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt @@ -0,0 +1,37 @@ +uniqueSymbolsDeclarationsInJs.js(11,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +uniqueSymbolsDeclarationsInJs.js(16,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + + +==== uniqueSymbolsDeclarationsInJs.js (2 errors) ==== + // classes + class C { + /** + * @readonly + */ + static readonlyStaticCall = Symbol(); + /** + * @type {unique symbol} + * @readonly + */ + static readonlyStaticType; + ~~~~~~~~~~~~~~~~~~ +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + /** + * @type {unique symbol} + * @readonly + */ + static readonlyStaticTypeAndCall = Symbol(); + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + static readwriteStaticCall = Symbol(); + + /** + * @readonly + */ + readonlyCall = Symbol(); + readwriteCall = Symbol(); + } + + /** @type {unique symbol} */ + const a = Symbol(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.types b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.types index c428356887..4b44b1dc5e 100644 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.types +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.types @@ -18,7 +18,7 @@ class C { * @readonly */ static readonlyStaticType; ->readonlyStaticType : any +>readonlyStaticType : symbol /** * @type {unique symbol} diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt new file mode 100644 index 0000000000..e7c5d274aa --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt @@ -0,0 +1,28 @@ +uniqueSymbolsDeclarationsInJsErrors.js(5,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +uniqueSymbolsDeclarationsInJsErrors.js(10,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +uniqueSymbolsDeclarationsInJsErrors.js(14,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + + +==== uniqueSymbolsDeclarationsInJsErrors.js (3 errors) ==== + class C { + /** + * @type {unique symbol} + */ + static readwriteStaticType; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + /** + * @type {unique symbol} + * @readonly + */ + static readonlyType; + ~~~~~~~~~~~~ +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + /** + * @type {unique symbol} + */ + static readwriteType; + ~~~~~~~~~~~~~ +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.types b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.types index a8c3d4e36f..f5a9ef8de0 100644 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.types +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.types @@ -8,19 +8,19 @@ class C { * @type {unique symbol} */ static readwriteStaticType; ->readwriteStaticType : any +>readwriteStaticType : symbol /** * @type {unique symbol} * @readonly */ static readonlyType; ->readonlyType : any +>readonlyType : symbol /** * @type {unique symbol} */ static readwriteType; ->readwriteType : any +>readwriteType : symbol } diff --git a/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt b/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt index f9cda79166..d8c96807f4 100644 --- a/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt @@ -1,5 +1,5 @@ use.js(1,10): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -use.js(12,12): error TS7006: Parameter 'wrap' implicitly has an 'any' type. +use.js(10,12): error TS2503: Cannot find namespace 'ex'. ==== use.js (2 errors) ==== @@ -15,10 +15,10 @@ use.js(12,12): error TS7006: Parameter 'wrap' implicitly has an 'any' type. // types work /** * @param {ex.Crunch} wrap + ~~ +!!! error TS2503: Cannot find namespace 'ex'. */ function f(wrap) { - ~~~~ -!!! error TS7006: Parameter 'wrap' implicitly has an 'any' type. wrap.n } diff --git a/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.types b/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.types index c267bc137a..139f19cb5f 100644 --- a/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.types +++ b/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.types @@ -27,12 +27,12 @@ crunch.n * @param {ex.Crunch} wrap */ function f(wrap) { ->f : (wrap: any) => void ->wrap : any +>f : (wrap: Crunch) => void +>wrap : Crunch wrap.n >wrap.n : any ->wrap : any +>wrap : Crunch >n : any } diff --git a/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt b/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt index 81d62d2302..f53556abb1 100644 --- a/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt @@ -1,6 +1,6 @@ use.js(1,10): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -use.js(13,12): error TS7006: Parameter 'greatest' implicitly has an 'any' type. -use.js(13,22): error TS7006: Parameter 'wrap' implicitly has an 'any' type. +use.js(10,12): error TS2503: Cannot find namespace 'ex'. +use.js(11,12): error TS2503: Cannot find namespace 'ex'. ==== use.js (3 errors) ==== @@ -16,13 +16,13 @@ use.js(13,22): error TS7006: Parameter 'wrap' implicitly has an 'any' type. // types work /** * @param {ex.Greatest} greatest + ~~ +!!! error TS2503: Cannot find namespace 'ex'. * @param {ex.Crunch} wrap + ~~ +!!! error TS2503: Cannot find namespace 'ex'. */ function f(greatest, wrap) { - ~~~~~~~~ -!!! error TS7006: Parameter 'greatest' implicitly has an 'any' type. - ~~~~ -!!! error TS7006: Parameter 'wrap' implicitly has an 'any' type. greatest.day wrap.n } diff --git a/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.types b/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.types index 80075bcd63..d0fa7caa43 100644 --- a/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.types +++ b/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.types @@ -28,18 +28,18 @@ crunch.n * @param {ex.Crunch} wrap */ function f(greatest, wrap) { ->f : (greatest: any, wrap: any) => void ->greatest : any ->wrap : any +>f : (greatest: Greatest, wrap: Crunch) => void +>greatest : Greatest +>wrap : Crunch greatest.day >greatest.day : any ->greatest : any +>greatest : Greatest >day : any wrap.n >wrap.n : any ->wrap : any +>wrap : Crunch >n : any } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff index 80e58473c2..5215064b30 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+ExtendedClass.js(9,37): error TS2339: Property 'extends' does not exist on type 'unknown'. +ExtendedClass.js(17,12): error TS2339: Property 'exports' does not exist on type '{}'. +ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type '{}'. + @@ -17,7 +16,7 @@ + } + export = BaseClass; + } -+==== ExtendedClass.js (3 errors) ==== ++==== ExtendedClass.js (2 errors) ==== + define("lib/ExtendedClass", ["deps/BaseClass"], + /** + * {typeof import("deps/BaseClass")} @@ -27,8 +26,6 @@ + (BaseClass) => { + + const ExtendedClass = BaseClass.extends({ -+ ~~~~~~~ -+!!! error TS2339: Property 'extends' does not exist on type 'unknown'. + f: function() { + return "something"; + } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.types.diff index 583a1708ec..df7286b7f1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.types.diff @@ -24,8 +24,8 @@ (BaseClass) => { ->(BaseClass) => { const ExtendedClass = BaseClass.extends({ f: function() { return "something"; } }); // Exports the module in a way tsc recognize class export const module = {}; module.exports = ExtendedClass return module.exports;} : (BaseClass: typeof import("deps/BaseClass")) => any ->BaseClass : typeof import("deps/BaseClass") -+>(BaseClass) => { const ExtendedClass = BaseClass.extends({ f: function() { return "something"; } }); // Exports the module in a way tsc recognize class export const module = {}; module.exports = ExtendedClass return module.exports;} : (BaseClass: unknown) => any -+>BaseClass : unknown ++>(BaseClass) => { const ExtendedClass = BaseClass.extends({ f: function() { return "something"; } }); // Exports the module in a way tsc recognize class export const module = {}; module.exports = ExtendedClass return module.exports;} : (BaseClass: typeof BaseClass) => any ++>BaseClass : typeof BaseClass const ExtendedClass = BaseClass.extends({ ->ExtendedClass : new () => { f: () => "something"; } & import("deps/BaseClass") @@ -33,28 +33,25 @@ ->BaseClass.extends :
(a: A) => new () => A & import("deps/BaseClass") ->BaseClass : typeof import("deps/BaseClass") ->extends : (a: A) => new () => A & import("deps/BaseClass") -->{ f: function() { return "something"; } } : { f: () => "something"; } -+>ExtendedClass : any -+>BaseClass.extends({ f: function() { return "something"; } }) : any -+>BaseClass.extends : any -+>BaseClass : unknown -+>extends : any -+>{ f: function() { return "something"; } } : { f: () => string; } ++>ExtendedClass : new () => { f: () => "something"; } & BaseClass ++>BaseClass.extends({ f: function() { return "something"; } }) : new () => { f: () => "something"; } & BaseClass ++>BaseClass.extends : (a: A) => new () => A & BaseClass ++>BaseClass : typeof BaseClass ++>extends : (a: A) => new () => A & BaseClass + >{ f: function() { return "something"; } } : { f: () => "something"; } f: function() { -->f : () => "something" -->function() { return "something"; } : () => "something" -+>f : () => string -+>function() { return "something"; } : () => string +@@= skipped -26, +26 lines =@@ + >{} : {} - return "something"; - >"something" : "something" -@@= skipped -30, +30 lines =@@ + module.exports = ExtendedClass +->module.exports = ExtendedClass : any ++>module.exports = ExtendedClass : new () => { f: () => "something"; } & BaseClass >module.exports : any >module : {} >exports : any ->ExtendedClass : new () => { f: () => "something"; } & import("deps/BaseClass") -+>ExtendedClass : any ++>ExtendedClass : new () => { f: () => "something"; } & BaseClass return module.exports; >module.exports : any diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.types.diff index 7719a14e7a..5f75ac737d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.types.diff @@ -45,15 +45,14 @@ */ function jsdocced(x) { arguments; } ->jsdocced : (x: number, ...args: any[]) => void -->x : number -+>jsdocced : (x: any) => void -+>x : any ++>jsdocced : (x: number) => void + >x : number >arguments : IArguments jsdocced(1); >jsdocced(1) : void ->jsdocced : (x: number, ...args: any[]) => void -+>jsdocced : (x: any) => void ++>jsdocced : (x: number) => void >1 : 1 function dontDoubleRest(x, ...y) { arguments; } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff index 37d9dadea2..e2548a1038 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.types.diff @@ -5,7 +5,7 @@ */ constructor(foo = {}) { ->foo : any -+>foo : {} ++>foo : object >{} : {} /** @@ -13,12 +13,12 @@ */ this.arguments = foo; ->this.arguments = foo : any -+>this.arguments = foo : {} ++>this.arguments = foo : object >this.arguments : any >this : this >arguments : any ->foo : any -+>foo : {} ++>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 47e48afd29..60842c2b62 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.types.diff @@ -5,7 +5,7 @@ */ constructor(foo = {}) { ->foo : any -+>foo : {} ++>foo : object >{} : {} /** @@ -13,12 +13,12 @@ */ this["arguments"] = foo; ->this["arguments"] = foo : any -+>this["arguments"] = foo : {} ++>this["arguments"] = foo : object >this["arguments"] : any >this : this >"arguments" : "arguments" ->foo : any -+>foo : {} ++>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 7432d0182e..015c013c5a 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.types.diff @@ -5,7 +5,7 @@ */ constructor(foo = {}) { ->foo : any -+>foo : {} ++>foo : object >{} : {} super(); @@ -14,12 +14,12 @@ */ this.foo = foo; ->this.foo = foo : any -+>this.foo = foo : {} ++>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : any -+>foo : {} ++>foo : object /** * @type object diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff index 9234266d65..4a145d31da 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff @@ -4,16 +4,17 @@ +/a.js(13,8): error TS2339: Property 'foo' does not exist on type 'A'. /a.js(18,9): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. +/a.js(23,8): error TS2339: Property 'bar' does not exist on type 'A'. ++/a.js(23,24): error TS2339: Property 'bar' does not exist on type 'object'. +/a.js(28,8): error TS2339: Property 'baz' does not exist on type 'A'. +/a.js(33,8): error TS2339: Property 'options' does not exist on type 'A'. -==== /a.js (1 errors) ==== -+==== /a.js (5 errors) ==== ++==== /a.js (6 errors) ==== class A { /** * Constructor -@@= skipped -14, +18 lines =@@ +@@= skipped -14, +19 lines =@@ * @type object */ this.foo = foo; @@ -28,6 +29,8 @@ this.bar = arguments.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'A'. ++ ~~~ ++!!! error TS2339: Property 'bar' does not exist on type 'object'. /** * @type object diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff index 5e1994bca4..449dbd05f8 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.types.diff @@ -5,7 +5,7 @@ */ constructor(foo = {}) { ->foo : any -+>foo : {} ++>foo : object >{} : {} const key = "bar"; @@ -14,51 +14,37 @@ */ this.foo = foo; ->this.foo = foo : any -+>this.foo = foo : {} ++>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : any -+>foo : {} ++>foo : object /** * @type object */ const arguments = this.arguments; ->arguments : any -+>arguments : { bar: {}; } ++>arguments : object >this.arguments : { bar: {}; } >this : this >arguments : { bar: {}; } -@@= skipped -19, +19 lines =@@ - * @type object - */ - this.bar = arguments.bar; -->this.bar = arguments.bar : any -+>this.bar = arguments.bar : {} - >this.bar : any +@@= skipped -24, +24 lines =@@ >this : this >bar : any -->arguments.bar : any + >arguments.bar : any ->arguments : any -->bar : any -+>arguments.bar : {} -+>arguments : { bar: {}; } -+>bar : {} ++>arguments : object + >bar : any /** - * @type object - */ - this.baz = arguments[key]; -->this.baz = arguments[key] : any -+>this.baz = arguments[key] : {} - >this.baz : any +@@= skipped -12, +12 lines =@@ >this : this >baz : any -->arguments[key] : any + >arguments[key] : any ->arguments : any -+>arguments[key] : {} -+>arguments : { bar: {}; } ++>arguments : object >key : "bar" /** @@ -66,12 +52,12 @@ */ this.options = arguments; ->this.options = arguments : any -+>this.options = arguments : { bar: {}; } ++>this.options = arguments : object >this.options : any >this : this >options : any ->arguments : any -+>arguments : { bar: {}; } ++>arguments : object } get arguments() { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff index 38163af1ab..0dd69b0a71 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.types.diff @@ -5,7 +5,7 @@ */ constructor(foo = {}) { ->foo : any -+>foo : {} ++>foo : object >{} : {} /** @@ -13,12 +13,12 @@ */ this.foo = foo; ->this.foo = foo : any -+>this.foo = foo : {} ++>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : any -+>foo : {} ++>foo : object /** * @type object diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff index 0621ed945c..afc0903395 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.types.diff @@ -1,13 +1,11 @@ --- old.argumentsReferenceInMethod1_Js.types +++ new.argumentsReferenceInMethod1_Js.types -@@= skipped -7, +7 lines =@@ - * @param {object} [foo={}] +@@= skipped -8, +8 lines =@@ */ m(foo = {}) { -->m : (foo?: object) => void + >m : (foo?: object) => void ->foo : any -+>m : (foo?: {}) => void -+>foo : {} ++>foo : object >{} : {} /** @@ -15,12 +13,12 @@ */ this.arguments = foo; ->this.arguments = foo : any -+>this.arguments = foo : {} ++>this.arguments = foo : object >this.arguments : any >this : this >arguments : any ->foo : any -+>foo : {} ++>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 dea65c918a..0b6bfccd7d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.types.diff @@ -1,13 +1,11 @@ --- old.argumentsReferenceInMethod2_Js.types +++ new.argumentsReferenceInMethod2_Js.types -@@= skipped -7, +7 lines =@@ - * @param {object} [foo={}] +@@= skipped -8, +8 lines =@@ */ m(foo = {}) { -->m : (foo?: object) => void + >m : (foo?: object) => void ->foo : any -+>m : (foo?: {}) => void -+>foo : {} ++>foo : object >{} : {} /** @@ -15,12 +13,12 @@ */ this["arguments"] = foo; ->this["arguments"] = foo : any -+>this["arguments"] = foo : {} ++>this["arguments"] = foo : object >this["arguments"] : any >this : this >"arguments" : "arguments" ->foo : any -+>foo : {} ++>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 43cf046736..c5176342a1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.types.diff @@ -1,13 +1,11 @@ --- old.argumentsReferenceInMethod3_Js.types +++ new.argumentsReferenceInMethod3_Js.types -@@= skipped -21, +21 lines =@@ - * @param {object} [foo={}] +@@= skipped -22, +22 lines =@@ */ m(foo = {}) { -->m : (foo?: object) => void + >m : (foo?: object) => void ->foo : any -+>m : (foo?: {}) => void -+>foo : {} ++>foo : object >{} : {} /** @@ -15,12 +13,12 @@ */ this.x = foo; ->this.x = foo : any -+>this.x = foo : {} ++>this.x = foo : object >this.x : any >this : this >x : any ->foo : any -+>foo : {} ++>foo : object /** * @type object diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff index ae9b1b7f21..8a1b1f64d1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff @@ -4,16 +4,17 @@ +/a.js(11,8): error TS2339: Property 'foo' does not exist on type 'A'. /a.js(16,9): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. +/a.js(21,8): error TS2339: Property 'bar' does not exist on type 'A'. ++/a.js(21,24): error TS2339: Property 'bar' does not exist on type 'object'. +/a.js(26,8): error TS2339: Property 'baz' does not exist on type 'A'. +/a.js(31,8): error TS2339: Property 'options' does not exist on type 'A'. -==== /a.js (1 errors) ==== -+==== /a.js (5 errors) ==== ++==== /a.js (6 errors) ==== class A { /** * @param {object} [foo={}] -@@= skipped -12, +16 lines =@@ +@@= skipped -12, +17 lines =@@ * @type object */ this.foo = foo; @@ -28,6 +29,8 @@ this.bar = arguments.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'A'. ++ ~~~ ++!!! error TS2339: Property 'bar' does not exist on type 'object'. /** * @type object diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff index d79ce1087d..1a227db627 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.types.diff @@ -1,66 +1,50 @@ --- old.argumentsReferenceInMethod4_Js.types +++ new.argumentsReferenceInMethod4_Js.types -@@= skipped -7, +7 lines =@@ - * @param {object} [foo={}] +@@= skipped -8, +8 lines =@@ */ m(foo = {}) { -->m : (foo?: object) => void + >m : (foo?: object) => void ->foo : any -+>m : (foo?: {}) => void -+>foo : {} ++>foo : object >{} : {} const key = "bar"; -@@= skipped -12, +12 lines =@@ +@@= skipped -11, +11 lines =@@ * @type object */ this.foo = foo; ->this.foo = foo : any -+>this.foo = foo : {} ++>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : any -+>foo : {} ++>foo : object /** * @type object */ const arguments = this.arguments; ->arguments : any -+>arguments : { bar: {}; } ++>arguments : object >this.arguments : { bar: {}; } >this : this >arguments : { bar: {}; } -@@= skipped -19, +19 lines =@@ - * @type object - */ - this.bar = arguments.bar; -->this.bar = arguments.bar : any -+>this.bar = arguments.bar : {} - >this.bar : any +@@= skipped -24, +24 lines =@@ >this : this >bar : any -->arguments.bar : any + >arguments.bar : any ->arguments : any -->bar : any -+>arguments.bar : {} -+>arguments : { bar: {}; } -+>bar : {} ++>arguments : object + >bar : any /** - * @type object - */ - this.baz = arguments[key]; -->this.baz = arguments[key] : any -+>this.baz = arguments[key] : {} - >this.baz : any +@@= skipped -12, +12 lines =@@ >this : this >baz : any -->arguments[key] : any + >arguments[key] : any ->arguments : any -+>arguments[key] : {} -+>arguments : { bar: {}; } ++>arguments : object >key : "bar" /** @@ -68,12 +52,12 @@ */ this.options = arguments; ->this.options = arguments : any -+>this.options = arguments : { bar: {}; } ++>this.options = arguments : object >this.options : any >this : this >options : any ->arguments : any -+>arguments : { bar: {}; } ++>arguments : object } get arguments() { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff index ade06040cf..3727d48396 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.types.diff @@ -1,13 +1,11 @@ --- old.argumentsReferenceInMethod5_Js.types +++ new.argumentsReferenceInMethod5_Js.types -@@= skipped -16, +16 lines =@@ - * @param {object} [foo={}] +@@= skipped -17, +17 lines =@@ */ m(foo = {}) { -->m : (foo?: object) => void + >m : (foo?: object) => void ->foo : any -+>m : (foo?: {}) => void -+>foo : {} ++>foo : object >{} : {} /** @@ -15,12 +13,12 @@ */ this.foo = foo; ->this.foo = foo : any -+>this.foo = foo : {} ++>this.foo = foo : object >this.foo : any >this : this >foo : any ->foo : any -+>foo : {} ++>foo : object /** * @type object diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.errors.txt.diff deleted file mode 100644 index ba394c12dd..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.arrowFunctionJSDocAnnotation.errors.txt -+++ new.arrowFunctionJSDocAnnotation.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+index.js(4,19): error TS7006: Parameter 'v' implicitly has an 'any' type. -+index.js(13,5): error TS7006: Parameter 'param' implicitly has an 'any' type. -+ -+ -+==== index.js (2 errors) ==== -+ /** -+ * @param {any} v -+ */ -+ function identity(v) { -+ ~ -+!!! error TS7006: Parameter 'v' implicitly has an 'any' type. -+ return v; -+ } -+ -+ const x = identity( -+ /** -+ * @param {number} param -+ * @returns {number=} -+ */ -+ param => param -+ ~~~~~ -+!!! error TS7006: Parameter 'param' implicitly has an 'any' type. -+ ); -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.types.diff deleted file mode 100644 index c36a517902..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.types.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.arrowFunctionJSDocAnnotation.types -+++ new.arrowFunctionJSDocAnnotation.types -@@= skipped -21, +21 lines =@@ - * @returns {number=} - */ - param => param -->param => param : (param: number) => number | undefined -->param : number -->param : number -+>param => param : (param: any) => any -+>param : any -+>param : any - - ); - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt.diff deleted file mode 100644 index f353883d9e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.checkJsObjectLiteralHasCheckedKeyof.errors.txt -+++ new.checkJsObjectLiteralHasCheckedKeyof.errors.txt -@@= skipped -0, +-1 lines =@@ --file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. -- -- --==== file.js (1 errors) ==== -- // @ts-check -- const obj = { -- x: 1, -- y: 2 -- }; -- -- /** -- * @type {keyof typeof obj} -- */ -- let selected = "x"; -- selected = "z"; // should fail -- ~~~~~~~~ --!!! error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.types.diff deleted file mode 100644 index 19f363c177..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.types.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.checkJsObjectLiteralHasCheckedKeyof.types -+++ new.checkJsObjectLiteralHasCheckedKeyof.types -@@= skipped -19, +19 lines =@@ - * @type {keyof typeof obj} - */ - let selected = "x"; -->selected : "x" | "y" -+>selected : string - >"x" : "x" - - selected = "z"; // should fail - >selected = "z" : "z" -->selected : "x" | "y" -+>selected : string - >"z" : "z" - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff index 3a095582c9..bda57e861e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff @@ -9,11 +9,12 @@ ->module : { exports: (foo: Foo) => string; } ->exports : (foo: Foo) => string ->(void 0) : FooFun -+>module.exports = /** @type {FooFun} */(void 0) : undefined ++>module.exports = /** @type {FooFun} */(void 0) : (foo: typeof Foo) => string +>module.exports : any +>module : any +>exports : any -+>(void 0) : undefined ++>(void 0) : (foo: typeof Foo) => string ++>void 0 : (foo: typeof Foo) => string >void 0 : undefined >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt.diff index 1e8ac76736..9ea3b3212f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.errors.txt.diff @@ -1,26 +1,23 @@ --- old.checkJsdocTypeTagOnExportAssignment1.errors.txt +++ new.checkJsdocTypeTagOnExportAssignment1.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= 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) ==== - --==== a.js (1 errors) ==== -- /** -- * @typedef {Object} Foo -- * @property {boolean} a -- * @property {boolean} b -- */ -- -- /** @type {Foo} */ -- export default { c: false }; + ==== a.js (1 errors) ==== + /** + * @typedef {Object} Foo +@@= skipped -11, +9 lines =@@ + + /** @type {Foo} */ + export default { c: false }; - ~ -!!! 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; -- -@@= skipped --1, +1 lines =@@ -+ ++ ~~~~~~~~~~~~ ++!!! error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b + + ==== b.js (0 errors) ==== + import a from "./a"; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.types.diff index 5ac4999981..53c009ce94 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment1.types.diff @@ -1,13 +1,20 @@ --- old.checkJsdocTypeTagOnExportAssignment1.types +++ new.checkJsdocTypeTagOnExportAssignment1.types -@@= skipped -16, +16 lines =@@ +@@= skipped -10, +10 lines =@@ + + /** @type {Foo} */ + export default { c: false }; ++>{ c: false } : Foo + >{ c: false } : { c: boolean; } + >c : boolean + >false : false === b.js === import a from "./a"; ->a : import("a").Foo -+>a : { c: boolean; } ++>a : Foo a; ->a : import("a").Foo -+>a : { c: boolean; } ++>a : Foo diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt.diff index d5c9b8cf66..4002e30751 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.errors.txt.diff @@ -1,26 +1,23 @@ --- old.checkJsdocTypeTagOnExportAssignment2.errors.txt +++ new.checkJsdocTypeTagOnExportAssignment2.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= 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) ==== - --==== a.ts (0 errors) ==== -- export interface Foo { -- a: number; -- b: number; -- } -- --==== b.js (1 errors) ==== -- /** @type {import("./a").Foo} */ -- export default { c: false }; + ==== a.ts (0 errors) ==== + export interface Foo { + a: number; +@@= skipped -11, +9 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'. -- --==== c.js (0 errors) ==== -- import b from "./b"; -- b; -- -@@= skipped --1, +1 lines =@@ -+ ++ ~~~~~~~~~~~~ ++!!! error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b + + ==== c.js (0 errors) ==== + import b from "./b"; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.types.diff index 7e43d56d17..e85a405370 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment2.types.diff @@ -1,13 +1,20 @@ --- old.checkJsdocTypeTagOnExportAssignment2.types +++ new.checkJsdocTypeTagOnExportAssignment2.types -@@= skipped -19, +19 lines =@@ +@@= skipped -13, +13 lines =@@ + === b.js === + /** @type {import("./a").Foo} */ + export default { c: false }; ++>{ c: false } : Foo + >{ c: false } : { c: boolean; } + >c : boolean + >false : false === c.js === import b from "./b"; ->b : import("a").Foo -+>b : { c: boolean; } ++>b : Foo b; ->b : import("a").Foo -+>b : { c: boolean; } ++>b : Foo diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.errors.txt.diff index 5ff3a7c368..fabeb0dd5b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.errors.txt.diff @@ -1,28 +1,11 @@ --- old.checkJsdocTypeTagOnExportAssignment3.errors.txt +++ new.checkJsdocTypeTagOnExportAssignment3.errors.txt -@@= skipped -0, +-1 lines =@@ --a.js(10,16): error TS2739: Type '{ c: number; }' is missing the following properties from type 'Foo': a, b -- -- +@@= skipped -0, +0 lines =@@ + a.js(10,16): error TS2739: Type '{ c: number; }' is missing the following properties from type 'Foo': a, b + + -==== checkJsdocTypeTagOnExportAssignment3.js (0 errors) ==== - --==== a.js (1 errors) ==== -- /** -- * @typedef {Object} Foo -- * @property {boolean} a -- * @property {boolean} b -- */ -- -- const bar = { c: 1 }; -- -- /** @type {Foo} */ -- export default bar; -- ~~~ --!!! error TS2739: Type '{ c: number; }' is missing the following properties from type 'Foo': a, b -- --==== b.js (0 errors) ==== -- import a from "./a"; -- a; -- -@@= skipped --1, +1 lines =@@ -+ + ==== a.js (1 errors) ==== + /** + * @typedef {Object} Foo diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff index 89fa452fa7..d4bf0180db 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment3.types.diff @@ -1,13 +1,18 @@ --- old.checkJsdocTypeTagOnExportAssignment3.types +++ new.checkJsdocTypeTagOnExportAssignment3.types -@@= skipped -20, +20 lines =@@ +@@= skipped -16, +16 lines =@@ + + /** @type {Foo} */ + export default bar; ++>bar : Foo + >bar : { c: number; } === b.js === import a from "./a"; ->a : import("a").Foo -+>a : { c: number; } ++>a : Foo a; ->a : import("a").Foo -+>a : { c: number; } ++>a : Foo diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt.diff index 32ddc1e69a..b163f012f0 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.errors.txt.diff @@ -1,21 +1,20 @@ --- old.checkJsdocTypeTagOnExportAssignment4.errors.txt +++ new.checkJsdocTypeTagOnExportAssignment4.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= 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) ==== - --==== a.js (1 errors) ==== -- /** -- * @typedef {number} Foo -- */ -- -- /** @type {Foo} */ -- export default ""; -- ~~ + ==== a.js (1 errors) ==== + /** + * @typedef {number} Foo +@@= skipped -10, +8 lines =@@ + /** @type {Foo} */ + export default ""; + ~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. -- -- -@@= skipped --1, +1 lines =@@ -+ ++!!! 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. + + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.types.diff new file mode 100644 index 0000000000..6616672785 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment4.types.diff @@ -0,0 +1,17 @@ +--- 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 673e35bb07..bcbd781d56 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment5.types.diff @@ -1,13 +1,21 @@ --- old.checkJsdocTypeTagOnExportAssignment5.types +++ new.checkJsdocTypeTagOnExportAssignment5.types -@@= skipped -18, +18 lines =@@ +@@= 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 =@@ === b.js === import a from "./a"; ->a : import("a").Foo -+>a : { a: number; b: number; } ++>a : Foo a; ->a : import("a").Foo -+>a : { a: number; b: number; } ++>a : Foo diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.types.diff index 42f203cb3c..9b7810a7ed 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment6.types.diff @@ -1,13 +1,21 @@ --- old.checkJsdocTypeTagOnExportAssignment6.types +++ new.checkJsdocTypeTagOnExportAssignment6.types -@@= skipped -20, +20 lines =@@ +@@= 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 =@@ === b.js === import a from "./a"; ->a : import("a").Foo -+>a : { a: number; b: number; c: number; } ++>a : Foo a; ->a : import("a").Foo -+>a : { a: number; b: number; c: number; } ++>a : Foo diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff index b6c4a8026b..f2ef24ccf6 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment7.types.diff @@ -1,13 +1,18 @@ --- old.checkJsdocTypeTagOnExportAssignment7.types +++ new.checkJsdocTypeTagOnExportAssignment7.types -@@= skipped -24, +24 lines =@@ +@@= skipped -20, +20 lines =@@ + + /** @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 : Foo a; ->a : import("a").Foo -+>a : { a: number; b: number; c: number; } ++>a : Foo diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff index f5b0d64b85..57c791389e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff @@ -5,6 +5,7 @@ /** @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/contextuallyTypedParametersOptionalInJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt.diff deleted file mode 100644 index 502c07252a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt.diff +++ /dev/null @@ -1,66 +0,0 @@ ---- old.contextuallyTypedParametersOptionalInJSDoc.errors.txt -+++ new.contextuallyTypedParametersOptionalInJSDoc.errors.txt -@@= skipped -0, +0 lines =@@ --index.js(17,15): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. -- Type 'undefined' is not assignable to type 'number'. --index.js(28,15): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. -- Type 'undefined' is not assignable to type 'number'. -+index.js(5,20): error TS7006: Parameter 'num' implicitly has an 'any' type. -+index.js(16,17): error TS7006: Parameter 'a' implicitly has an 'any' type. -+index.js(16,20): error TS7006: Parameter 'b' implicitly has an 'any' type. -+index.js(18,5): error TS2554: Expected 2 arguments, but got 1. -+index.js(27,17): error TS7006: Parameter 'a' implicitly has an 'any' type. -+index.js(27,20): error TS7006: Parameter 'b' implicitly has an 'any' type. -+index.js(29,5): error TS2554: Expected 2 arguments, but got 1. - - --==== index.js (2 errors) ==== -+==== index.js (7 errors) ==== - /** - * - * @param {number} num - */ - function acceptNum(num) {} -+ ~~~ -+!!! error TS7006: Parameter 'num' implicitly has an 'any' type. - - /** - * @typedef {(a: string, b: number) => void} Fn -@@= skipped -20, +25 lines =@@ - * @param [b] - */ - function self(a, b) { -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. - acceptNum(b); // error -- ~ --!!! error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. --!!! error TS2345: Type 'undefined' is not assignable to type 'number'. - self(""); -+ ~~~~ -+!!! error TS2554: Expected 2 arguments, but got 1. -+!!! related TS6210 index.js:16:20: An argument for 'b' was not provided. - self("", undefined); - }; - -@@= skipped -14, +18 lines =@@ - * @param {number} [b] - */ - function self(a, b) { -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. - acceptNum(b); // error -- ~ --!!! error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. --!!! error TS2345: Type 'undefined' is not assignable to type 'number'. - self(""); -+ ~~~~ -+!!! error TS2554: Expected 2 arguments, but got 1. -+!!! related TS6210 index.js:27:20: An argument for 'b' was not provided. - self("", undefined); - }; - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff index ef23d5f50c..957f82402c 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.types.diff @@ -1,62 +1,20 @@ --- old.contextuallyTypedParametersOptionalInJSDoc.types +++ new.contextuallyTypedParametersOptionalInJSDoc.types -@@= skipped -5, +5 lines =@@ - * @param {number} num - */ - function acceptNum(num) {} -->acceptNum : (num: number) => void -->num : number -+>acceptNum : (num: any) => void -+>num : any - - /** - * @typedef {(a: string, b: number) => void} Fn -@@= skipped -9, +9 lines =@@ +@@= skipped -14, +14 lines =@@ /** @type {Fn} */ const fn1 = ->fn1 : Fn -+>fn1 : (a: any, b: any) => void ++>fn1 : (a: string, b: number) => void /** * @param [b] - */ - function self(a, b) { -->function self(a, b) { acceptNum(b); // error self(""); self("", undefined); } : (a: string, b?: number | undefined) => void -->self : (a: string, b?: number | undefined) => void -->a : string -->b : number | undefined -+>function self(a, b) { acceptNum(b); // error self(""); self("", undefined); } : (a: any, b: any) => void -+>self : (a: any, b: any) => void -+>a : any -+>b : any - - acceptNum(b); // error - >acceptNum(b) : void -->acceptNum : (num: number) => void -->b : number | undefined -+>acceptNum : (num: any) => void -+>b : any - - self(""); - >self("") : void -->self : (a: string, b?: number | undefined) => void -+>self : (a: any, b: any) => void - >"" : "" - - self("", undefined); - >self("", undefined) : void -->self : (a: string, b?: number | undefined) => void -+>self : (a: any, b: any) => void - >"" : "" - >undefined : undefined - @@= skipped -31, +31 lines =@@ /** @type {Fn} */ const fn2 = ->fn2 : Fn -+>fn2 : (a: any, b: any) => void ++>fn2 : (a: string, b: number) => void /** * @param {number} [b] @@ -64,30 +22,23 @@ function self(a, b) { ->function self(a, b) { acceptNum(b); // error self(""); self("", undefined); } : (a: string, b?: number) => void ->self : (a: string, b?: number) => void -->a : string -->b : number | undefined -+>function self(a, b) { acceptNum(b); // error self(""); self("", undefined); } : (a: any, b: any) => void -+>self : (a: any, b: any) => void -+>a : any -+>b : any ++>function self(a, b) { acceptNum(b); // error self(""); self("", undefined); } : (a: string, b?: number | undefined) => void ++>self : (a: string, b?: number | undefined) => void + >a : string + >b : number | undefined - acceptNum(b); // error - >acceptNum(b) : void -->acceptNum : (num: number) => void -->b : number | undefined -+>acceptNum : (num: any) => void -+>b : any +@@= skipped -18, +18 lines =@@ self(""); >self("") : void ->self : (a: string, b?: number) => void -+>self : (a: any, b: any) => void ++>self : (a: string, b?: number | undefined) => void >"" : "" self("", undefined); >self("", undefined) : void ->self : (a: string, b?: number) => void -+>self : (a: any, b: any) => void ++>self : (a: string, b?: number | undefined) => void >"" : "" >undefined : undefined diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff deleted file mode 100644 index 1c6304dd5d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt -+++ new.contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+index.js(13,14): error TS7006: Parameter 'fns' implicitly has an 'any' type. -+index.js(21,8): error TS7006: Parameter 'a' implicitly has an 'any' type. -+ -+ -+==== index.js (2 errors) ==== -+ /** -+ * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs -+ * @template A -+ * @template {Record} B -+ */ -+ -+ /** -+ * @template A -+ * @template {Record} B -+ * @param {Funcs} fns -+ * @returns {[A, B]} -+ */ -+ function foo(fns) { -+ ~~~ -+!!! error TS7006: Parameter 'fns' implicitly has an 'any' type. -+ return /** @type {any} */ (null); -+ } -+ -+ const result = foo({ -+ bar: { -+ fn: -+ /** @param {string} a */ -+ (a) => {}, -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ thing: "asd", -+ }, -+ }); diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff index c48ebde200..99fee27e27 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff @@ -1,45 +1,10 @@ --- old.contravariantOnlyInferenceFromAnnotatedFunctionJs.types +++ new.contravariantOnlyInferenceFromAnnotatedFunctionJs.types -@@= skipped -13, +13 lines =@@ - * @returns {[A, B]} - */ - function foo(fns) { -->foo : >(fns: Funcs) => [A, B] -->fns : Funcs -+>foo : (fns: any) => null -+>fns : any +@@= skipped -18, +18 lines =@@ return /** @type {any} */ (null); -->(null) : any -+>(null) : null + >(null) : any ++>null : any } const result = foo({ -->result : [string, { bar: string; }] -->foo({ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },}) : [string, { bar: string; }] -->foo : >(fns: Funcs) => [A, B] -->{ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },} : { bar: { fn: (a: string) => void; thing: string; }; } -+>result : null -+>foo({ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },}) : null -+>foo : (fns: any) => null -+>{ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },} : { bar: { fn: (a: any) => void; thing: string; }; } - - bar: { -->bar : { fn: (a: string) => void; thing: string; } -->{ fn: /** @param {string} a */ (a) => {}, thing: "asd", } : { fn: (a: string) => void; thing: string; } -+>bar : { fn: (a: any) => void; thing: string; } -+>{ fn: /** @param {string} a */ (a) => {}, thing: "asd", } : { fn: (a: any) => void; thing: string; } - - fn: -->fn : (a: string) => void -+>fn : (a: any) => void - - /** @param {string} a */ - (a) => {}, -->(a) => {} : (a: string) => void -->a : string -+>(a) => {} : (a: any) => void -+>a : any - - thing: "asd", - >thing : string diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff deleted file mode 100644 index 7dd3b2988c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff +++ /dev/null @@ -1,44 +0,0 @@ ---- old.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt -+++ new.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+index.js(6,17): error TS7006: Parameter 'predicate' implicitly has an 'any' type. -+index.js(14,4): error TS7006: Parameter 'pose' implicitly has an 'any' type. -+index.js(22,4): error TS7006: Parameter 'pose' implicitly has an 'any' type. -+index.js(22,10): error TS7006: Parameter '_' implicitly has an 'any' type. -+ -+ -+==== index.js (4 errors) ==== -+ /** -+ * @template T -+ * @param {(value: T, index: number) => boolean} predicate -+ * @returns {T} -+ */ -+ function filter(predicate) { -+ ~~~~~~~~~ -+!!! error TS7006: Parameter 'predicate' implicitly has an 'any' type. -+ return /** @type {any} */ (null); -+ } -+ -+ const a = filter( -+ /** -+ * @param {number} [pose] -+ */ -+ (pose) => true -+ ~~~~ -+!!! error TS7006: Parameter 'pose' implicitly has an 'any' type. -+ ); -+ -+ const b = filter( -+ /** -+ * @param {number} [pose] -+ * @param {number} [_] -+ */ -+ (pose, _) => true -+ ~~~~ -+!!! error TS7006: Parameter 'pose' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter '_' implicitly has an 'any' type. -+ ); -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff index e0f29357b1..c1be129b9e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff @@ -1,58 +1,28 @@ --- old.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types +++ new.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types -@@= skipped -6, +6 lines =@@ - * @returns {T} - */ - function filter(predicate) { -->filter : (predicate: (value: T, index: number) => boolean) => T -->predicate : (value: T, index: number) => boolean -+>filter : (predicate: any) => null -+>predicate : any +@@= skipped -11, +11 lines =@@ return /** @type {any} */ (null); -->(null) : any -+>(null) : null + >(null) : any ++>null : any } const a = filter( -->a : number | undefined -->filter( /** * @param {number} [pose] */ (pose) => true) : number | undefined -->filter : (predicate: (value: T, index: number) => boolean) => T -+>a : null -+>filter( /** * @param {number} [pose] */ (pose) => true) : null -+>filter : (predicate: any) => null - - /** +@@= skipped -11, +12 lines =@@ * @param {number} [pose] */ (pose) => true ->(pose) => true : (pose?: number) => true -->pose : number | undefined -+>(pose) => true : (pose: any) => boolean -+>pose : any ++>(pose) => true : (pose?: number | undefined) => true + >pose : number | undefined >true : true - ); - - const b = filter( -->b : number | undefined -->filter( /** * @param {number} [pose] * @param {number} [_] */ (pose, _) => true) : number | undefined -->filter : (predicate: (value: T, index: number) => boolean) => T -+>b : null -+>filter( /** * @param {number} [pose] * @param {number} [_] */ (pose, _) => true) : null -+>filter : (predicate: any) => null - - /** - * @param {number} [pose] +@@= skipped -16, +16 lines =@@ * @param {number} [_] */ (pose, _) => true ->(pose, _) => true : (pose?: number, _?: number) => true -->pose : number | undefined -->_ : number | undefined -+>(pose, _) => true : (pose: any, _: any) => boolean -+>pose : any -+>_ : any ++>(pose, _) => true : (pose?: number | undefined, _?: number | undefined) => true + >pose : number | undefined + >_ : number | undefined >true : true - - ); diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff index 7e2fe09aca..55b29876ac 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff @@ -3,8 +3,7 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+uglify.js(5,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. -+uglify.js(6,7): error TS2339: Property 'val' does not exist on type 'number'. ++uglify.js(6,7): error TS2339: Property 'val' does not exist on type '{}'. + + +==== controlFlowInstanceof.ts (0 errors) ==== @@ -116,16 +115,14 @@ + } + + // Repro from #27550 (based on uglify code) -+==== uglify.js (2 errors) ==== ++==== uglify.js (1 errors) ==== + /** @constructor */ + function AtTop(val) { this.val = val } + /** @type {*} */ + var v = 1; + if (v instanceof AtTop) { -+ ~ -+!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. + v.val + ~~~ -+!!! error TS2339: Property 'val' does not exist on type 'number'. ++!!! error TS2339: Property 'val' does not exist on type '{}'. + } + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.types.diff index 88fcfed889..2ef4412868 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.types.diff @@ -14,23 +14,17 @@ >val : any >val : any - /** @type {*} */ - var v = 1; -->v : any -+>v : number - >1 : 1 - +@@= skipped -16, +16 lines =@@ if (v instanceof AtTop) { >v instanceof AtTop : boolean -->v : any + >v : any ->AtTop : typeof AtTop -+>v : number +>AtTop : (val: any) => void v.val >v.val : any ->v : AtTop -+>v : number ++>v : {} >val : any } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt.diff deleted file mode 100644 index 1f774adc3e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt.diff +++ /dev/null @@ -1,57 +0,0 @@ ---- old.declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt -+++ new.declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+input.js(5,7): error TS7005: Variable 'something' implicitly has an 'any' type. -+input.js(13,77): error TS7006: Parameter 'req' implicitly has an 'any' type. -+input.js(21,64): error TS7006: Parameter 'req' implicitly has an 'any' type. -+input.js(37,88): error TS7006: Parameter 'b' implicitly has an 'any' type. -+ -+ -+==== input.js (4 errors) ==== -+ /** -+ * @typedef {{ } & { name?: string }} P -+ */ -+ -+ const something = /** @type {*} */(null); -+ ~~~~~~~~~ -+!!! error TS7005: Variable 'something' implicitly has an 'any' type. -+ -+ export let vLet = /** @type {P} */(something); -+ export const vConst = /** @type {P} */(something); -+ -+ export function fn(p = /** @type {P} */(something)) {} -+ -+ /** @param {number} req */ -+ export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} -+ ~~~ -+!!! error TS7006: Parameter 'req' implicitly has an 'any' type. -+ -+ export class C { -+ field = /** @type {P} */(something); -+ /** @optional */ optField = /** @type {P} */(something); // not a thing -+ /** @readonly */ roFiled = /** @type {P} */(something); -+ method(p = /** @type {P} */(something)) {} -+ /** @param {number} req */ -+ methodWithRequiredDefault(p = /** @type {P} */(something), req) {} -+ ~~~ -+!!! error TS7006: Parameter 'req' implicitly has an 'any' type. -+ -+ constructor(ctorField = /** @type {P} */(something)) {} -+ -+ get x() { return /** @type {P} */(something) } -+ set x(v) { } -+ } -+ -+ export default /** @type {P} */(something); -+ -+ // allows `undefined` on the input side, thanks to the initializer -+ /** -+ * -+ * @param {P} x -+ * @param {number} b -+ */ -+ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt.diff deleted file mode 100644 index 44bdfc61d2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt.diff +++ /dev/null @@ -1,54 +0,0 @@ ---- old.declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt -+++ new.declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+input.js(13,77): error TS7006: Parameter 'req' implicitly has an 'any' type. -+input.js(21,64): error TS7006: Parameter 'req' implicitly has an 'any' type. -+input.js(37,88): error TS7006: Parameter 'b' implicitly has an 'any' type. -+ -+ -+==== input.js (3 errors) ==== -+ /** -+ * @typedef {{ } & { name?: string }} P -+ */ -+ -+ const something = /** @type {*} */(null); -+ -+ export let vLet = /** @type {P} */(something); -+ export const vConst = /** @type {P} */(something); -+ -+ export function fn(p = /** @type {P} */(something)) {} -+ -+ /** @param {number} req */ -+ export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} -+ ~~~ -+!!! error TS7006: Parameter 'req' implicitly has an 'any' type. -+ -+ export class C { -+ field = /** @type {P} */(something); -+ /** @optional */ optField = /** @type {P} */(something); // not a thing -+ /** @readonly */ roFiled = /** @type {P} */(something); -+ method(p = /** @type {P} */(something)) {} -+ /** @param {number} req */ -+ methodWithRequiredDefault(p = /** @type {P} */(something), req) {} -+ ~~~ -+!!! error TS7006: Parameter 'req' implicitly has an 'any' type. -+ -+ constructor(ctorField = /** @type {P} */(something)) {} -+ -+ get x() { return /** @type {P} */(something) } -+ set x(v) { } -+ } -+ -+ export default /** @type {P} */(something); -+ -+ // allows `undefined` on the input side, thanks to the initializer -+ /** -+ * -+ * @param {P} x -+ * @param {number} b -+ */ -+ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.types.diff deleted file mode 100644 index 767a0e1512..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.declarationEmitClassAccessorsJs1.types -+++ new.declarationEmitClassAccessorsJs1.types -@@= skipped -20, +20 lines =@@ - */ - set path(path) { - >path : string -->path : string | URL -+>path : string - } - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.types.diff deleted file mode 100644 index f17be3923d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.types.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.declarationEmitClassSetAccessorParamNameInJs.types -+++ new.declarationEmitClassSetAccessorParamNameInJs.types -@@= skipped -11, +11 lines =@@ - * @param {string} baz Baz. - */ - set bar(baz) {} -->bar : string -->baz : string -+>bar : any -+>baz : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt.diff deleted file mode 100644 index 970edf2a77..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt.diff +++ /dev/null @@ -1,64 +0,0 @@ ---- old.declarationEmitObjectLiteralAccessorsJs1.errors.txt -+++ new.declarationEmitObjectLiteralAccessorsJs1.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+index.js(48,7): error TS7032: Property 'x' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+index.js(48,9): error TS7006: Parameter 'a' implicitly has an 'any' type. -+ -+ -+==== index.js (2 errors) ==== -+ // same type accessors -+ export const obj1 = { -+ /** -+ * my awesome getter (first in source order) -+ * @returns {string} -+ */ -+ get x() { -+ return ""; -+ }, -+ /** -+ * my awesome setter (second in source order) -+ * @param {string} a -+ */ -+ set x(a) {}, -+ }; -+ -+ // divergent accessors -+ export const obj2 = { -+ /** -+ * my awesome getter -+ * @returns {string} -+ */ -+ get x() { -+ return ""; -+ }, -+ /** -+ * my awesome setter -+ * @param {number} a -+ */ -+ set x(a) {}, -+ }; -+ -+ export const obj3 = { -+ /** -+ * my awesome getter -+ * @returns {string} -+ */ -+ get x() { -+ return ""; -+ }, -+ }; -+ -+ export const obj4 = { -+ /** -+ * my awesome setter -+ * @param {number} a -+ */ -+ set x(a) {}, -+ ~ -+!!! error TS7032: Property 'x' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ }; -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.types.diff index ecf89c190d..e1fa2701f4 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.types.diff @@ -11,33 +11,3 @@ /** * my awesome getter -@@= skipped -20, +20 lines =@@ - */ - set x(a) {}, - >x : string -->a : number -+>a : string - - }; - -@@= skipped -22, +22 lines =@@ - }; - - export const obj4 = { -->obj4 : { x: number; } -->{ /** * my awesome setter * @param {number} a */ set x(a) {},} : { x: number; } -+>obj4 : { x: any; } -+>{ /** * my awesome setter * @param {number} a */ set x(a) {},} : { x: any; } - - /** - * my awesome setter - * @param {number} a - */ - set x(a) {}, -->x : number -->a : number -+>x : any -+>a : any - - }; - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff index 19326846f3..edb9efdfe1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff @@ -3,16 +3,19 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++input.js(5,48): error TS2304: Cannot find name 'P'. +input.js(48,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +input.js(52,24): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + -+==== input.js (2 errors) ==== ++==== input.js (3 errors) ==== + /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ + + /** + * @template P + * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ ++ ~ ++!!! error TS2304: Cannot find name 'P'. + + /** + * @type {StatelessComponent} diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff index 5d933061c9..2601f4799d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff @@ -6,7 +6,7 @@ const MyComponent = () => /* @type {any} */(null); ->MyComponent : StatelessComponent ->() => /* @type {any} */(null) : { (): any; defaultProps: Partial; } -+>MyComponent : { (): any; defaultProps: { color: string; }; } ++>MyComponent : { (): any; defaultProps?: P; } +>() => /* @type {any} */(null) : { (): any; defaultProps: { color: string; }; } >(null) : null @@ -17,9 +17,9 @@ ->defaultProps : Partial ->{ color: "red"} : { color: "red"; } +>MyComponent.defaultProps = { color: "red"} : { color: string; } -+>MyComponent.defaultProps : { color: string; } -+>MyComponent : { (): any; defaultProps: { color: string; }; } -+>defaultProps : { color: string; } ++>MyComponent.defaultProps : P ++>MyComponent : { (): any; defaultProps?: P; } ++>defaultProps : P +>{ color: "red"} : { color: string; } color: "red" @@ -62,7 +62,7 @@ const check = MyComponent2; ->check : StatelessComponent ->MyComponent2 : { (): any; defaultProps: MyComponentProps; } -+>check : { (): any; defaultProps: { color: string; }; } ++>check : { (): any; defaultProps?: P; } +>MyComponent2 : { (): any; defaultProps: { color: string; }; } /** @@ -72,8 +72,8 @@ function expectLiteral(p) {} ->expectLiteral : (p: { props: MyComponentProps; }) => void ->p : { props: MyComponentProps; } -+>expectLiteral : (p: any) => void -+>p : any ++>expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void ++>p : { props: { color: "blue" | "red"; }; } function foo() { ->foo : typeof foo @@ -101,7 +101,7 @@ >expectLiteral(this) : void ->expectLiteral : (p: { props: MyComponentProps; }) => void ->this : this -+>expectLiteral : (p: any) => void ++>expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void +>this : any } @@ -134,7 +134,7 @@ ->module.exports : MyComponentProps ->module : { exports: MyComponentProps; } ->exports : MyComponentProps -+>expectLiteral : (p: any) => void ++>expectLiteral : (p: { props: { color: "blue" | "red"; }; }) => void +>{ props: module.exports } : { props: any; } +>props : any +>module.exports : any diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.types.diff index 75475f1279..2332f14109 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.types.diff @@ -5,7 +5,7 @@ */ export function test() { ->test : () => import("./types").TestSymb -+>test : () => { (): void; inner[symb]: boolean; } ++>test : () => TestSymb function inner() {} ->inner : { (): void; [symb]: boolean; } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff index e778c128ec..03abd1d5db 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc1.types.diff @@ -5,18 +5,19 @@ /** @type {NumberLike[]} */export default ([ ]); ->([ ]) : NumberLike[] ++>([ ]) : (string | number)[] +>([ ]) : undefined[] >[ ] : undefined[] === b.ts === import A from './a' ->A : import("a").NumberLike[] -+>A : any[] ++>A : (string | number)[] A[0] ->A[0] : import("a").NumberLike ->A : import("a").NumberLike[] -+>A[0] : any -+>A : any[] ++>A[0] : string | number ++>A : (string | number)[] >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff index 0fae91fe0d..9697bd00c8 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff @@ -5,18 +5,19 @@ export default /** @type {NumberLike[]} */([ ]); ->([ ]) : NumberLike[] -+>([ ]) : undefined[] ++>([ ]) : (string | number)[] ++>[ ] : (string | number)[] >[ ] : undefined[] === b.ts === import A from './a' ->A : import("a").NumberLike[] -+>A : any[] ++>A : (string | number)[] A[0] ->A[0] : import("a").NumberLike ->A : import("a").NumberLike[] -+>A[0] : any -+>A : any[] ++>A[0] : string | number ++>A : (string | number)[] >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.types.diff deleted file mode 100644 index 915ac80b5c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.types.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.extendedUnicodePlaneIdentifiersJSDoc.types -+++ new.extendedUnicodePlaneIdentifiersJSDoc.types -@@= skipped -6, +6 lines =@@ - * @param {number} 𝑀 - */ - function foo(𝑚, 𝑀) { -->foo : (𝑚: number, 𝑀: number) => void -->𝑚 : number -->𝑀 : number -+>foo : (𝑚: any, 𝑀: any) => void -+>𝑚 : any -+>𝑀 : any - - console.log(𝑀 + 𝑚); - >console.log(𝑀 + 𝑚) : void - >console.log : (...data: any[]) => void - >console : Console - >log : (...data: any[]) => void -->𝑀 + 𝑚 : number -->𝑀 : number -->𝑚 : number -+>𝑀 + 𝑚 : any -+>𝑀 : any -+>𝑚 : any - } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.errors.txt.diff new file mode 100644 index 0000000000..2f9a807d64 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.importTypeResolutionJSDocEOF.errors.txt ++++ new.importTypeResolutionJSDocEOF.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++usage.js(1,12): error TS2304: Cannot find name 'Bar'. ++ ++ ++==== interfaces.d.ts (0 errors) ==== ++ export interface Bar { ++ prop: string ++ } ++ ++==== usage.js (1 errors) ==== ++ /** @type {Bar} */ ++ ~~~ ++!!! error TS2304: Cannot find name 'Bar'. ++ export let bar; ++ ++ /** @typedef {import('./interfaces').Bar} Bar */ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.types.diff index cc94917b48..aeb136fc3c 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.types.diff @@ -5,6 +5,6 @@ /** @type {Bar} */ export let bar; ->bar : import("interfaces").Bar -+>bar : any ++>bar : Bar /** @typedef {import('./interfaces').Bar} Bar */ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.types.diff index f60e5538c5..f99a8829f1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.types.diff @@ -1,22 +1,13 @@ --- old.jsDeclarationEmitDoesNotRenameImport.types +++ new.jsDeclarationEmitDoesNotRenameImport.types -@@= skipped -32, +32 lines =@@ - * @param {Options} options - */ - constructor(options) { -->options : Options -+>options : any - - super(); - >super() : void +@@= skipped -39, +39 lines =@@ >super : typeof Test if (options.test) { ->options.test : typeof import("Test").default | undefined -->options : Options -->test : typeof import("Test").default | undefined +>options.test : any -+>options : any + >options : Options +->test : typeof import("Test").default | undefined +>test : any this.test = new options.test(); @@ -27,11 +18,10 @@ >test : any ->new options.test() : import("Test").default ->options.test : typeof import("Test").default -->options : Options -->test : typeof import("Test").default +>new options.test() : any +>options.test : any -+>options : any + >options : Options +->test : typeof import("Test").default +>test : any } } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.types.diff deleted file mode 100644 index c90655a08f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.types.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.jsDeclarationsInheritedTypes.types -+++ new.jsDeclarationsInheritedTypes.types -@@= skipped -17, +17 lines =@@ - * @type {A} - */ - value; -->value : A -+>value : any - } - - class C2 extends C1 { -@@= skipped -11, +11 lines =@@ - * @type {A} - */ - value; -->value : A -+>value : any - } - - class C3 extends C1 { -@@= skipped -11, +11 lines =@@ - * @type {A & B} - */ - value; -->value : A & B -+>value : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt.diff deleted file mode 100644 index 34acefb524..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt.diff +++ /dev/null @@ -1,53 +0,0 @@ ---- old.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt -+++ new.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+index.js(9,49): error TS7006: Parameter 'init' implicitly has an 'any' type. -+ -+ -+==== package.json (0 errors) ==== -+ { -+ "name": "typescript-issue", -+ "private": true, -+ "version": "0.0.0", -+ "type": "module" -+ } -+==== node_modules/@lion/ajax/package.json (0 errors) ==== -+ { -+ "name": "@lion/ajax", -+ "version": "2.0.2", -+ "type": "module", -+ "exports": { -+ ".": { -+ "types": "./dist-types/src/index.d.ts", -+ "default": "./src/index.js" -+ }, -+ "./docs/*": "./docs/*" -+ } -+ } -+==== node_modules/@lion/ajax/dist-types/src/index.d.ts (0 errors) ==== -+ export type LionRequestInit = import('../types/types.js').LionRequestInit; -+==== node_modules/@lion/ajax/dist-types/types/types.d.ts (0 errors) ==== -+ export interface LionRequestInit { -+ body?: null | Object; -+ } -+==== index.js (1 errors) ==== -+ /** -+ * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit -+ */ -+ -+ export class NewAjax { -+ /** -+ * @param {LionRequestInit} [init] -+ */ -+ case5_unexpectedlyResolvesPathToNodeModules(init) {} -+ ~~~~ -+!!! error TS7006: Parameter 'init' implicitly has an 'any' type. -+ } -+ -+ /** -+ * @type {(init?: LionRequestInit) => void} -+ */ -+ // @ts-expect-error -+ NewAjax.prototype.case6_unexpectedlyResolvesPathToNodeModules; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types.diff index 2c686b8104..3ac8a33028 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.types.diff @@ -15,8 +15,8 @@ case5_unexpectedlyResolvesPathToNodeModules(init) {} ->case5_unexpectedlyResolvesPathToNodeModules : (init?: LionRequestInit) => void ->init : import("node_modules/@lion/ajax/dist-types/types/types").LionRequestInit | undefined -+>case5_unexpectedlyResolvesPathToNodeModules : (init: any) => void -+>init : any ++>case5_unexpectedlyResolvesPathToNodeModules : (init?: LionRequestInit | undefined) => void ++>init : LionRequestInit | undefined } /** diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff index 61a65b20a6..0aa18b02f5 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff @@ -7,7 +7,10 @@ +enumDef.js(4,6): error TS2339: Property 'UserMetrics' does not exist on type '{}'. +enumDef.js(16,6): error TS2339: Property 'UserMetrics' does not exist on type '{}'. +index.js(2,7): error TS2339: Property 'Cls' does not exist on type '{}'. -+index.js(8,26): error TS2339: Property 'UserMetrics' does not exist on type '{}'. ++index.js(4,17): error TS2503: Cannot find namespace 'Host'. ++index.js(8,21): error TS2304: Cannot find name 'Host'. ++index.js(13,11): error TS2503: Cannot find namespace 'Host'. ++index.js(18,11): error TS2503: Cannot find namespace 'Host'. + + +==== enumDef.js (3 errors) ==== @@ -35,29 +38,35 @@ +!!! error TS2339: Property 'UserMetrics' does not exist on type '{}'. + x: 12 + } -+==== index.js (2 errors) ==== ++==== index.js (5 errors) ==== + var Other = {}; + Other.Cls = class { + ~~~ +!!! error TS2339: Property 'Cls' does not exist on type '{}'. + /** + * @param {!Host.UserMetrics.Action} p ++ ~~~~ ++!!! error TS2503: Cannot find namespace 'Host'. + */ + method(p) {} + usage() { + this.method(Host.UserMetrics.Action.WindowDocked); -+ ~~~~~~~~~~~ -+!!! error TS2339: Property 'UserMetrics' does not exist on type '{}'. ++ ~~~~ ++!!! error TS2304: Cannot find name 'Host'. + } + } + + /** + * @type {Host.UserMetrics.Bargh} ++ ~~~~ ++!!! error TS2503: Cannot find namespace 'Host'. + */ + var x = "ok"; + + /** + * @type {Host.UserMetrics.Blah} ++ ~~~~ ++!!! error TS2503: Cannot find namespace 'Host'. + */ + var y = "ok"; + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff index 9d99f2cb1e..0b17abe7b9 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff @@ -76,8 +76,8 @@ method(p) {} ->method : (p: Host.UserMetrics.Action) => void ->p : number -+>method : (p: any) => void -+>p : any ++>method : (p: Action) => void ++>p : Action usage() { >usage : () => void @@ -85,7 +85,7 @@ this.method(Host.UserMetrics.Action.WindowDocked); >this.method(Host.UserMetrics.Action.WindowDocked) : void ->this.method : (p: Host.UserMetrics.Action) => void -+>this.method : (p: any) => void ++>this.method : (p: Action) => void >this : this ->method : (p: Host.UserMetrics.Action) => void ->Host.UserMetrics.Action.WindowDocked : number @@ -95,14 +95,30 @@ ->UserMetrics : typeof Host.UserMetrics ->Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } ->WindowDocked : number -+>method : (p: any) => void ++>method : (p: Action) => void +>Host.UserMetrics.Action.WindowDocked : any +>Host.UserMetrics.Action : any +>Host.UserMetrics : any -+>Host : {} ++>Host : any +>UserMetrics : any +>Action : any +>WindowDocked : any } } +@@= skipped -39, +39 lines =@@ + * @type {Host.UserMetrics.Bargh} + */ + var x = "ok"; +->x : string ++>x : Bargh + >"ok" : "ok" + + /** + * @type {Host.UserMetrics.Blah} + */ + var y = "ok"; +->y : string ++>y : Blah + >"ok" : "ok" + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff index 752048e690..a408d5cc85 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff @@ -44,9 +44,8 @@ /** @type {LogEntry} */ const logEntry = { -->logEntry : LogEntry + >logEntry : LogEntry ->{ time: Date.now(), type, } : { time: number; type: string; } -+>logEntry : { time: number; type: any; } +>{ time: Date.now(), type, } : { time: number; type: any; } time: Date.now(), diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.types.diff index c32881c2aa..75821d6038 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.types.diff @@ -1,11 +1,6 @@ --- old.jsExportMemberMergedWithModuleAugmentation.types +++ new.jsExportMemberMergedWithModuleAugmentation.types -@@= skipped -5, +5 lines =@@ - - /** @type {string} */ - x; -->x : string -+>x : any +@@= skipped -9, +9 lines =@@ } module.exports = { @@ -20,7 +15,7 @@ >{ Abcde} : { Abcde: typeof Abcde; } Abcde -@@= skipped -17, +17 lines =@@ +@@= skipped -13, +13 lines =@@ === /index.ts === import { Abcde } from "./test"; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationRestParamJsDocFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationRestParamJsDocFunction.types.diff deleted file mode 100644 index 88feb90040..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationRestParamJsDocFunction.types.diff +++ /dev/null @@ -1,81 +0,0 @@ ---- old.jsFileCompilationRestParamJsDocFunction.types -+++ new.jsFileCompilationRestParamJsDocFunction.types -@@= skipped -11, +11 lines =@@ - * @returns {*} Returns the result of `func`. - */ - function apply(func, thisArg, ...args) { -->apply : (func: Function, thisArg: any, ...args: any[]) => any -->func : Function -+>apply : (func: any, thisArg: any, ...args: any[]) => any -+>func : any - >thisArg : any - >args : any[] - -@@= skipped -17, +17 lines =@@ - case 0: return func.call(thisArg); - >0 : 0 - >func.call(thisArg) : any -->func.call : (this: Function, thisArg: any, ...argArray: any[]) => any -->func : Function -->call : (this: Function, thisArg: any, ...argArray: any[]) => any -+>func.call : any -+>func : any -+>call : any - >thisArg : any - - case 1: return func.call(thisArg, args[0]); - >1 : 1 - >func.call(thisArg, args[0]) : any -->func.call : (this: Function, thisArg: any, ...argArray: any[]) => any -->func : Function -->call : (this: Function, thisArg: any, ...argArray: any[]) => any -+>func.call : any -+>func : any -+>call : any - >thisArg : any - >args[0] : any - >args : any[] -@@= skipped -19, +19 lines =@@ - case 2: return func.call(thisArg, args[0], args[1]); - >2 : 2 - >func.call(thisArg, args[0], args[1]) : any -->func.call : (this: Function, thisArg: any, ...argArray: any[]) => any -->func : Function -->call : (this: Function, thisArg: any, ...argArray: any[]) => any -+>func.call : any -+>func : any -+>call : any - >thisArg : any - >args[0] : any - >args : any[] -@@= skipped -14, +14 lines =@@ - case 3: return func.call(thisArg, args[0], args[1], args[2]); - >3 : 3 - >func.call(thisArg, args[0], args[1], args[2]) : any -->func.call : (this: Function, thisArg: any, ...argArray: any[]) => any -->func : Function -->call : (this: Function, thisArg: any, ...argArray: any[]) => any -+>func.call : any -+>func : any -+>call : any - >thisArg : any - >args[0] : any - >args : any[] -@@= skipped -16, +16 lines =@@ - } - return func.apply(thisArg, args); - >func.apply(thisArg, args) : any -->func.apply : (this: Function, thisArg: any, argArray?: any) => any -->func : Function -->apply : (this: Function, thisArg: any, argArray?: any) => any -+>func.apply : any -+>func : any -+>apply : any - >thisArg : any - >args : any[] - } - - export default apply; -->apply : (func: Function, thisArg: any, ...args: any[]) => any -+>apply : (func: any, thisArg: any, ...args: any[]) => any - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.types.diff deleted file mode 100644 index b86f4ec697..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.jsFileCompilationSyntaxError.types -+++ new.jsFileCompilationSyntaxError.types -@@= skipped -5, +5 lines =@@ - * @type {string} - */ - var v; -->v : number -+>v : any - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff index 8dab266723..4f31cbbd15 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff @@ -5,90 +5,28 @@ */ function getTypeName(x) { ->getTypeName : { (x: number): "number"; (x: string): "string"; (x: boolean): "boolean"; } -->x : unknown -+>getTypeName : (x: any) => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" -+>x : any ++>getTypeName : (x: unknown) => string + >x : unknown return typeof x; - >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" -->x : unknown -+>x : any - } - - /** -@@= skipped -14, +14 lines =@@ - * @returns {T} - */ - const identity = x => x; -->identity : (x: T) => T -->x => x : (x: T) => T -->x : T -->x : T -+>identity : (x: any) => any -+>x => x : (x: any) => any -+>x : any -+>x : any - - /** - * @template T -@@= skipped -25, +25 lines =@@ +@@= skipped -39, +39 lines =@@ * @returns {unknown[]} */ function flatMap(array, iterable = identity) { ->flatMap : { (array: T[], iterable: (x: T) => U[]): U[]; (array: T[][]): T[]; } -->array : unknown[] -->iterable : (x: unknown) => unknown ++>flatMap : (array: unknown[], iterable?: (x: unknown) => unknown) => unknown[] + >array : unknown[] + >iterable : (x: unknown) => unknown ->identity : (x: T_1) => T_1 -+>flatMap : (array: any, iterable?: (x: any) => any) => any[] -+>array : any -+>iterable : (x: any) => any -+>identity : (x: any) => any ++>identity : (x: T) => T /** @type {unknown[]} */ const result = []; -->result : unknown[] -+>result : any[] - >[] : undefined[] - - for (let i = 0; i < array.length; i += 1) { -@@= skipped -15, +15 lines =@@ - >0 : 0 - >i < array.length : boolean - >i : number -->array.length : number -->array : unknown[] -->length : number -+>array.length : any -+>array : any -+>length : any - >i += 1 : number - >i : number - >1 : 1 - - result.push(.../** @type {unknown[]} */(iterable(array[i]))); - >result.push(.../** @type {unknown[]} */(iterable(array[i]))) : number -->result.push : (...items: unknown[]) => number -->result : unknown[] -->push : (...items: unknown[]) => number -->.../** @type {unknown[]} */(iterable(array[i])) : unknown -->(iterable(array[i])) : unknown[] -->iterable(array[i]) : unknown -->iterable : (x: unknown) => unknown -->array[i] : unknown -->array : unknown[] -+>result.push : (...items: any[]) => number -+>result : any[] -+>push : (...items: any[]) => number -+>.../** @type {unknown[]} */(iterable(array[i])) : any -+>(iterable(array[i])) : any -+>iterable(array[i]) : any -+>iterable : (x: any) => any -+>array[i] : any -+>array : any - >i : number - } - return result; -->result : unknown[] -+>result : any[] - } - +@@= skipped -29, +29 lines =@@ + >push : (...items: unknown[]) => number + >.../** @type {unknown[]} */(iterable(array[i])) : unknown + >(iterable(array[i])) : unknown[] ++>iterable(array[i]) : unknown[] + >iterable(array[i]) : unknown + >iterable : (x: unknown) => unknown + >array[i] : unknown diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff index a0178ca139..719bd846ea 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff @@ -5,90 +5,28 @@ */ function getTypeName(x) { ->getTypeName : { (x: number): "number"; (x: string): "string"; (x: boolean): "boolean"; } -->x : unknown -+>getTypeName : (x: any) => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" -+>x : any ++>getTypeName : (x: unknown) => string + >x : unknown return typeof x; - >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" -->x : unknown -+>x : any - } - - /** -@@= skipped -14, +14 lines =@@ - * @returns {T} - */ - const identity = x => x; -->identity : (x: T) => T -->x => x : (x: T) => T -->x : T -->x : T -+>identity : (x: any) => any -+>x => x : (x: any) => any -+>x : any -+>x : any - - /** - * @template T -@@= skipped -22, +22 lines =@@ +@@= skipped -36, +36 lines =@@ * @returns {unknown[]} */ function flatMap(array, iterable = identity) { ->flatMap : { (array: T[], iterable: (x: T) => U[]): U[]; (array: T[][]): T[]; } -->array : unknown[] -->iterable : (x: unknown) => unknown ++>flatMap : (array: unknown[], iterable?: (x: unknown) => unknown) => unknown[] + >array : unknown[] + >iterable : (x: unknown) => unknown ->identity : (x: T_1) => T_1 -+>flatMap : (array: any, iterable?: (x: any) => any) => any[] -+>array : any -+>iterable : (x: any) => any -+>identity : (x: any) => any ++>identity : (x: T) => T /** @type {unknown[]} */ const result = []; -->result : unknown[] -+>result : any[] - >[] : undefined[] - - for (let i = 0; i < array.length; i += 1) { -@@= skipped -15, +15 lines =@@ - >0 : 0 - >i < array.length : boolean - >i : number -->array.length : number -->array : unknown[] -->length : number -+>array.length : any -+>array : any -+>length : any - >i += 1 : number - >i : number - >1 : 1 - - result.push(.../** @type {unknown[]} */(iterable(array[i]))); - >result.push(.../** @type {unknown[]} */(iterable(array[i]))) : number -->result.push : (...items: unknown[]) => number -->result : unknown[] -->push : (...items: unknown[]) => number -->.../** @type {unknown[]} */(iterable(array[i])) : unknown -->(iterable(array[i])) : unknown[] -->iterable(array[i]) : unknown -->iterable : (x: unknown) => unknown -->array[i] : unknown -->array : unknown[] -+>result.push : (...items: any[]) => number -+>result : any[] -+>push : (...items: any[]) => number -+>.../** @type {unknown[]} */(iterable(array[i])) : any -+>(iterable(array[i])) : any -+>iterable(array[i]) : any -+>iterable : (x: any) => any -+>array[i] : any -+>array : any - >i : number - } - return result; -->result : unknown[] -+>result : any[] - } - +@@= skipped -29, +29 lines =@@ + >push : (...items: unknown[]) => number + >.../** @type {unknown[]} */(iterable(array[i])) : unknown + >(iterable(array[i])) : unknown[] ++>iterable(array[i]) : unknown[] + >iterable(array[i]) : unknown + >iterable : (x: unknown) => unknown + >array[i] : unknown diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff index 689954c6eb..0cace8ce94 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff @@ -3,8 +3,8 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+index.js(9,10): error TS7006: Parameter 'obj' implicitly has an 'any' type. -+index.js(9,15): error TS7006: Parameter 'vm' implicitly has an 'any' type. ++index.js(11,12): error TS2339: Property 'objects' does not exist on type 'object'. ++index.js(13,26): error TS2698: Spread types may only be created from object types. + + +==== dash.d.ts (0 errors) ==== @@ -27,14 +27,14 @@ + * @param {object} vm + */ + test(obj, vm) { -+ ~~~ -+!!! error TS7006: Parameter 'obj' implicitly has an 'any' type. -+ ~~ -+!!! error TS7006: Parameter 'vm' implicitly has an 'any' type. + let index = 0; + vm.objects = _.mapValues( ++ ~~~~~~~ ++!!! error TS2339: Property 'objects' does not exist on type 'object'. + obj, + object => ({ ...object, [INDEX_FIELD]: index++ }), ++ ~~~~~~~~~ ++!!! error TS2698: Spread types may only be created from object types. + ); + } + } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.types.diff index 489027142b..634c916253 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.types.diff @@ -1,51 +1,30 @@ --- old.jsFileImportPreservedWhenUsed.types +++ new.jsFileImportPreservedWhenUsed.types -@@= skipped -38, +38 lines =@@ - * @param {object} vm - */ - test(obj, vm) { -->test : (obj: object, vm: object) => void -->obj : object -->vm : object -+>test : (obj: any, vm: any) => void -+>obj : any -+>vm : any - - let index = 0; - >index : number - >0 : 0 +@@= skipped -48, +48 lines =@@ vm.objects = _.mapValues( -->vm.objects = _.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : object + >vm.objects = _.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : object ->vm.objects : error -->vm : object -+>vm.objects = _.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : { [x: string]: any; } +>vm.objects : any -+>vm : any + >vm : object >objects : any -->_.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : object + >_.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : object ->_.mapValues : (obj: T | null | undefined, callback: (value: T[keyof T], key: string, collection: T) => TResult) => { [P in keyof T]: TResult; } -+>_.mapValues( obj, object => ({ ...object, [INDEX_FIELD]: index++ }), ) : { [x: string]: any; } +>_.mapValues : (obj: T | null | undefined, callback: ObjectIterator) => { [P in keyof T]: TResult; } >_ : LoDashStatic ->mapValues : (obj: T | null | undefined, callback: (value: T[keyof T], key: string, collection: T) => TResult) => { [P in keyof T]: TResult; } +>mapValues : (obj: T | null | undefined, callback: ObjectIterator) => { [P in keyof T]: TResult; } obj, -->obj : object -+>obj : any - + >obj : object +@@= skipped -14, +14 lines =@@ object => ({ ...object, [INDEX_FIELD]: index++ }), -->object => ({ ...object, [INDEX_FIELD]: index++ }) : (object: never) => any -->object : never + >object => ({ ...object, [INDEX_FIELD]: index++ }) : (object: never) => any + >object : never ->({ ...object, [INDEX_FIELD]: index++ }) : error ->{ ...object, [INDEX_FIELD]: index++ } : error -->object : never -+>object => ({ ...object, [INDEX_FIELD]: index++ }) : (object: any) => any -+>object : any +>({ ...object, [INDEX_FIELD]: index++ }) : any +>{ ...object, [INDEX_FIELD]: index++ } : any -+>object : any + >object : never >[INDEX_FIELD] : number >INDEX_FIELD : "__INDEX" - >index++ : number diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff index c7ba1d7958..3111d5f6b7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff @@ -3,10 +3,10 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+jsFileMethodOverloads.js(9,10): error TS2339: Property 'value' does not exist on type 'Example'. -+jsFileMethodOverloads.js(26,24): error TS2339: Property 'value' does not exist on type 'Example'. -+jsFileMethodOverloads.js(44,25): error TS2339: Property 'value' does not exist on type 'Example'. -+jsFileMethodOverloads.js(44,39): error TS2339: Property 'value' does not exist on type 'Example'. ++jsFileMethodOverloads.js(9,10): error TS2339: Property 'value' does not exist on type 'Example'. ++jsFileMethodOverloads.js(26,24): error TS2339: Property 'value' does not exist on type 'Example'. ++jsFileMethodOverloads.js(44,25): error TS2339: Property 'value' does not exist on type 'Example'. ++jsFileMethodOverloads.js(44,39): error TS2339: Property 'value' does not exist on type 'Example'. + + +==== jsFileMethodOverloads.js (4 errors) ==== @@ -20,7 +20,7 @@ + constructor(value) { + this.value = value; + ~~~~~ -+!!! error TS2339: Property 'value' does not exist on type 'Example'. ++!!! error TS2339: Property 'value' does not exist on type 'Example'. + } + + /** @@ -39,7 +39,7 @@ + getTypeName() { + return typeof this.value; + ~~~~~ -+!!! error TS2339: Property 'value' does not exist on type 'Example'. ++!!! error TS2339: Property 'value' does not exist on type 'Example'. + } + + /** @@ -59,9 +59,9 @@ + transform(fn) { + return fn ? fn(this.value) : this.value; + ~~~~~ -+!!! error TS2339: Property 'value' does not exist on type 'Example'. ++!!! error TS2339: Property 'value' does not exist on type 'Example'. + ~~~~~ -+!!! error TS2339: Property 'value' does not exist on type 'Example'. ++!!! error TS2339: Property 'value' does not exist on type 'Example'. + } + } + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.types.diff index 2e486b72f6..884f20ef67 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.types.diff @@ -1,36 +1,11 @@ --- old.jsFileMethodOverloads.types +++ new.jsFileMethodOverloads.types -@@= skipped -4, +4 lines =@@ - * @template T - */ - class Example { -->Example : Example -+>Example : Example - - /** - * @param {T} value - */ - constructor(value) { -->value : T -+>value : any - - this.value = value; -->this.value = value : T -+>this.value = value : any - >this.value : any - >this : this - >value : any -->value : T -+>value : any - } - - /** -@@= skipped -30, +30 lines =@@ +@@= skipped -34, +34 lines =@@ * @returns {string} */ getTypeName() { ->getTypeName : { (this: Example): "number"; (this: Example): "string"; } -+>getTypeName : () => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ++>getTypeName : () => string return typeof this.value; >typeof this.value : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" @@ -47,20 +22,16 @@ */ transform(fn) { ->transform : { (fn: (y: T) => U): U; (): T; } -->fn : (y: T) => unknown -+>transform : (fn: any) => any -+>fn : any ++>transform : (fn?: (y: T) => unknown) => unknown + >fn : (y: T) => unknown return fn ? fn(this.value) : this.value; ->fn ? fn(this.value) : this.value : unknown -->fn : (y: T) => unknown -->fn(this.value) : unknown -->fn : (y: T) => unknown -->this.value : T +>fn ? fn(this.value) : this.value : any -+>fn : any -+>fn(this.value) : any -+>fn : any + >fn : (y: T) => unknown + >fn(this.value) : unknown + >fn : (y: T) => unknown +->this.value : T +>this.value : any >this : this ->value : T diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff index 4b61d6f32c..fd3edaeb41 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff @@ -3,10 +3,10 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+jsFileMethodOverloads2.js(10,10): error TS2339: Property 'value' does not exist on type 'Example'. -+jsFileMethodOverloads2.js(25,24): error TS2339: Property 'value' does not exist on type 'Example'. -+jsFileMethodOverloads2.js(41,25): error TS2339: Property 'value' does not exist on type 'Example'. -+jsFileMethodOverloads2.js(41,39): error TS2339: Property 'value' does not exist on type 'Example'. ++jsFileMethodOverloads2.js(10,10): error TS2339: Property 'value' does not exist on type 'Example'. ++jsFileMethodOverloads2.js(25,24): error TS2339: Property 'value' does not exist on type 'Example'. ++jsFileMethodOverloads2.js(41,25): error TS2339: Property 'value' does not exist on type 'Example'. ++jsFileMethodOverloads2.js(41,39): error TS2339: Property 'value' does not exist on type 'Example'. + + +==== jsFileMethodOverloads2.js (4 errors) ==== @@ -21,7 +21,7 @@ + constructor(value) { + this.value = value; + ~~~~~ -+!!! error TS2339: Property 'value' does not exist on type 'Example'. ++!!! error TS2339: Property 'value' does not exist on type 'Example'. + } + + /** @@ -38,7 +38,7 @@ + getTypeName() { + return typeof this.value; + ~~~~~ -+!!! error TS2339: Property 'value' does not exist on type 'Example'. ++!!! error TS2339: Property 'value' does not exist on type 'Example'. + } + + /** @@ -56,9 +56,9 @@ + transform(fn) { + return fn ? fn(this.value) : this.value; + ~~~~~ -+!!! error TS2339: Property 'value' does not exist on type 'Example'. ++!!! error TS2339: Property 'value' does not exist on type 'Example'. + ~~~~~ -+!!! error TS2339: Property 'value' does not exist on type 'Example'. ++!!! error TS2339: Property 'value' does not exist on type 'Example'. + } + } + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff index 0740fbc90a..290a461452 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff @@ -1,36 +1,11 @@ --- old.jsFileMethodOverloads2.types +++ new.jsFileMethodOverloads2.types -@@= skipped -5, +5 lines =@@ - * @template T - */ - class Example { -->Example : Example -+>Example : Example - - /** - * @param {T} value - */ - constructor(value) { -->value : T -+>value : any - - this.value = value; -->this.value = value : T -+>this.value = value : any - >this.value : any - >this : this - >value : any -->value : T -+>value : any - } - - /** -@@= skipped -28, +28 lines =@@ +@@= skipped -33, +33 lines =@@ * @returns {string} */ getTypeName() { ->getTypeName : { (this: Example): "number"; (this: Example): "string"; } -+>getTypeName : () => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ++>getTypeName : () => string return typeof this.value; >typeof this.value : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" @@ -47,20 +22,16 @@ */ transform(fn) { ->transform : { (fn: (y: T) => U): U; (): T; } -->fn : (y: T) => unknown -+>transform : (fn: any) => any -+>fn : any ++>transform : (fn?: (y: T) => unknown) => unknown + >fn : (y: T) => unknown return fn ? fn(this.value) : this.value; ->fn ? fn(this.value) : this.value : unknown -->fn : (y: T) => unknown -->fn(this.value) : unknown -->fn : (y: T) => unknown -->this.value : T +>fn ? fn(this.value) : this.value : any -+>fn : any -+>fn(this.value) : any -+>fn : any + >fn : (y: T) => unknown + >fn(this.value) : unknown + >fn : (y: T) => unknown +->this.value : T +>this.value : any >this : this ->value : T diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff index 376d4dab51..2021e5deba 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff @@ -1,33 +1,35 @@ --- old.jsFileMethodOverloads3.errors.txt +++ new.jsFileMethodOverloads3.errors.txt -@@= skipped -0, +0 lines =@@ +@@= skipped -0, +-1 lines =@@ -/a.js(2,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -/a.js(7,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+/a.js(15,13): error TS7006: Parameter 'x' implicitly has an 'any' type. - - +- +- -==== /a.js (2 errors) ==== -+==== /a.js (1 errors) ==== - /** - * @overload +- /** +- * @overload - ~~~~~~~~ -!!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. - * @param {number} x - */ - - /** - * @overload +- * @param {number} x +- */ +- +- /** +- * @overload - ~~~~~~~~ -!!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. - * @param {string} x - */ - -@@= skipped -21, +16 lines =@@ - * @returns {string | number} - */ - function id(x) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - return x; - } - +- * @param {string} x +- */ +- +- /** +- * @param {string | number} x +- * @returns {string | number} +- */ +- function id(x) { +- return x; +- } +- +- export let a = id(123); +- export let b = id("hello"); +- +@@= skipped --1, +1 lines =@@ ++ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.types.diff index f12b6413e2..02cca06620 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.types.diff @@ -5,26 +5,28 @@ */ function id(x) { ->id : { (x: number): any; (x: string): any; } -->x : string | number -+>id : (x: any) => any -+>x : any ++>id : (x: string | number) => string | number + >x : string | number return x; -->x : string | number -+>x : any +@@= skipped -8, +8 lines =@@ } export let a = id(123); - >a : any - >id(123) : any +->a : any +->id(123) : any ->id : { (x: number): any; (x: string): any; } -+>id : (x: any) => any ++>a : string | number ++>id(123) : string | number ++>id : (x: string | number) => string | number >123 : 123 export let b = id("hello"); - >b : any - >id("hello") : any +->b : any +->id("hello") : any ->id : { (x: number): any; (x: string): any; } -+>id : (x: any) => any ++>b : string | number ++>id("hello") : string | number ++>id : (x: string | number) => string | number >"hello" : "hello" diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.types.diff index d92bba1afc..a85e8ff97e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.types.diff @@ -6,10 +6,8 @@ export const foo = function (a, b) { } ->foo : { (a: string): void; (a: number, b?: number): void; } ->function (a, b) { } : { (a: string): void; (a: number, b?: number): void; } -->a : string | number -->b : number -+>foo : (a: any, b: any) => void -+>function (a, b) { } : (a: any, b: any) => void -+>a : any -+>b : any ++>foo : (a: string | number, b?: number) => void ++>function (a, b) { } : (a: string | number, b?: number) => void + >a : string | number + >b : number diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.types.diff deleted file mode 100644 index 60058b346c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsdocAccessEnumType.types -+++ new.jsdocAccessEnumType.types -@@= skipped -10, +10 lines =@@ - - /** @type {E} */ - const e = E.A; -->e : E -+>e : E.A - >E.A : E - >E : typeof E - >A : E diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff new file mode 100644 index 0000000000..64a04b64c4 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff @@ -0,0 +1,74 @@ +--- old.jsdocArrayObjectPromiseImplicitAny.errors.txt ++++ new.jsdocArrayObjectPromiseImplicitAny.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++jsdocArrayObjectPromiseImplicitAny.js(1,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). ++jsdocArrayObjectPromiseImplicitAny.js(8,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). ++jsdocArrayObjectPromiseImplicitAny.js(9,13): error TS2314: Generic type 'T[]' requires 1 type argument(s). ++jsdocArrayObjectPromiseImplicitAny.js(15,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++jsdocArrayObjectPromiseImplicitAny.js(22,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++jsdocArrayObjectPromiseImplicitAny.js(23,13): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++jsdocArrayObjectPromiseImplicitAny.js(30,18): error TS2322: Type 'number' is not assignable to type '() => Object'. ++jsdocArrayObjectPromiseImplicitAny.js(32,12): error TS2315: Type 'Object' is not generic. ++ ++ ++==== jsdocArrayObjectPromiseImplicitAny.js (8 errors) ==== ++ /** @type {Array} */ ++ ~~~~~ ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). ++ var anyArray = [5]; ++ ++ /** @type {Array} */ ++ var numberArray = [5]; ++ ++ /** ++ * @param {Array} arr ++ ~~~~~ ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). ++ * @return {Array} ++ ~~~~~ ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). ++ */ ++ function returnAnyArray(arr) { ++ return arr; ++ } ++ ++ /** @type {Promise} */ ++ ~~~~~~~ ++!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ var anyPromise = Promise.resolve(5); ++ ++ /** @type {Promise} */ ++ var numberPromise = Promise.resolve(5); ++ ++ /** ++ * @param {Promise} pr ++ ~~~~~~~ ++!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ * @return {Promise} ++ ~~~~~~~ ++!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ */ ++ function returnAnyPromise(pr) { ++ return pr; ++ } ++ ++ /** @type {Object} */ ++ var anyObject = {valueOf: 1}; // not an error since assigning to any. ++ ~~~~~~~ ++!!! error TS2322: Type 'number' is not assignable to type '() => Object'. ++ ++ /** @type {Object} */ ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ var paramedObject = {valueOf: 1}; ++ ++ /** ++ * @param {Object} obj ++ * @return {Object} ++ */ ++ function returnAnyObject(obj) { ++ return obj; ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.types.diff index 68f53b0ffc..392bc3b554 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.types.diff @@ -5,7 +5,7 @@ /** @type {Array} */ var anyArray = [5]; ->anyArray : any[] -+>anyArray : number[] ++>anyArray : any >[5] : number[] >5 : 5 @@ -26,7 +26,7 @@ /** @type {Promise} */ var anyPromise = Promise.resolve(5); ->anyPromise : Promise -+>anyPromise : Promise ++>anyPromise : any >Promise.resolve(5) : Promise >Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } >Promise : PromiseConstructor @@ -47,7 +47,7 @@ /** @type {Object} */ var anyObject = {valueOf: 1}; // not an error since assigning to any. ->anyObject : any -+>anyObject : { valueOf: number; } ++>anyObject : Object >{valueOf: 1} : { valueOf: number; } >valueOf : number >1 : 1 @@ -55,7 +55,21 @@ /** @type {Object} */ var paramedObject = {valueOf: 1}; ->paramedObject : { [x: string]: number; } -+>paramedObject : { valueOf: number; } ++>paramedObject : any >{valueOf: 1} : { valueOf: number; } >valueOf : number >1 : 1 +@@= skipped -26, +26 lines =@@ + * @return {Object} + */ + function returnAnyObject(obj) { +->returnAnyObject : (obj: any) => any +->obj : any ++>returnAnyObject : (obj: Object) => Object ++>obj : Object + + return obj; +->obj : any ++>obj : Object + } + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff index f983e79f48..8907da0eca 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff @@ -4,74 +4,44 @@ -jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS2314: Generic type 'Array' requires 1 type argument(s). -jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS2314: Generic type 'Array' requires 1 type argument(s). -jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS2314: Generic type 'Array' requires 1 type argument(s). --jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). --jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). --jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS2314: Generic type 'Promise' requires 1 type argument(s). --jsdocArrayObjectPromiseNoImplicitAny.js(30,21): error TS2322: Type 'number' is not assignable to type '() => Object'. -+jsdocArrayObjectPromiseNoImplicitAny.js(11,28): error TS7006: Parameter 'arr' implicitly has an 'any' type. -+jsdocArrayObjectPromiseNoImplicitAny.js(25,30): error TS7006: Parameter 'pr' implicitly has an 'any' type. -+jsdocArrayObjectPromiseNoImplicitAny.js(39,29): error TS7006: Parameter 'obj' implicitly has an 'any' type. ++jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). ++jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). ++jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS2314: Generic type 'T[]' requires 1 type argument(s). + jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). + jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). + jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS2314: Generic type 'Promise' requires 1 type argument(s). + jsdocArrayObjectPromiseNoImplicitAny.js(30,21): error TS2322: Type 'number' is not assignable to type '() => Object'. ++jsdocArrayObjectPromiseNoImplicitAny.js(32,12): error TS2315: Type 'Object' is not generic. -==== jsdocArrayObjectPromiseNoImplicitAny.js (7 errors) ==== -+==== jsdocArrayObjectPromiseNoImplicitAny.js (3 errors) ==== ++==== jsdocArrayObjectPromiseNoImplicitAny.js (8 errors) ==== /** @type {Array} */ -- ~~~~~ + ~~~~~ -!!! error TS2314: Generic type 'Array' requires 1 type argument(s). ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). var notAnyArray = [5]; /** @type {Array} */ -@@= skipped -17, +11 lines =@@ - +@@= skipped -18, +19 lines =@@ /** * @param {Array} arr -- ~~~~~ + ~~~~~ -!!! error TS2314: Generic type 'Array' requires 1 type argument(s). ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). * @return {Array} -- ~~~~~ + ~~~~~ -!!! error TS2314: Generic type 'Array' requires 1 type argument(s). ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). */ function returnNotAnyArray(arr) { -+ ~~~ -+!!! error TS7006: Parameter 'arr' implicitly has an 'any' type. return arr; - } - - /** @type {Promise} */ -- ~~~~~~~ --!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). - var notAnyPromise = Promise.resolve(5); - - /** @type {Promise} */ -@@= skipped -20, +16 lines =@@ - - /** - * @param {Promise} pr -- ~~~~~~~ --!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). - * @return {Promise} -- ~~~~~~~ --!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). - */ - function returnNotAnyPromise(pr) { -+ ~~ -+!!! error TS7006: Parameter 'pr' implicitly has an 'any' type. - return pr; - } - - /** @type {Object} */ - var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. -- ~~~~~~~ --!!! error TS2322: Type 'number' is not assignable to type '() => Object'. +@@= skipped -35, +35 lines =@@ + !!! error TS2322: Type 'number' is not assignable to type '() => Object'. /** @type {Object} */ ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. var paramedObject = {valueOf: 1}; -@@= skipped -23, +19 lines =@@ - * @return {Object} - */ - function returnNotAnyObject(obj) { -+ ~~~ -+!!! error TS7006: Parameter 'obj' implicitly has an 'any' type. - return obj; - } + /** diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.types.diff index 1256f721e6..c26d884397 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.types.diff @@ -5,7 +5,7 @@ /** @type {Array} */ var notAnyArray = [5]; ->notAnyArray : any[] -+>notAnyArray : number[] ++>notAnyArray : any >[5] : number[] >5 : 5 @@ -26,7 +26,7 @@ /** @type {Promise} */ var notAnyPromise = Promise.resolve(5); ->notAnyPromise : Promise -+>notAnyPromise : Promise ++>notAnyPromise : any >Promise.resolve(5) : Promise >Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } >Promise : PromiseConstructor @@ -45,31 +45,12 @@ } /** @type {Object} */ - var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. -->notAnyObject : Object -+>notAnyObject : { valueOf: number; } - >{valueOf: 1} : { valueOf: number; } - >valueOf : number - >1 : 1 +@@= skipped -16, +16 lines =@@ /** @type {Object} */ var paramedObject = {valueOf: 1}; ->paramedObject : { [x: string]: number; } -+>paramedObject : { valueOf: number; } ++>paramedObject : any >{valueOf: 1} : { valueOf: number; } >valueOf : number >1 : 1 -@@= skipped -26, +26 lines =@@ - * @return {Object} - */ - function returnNotAnyObject(obj) { -->returnNotAnyObject : (obj: Object) => Object -->obj : Object -+>returnNotAnyObject : (obj: any) => any -+>obj : any - - return obj; -->obj : Object -+>obj : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff index 76cf807f5e..2b378d31df 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff @@ -2,12 +2,11 @@ +++ new.jsdocBracelessTypeTag1.errors.txt @@= skipped -0, +0 lines =@@ -index.js(3,3): error TS2322: Type 'number' is not assignable to type 'string'. --index.js(20,16): error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. +index.js(12,14): error TS7006: Parameter 'arg' implicitly has an 'any' type. + index.js(20,16): error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. --==== index.js (2 errors) ==== -+==== index.js (1 errors) ==== +@@= skipped -5, +5 lines =@@ /** @type () => string */ function fn1() { return 42; @@ -16,7 +15,7 @@ } /** @type () => string */ -@@= skipped -16, +13 lines =@@ +@@= skipped -11, +9 lines =@@ /** @type (arg: string) => string */ function fn3(arg) { @@ -25,11 +24,3 @@ return arg; } -@@= skipped -8, +10 lines =@@ - - /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ - const obj2 = { type: "other", prop: 10 }; -- ~~~~ --!!! error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. --!!! related TS6500 index.js:19:14: The expected type comes from property 'type' which is declared here on type '({ type: "foo"; } | { type: "bar"; }) & { prop: number; }' - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.types.diff index 7957df75cd..fb8fca68cd 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.types.diff @@ -24,25 +24,3 @@ } /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ - const obj1 = { type: "foo", prop: 10 }; -->obj1 : ({ type: "foo"; } | { type: "bar"; }) & { prop: number; } -->{ type: "foo", prop: 10 } : { type: "foo"; prop: number; } -->type : "foo" -+>obj1 : { type: string; prop: number; } -+>{ type: "foo", prop: 10 } : { type: string; prop: number; } -+>type : string - >"foo" : "foo" - >prop : number - >10 : 10 - - /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ - const obj2 = { type: "other", prop: 10 }; -->obj2 : ({ type: "foo"; } | { type: "bar"; }) & { prop: number; } -->{ type: "other", prop: 10 } : { type: "other"; prop: number; } -->type : "other" -+>obj2 : { type: string; prop: number; } -+>{ type: "other", prop: 10 } : { type: string; prop: number; } -+>type : string - >"other" : "other" - >prop : number - >10 : 10 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff index 68509d8155..9f045ce14f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff @@ -1,20 +1,20 @@ --- old.jsdocCallbackAndType.errors.txt +++ new.jsdocCallbackAndType.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -/a.js(8,3): error TS2554: Expected 0 arguments, but got 1. -- -- --==== /a.js (1 errors) ==== -- /** -- * @template T -- * @callback B -- */ -- /** @type {B} */ -- let b; -- b(); -- b(1); ++/a.js(5,12): error TS2304: Cannot find name 'B'. + + + ==== /a.js (1 errors) ==== +@@= skipped -6, +6 lines =@@ + * @callback B + */ + /** @type {B} */ ++ ~ ++!!! error TS2304: Cannot find name 'B'. + let b; + b(); + b(1); - ~ -!!! error TS2554: Expected 0 arguments, but got 1. -- -@@= skipped --1, +1 lines =@@ -+ + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.types.diff deleted file mode 100644 index 00a2610a27..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.types.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsdocCallbackAndType.types -+++ new.jsdocCallbackAndType.types -@@= skipped -6, +6 lines =@@ - */ - /** @type {B} */ - let b; -->b : B -+>b : any - - b(); - >b() : any -->b : B -+>b : any - - b(1); - >b(1) : any -->b : B -+>b : any - >1 : 1 - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff deleted file mode 100644 index e9a65b7987..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.jsdocClassMissingTypeArguments.errors.txt -+++ new.jsdocClassMissingTypeArguments.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(4,13): error TS2314: Generic type 'C' requires 1 type argument(s). -+/a.js(5,12): error TS7006: Parameter 'p' implicitly has an 'any' type. - - - ==== /a.js (1 errors) ==== -@@= skipped -5, +5 lines =@@ - class C {} - - /** @param {C} p */ -- ~ --!!! error TS2314: Generic type 'C' requires 1 type argument(s). - function f(p) {} -+ ~ -+!!! error TS7006: Parameter 'p' implicitly has an 'any' type. - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.types.diff index 5969ef1cbc..15b52eecbb 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.types.diff @@ -1,11 +1,6 @@ --- old.jsdocClassMissingTypeArguments.types +++ new.jsdocClassMissingTypeArguments.types -@@= skipped -2, +2 lines =@@ - === /a.js === - /** @template T */ - class C {} -->C : C -+>C : C +@@= skipped -6, +6 lines =@@ /** @param {C} p */ function f(p) {} diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff index abf3798c4f..85984deafb 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff @@ -3,24 +3,18 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+/a.js(5,21): error TS7006: Parameter 'x' implicitly has an 'any' type. -+/a.js(5,24): error TS7006: Parameter 'y' implicitly has an 'any' type. +/a.js(6,11): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +/a.js(7,16): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. +/a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +/a.js(10,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + + -+==== /a.js (6 errors) ==== ++==== /a.js (4 errors) ==== + /** + * @param {number | undefined} x + * @param {number | undefined} y + */ + export function Foo(x, y) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'y' implicitly has an 'any' type. + if (!(this instanceof Foo)) { + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.types.diff index 862e3cf251..1a88902f9c 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.types.diff @@ -5,49 +5,40 @@ */ export function Foo(x, y) { ->Foo : typeof Foo -->x : number | undefined -->y : number | undefined -+>Foo : (x: any, y: any) => any -+>x : any -+>y : any ++>Foo : (x: number | undefined, y: number | undefined) => any + >x : number | undefined + >y : number | undefined - if (!(this instanceof Foo)) { +@@= skipped -8, +8 lines =@@ >!(this instanceof Foo) : boolean >(this instanceof Foo) : boolean >this instanceof Foo : boolean ->this : this ->Foo : typeof Foo +>this : any -+>Foo : (x: any, y: any) => any ++>Foo : (x: number | undefined, y: number | undefined) => any return new Foo(x, y); ->new Foo(x, y) : Foo ->Foo : typeof Foo -->x : number | undefined -->y : number | undefined +>new Foo(x, y) : any -+>Foo : (x: any, y: any) => any -+>x : any -+>y : any ++>Foo : (x: number | undefined, y: number | undefined) => any + >x : number | undefined + >y : number | undefined } this.x = x; -->this.x = x : number | undefined -+>this.x = x : any + >this.x = x : number | undefined >this.x : any ->this : this +>this : any >x : any -->x : number | undefined -+>x : any + >x : number | undefined this.y = y; -->this.y = y : number | undefined -+>this.y = y : any + >this.y = y : number | undefined >this.y : any ->this : this +>this : any >y : any -->y : number | undefined -+>y : any + >y : number | undefined } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff index 67967f145e..0bd8003afb 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff @@ -1,17 +1,16 @@ --- old.jsdocFunctionTypeFalsePositive.errors.txt +++ new.jsdocFunctionTypeFalsePositive.errors.txt -@@= skipped -0, +-1 lines =@@ --/a.js(1,13): error TS1098: Type parameter list cannot be empty. +@@= skipped -0, +0 lines =@@ + /a.js(1,13): error TS1098: Type parameter list cannot be empty. -/a.js(1,14): error TS1139: Type parameter declaration expected. -- -- + + -==== /a.js (2 errors) ==== -- /** @param {<} x */ -- ~~ --!!! error TS1098: Type parameter list cannot be empty. ++==== /a.js (1 errors) ==== + /** @param {<} x */ + ~~ + !!! error TS1098: Type parameter list cannot be empty. - ~ -!!! error TS1139: Type parameter declaration expected. -- function f(x) {} -- -@@= skipped --1, +1 lines =@@ -+ + function f(x) {} + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.types.diff deleted file mode 100644 index 5c224bdbab..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsdocFunctionTypeFalsePositive.types -+++ new.jsdocFunctionTypeFalsePositive.types -@@= skipped -2, +2 lines =@@ - === /a.js === - /** @param {<} x */ - function f(x) {} -->f : (x: () => any) => void -->x : () => any -+>f : (x: any) => void -+>x : any - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff index e6699eee2c..a19b5cc0ae 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff @@ -1,23 +1,16 @@ --- old.jsdocIllegalTags.errors.txt +++ new.jsdocIllegalTags.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -/a.js(2,19): error TS1092: Type parameters cannot appear on a constructor declaration. --/a.js(6,18): error TS1093: Type annotation cannot appear on a constructor declaration. -- -- --==== /a.js (2 errors) ==== -- class C { -- /** @template T */ ++/a.js(2,9): error TS1092: Type parameters cannot appear on a constructor declaration. + /a.js(6,18): error TS1093: Type annotation cannot appear on a constructor declaration. + + + ==== /a.js (2 errors) ==== + class C { + /** @template T */ - ~ --!!! error TS1092: Type parameters cannot appear on a constructor declaration. -- constructor() { } -- } -- class D { -- /** @return {number} */ -- ~~~~~~ --!!! error TS1093: Type annotation cannot appear on a constructor declaration. -- constructor() {} -- } -- -@@= skipped --1, +1 lines =@@ -+ ++ ~~~~~~~~~~~~ + !!! error TS1092: Type parameters cannot appear on a constructor declaration. + constructor() { } + } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff index ce72455d0a..a5f57dfca2 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff @@ -1,21 +1,18 @@ --- old.jsdocImportTypeNodeNamespace.errors.txt +++ new.jsdocImportTypeNodeNamespace.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -Main.js(2,21): error TS2352: Conversion of type 'string' to type 'typeof _default' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- -- --==== GeometryType.d.ts (0 errors) ==== -- declare namespace _default { -- export const POINT: string; -- } -- export default _default; -- --==== Main.js (1 errors) ==== -- export default function () { -- return /** @type {import('./GeometryType.js').default} */ ('Point'); ++Main.js(2,49): error TS2694: Namespace '"GeometryType"' has no exported member 'default'. + + + ==== GeometryType.d.ts (0 errors) ==== +@@= skipped -9, +9 lines =@@ + ==== Main.js (1 errors) ==== + export default function () { + return /** @type {import('./GeometryType.js').default} */ ('Point'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Conversion of type 'string' to type 'typeof _default' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -- } -- -@@= skipped --1, +1 lines =@@ -+ ++ ~~~~~~~ ++!!! error TS2694: Namespace '"GeometryType"' has no exported member 'default'. + } + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff index bed110cb86..9b8fabf4c6 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff @@ -5,7 +5,8 @@ export default function () { return /** @type {import('./GeometryType.js').default} */ ('Point'); ->('Point') : typeof import("GeometryType").default -+>('Point') : "Point" ++>('Point') : any ++>'Point' : any >'Point' : "Point" } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.types.diff deleted file mode 100644 index 6dda424a15..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.jsdocImportTypeResolution.types -+++ new.jsdocImportTypeResolution.types -@@= skipped -11, +11 lines =@@ - */ - /** @type {options} */ - let v; -->v : options -+>v : any - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.errors.txt.diff deleted file mode 100644 index 314d1d1969..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsdocParamTagOnPropertyInitializer.errors.txt -+++ new.jsdocParamTagOnPropertyInitializer.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+/a.js(3,9): error TS7006: Parameter 'x' implicitly has an 'any' type. -+ -+ -+==== /a.js (1 errors) ==== -+ class Foo { -+ /**@param {string} x */ -+ m = x => x.toLowerCase(); -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ } -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.types.diff deleted file mode 100644 index 7dfb483cf1..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.types.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.jsdocParamTagOnPropertyInitializer.types -+++ new.jsdocParamTagOnPropertyInitializer.types -@@= skipped -5, +5 lines =@@ - - /**@param {string} x */ - m = x => x.toLowerCase(); -->m : (x: string) => string -->x => x.toLowerCase() : (x: string) => string -->x : string -->x.toLowerCase() : string -->x.toLowerCase : () => string -->x : string -->toLowerCase : () => string -+>m : (x: any) => any -+>x => x.toLowerCase() : (x: any) => any -+>x : any -+>x.toLowerCase() : any -+>x.toLowerCase : any -+>x : any -+>toLowerCase : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff index 795b5d4d8d..02309368e5 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff @@ -1,22 +1,25 @@ --- old.jsdocParameterParsingInfiniteLoop.errors.txt +++ new.jsdocParameterParsingInfiniteLoop.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -example.js(3,11): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -example.js(3,20): error TS1110: Type expected. -example.js(3,21): error TS2304: Cannot find name 'foo'. -- -- ++example.js(3,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + -==== example.js (3 errors) ==== -- // @ts-check -- /** -- * @type {function(@foo)} ++==== example.js (1 errors) ==== + // @ts-check + /** + * @type {function(@foo)} - ~~~~~~~~~~~~~~ -!!! error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. - ~ -!!! error TS1110: Type expected. - ~~~ -!!! error TS2304: Cannot find name 'foo'. -- */ -- let x; -@@= skipped --1, +1 lines =@@ -+ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + */ + let x; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.types.diff index ce95d22415..1f501e7ba6 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.types.diff @@ -5,5 +5,5 @@ */ let x; ->x : (arg0: any, arg1: foo) => any -+>x : any ++>x : function diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.types.diff deleted file mode 100644 index 922db8114b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.types.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsdocPropertyTagInvalid.types -+++ new.jsdocPropertyTagInvalid.types -@@= skipped -7, +7 lines =@@ - - /** @param {MyType} p */ - export function f(p) { } -->f : (p: MyType) => void -->p : MyType -+>f : (p: any) => void -+>p : any - - === /b.js === - import { f } from "./a.js" -->f : (p: MyType) => void -+>f : (p: any) => void - - f({ x: 42 }) - >f({ x: 42 }) : void -->f : (p: MyType) => void -+>f : (p: any) => void - >{ x: 42 } : { x: number; } - >x : number - >42 : 42 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.types.diff index 24508c8c9b..bc912162d7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.types.diff @@ -14,7 +14,7 @@ /** @type {Puppeteer.Keyboard} */ var ppk; ->ppk : Puppeteer.Keyboard -+>ppk : any ++>ppk : Keyboard Puppeteer.connect; >Puppeteer.connect : (name: string) => void diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff index 4b568dd738..77654e6eef 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff @@ -1,20 +1,21 @@ --- old.jsdocResolveNameFailureInTypedef.errors.txt +++ new.jsdocResolveNameFailureInTypedef.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -/a.js(7,14): error TS2304: Cannot find name 'CantResolveThis'. -- -- --==== /a.js (1 errors) ==== -- /** -- * @param {Ty} x -- */ -- function f(x) {} -- -- /** -- * @typedef {CantResolveThis} Ty ++/a.js(2,12): error TS2304: Cannot find name 'Ty'. + + + ==== /a.js (1 errors) ==== + /** + * @param {Ty} x ++ ~~ ++!!! error TS2304: Cannot find name 'Ty'. + */ + function f(x) {} + + /** + * @typedef {CantResolveThis} Ty - ~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'CantResolveThis'. -- */ -- -@@= skipped --1, +1 lines =@@ -+ + */ + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.types.diff index e7579dfbed..ce2247023a 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.types.diff @@ -1,13 +1,11 @@ --- old.jsdocResolveNameFailureInTypedef.types +++ new.jsdocResolveNameFailureInTypedef.types -@@= skipped -4, +4 lines =@@ - * @param {Ty} x +@@= skipped -5, +5 lines =@@ */ function f(x) {} -->f : (x: Ty) => void + >f : (x: Ty) => void ->x : CantResolveThis -+>f : (x: any) => void -+>x : any ++>x : Ty /** * @typedef {CantResolveThis} Ty diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff index 63d4ee2cb2..29c8d2b01c 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff @@ -3,19 +3,12 @@ @@= skipped -0, +0 lines =@@ -/a.js(7,3): error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'number'. -/a.js(8,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -+/a.js(2,12): error TS7006: Parameter 'a' implicitly has an 'any' type. +/a.js(8,6): error TS2554: Expected 1 arguments, but got 2. +/a.js(9,6): error TS2554: Expected 1 arguments, but got 2. --==== /a.js (2 errors) ==== -+==== /a.js (3 errors) ==== - /** @param {...number} a */ - function f(a) { -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - a; // number | undefined - // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. + ==== /a.js (2 errors) ==== +@@= skipped -9, +9 lines =@@ arguments[0]; } f([1, 2]); // Error diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.types.diff index aa401b01bf..c467d5e766 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.types.diff @@ -6,12 +6,12 @@ function f(a) { ->f : (...args: number[]) => void ->a : number | undefined -+>f : (a: any) => void -+>a : any ++>f : (a: number[]) => void ++>a : number[] a; // number | undefined ->a : number | undefined -+>a : any ++>a : number[] // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. arguments[0]; @@ -20,7 +20,7 @@ f([1, 2]); // Error >f([1, 2]) : void ->f : (...args: number[]) => void -+>f : (a: any) => void ++>f : (a: number[]) => void >[1, 2] : number[] >1 : 1 >2 : 2 @@ -28,14 +28,14 @@ f(1, "2"); // Error >f(1, "2") : void ->f : (...args: number[]) => void -+>f : (a: any) => void ++>f : (a: number[]) => void >1 : 1 >"2" : "2" f(1, 2); >f(1, 2) : void ->f : (...args: number[]) => void -+>f : (a: any) => void ++>f : (a: number[]) => void >1 : 1 >2 : 2 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff deleted file mode 100644 index 79fa219903..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsdocRestParameter_es6.errors.txt -+++ new.jsdocRestParameter_es6.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+/a.js(2,12): error TS7019: Rest parameter 'a' implicitly has an 'any[]' type. -+ -+ -+==== /a.js (1 errors) ==== -+ /** @param {...number} a */ -+ function f(...a) { -+ ~~~~ -+!!! error TS7019: Rest parameter 'a' implicitly has an 'any[]' type. -+ a; // number[] -+ } -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.types.diff deleted file mode 100644 index 6ec6fe64b2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.types.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsdocRestParameter_es6.types -+++ new.jsdocRestParameter_es6.types -@@= skipped -2, +2 lines =@@ - === /a.js === - /** @param {...number} a */ - function f(...a) { -->f : (...a: number[]) => void -->a : number[] -+>f : (...a: any[]) => void -+>a : any[] - - a; // number[] -->a : number[] -+>a : any[] - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.errors.txt.diff deleted file mode 100644 index 0d143fd995..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.jsdocTypeCast.errors.txt -+++ new.jsdocTypeCast.errors.txt -@@= skipped -0, +-1 lines =@@ --jsdocTypeCast.js(6,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. --jsdocTypeCast.js(10,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. -- -- --==== jsdocTypeCast.js (2 errors) ==== -- /** -- * @param {string} x -- */ -- function f(x) { -- /** @type {'a' | 'b'} */ -- let a = (x); // Error -- ~ --!!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. -- a; -- -- /** @type {'a' | 'b'} */ -- let b = (((x))); // Error -- ~ --!!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. -- b; -- -- /** @type {'a' | 'b'} */ -- let c = /** @type {'a' | 'b'} */ (x); // Ok -- c; -- } -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff index 4a1517118b..443aeb47e0 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff @@ -1,55 +1,28 @@ --- old.jsdocTypeCast.types +++ new.jsdocTypeCast.types -@@= skipped -4, +4 lines =@@ - * @param {string} x - */ - function f(x) { -->f : (x: string) => void -->x : string -+>f : (x: any) => void -+>x : any - +@@= skipped -10, +10 lines =@@ /** @type {'a' | 'b'} */ let a = (x); // Error -->a : "a" | "b" + >a : "a" | "b" ->(x) : "a" | "b" -->x : string -+>a : any -+>(x) : any -+>x : any ++>(x) : string + >x : string a; -->a : "a" | "b" -+>a : any - +@@= skipped -9, +9 lines =@@ /** @type {'a' | 'b'} */ let b = (((x))); // Error -->b : "a" | "b" + >b : "a" | "b" ->(((x))) : "a" | "b" -->((x)) : string -->(x) : string -->x : string -+>b : any -+>(((x))) : any -+>((x)) : any -+>(x) : any -+>x : any - - b; -->b : "a" | "b" -+>b : any - - /** @type {'a' | 'b'} */ ++>(((x))) : string + >((x)) : string + >(x) : string + >x : string +@@= skipped -12, +12 lines =@@ let c = /** @type {'a' | 'b'} */ (x); // Ok -->c : "a" | "b" -->(x) : "a" | "b" -->x : string -+>c : any -+>(x) : any -+>x : any + >c : "a" | "b" + >(x) : "a" | "b" ++>x : "a" | "b" + >x : string c; -->c : "a" | "b" -+>c : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.types.diff index 99c91b3454..8f9e806f12 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.types.diff @@ -5,12 +5,7 @@ */ function thing(list) { ->thing : (list: Array) => any[] -->list : any[] -+>thing : (list: any) => any -+>list : any ++>thing : (list: any[]) => any[] + >list : any[] return list; -->list : any[] -+>list : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff index 0632a01195..718407d02f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff @@ -1,99 +1,134 @@ --- old.jsdocTypeNongenericInstantiationAttempt.errors.txt +++ new.jsdocTypeNongenericInstantiationAttempt.errors.txt -@@= skipped -0, +-1 lines =@@ --index.js(2,19): error TS2315: Type 'Boolean' is not generic. +@@= skipped -0, +0 lines =@@ + 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. --index4.js(2,19): error TS2315: Type 'Function' is not generic. --index5.js(2,19): error TS2315: Type 'String' is not generic. --index6.js(2,19): error TS2315: Type 'Number' is not generic. --index7.js(2,19): error TS2315: Type 'Object' is not generic. --index8.js(4,15): error TS2304: Cannot find name 'T'. -- -- ++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) ==== -- /** -- * @param {(m: Boolean) => string} somebody -- ~~~~~~~~~~ --!!! error TS2315: Type 'Boolean' is not generic. -- */ -- function sayHello(somebody) { -- return 'Hello ' + somebody; -- } -- ++==== 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) ==== -- /** -- * @param {(m: Void) => string} somebody ++==== index2.js (2 errors) ==== + /** + * @param {(m: Void) => string} somebody - ~~~~~~~ -!!! error TS2315: Type 'Void' is not generic. -- */ -- function sayHello2(somebody) { -- return 'Hello ' + somebody; -- } -- -- ++ ~~~~ ++!!! error TS2304: Cannot find name 'Void'. ++ ~ ++!!! error TS2304: Cannot find name 'T'. + */ + function sayHello2(somebody) { + return 'Hello ' + somebody; + } + + -==== index3.js (1 errors) ==== -- /** -- * @param {(m: Undefined) => string} somebody ++==== index3.js (2 errors) ==== + /** + * @param {(m: Undefined) => string} somebody - ~~~~~~~~~~~~ -!!! error TS2315: Type 'Undefined' is not generic. -- */ -- function sayHello3(somebody) { -- return 'Hello ' + somebody; -- } -- -- ++ ~~~~~~~~~ ++!!! error TS2304: Cannot find name 'Undefined'. ++ ~ ++!!! error TS2304: Cannot find name 'T'. + */ + function sayHello3(somebody) { + return 'Hello ' + somebody; + } + + -==== index4.js (1 errors) ==== -- /** -- * @param {(m: Function) => string} somebody -- ~~~~~~~~~~~ --!!! error TS2315: Type 'Function' is not generic. -- */ -- function sayHello4(somebody) { -- return 'Hello ' + somebody; -- } -- -- ++==== 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) ==== -- /** -- * @param {(m: String) => string} somebody -- ~~~~~~~~~ --!!! error TS2315: Type 'String' is not generic. -- */ -- function sayHello5(somebody) { -- return 'Hello ' + somebody; -- } -- -- ++==== 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) ==== -- /** -- * @param {(m: Number) => string} somebody -- ~~~~~~~~~ --!!! error TS2315: Type 'Number' is not generic. -- */ -- function sayHello6(somebody) { -- return 'Hello ' + somebody; -- } -- -- ++==== 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) ==== -- /** -- * @param {(m: Object) => string} somebody -- ~~~~~~~~~ --!!! error TS2315: Type 'Object' is not generic. -- */ -- function sayHello7(somebody) { -- return 'Hello ' + somebody; -- } -- ++==== 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) { + return 'Hello ' + somebody; + } + -==== index8.js (1 errors) ==== -- function fn() {} -- -- /** -- * @param {fn} somebody -- ~ --!!! error TS2304: Cannot find name 'T'. -- */ -- function sayHello8(somebody) { } -@@= skipped --1, +1 lines =@@ -+ ++==== index8.js (2 errors) ==== + function fn() {} + + /** + * @param {fn} somebody ++ ~~ ++!!! error TS2749: 'fn' refers to a value, but is being used as a type here. Did you mean 'typeof fn'? + ~ + !!! error TS2304: Cannot find name 'T'. + */ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.types.diff index e6def65a42..50544407b0 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.types.diff @@ -6,14 +6,14 @@ function sayHello(somebody) { ->sayHello : (somebody: (m: boolean) => string) => string ->somebody : (m: boolean) => string -+>sayHello : (somebody: any) => string -+>somebody : any ++>sayHello : (somebody: (m: any) => string) => string ++>somebody : (m: any) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : (m: boolean) => string -+>somebody : any ++>somebody : (m: any) => string } === index2.js === @@ -23,14 +23,14 @@ function sayHello2(somebody) { ->sayHello2 : (somebody: (m: void) => string) => string ->somebody : (m: void) => string -+>sayHello2 : (somebody: any) => string -+>somebody : any ++>sayHello2 : (somebody: (m: Void) => string) => string ++>somebody : (m: Void) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : (m: void) => string -+>somebody : any ++>somebody : (m: Void) => string } @@ -40,14 +40,14 @@ function sayHello3(somebody) { ->sayHello3 : (somebody: (m: undefined) => string) => string ->somebody : (m: undefined) => string -+>sayHello3 : (somebody: any) => string -+>somebody : any ++>sayHello3 : (somebody: (m: Undefined) => string) => string ++>somebody : (m: Undefined) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : (m: undefined) => string -+>somebody : any ++>somebody : (m: Undefined) => string } @@ -57,14 +57,14 @@ function sayHello4(somebody) { ->sayHello4 : (somebody: (m: Function) => string) => string ->somebody : (m: Function) => string -+>sayHello4 : (somebody: any) => string -+>somebody : any ++>sayHello4 : (somebody: (m: any) => string) => string ++>somebody : (m: any) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : (m: Function) => string -+>somebody : any ++>somebody : (m: any) => string } @@ -74,14 +74,14 @@ function sayHello5(somebody) { ->sayHello5 : (somebody: (m: string) => string) => string ->somebody : (m: string) => string -+>sayHello5 : (somebody: any) => string -+>somebody : any ++>sayHello5 : (somebody: (m: any) => string) => string ++>somebody : (m: any) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : (m: string) => string -+>somebody : any ++>somebody : (m: any) => string } @@ -91,40 +91,23 @@ function sayHello6(somebody) { ->sayHello6 : (somebody: (m: number) => string) => string ->somebody : (m: number) => string -+>sayHello6 : (somebody: any) => string -+>somebody : any ++>sayHello6 : (somebody: (m: any) => string) => string ++>somebody : (m: any) => string return 'Hello ' + somebody; >'Hello ' + somebody : string >'Hello ' : "Hello " ->somebody : (m: number) => string -+>somebody : any ++>somebody : (m: any) => string } -@@= skipped -15, +15 lines =@@ - * @param {(m: Object) => string} somebody - */ - function sayHello7(somebody) { -->sayHello7 : (somebody: (m: any) => string) => string -->somebody : (m: any) => string -+>sayHello7 : (somebody: any) => string -+>somebody : any - - return 'Hello ' + somebody; - >'Hello ' + somebody : string - >'Hello ' : "Hello " -->somebody : (m: any) => string -+>somebody : any - } - - === index8.js === -@@= skipped -17, +17 lines =@@ +@@= skipped -32, +32 lines =@@ * @param {fn} somebody */ function sayHello8(somebody) { } ->sayHello8 : (somebody: () => void) => void ->somebody : () => void -+>sayHello8 : (somebody: any) => void -+>somebody : any ++>sayHello8 : (somebody: fn) => void ++>somebody : fn diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.types.diff deleted file mode 100644 index 4f663acef0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsdocTypedefBeforeParenthesizedExpression.types -+++ new.jsdocTypedefBeforeParenthesizedExpression.types -@@= skipped -26, +26 lines =@@ - * @param b {AlsoNotADuplicate} - */ - function makeSureTypedefsAreStillRecognized(a, b) {} -->makeSureTypedefsAreStillRecognized : (a: number, b: number) => void -->a : number -->b : number -+>makeSureTypedefsAreStillRecognized : (a: any, b: any) => void -+>a : any -+>b : any - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.types.diff deleted file mode 100644 index f6c9a86a0f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsdocTypedefMissingType.types -+++ new.jsdocTypedefMissingType.types -@@= skipped -15, +15 lines =@@ - - /** @type Person */ - const person = { name: "" }; -->person : Person -+>person : { name: string; } - >{ name: "" } : { name: string; } - >name : string - >"" : "" diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.types.diff deleted file mode 100644 index 7cf27629a6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsdocTypedef_propertyWithNoType.types -+++ new.jsdocTypedef_propertyWithNoType.types -@@= skipped -7, +7 lines =@@ - - /** @type {Foo} */ - const x = { foo: 0 }; -->x : Foo -+>x : { foo: number; } - >{ foo: 0 } : { foo: number; } - >foo : number - >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/misspelledJsDocTypedefTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/misspelledJsDocTypedefTags.errors.txt.diff index ce597f7f1a..5a963d9941 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/misspelledJsDocTypedefTags.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/misspelledJsDocTypedefTags.errors.txt.diff @@ -4,16 +4,19 @@ - @@= skipped --1, +1 lines =@@ +a.js(2,11): error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. ++a.js(4,48): error TS2304: Cannot find name 'B'. +a.js(5,11): error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. + + -+==== a.js (2 errors) ==== ++==== a.js (3 errors) ==== + /** @typedef {{ endTime: number, screenshots: number}} A.*/ + Animation.AnimationModel.ScreenshotCapture.Request; + ~~~~~~~~~~~~~~ +!!! error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. + + /** @typedef {{ endTime: number, screenshots: !B.}} */ ++ ~ ++!!! error TS2304: Cannot find name 'B'. + Animation.AnimationModel.ScreenshotCapture.Request; + ~~~~~~~~~~~~~~ +!!! error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt.diff deleted file mode 100644 index 80bc30a895..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.parenthesizedJSDocCastAtReturnStatement.errors.txt -+++ new.parenthesizedJSDocCastAtReturnStatement.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+index.js(8,26): error TS7006: Parameter 'key' implicitly has an 'any' type. -+ -+ -+==== index.js (1 errors) ==== -+ /** @type {Map>} */ -+ const cache = new Map() -+ -+ /** -+ * @param {string} key -+ * @returns {() => string} -+ */ -+ const getStringGetter = (key) => { -+ ~~~ -+!!! error TS7006: Parameter 'key' implicitly has an 'any' type. -+ return () => { -+ return /** @type {string} */ (cache.get(key)) -+ } -+ } -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.types.diff index 3cbf43a46a..eb228433cf 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.types.diff @@ -1,42 +1,10 @@ --- old.parenthesizedJSDocCastAtReturnStatement.types +++ new.parenthesizedJSDocCastAtReturnStatement.types -@@= skipped -2, +2 lines =@@ - === index.js === - /** @type {Map>} */ - const cache = new Map() -->cache : Map> -+>cache : Map - >new Map() : Map - >Map : MapConstructor - -@@= skipped -9, +9 lines =@@ - * @returns {() => string} - */ - const getStringGetter = (key) => { -->getStringGetter : (key: string) => () => string -->(key) => { return () => { return /** @type {string} */ (cache.get(key)) }} : (key: string) => () => string -->key : string -+>getStringGetter : (key: any) => () => any -+>(key) => { return () => { return /** @type {string} */ (cache.get(key)) }} : (key: any) => () => any -+>key : any - - return () => { -->() => { return /** @type {string} */ (cache.get(key)) } : () => string -+>() => { return /** @type {string} */ (cache.get(key)) } : () => any +@@= skipped -20, +20 lines =@@ return /** @type {string} */ (cache.get(key)) -->(cache.get(key)) : string -->cache.get(key) : string | Set | undefined -->cache.get : (key: string) => string | Set | undefined -->cache : Map> -->get : (key: string) => string | Set | undefined -->key : string -+>(cache.get(key)) : any -+>cache.get(key) : any -+>cache.get : (key: any) => any -+>cache : Map -+>get : (key: any) => any -+>key : any - } - } - + >(cache.get(key)) : string ++>cache.get(key) : string + >cache.get(key) : string | Set | undefined + >cache.get : (key: string) => string | Set | undefined + >cache : Map> diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt.diff deleted file mode 100644 index b3d5cf300b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.parenthesizedJSDocCastDoesNotNarrow.errors.txt -+++ new.parenthesizedJSDocCastDoesNotNarrow.errors.txt -@@= skipped -0, +-1 lines =@@ --index.js(12,8): error TS2678: Type '"invalid"' is not comparable to type '"bar" | "foo"'. -- -- --==== index.js (1 errors) ==== -- let value = ""; -- -- switch (/** @type {"foo" | "bar"} */ (value)) { -- case "bar": -- value; -- break; -- -- case "foo": -- value; -- break; -- -- case "invalid": -- ~~~~~~~~~ --!!! error TS2678: Type '"invalid"' is not comparable to type '"bar" | "foo"'. -- value; -- break; -- } -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.types.diff index 1a53e3ac5c..2d21b04845 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.types.diff @@ -1,37 +1,10 @@ --- old.parenthesizedJSDocCastDoesNotNarrow.types +++ new.parenthesizedJSDocCastDoesNotNarrow.types -@@= skipped -5, +5 lines =@@ - >"" : "" +@@= skipped -6, +6 lines =@@ switch (/** @type {"foo" | "bar"} */ (value)) { -->(value) : "bar" | "foo" -+>(value) : string + >(value) : "bar" | "foo" ++>value : "bar" | "foo" >value : string case "bar": - >"bar" : "bar" - - value; -->value : string -+>value : "bar" - - break; - -@@= skipped -15, +15 lines =@@ - >"foo" : "foo" - - value; -->value : string -+>value : "foo" - - break; - -@@= skipped -8, +8 lines =@@ - >"invalid" : "invalid" - - value; -->value : string -+>value : "invalid" - - break; - } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.types.diff index aefdcc4231..1b6fd0596b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.types.diff @@ -19,20 +19,14 @@ /** @type {{ b: number }} */ const json1 = require("./json.json"); // No error (bad) -->json1 : { b: number; } + >json1 : { b: number; } ->require("./json.json") : { a: number; } -+>json1 : any +>require("./json.json") : any >require : any >"./json.json" : "./json.json" - json1.b; // No error (OK since that's the type annotation) -->json1.b : number -->json1 : { b: number; } -->b : number -+>json1.b : any -+>json1 : any -+>b : any +@@= skipped -23, +23 lines =@@ + >b : number const js0 = require("./js.js"); ->js0 : { a: number; } @@ -50,24 +44,13 @@ /** @type {{ b: number }} */ const js1 = require("./js.js"); // Error (good) -->js1 : { b: number; } + >js1 : { b: number; } ->require("./js.js") : { a: number; } -+>js1 : any +>require("./js.js") : any >require : any >"./js.js" : "./js.js" - js1.b; -->js1.b : number -->js1 : { b: number; } -->b : number -+>js1.b : any -+>js1 : any -+>b : any - - === /json.json === - { "a": 0 } -@@= skipped -51, +51 lines =@@ +@@= skipped -28, +28 lines =@@ >"a" : number >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff index 0732681a52..df1ecaaac6 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff @@ -1,37 +1,37 @@ --- old.strictOptionalProperties3.errors.txt +++ new.strictOptionalProperties3.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -a.js(7,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'A' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. -- Types of property 'value' are incompatible. -- Type 'undefined' is not assignable to type 'number'. ++a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. + Types of property 'value' are incompatible. + Type 'undefined' is not assignable to type 'number'. -a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. - Types of property 'value' are incompatible. - Type 'undefined' is not assignable to type 'number'. -- -- + + -==== a.js (2 errors) ==== -- /** -- * @typedef {object} A -- * @property {number} [value] -- */ -- -- /** @type {A} */ -- const a = { value: undefined }; // error ++==== a.js (1 errors) ==== + /** + * @typedef {object} A + * @property {number} [value] +@@= skipped -13, +10 lines =@@ + + /** @type {A} */ + const a = { value: undefined }; // error - ~ -!!! error TS2375: Type '{ value: undefined; }' is not assignable to type 'A' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. -!!! error TS2375: Types of property 'value' are incompatible. -!!! error TS2375: Type 'undefined' is not assignable to type 'number'. -- -- /** -- * @typedef {{ value?: number }} B -- */ -- -- /** @type {B} */ -- const b = { value: undefined }; // error -- ~ + + /** + * @typedef {{ value?: number }} B +@@= skipped -12, +8 lines =@@ + /** @type {B} */ + const b = { value: undefined }; // error + ~ -!!! error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. --!!! error TS2375: Types of property 'value' are incompatible. --!!! error TS2375: Type 'undefined' is not assignable to type 'number'. -- -@@= skipped --1, +1 lines =@@ -+ ++!!! error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. + !!! error TS2375: Types of property 'value' are incompatible. + !!! error TS2375: Type 'undefined' is not assignable to type 'number'. + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.types.diff index 5194029ac3..522a97b843 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.types.diff @@ -1,20 +1,11 @@ --- old.strictOptionalProperties3.types +++ new.strictOptionalProperties3.types -@@= skipped -7, +7 lines =@@ - - /** @type {A} */ - const a = { value: undefined }; // error -->a : A -+>a : { value: undefined; } - >{ value: undefined } : { value: undefined; } - >value : undefined - >undefined : undefined -@@= skipped -11, +11 lines =@@ +@@= skipped -18, +18 lines =@@ /** @type {B} */ const b = { value: undefined }; // error ->b : B -+>b : { value: undefined; } ++>b : { value?: number; } >{ value: undefined } : { value: undefined; } >value : undefined >undefined : undefined diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.errors.txt.diff deleted file mode 100644 index e1a04c729e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.strictOptionalProperties4.errors.txt -+++ new.strictOptionalProperties4.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+a.js(7,3): error TS2339: Property 'foo' does not exist on type '{}'. -+a.js(10,3): error TS2339: Property 'foo' does not exist on type '{}'. -+ -+ -+==== a.js (2 errors) ==== -+ /** -+ * @typedef Foo -+ * @property {number} [foo] -+ */ -+ -+ const x = /** @type {Foo} */ ({}); -+ x.foo; // number | undefined -+ ~~~ -+!!! error TS2339: Property 'foo' does not exist on type '{}'. -+ -+ const y = /** @type {Required} */ ({}); -+ y.foo; // number -+ ~~~ -+!!! error TS2339: Property 'foo' does not exist on type '{}'. -+ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff index 5104f3894a..54058c5524 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff @@ -1,35 +1,29 @@ --- old.strictOptionalProperties4.types +++ new.strictOptionalProperties4.types -@@= skipped -6, +6 lines =@@ - */ - +@@= skipped -8, +8 lines =@@ const x = /** @type {Foo} */ ({}); -->x : Foo -->({}) : Foo -+>x : {} -+>({}) : {} + >x : Foo + >({}) : Foo ++>{} : Foo >{} : {} x.foo; // number | undefined ->x.foo : number | undefined -->x : Foo -->foo : number | undefined +>x.foo : any -+>x : {} + >x : Foo +->foo : number | undefined +>foo : any const y = /** @type {Required} */ ({}); -->y : Required -->({}) : Required -+>y : {} -+>({}) : {} + >y : Required + >({}) : Required ++>{} : Required >{} : {} y.foo; // number ->y.foo : number -->y : Required -->foo : number +>y.foo : any -+>y : {} + >y : Required +->foo : number +>foo : any diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.errors.txt.diff deleted file mode 100644 index 13748f7453..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.subclassThisTypeAssignable01.errors.txt -+++ new.subclassThisTypeAssignable01.errors.txt -@@= skipped -0, +0 lines =@@ --file1.js(2,7): error TS2322: Type 'C' is not assignable to type 'ClassComponent'. -- Index signature for type 'number' is missing in type 'C'. - tile1.ts(2,30): error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle'. - tile1.ts(6,81): error TS2744: Type parameter defaults can only reference previously declared type parameters. - tile1.ts(11,40): error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle'. -@@= skipped -57, +55 lines =@@ - ~~~~~ - !!! error TS2322: Type 'C' is not assignable to type 'ClassComponent'. - !!! error TS2322: Index signature for type 'number' is missing in type 'C'. --==== file1.js (1 errors) ==== -+==== file1.js (0 errors) ==== - /** @type {ClassComponent} */ - const test9 = new C(); -- ~~~~~ --!!! error TS2322: Type 'C' is not assignable to type 'ClassComponent'. --!!! error TS2322: Index signature for type 'number' is missing in type 'C'. - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.types.diff index 72c5056c2a..06a2cad872 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.types.diff @@ -9,12 +9,3 @@ >v : Vnode> >0 : 0 } -@@= skipped -13, +13 lines =@@ - === file1.js === - /** @type {ClassComponent} */ - const test9 = new C(); -->test9 : ClassComponent -+>test9 : C - >new C() : C - >C : typeof C - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.types.diff deleted file mode 100644 index bc922e84f6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.subclassThisTypeAssignable02.types -+++ new.subclassThisTypeAssignable02.types -@@= skipped -56, +56 lines =@@ - === file1.js === - /** @type {ClassComponent} */ - const test9 = new C(); -->test9 : ClassComponent -+>test9 : C - >new C() : C - >C : typeof C - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.types.diff deleted file mode 100644 index 8800f1150b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.types.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.topLevelBlockExpando.types -+++ new.topLevelBlockExpando.types -@@= skipped -55, +55 lines =@@ - * @param {Human} param used as a validation tool - */ - function doHumanThings(param) {} -->doHumanThings : (param: Human) => void -->param : Human -+>doHumanThings : (param: any) => void -+>param : any - - const dice1 = () => Math.floor(Math.random() * 6); - >dice1 : { (): number; last: string; } -@@= skipped -59, +59 lines =@@ - - doHumanThings(dice2) - >doHumanThings(dice2) : void -->doHumanThings : (param: Human) => void -+>doHumanThings : (param: any) => void - >dice2 : { (): number; first: string; last: string; } - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.types.diff deleted file mode 100644 index 76f5c6aa92..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.types.diff +++ /dev/null @@ -1,51 +0,0 @@ ---- old.unicodeEscapesInJSDoc.types -+++ new.unicodeEscapesInJSDoc.types -@@= skipped -5, +5 lines =@@ - * @param {number} a\u0061 - */ - function foo(a, aa) { -->foo : (a: number, aa: number) => void -->a : number -->aa : number -+>foo : (a: any, aa: any) => void -+>a : any -+>aa : any - - console.log(a + aa); - >console.log(a + aa) : void - >console.log : (...data: any[]) => void - >console : Console - >log : (...data: any[]) => void -->a + aa : number -->a : number -->aa : number -+>a + aa : any -+>a : any -+>aa : any - } - - /** -@@= skipped -19, +19 lines =@@ - * @param {number} a\u{0061} - */ - function bar(a, aa) { -->bar : (a: number, aa: number) => void -->a : number -->aa : number -+>bar : (a: any, aa: any) => void -+>a : any -+>aa : any - - console.log(a + aa); - >console.log(a + aa) : void - >console.log : (...data: any[]) => void - >console : Console - >log : (...data: any[]) => void -->a + aa : number -->a : number -->aa : number -+>a + aa : any -+>a : any -+>aa : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt.diff index 84f28addd1..41957c2ca1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt.diff @@ -1,25 +1,28 @@ --- old.unmetTypeConstraintInJSDocImportCall.errors.txt +++ new.unmetTypeConstraintInJSDocImportCall.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -file2.js(3,36): error TS2344: Type 'T' does not satisfy the constraint 'string'. -- -- ++file1.js(3,21): error TS2304: Cannot find name 'T'. + + -==== file1.js (0 errors) ==== -- /** -- * @template {string} T -- * @typedef {{ foo: T }} Foo -- */ -- -- export default {}; -- ++==== file1.js (1 errors) ==== + /** + * @template {string} T + * @typedef {{ foo: T }} Foo ++ ~ ++!!! error TS2304: Cannot find name 'T'. + */ + + export default {}; + -==== file2.js (1 errors) ==== -- /** -- * @template T -- * @typedef {import('./file1').Foo} Bar ++==== file2.js (0 errors) ==== + /** + * @template T + * @typedef {import('./file1').Foo} Bar - ~ -!!! error TS2344: Type 'T' does not satisfy the constraint 'string'. -!!! related TS2208 file2.js:2:14: This type parameter might need an `extends string` constraint. -- */ -- -@@= skipped --1, +1 lines =@@ -+ + */ + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.errors.txt.diff index 27ab577471..0c8b74d1d4 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.errors.txt.diff @@ -1,14 +1,15 @@ --- old.unusedTypeParameters_templateTag.errors.txt +++ new.unusedTypeParameters_templateTag.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -/a.js(1,5): error TS6133: 'T' is declared but its value is never read. -- -- --==== /a.js (1 errors) ==== -- /** @template T */ ++/a.js(1,15): error TS6196: 'T' is declared but never used. + + + ==== /a.js (1 errors) ==== + /** @template T */ - ~~~~~~~~~~~~ -!!! error TS6133: 'T' is declared but its value is never read. -- function f() {} -- -@@= skipped --1, +1 lines =@@ -+ ++ ~ ++!!! error TS6196: 'T' is declared but never used. + function f() {} + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.types.diff deleted file mode 100644 index 2206bfccf9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.unusedTypeParameters_templateTag.types -+++ new.unusedTypeParameters_templateTag.types -@@= skipped -2, +2 lines =@@ - === /a.js === - /** @template T */ - function f() {} -->f : () => void -+>f : () => void - diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.errors.txt.diff index 7b94e6883d..fd58898148 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.errors.txt.diff @@ -5,37 +5,46 @@ -/a.js(13,4): error TS6205: All type parameters are unused. -/a.js(20,16): error TS6133: 'V' is declared but its value is never read. -/a.js(20,18): error TS6133: 'X' is declared but its value is never read. -+/a.js(8,14): error TS2339: Property 'p' does not exist on type 'C1'. -+/a.js(25,14): error TS2339: Property 'p' does not exist on type 'C3'. ++/a.js(2,3): error TS6205: All type parameters are unused. ++/a.js(8,14): error TS2339: Property 'p' does not exist on type 'C1'. ++/a.js(13,3): error TS6205: All type parameters are unused. ++/a.js(20,3): error TS6205: All type parameters are unused. ++/a.js(25,14): error TS2339: Property 'p' does not exist on type 'C3'. -==== /a.js (4 errors) ==== -+==== /a.js (2 errors) ==== ++==== /a.js (5 errors) ==== /** * @template T ++ ~~~~~~~~~~~~ * @template V - ~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~ */ - ~ -!!! error TS6133: 'V' is declared but its value is never read. ++ ~~ ++!!! error TS6205: All type parameters are unused. class C1 { constructor() { /** @type {T} */ this.p; + ~ -+!!! error TS2339: Property 'p' does not exist on type 'C1'. ++!!! error TS2339: Property 'p' does not exist on type 'C1'. } } /** * @template T,V - ~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~ */ - ~ --!!! error TS6205: All type parameters are unused. ++ ~~ + !!! error TS6205: All type parameters are unused. class C2 { constructor() { } - } +@@= skipped -30, +34 lines =@@ /** * @template T,V,X @@ -43,12 +52,15 @@ -!!! error TS6133: 'V' is declared but its value is never read. - ~ -!!! error TS6133: 'X' is declared but its value is never read. ++ ~~~~~~~~~~~~~~~~ */ ++ ~~ ++!!! error TS6205: All type parameters are unused. class C3 { constructor() { /** @type {T} */ this.p; + ~ -+!!! error TS2339: Property 'p' does not exist on type 'C3'. ++!!! error TS2339: Property 'p' does not exist on type 'C3'. } } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.types.diff index a847a4dbe7..ced5bb2cc0 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.types.diff @@ -1,12 +1,6 @@ --- old.unusedTypeParameters_templateTag2.types +++ new.unusedTypeParameters_templateTag2.types -@@= skipped -5, +5 lines =@@ - * @template V - */ - class C1 { -->C1 : C1 -+>C1 : C1 - +@@= skipped -10, +10 lines =@@ constructor() { /** @type {T} */ this.p; @@ -18,22 +12,7 @@ } } -@@= skipped -15, +15 lines =@@ - * @template T,V - */ - class C2 { -->C2 : C2 -+>C2 : C2 - - constructor() { } - } -@@= skipped -9, +9 lines =@@ - * @template T,V,X - */ - class C3 { -->C3 : C3 -+>C3 : C3 - +@@= skipped -24, +24 lines =@@ constructor() { /** @type {T} */ this.p; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.types.diff index 32ff0c5404..f997643453 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.types.diff @@ -1,17 +1,6 @@ --- old.annotatedThisPropertyInitializerDoesntNarrow.types +++ new.annotatedThisPropertyInitializerDoesntNarrow.types -@@= skipped -3, +3 lines =@@ - // from webpack/lib/Compilation.js and filed at #26427 - /** @param {{ [s: string]: number }} map */ - function mappy(map) {} -->mappy : (map: { [s: string]: number; }) => void -->map : { [s: string]: number; } -+>mappy : (map: any) => void -+>map : any - - export class C { - >C : C -@@= skipped -10, +10 lines =@@ +@@= skipped -13, +13 lines =@@ /** @type {{ [assetName: string]: number}} */ this.assets = {}; >this.assets = {} : {} @@ -23,13 +12,11 @@ >{} : {} } m() { -@@= skipped -10, +10 lines =@@ - +@@= skipped -11, +11 lines =@@ mappy(this.assets) >mappy(this.assets) : void -->mappy : (map: { [s: string]: number; }) => void + >mappy : (map: { [s: string]: number; }) => void ->this.assets : { [assetName: string]: number; } -+>mappy : (map: any) => void +>this.assets : any >this : this ->assets : { [assetName: string]: number; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff new file mode 100644 index 0000000000..0f1e2740c5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.assertionTypePredicates2.errors.txt ++++ new.assertionTypePredicates2.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. ++assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. ++ ++ ++==== assertionTypePredicates2.js (2 errors) ==== ++ /** ++ * @typedef {{ x: number }} A ++ */ ++ ++ /** ++ * @typedef { A & { y: number } } B ++ */ ++ ++ /** ++ * @param {A} a ++ * @returns { asserts a is B } ++ */ ++ const foo = (a) => { ++ if (/** @type { B } */ (a).y !== 0) throw TypeError(); ++ return undefined; ++ }; ++ ++ export const main = () => { ++ /** @type { A } */ ++ const a = { x: 1 }; ++ foo(a); ++ ~~~ ++!!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. ++!!! related TS2782 assertionTypePredicates2.js:13:7: 'foo' needs an explicit type annotation. ++ ~~~ ++!!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. ++ }; ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff index 2f0efd3ae9..9fd7a1a7ab 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff @@ -7,24 +7,22 @@ ->foo : (a: A) => asserts a is B ->(a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); return undefined;} : (a: A) => asserts a is B ->a : A -+>foo : (a: any) => any -+>(a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); return undefined;} : (a: any) => any -+>a : any ++>foo : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } ++>(a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); return undefined;} : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } ++>a : { x: number; } if (/** @type { B } */ (a).y !== 0) throw TypeError(); >(a).y !== 0 : boolean -->(a).y : number + >(a).y : number ->(a) : B ->a : A -->y : number -+>(a).y : any -+>(a) : any -+>a : any -+>y : any ++>(a) : { x: number; } & { y: number; } ++>a : { x: number; } & { y: number; } ++>a : { x: number; } + >y : number >0 : 0 >TypeError() : TypeError - >TypeError : TypeErrorConstructor -@@= skipped -25, +25 lines =@@ +@@= skipped -25, +26 lines =@@ /** @type { A } */ const a = { x: 1 }; @@ -35,11 +33,10 @@ >1 : 1 foo(a); -->foo(a) : void + >foo(a) : void ->foo : (a: A) => asserts a is B ->a : A -+>foo(a) : any -+>foo : (a: any) => any ++>foo : (a: { x: number; }) => asserts a is { x: number; } & { y: number; } +>a : { x: number; } }; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.errors.txt.diff deleted file mode 100644 index 991af43a91..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.errors.txt.diff +++ /dev/null @@ -1,74 +0,0 @@ ---- old.assertionsAndNonReturningFunctions.errors.txt -+++ new.assertionsAndNonReturningFunctions.errors.txt -@@= skipped -0, +-1 lines =@@ --assertionsAndNonReturningFunctions.js(46,9): error TS7027: Unreachable code detected. --assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code detected. -- -- --==== assertionsAndNonReturningFunctions.js (2 errors) ==== -- /** @typedef {(check: boolean) => asserts check} AssertFunc */ -- -- /** @type {AssertFunc} */ -- const assert = check => { -- if (!check) throw new Error(); -- } -- -- /** @type {(x: unknown) => asserts x is string } */ -- function assertIsString(x) { -- if (!(typeof x === "string")) throw new Error(); -- } -- -- /** -- * @param {boolean} check -- * @returns {asserts check} -- */ -- function assert2(check) { -- if (!check) throw new Error(); -- } -- -- /** -- * @returns {never} -- */ -- function fail() { -- throw new Error(); -- } -- -- /** -- * @param {*} x -- */ -- function f1(x) { -- if (!!true) { -- assert(typeof x === "string"); -- x.length; -- } -- if (!!true) { -- assert2(typeof x === "string"); -- x.length; -- } -- if (!!true) { -- assertIsString(x); -- x.length; -- } -- if (!!true) { -- fail(); -- x; // Unreachable -- ~~ --!!! error TS7027: Unreachable code detected. -- } -- } -- -- /** -- * @param {boolean} b -- */ -- function f2(b) { -- switch (b) { -- case true: return 1; -- case false: return 0; -- } -- b; // Unreachable -- ~~ --!!! error TS7027: Unreachable code detected. -- } -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.types.diff index 063aa04d5c..81d3e64add 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.types.diff @@ -6,18 +6,12 @@ const assert = check => { ->assert : AssertFunc ->check => { if (!check) throw new Error();} : (check: boolean) => asserts check -->check : boolean -+>assert : (check: any) => void -+>check => { if (!check) throw new Error();} : (check: any) => void -+>check : any ++>assert : (check: boolean) => asserts check ++>check => { if (!check) throw new Error();} : (check: boolean) => void + >check : boolean if (!check) throw new Error(); - >!check : boolean -->check : boolean -+>check : any - >new Error() : Error - >Error : ErrorConstructor - } +@@= skipped -13, +13 lines =@@ /** @type {(x: unknown) => asserts x is string } */ function assertIsString(x) { @@ -36,74 +30,16 @@ >"string" : "string" >new Error() : Error >Error : ErrorConstructor -@@= skipped -32, +32 lines =@@ - * @returns {asserts check} - */ - function assert2(check) { -->assert2 : (check: boolean) => asserts check -->check : boolean -+>assert2 : (check: any) => void -+>check : any - - if (!check) throw new Error(); - >!check : boolean -->check : boolean -+>check : any - >new Error() : Error - >Error : ErrorConstructor - } -@@= skipped -14, +14 lines =@@ - * @returns {never} - */ - function fail() { -->fail : () => never -+>fail : () => void - - throw new Error(); - >new Error() : Error -@@= skipped -21, +21 lines =@@ +@@= skipped -54, +54 lines =@@ assert(typeof x === "string"); >assert(typeof x === "string") : void ->assert : AssertFunc -+>assert : (check: any) => void ++>assert : (check: boolean) => asserts check >typeof x === "string" : boolean >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" >x : any - >"string" : "string" - - x.length; -->x.length : number -->x : string -->length : number -+>x.length : any -+>x : any -+>length : any - } - if (!!true) { - >!!true : boolean -@@= skipped -18, +18 lines =@@ - - assert2(typeof x === "string"); - >assert2(typeof x === "string") : void -->assert2 : (check: boolean) => asserts check -+>assert2 : (check: any) => void - >typeof x === "string" : boolean - >typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" - >x : any - >"string" : "string" - - x.length; -->x.length : number -->x : string -->length : number -+>x.length : any -+>x : any -+>length : any - } - if (!!true) { - >!!true : boolean -@@= skipped -18, +18 lines =@@ +@@= skipped -36, +36 lines =@@ assertIsString(x); >assertIsString(x) : void @@ -121,37 +57,3 @@ } if (!!true) { >!!true : boolean -@@= skipped -14, +14 lines =@@ - >true : true - - fail(); -->fail() : never -->fail : () => never -+>fail() : void -+>fail : () => void - - x; // Unreachable - >x : any -@@= skipped -12, +12 lines =@@ - * @param {boolean} b - */ - function f2(b) { -->f2 : (b: boolean) => 0 | 1 -->b : boolean -+>f2 : (b: any) => 0 | 1 -+>b : any - - switch (b) { -->b : boolean -+>b : any - - case true: return 1; - >true : true -@@= skipped -15, +15 lines =@@ - >0 : 0 - } - b; // Unreachable -->b : never -+>b : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.errors.txt.diff index ca701d2045..0f2415be05 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.errors.txt.diff @@ -1,6 +1,6 @@ --- old.asyncArrowFunction_allowJs.errors.txt +++ new.asyncArrowFunction_allowJs.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -file.js(3,17): error TS2322: Type 'number' is not assignable to type 'string'. -file.js(6,24): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? -file.js(7,23): error TS2322: Type 'number' is not assignable to type 'string'. @@ -9,50 +9,69 @@ -file.js(16,24): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? -file.js(25,3): error TS2345: Argument of type '() => Promise' is not assignable to parameter of type '() => string'. - Type 'Promise' is not assignable to type 'string'. -- -- ++file.js(2,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++file.js(6,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++file.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++file.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + -==== file.js (7 errors) ==== -- // Error (good) -- /** @type {function(): string} */ -- const a = () => 0 ++==== file.js (5 errors) ==== + // Error (good) + /** @type {function(): string} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const a = () => 0 - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- -- // Error (good) -- /** @type {function(): string} */ + + // Error (good) + /** @type {function(): string} */ - ~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? -- const b = async () => 0 ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const b = async () => 0 - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- -- // No error (bad) -- /** @type {function(): string} */ + + // No error (bad) + /** @type {function(): string} */ - ~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? -- const c = async () => { -- return 0 ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const c = async () => { + return 0 - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- } -- -- // Error (good) -- /** @type {function(): string} */ + } + + // Error (good) + /** @type {function(): string} */ - ~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? -- const d = async () => { -- return "" -- } -- -- /** @type {function(function(): string): void} */ -- const f = (p) => {} -- -- // Error (good) -- f(async () => { ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const d = async () => { + return "" + } + + /** @type {function(function(): string): void} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const f = (p) => {} + + // Error (good) + f(async () => { - ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '() => Promise' is not assignable to parameter of type '() => string'. -!!! error TS2345: Type 'Promise' is not assignable to type 'string'. -- return 0 -- }) -@@= skipped --1, +1 lines =@@ -+ + return 0 + }) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.types.diff index 75f2f0c4c4..76d06c7fd0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.types.diff @@ -6,7 +6,7 @@ const a = () => 0 ->a : () => string ->() => 0 : () => string -+>a : () => number ++>a : function +>() => 0 : () => number >0 : 0 @@ -15,7 +15,7 @@ const b = async () => 0 ->b : () => string ->async () => 0 : () => string -+>b : () => Promise ++>b : function +>async () => 0 : () => Promise >0 : 0 @@ -24,7 +24,7 @@ const c = async () => { ->c : () => string ->async () => { return 0} : () => string -+>c : () => Promise ++>c : function +>async () => { return 0} : () => Promise return 0 @@ -35,7 +35,7 @@ const d = async () => { ->d : () => string ->async () => { return ""} : () => string -+>d : () => Promise ++>d : function +>async () => { return ""} : () => Promise return "" @@ -47,15 +47,16 @@ ->f : (arg0: () => string) => void ->(p) => {} : (p: () => string) => void ->p : () => string -+>f : (p: any) => void ++>f : function +>(p) => {} : (p: any) => void +>p : any // Error (good) f(async () => { - >f(async () => { return 0}) : void +->f(async () => { return 0}) : void ->f : (arg0: () => string) => void -+>f : (p: any) => void ++>f(async () => { return 0}) : any ++>f : function >async () => { return 0} : () => Promise return 0 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff index 7b01d94509..febfcff46c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff @@ -1,6 +1,6 @@ --- old.asyncFunctionDeclaration16_es5.errors.txt +++ new.asyncFunctionDeclaration16_es5.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -/a.js(21,14): error TS1055: Type 'string' is not a valid async function return type in ES5 because it does not refer to a Promise-compatible constructor value. -/a.js(27,12): error TS1065: The return type of an async function or method must be the global Promise type. -/a.js(45,12): error TS1065: The return type of an async function or method must be the global Promise type. @@ -8,71 +8,57 @@ - Construct signature return types 'Thenable' and 'PromiseLike' are incompatible. - The types returned by 'then(...)' are incompatible between these types. - Type 'void' is not assignable to type 'PromiseLike'. -- -- --==== /types.d.ts (0 errors) ==== -- declare class Thenable { then(): void; } -- ++/a.js(21,14): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? ++/a.js(27,12): error TS2304: Cannot find name 'T1'. ++/a.js(40,12): error TS2304: Cannot find name 'T2'. ++/a.js(45,12): error TS2304: Cannot find name 'T3'. + + + ==== /types.d.ts (0 errors) ==== + declare class Thenable { then(): void; } + -==== /a.js (3 errors) ==== -- /** -- * @callback T1 -- * @param {string} str -- * @returns {string} -- */ -- -- /** -- * @callback T2 -- * @param {string} str -- * @returns {Promise} -- */ -- -- /** -- * @callback T3 -- * @param {string} str -- * @returns {Thenable} -- */ -- -- /** -- * @param {string} str -- * @returns {string} -- ~~~~~~ ++==== /a.js (4 errors) ==== + /** + * @callback T1 + * @param {string} str +@@= skipped -32, +29 lines =@@ + * @param {string} str + * @returns {string} + ~~~~~~ -!!! error TS1055: Type 'string' is not a valid async function return type in ES5 because it does not refer to a Promise-compatible constructor value. -- */ -- const f1 = async str => { -- return str; -- } -- -- /** @type {T1} */ -- ~~ ++!!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? + */ + const f1 = async str => { + return str; +@@= skipped -8, +8 lines =@@ + + /** @type {T1} */ + ~~ -!!! error TS1065: The return type of an async function or method must be the global Promise type. -!!! related TS1055 /a.js:4:14: Type 'string' is not a valid async function return type in ES5 because it does not refer to a Promise-compatible constructor value. -- const f2 = async str => { -- return str; -- } -- -- /** -- * @param {string} str -- * @returns {Promise} -- */ -- const f3 = async str => { -- return str; -- } -- -- /** @type {T2} */ -- const f4 = async str => { -- return str; -- } -- -- /** @type {T3} */ -- ~~ ++!!! error TS2304: Cannot find name 'T1'. + const f2 = async str => { + return str; + } +@@= skipped -15, +14 lines =@@ + } + + /** @type {T2} */ ++ ~~ ++!!! error TS2304: Cannot find name 'T2'. + const f4 = async str => { + return str; + } + + /** @type {T3} */ + ~~ -!!! error TS1065: The return type of an async function or method must be the global Promise type. -!!! error TS1065: Type 'typeof Thenable' is not a valid async function return type in ES5 because it does not refer to a Promise-compatible constructor value. -!!! error TS1065: Construct signature return types 'Thenable' and 'PromiseLike' are incompatible. -!!! error TS1065: The types returned by 'then(...)' are incompatible between these types. -!!! error TS1065: Type 'void' is not assignable to type 'PromiseLike'. -- const f5 = async str => { -- return str; -- } -- -@@= skipped --1, +1 lines =@@ -+ ++!!! error TS2304: Cannot find name 'T3'. + const f5 = async str => { + return str; + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.types.diff index e8b7377df6..6a755833d4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.types.diff @@ -1,27 +1,11 @@ --- old.asyncFunctionDeclaration16_es5.types +++ new.asyncFunctionDeclaration16_es5.types -@@= skipped -28, +28 lines =@@ - * @returns {string} - */ - const f1 = async str => { -->f1 : (str: string) => string -->async str => { return str;} : (str: string) => string -->str : string -+>f1 : (str: any) => Promise -+>async str => { return str;} : (str: any) => Promise -+>str : any - - return str; -->str : string -+>str : any - } - +@@= skipped -39, +39 lines =@@ /** @type {T1} */ const f2 = async str => { -->f2 : T1 + >f2 : T1 ->async str => { return str;} : (str: string) => string ->str : string -+>f2 : (str: any) => Promise +>async str => { return str;} : (str: any) => Promise +>str : any @@ -32,27 +16,11 @@ /** @@= skipped -23, +23 lines =@@ - * @returns {Promise} - */ - const f3 = async str => { -->f3 : (str: string) => Promise -->async str => { return str;} : (str: string) => Promise -->str : string -+>f3 : (str: any) => Promise -+>async str => { return str;} : (str: any) => Promise -+>str : any - - return str; -->str : string -+>str : any - } - /** @type {T2} */ const f4 = async str => { -->f4 : T2 + >f4 : T2 ->async str => { return str;} : (str: string) => Promise ->str : string -+>f4 : (str: any) => Promise +>async str => { return str;} : (str: any) => Promise +>str : any @@ -63,10 +31,9 @@ /** @type {T3} */ const f5 = async str => { -->f5 : T3 + >f5 : T3 ->async str => { return str;} : (str: string) => Thenable ->str : string -+>f5 : (str: any) => Promise +>async str => { return str;} : (str: any) => Promise +>str : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff index ac9047c074..fc24b46f5c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff @@ -4,6 +4,7 @@ - @@= skipped --1, +1 lines =@@ +mod1.js(5,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++use.js(1,20): error TS2306: File 'mod1.js' is not a module. + + +==== mod1.js (1 errors) ==== @@ -18,8 +19,10 @@ + this.p = 1 + } + -+==== use.js (0 errors) ==== ++==== use.js (1 errors) ==== + /** @param {import('./mod1').Con} k */ ++ ~~~~~~~~ ++!!! error TS2306: File 'mod1.js' is not a module. + function f(k) { + if (1 === 2 - 1) { + // I guess basic math works! diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff new file mode 100644 index 0000000000..df85b5798e --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.callbackOnConstructor.errors.txt ++++ new.callbackOnConstructor.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++callbackOnConstructor.js(12,12): error TS2304: Cannot find name 'ValueGetter_2'. ++ ++ ++==== callbackOnConstructor.js (1 errors) ==== ++ export class Preferences { ++ assignability = "no" ++ /** ++ * @callback ValueGetter_2 ++ * @param {string} name ++ * @returns {boolean|number|string|undefined} ++ */ ++ constructor() {} ++ } ++ ++ ++ /** @type {ValueGetter_2} */ ++ ~~~~~~~~~~~~~ ++!!! error TS2304: Cannot find name 'ValueGetter_2'. ++ var ooscope2 = s => s.length > 0 ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.types.diff index 84b1064505..84dba7f57e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.types.diff @@ -7,7 +7,7 @@ ->ooscope2 : (name: string) => boolean | number | string | undefined ->s => s.length > 0 : (s: string) => string | number | boolean ->s : string -+>ooscope2 : (s: any) => boolean ++>ooscope2 : ValueGetter_2 +>s => s.length > 0 : (s: any) => boolean +>s : any >s.length > 0 : boolean diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff new file mode 100644 index 0000000000..f7336c1648 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff @@ -0,0 +1,32 @@ +--- old.callbackTag1.errors.txt ++++ new.callbackTag1.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++cb.js(7,12): error TS2304: Cannot find name 'Sid'. ++cb.js(11,12): error TS2304: Cannot find name 'NoReturn'. ++ ++ ++==== cb.js (2 errors) ==== ++ /** @callback Sid ++ * @param {string} s ++ * @returns {string} What were you expecting ++ */ ++ var x = 1 ++ ++ /** @type {Sid} smallId */ ++ ~~~ ++!!! error TS2304: Cannot find name 'Sid'. ++ var sid = s => s + "!"; ++ ++ ++ /** @type {NoReturn} */ ++ ~~~~~~~~ ++!!! error TS2304: Cannot find name 'NoReturn'. ++ var noreturn = obj => void obj.title ++ ++ /** ++ * @callback NoReturn ++ * @param {{ e: number, m: number, title: string }} s - Knee deep, shores, etc ++ */ ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.types.diff index 9524130d1f..26718ee325 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.types.diff @@ -1,13 +1,11 @@ --- old.callbackTag1.types +++ new.callbackTag1.types -@@= skipped -10, +10 lines =@@ - +@@= skipped -11, +11 lines =@@ /** @type {Sid} smallId */ var sid = s => s + "!"; -->sid : Sid + >sid : Sid ->s => s + "!" : (s: string) => string ->s : string -+>sid : (s: any) => string +>s => s + "!" : (s: any) => string +>s : any >s + "!" : string @@ -18,10 +16,9 @@ /** @type {NoReturn} */ var noreturn = obj => void obj.title -->noreturn : NoReturn + >noreturn : NoReturn ->obj => void obj.title : (obj: { e: number; m: number; title: string; }) => any ->obj : { e: number; m: number; title: string; } -+>noreturn : (obj: any) => any +>obj => void obj.title : (obj: any) => any +>obj : any >void obj.title : undefined diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff index c58ffc7f0c..1979e8649b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff @@ -2,11 +2,27 @@ +++ new.callbackTag2.errors.txt @@= skipped -0, +0 lines =@@ -cb.js(18,29): error TS2304: Cannot find name 'S'. -+cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. ++cb.js(8,12): error TS2304: Cannot find name 'Id'. ++cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. ++cb.js(22,12): error TS2304: Cannot find name 'SharedId'. ++cb.js(25,12): error TS2304: Cannot find name 'Final'. - ==== cb.js (1 errors) ==== -@@= skipped -19, +19 lines =@@ +-==== cb.js (1 errors) ==== ++==== cb.js (4 errors) ==== + /** @template T + * @callback Id + * @param {T} t +@@= skipped -9, +12 lines =@@ + var x = 1 + + /** @type {Id} I actually wanted to write `const "120"` */ ++ ~~ ++!!! error TS2304: Cannot find name 'Id'. + var one_twenty = s => "120"; + + /** @template S +@@= skipped -10, +12 lines =@@ class SharedClass { constructor() { /** @type {SharedId} */ @@ -14,7 +30,17 @@ -!!! error TS2304: Cannot find name 'S'. this.id; + ~~ -+!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. ++!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. } } /** @type {SharedId} */ ++ ~~~~~~~~ ++!!! error TS2304: Cannot find name 'SharedId'. + var outside = n => n + 1; + + /** @type {Final<{ fantasy }, { heroes }>} */ ++ ~~~~~ ++!!! error TS2304: Cannot find name 'Final'. + var noreturn = (barts, tidus, noctis) => "cecil" + + /** diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.types.diff index afc9b14dbb..a9917280c1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.types.diff @@ -1,19 +1,23 @@ --- old.callbackTag2.types +++ new.callbackTag2.types -@@= skipped -11, +11 lines =@@ - +@@= skipped -12, +12 lines =@@ /** @type {Id} I actually wanted to write `const "120"` */ var one_twenty = s => "120"; -->one_twenty : Id + >one_twenty : Id ->s => "120" : (s: string) => string ->s : string -+>one_twenty : (s: any) => string +>s => "120" : (s: any) => string +>s : any >"120" : "120" /** @template S -@@= skipped -16, +16 lines =@@ +@@= skipped -10, +10 lines =@@ + * @return {S} + */ + class SharedClass { +->SharedClass : SharedClass ++>SharedClass : SharedClass + constructor() { /** @type {SharedId} */ this.id; @@ -26,12 +30,11 @@ } /** @type {SharedId} */ var outside = n => n + 1; -->outside : SharedId + >outside : SharedId ->n => n + 1 : (n: number) => number ->n : number ->n + 1 : number ->n : number -+>outside : (n: any) => any +>n => n + 1 : (n: any) => any +>n : any +>n + 1 : any @@ -40,12 +43,11 @@ /** @type {Final<{ fantasy }, { heroes }>} */ var noreturn = (barts, tidus, noctis) => "cecil" -->noreturn : Final<{ fantasy: any; }, { heroes: any; }> + >noreturn : Final<{ fantasy: any; }, { heroes: any; }> ->(barts, tidus, noctis) => "cecil" : (barts: { fantasy: any; }, tidus: { heroes: any; }, noctis: { heroes: any; } & { fantasy: any; }) => "cecil" | "zidane" ->barts : { fantasy: any; } ->tidus : { heroes: any; } ->noctis : { heroes: any; } & { fantasy: any; } -+>noreturn : (barts: any, tidus: any, noctis: any) => string +>(barts, tidus, noctis) => "cecil" : (barts: any, tidus: any, noctis: any) => string +>barts : any +>tidus : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff new file mode 100644 index 0000000000..7ab5188958 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.callbackTag3.errors.txt ++++ new.callbackTag3.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++cb.js(4,12): error TS2304: Cannot find name 'Miracle'. ++ ++ ++==== cb.js (1 errors) ==== ++ /** @callback Miracle ++ * @returns {string} What were you expecting ++ */ ++ /** @type {Miracle} smallId */ ++ ~~~~~~~ ++!!! error TS2304: Cannot find name 'Miracle'. ++ var sid = () => "!"; ++ ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.types.diff deleted file mode 100644 index cd3c842a27..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.callbackTag3.types -+++ new.callbackTag3.types -@@= skipped -5, +5 lines =@@ - */ - /** @type {Miracle} smallId */ - var sid = () => "!"; -->sid : Miracle -+>sid : () => string - >() => "!" : () => string - >"!" : "!" - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff index 9977dcc3f9..0b07465530 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff @@ -3,12 +3,13 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++a.js(9,12): error TS2304: Cannot find name 'C'. +a.js(10,22): error TS7006: Parameter 'a' implicitly has an 'any' type. +a.js(10,25): error TS7006: Parameter 'b' implicitly has an 'any' type. +a.js(11,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + + -+==== a.js (3 errors) ==== ++==== a.js (4 errors) ==== + /** + * @callback C + * @this {{ a: string, b: number }} @@ -18,6 +19,8 @@ + */ + + /** @type {C} */ ++ ~ ++!!! error TS2304: Cannot find name 'C'. + const cb = function (a, b) { + ~ +!!! error TS7006: Parameter 'a' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.types.diff index b6c4896c70..369753e315 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.types.diff @@ -8,15 +8,13 @@ /** * @callback C * @this {{ a: string, b: number }} -@@= skipped -10, +10 lines =@@ - +@@= skipped -11, +11 lines =@@ /** @type {C} */ const cb = function (a, b) { -->cb : C + >cb : C ->function (a, b) { this return true} : (this: { a: string; b: number; }, a: string, b: number) => boolean ->a : string ->b : number -+>cb : (a: any, b: any) => boolean +>function (a, b) { this return true} : (a: any, b: any) => boolean +>a : any +>b : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff new file mode 100644 index 0000000000..f6ca9c7ec2 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff @@ -0,0 +1,28 @@ +--- old.callbackTagNestedParameter.errors.txt ++++ new.callbackTagNestedParameter.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++cb_nested.js(11,12): error TS2304: Cannot find name 'WorksWithPeopleCallback'. ++ ++ ++==== cb_nested.js (1 errors) ==== ++ /** ++ * @callback WorksWithPeopleCallback ++ * @param {Object} person ++ * @param {string} person.name ++ * @param {number} [person.age] ++ * @returns {void} ++ */ ++ ++ /** ++ * For each person, calls your callback. ++ * @param {WorksWithPeopleCallback} callback ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2304: Cannot find name 'WorksWithPeopleCallback'. ++ * @returns {void} ++ */ ++ function eachPerson(callback) { ++ callback({ name: "Empty" }); ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.types.diff index 4775e33ef4..d30f23f02a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.types.diff @@ -1,19 +1,11 @@ --- old.callbackTagNestedParameter.types +++ new.callbackTagNestedParameter.types -@@= skipped -14, +14 lines =@@ - * @returns {void} - */ - function eachPerson(callback) { -->eachPerson : (callback: WorksWithPeopleCallback) => void -->callback : WorksWithPeopleCallback -+>eachPerson : (callback: any) => void -+>callback : any +@@= skipped -18, +18 lines =@@ + >callback : WorksWithPeopleCallback callback({ name: "Empty" }); ->callback({ name: "Empty" }) : void -->callback : WorksWithPeopleCallback +>callback({ name: "Empty" }) : any -+>callback : any + >callback : WorksWithPeopleCallback >{ name: "Empty" } : { name: string; } >name : string - >"Empty" : "Empty" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff index 49adc28146..329423e0b5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff @@ -3,7 +3,7 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+callbackTagVariadicType.js(9,13): error TS2554: Expected 0 arguments, but got 2. ++callbackTagVariadicType.js(7,12): error TS2304: Cannot find name 'Foo'. + + +==== callbackTagVariadicType.js (1 errors) ==== @@ -14,8 +14,8 @@ + */ + + /** @type {Foo} */ ++ ~~~ ++!!! error TS2304: Cannot find name 'Foo'. + export const x = () => 1 + var res = x('a', 'b') -+ ~~~~~~~~ -+!!! error TS2554: Expected 0 arguments, but got 2. + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.types.diff index 9b1ccf79b4..886bdbca6c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.types.diff @@ -1,19 +1,13 @@ --- old.callbackTagVariadicType.types +++ new.callbackTagVariadicType.types -@@= skipped -8, +8 lines =@@ - - /** @type {Foo} */ - export const x = () => 1 -->x : Foo -+>x : () => number - >() => 1 : () => number +@@= skipped -13, +13 lines =@@ >1 : 1 var res = x('a', 'b') - >res : number - >x('a', 'b') : number -->x : Foo -+>x : () => number +->res : number +->x('a', 'b') : number ++>res : any ++>x('a', 'b') : any + >x : Foo >'a' : "a" >'b' : "b" - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.errors.txt.diff deleted file mode 100644 index 6cd1a12a45..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.checkJsdocOptionalParamOrder.errors.txt -+++ new.checkJsdocOptionalParamOrder.errors.txt -@@= skipped -0, +-1 lines =@@ --0.js(7,20): error TS1016: A required parameter cannot follow an optional parameter. -- -- --==== 0.js (1 errors) ==== -- // @ts-check -- /** -- * @param {number} a -- * @param {number} [b] -- * @param {number} c -- */ -- function foo(a, b, c) {} -- ~ --!!! error TS1016: A required parameter cannot follow an optional parameter. -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.types.diff index 8b4a04dc13..4e5cd89f15 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.types.diff @@ -5,11 +5,7 @@ */ function foo(a, b, c) {} ->foo : (a: number, b?: number, c: number) => void -->a : number -->b : number -->c : number -+>foo : (a: any, b: any, c: any) => void -+>a : any -+>b : any -+>c : any - ++>foo : (a: number, b: number, c: number) => void + >a : number + >b : number + >c : number diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.types.diff index 4f90472433..d09f5ecd48 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.types.diff @@ -7,16 +7,12 @@ ->x : (n?: number | undefined, s?: string) => void ->function foo(n, s) {} : (n?: number | undefined, s?: string) => void ->foo : (n?: number | undefined, s?: string) => void -->n : number -->s : string -+>x : (n: any, s: any) => void -+>function foo(n, s) {} : (n: any, s: any) => void -+>foo : (n: any, s: any) => void -+>n : any -+>s : any ++>x : (n?: number, s?: string) => void ++>function foo(n, s) {} : (n?: number, s?: string) => void ++>foo : (n?: number, s?: string) => void + >n : number + >s : string - var y; - >y : any @@= skipped -13, +13 lines =@@ * @param {boolean!} b */ @@ -33,14 +29,3 @@ /** * @param {string} s - */ - var one = function (s) { }, two = function (untyped) { }; -->one : (s: string) => void -->function (s) { } : (s: string) => void -->s : string -+>one : (s: any) => void -+>function (s) { } : (s: any) => void -+>s : any - >two : (untyped: any) => void - >function (untyped) { } : (untyped: any) => void - >untyped : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.errors.txt.diff deleted file mode 100644 index 5fb5ffe788..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.checkJsdocParamTag1.errors.txt -+++ new.checkJsdocParamTag1.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+0.js(8,1): error TS2554: Expected 2 arguments, but got 0. -+0.js(9,1): error TS2554: Expected 2 arguments, but got 1. -+ -+ -+==== 0.js (2 errors) ==== -+ // @ts-check -+ /** -+ * @param {number=} n -+ * @param {string} [s] -+ */ -+ function foo(n, s) {} -+ -+ foo(); -+ ~~~ -+!!! error TS2554: Expected 2 arguments, but got 0. -+!!! related TS6210 0.js:6:14: An argument for 'n' was not provided. -+ foo(1); -+ ~~~ -+!!! error TS2554: Expected 2 arguments, but got 1. -+!!! related TS6210 0.js:6:17: An argument for 's' was not provided. -+ foo(1, "hi"); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.types.diff index f45c6da257..f6dc725c1d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.types.diff @@ -5,27 +5,25 @@ */ function foo(n, s) {} ->foo : (n?: number | undefined, s?: string) => void -->n : number -->s : string -+>foo : (n: any, s: any) => void -+>n : any -+>s : any ++>foo : (n?: number, s?: string) => void + >n : number + >s : string foo(); >foo() : void ->foo : (n?: number | undefined, s?: string) => void -+>foo : (n: any, s: any) => void ++>foo : (n?: number, s?: string) => void foo(1); >foo(1) : void ->foo : (n?: number | undefined, s?: string) => void -+>foo : (n: any, s: any) => void ++>foo : (n?: number, s?: string) => void >1 : 1 foo(1, "hi"); >foo(1, "hi") : void ->foo : (n?: number | undefined, s?: string) => void -+>foo : (n: any, s: any) => void ++>foo : (n?: number, s?: string) => void >1 : 1 >"hi" : "hi" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.types.diff index 1e13e1787e..a13501ac4d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.types.diff @@ -9,12 +9,3 @@ return "hello world"; >"hello world" : "hello world" -@@= skipped -10, +10 lines =@@ - * @returns {string|number} This comment is not currently exposed - */ - function f2() { -->f2 : () => string | number -+>f2 : () => "hello" | 5 - - return 5 || "hello"; - >5 || "hello" : "hello" | 5 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.errors.txt.diff deleted file mode 100644 index d4d9342407..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.errors.txt.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.checkJsdocReturnTag2.errors.txt -+++ new.checkJsdocReturnTag2.errors.txt -@@= skipped -0, +0 lines =@@ --returns.js(6,5): error TS2322: Type 'number' is not assignable to type 'string'. --returns.js(13,5): error TS2322: Type 'number | boolean' is not assignable to type 'string | number'. -- Type 'boolean' is not assignable to type 'string | number'. - returns.js(13,12): error TS2872: This kind of expression is always truthy. - - --==== returns.js (3 errors) ==== -+==== returns.js (1 errors) ==== - // @ts-check - /** - * @returns {string} This comment is not currently exposed - */ - function f() { - return 5; -- ~~~~~~ --!!! error TS2322: Type 'number' is not assignable to type 'string'. - } - - /** -@@= skipped -19, +14 lines =@@ - */ - function f1() { - return 5 || true; -- ~~~~~~ --!!! error TS2322: Type 'number | boolean' is not assignable to type 'string | number'. --!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'. - ~ - !!! error TS2872: This kind of expression is always truthy. - } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.types.diff deleted file mode 100644 index 19a02215c1..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.types.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.checkJsdocReturnTag2.types -+++ new.checkJsdocReturnTag2.types -@@= skipped -5, +5 lines =@@ - * @returns {string} This comment is not currently exposed - */ - function f() { -->f : () => string -+>f : () => number - - return 5; - >5 : 5 -@@= skipped -10, +10 lines =@@ - * @returns {string | number} This comment is not currently exposed - */ - function f1() { -->f1 : () => string | number -+>f1 : () => 5 | true - - return 5 || true; - >5 || true : 5 | true diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff index 523019ce4c..22507e6d0f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff @@ -1,37 +1,19 @@ --- old.checkJsdocSatisfiesTag1.types +++ new.checkJsdocSatisfiesTag1.types -@@= skipped -42, +42 lines =@@ - +@@= skipped -43, +43 lines =@@ /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); -->t4 : T2 + >t4 : T2 ->({ a: "a" }) : T2 ->{ a: "a" } : { a: "a"; } ->a : "a" -+>t4 : { a: string; } +>({ a: "a" }) : { a: string; } +>{ a: "a" } : { a: string; } +>a : string >"a" : "a" /** @type {(m: string) => string} */ - const t5 = /** @satisfies {T3} */((m) => m.substring(0)); -->t5 : (m: string) => string -->((m) => m.substring(0)) : (m: string) => string -->(m) => m.substring(0) : (m: string) => string -->m : string -->m.substring(0) : string -->m.substring : (start: number, end?: number) => string -->m : string -->substring : (start: number, end?: number) => string -+>t5 : (m: any) => any -+>((m) => m.substring(0)) : (m: any) => any -+>(m) => m.substring(0) : (m: any) => any -+>m : any -+>m.substring(0) : any -+>m.substring : any -+>m : any -+>substring : any +@@= skipped -18, +18 lines =@@ >0 : 0 const t6 = /** @satisfies {[number, number]} */ ([1, 2]); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff new file mode 100644 index 0000000000..9d083d1300 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.checkJsdocSatisfiesTag2.errors.txt ++++ new.checkJsdocSatisfiesTag2.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/a.js(1,15): error TS2315: Type 'Object' is not generic. ++/a.js(1,21): error TS8020: JSDoc types can only be used inside documentation comments. ++ ++ ++==== /a.js (2 errors) ==== ++ /** @typedef {Object. boolean>} Predicates */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. ++ ++ const p = /** @satisfies {Predicates} */ ({ ++ isEven: n => n % 2 === 0, ++ isOdd: n => n % 2 === 1 ++ }); ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff index 318b609d0d..73eaaa76a0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff @@ -1,21 +1,20 @@ --- old.checkJsdocSatisfiesTag3.errors.txt +++ new.checkJsdocSatisfiesTag3.errors.txt @@= skipped -0, +0 lines =@@ - /a.js(3,7): error TS7006: Parameter 's' implicitly has an 'any' type. +-/a.js(3,7): error TS7006: Parameter 's' implicitly has an 'any' type. +/a.js(4,7): error TS7006: Parameter 's' implicitly has an 'any' type. +/a.js(8,49): error TS7006: Parameter 'x' implicitly has an 'any' type. -==== /a.js (1 errors) ==== -+==== /a.js (3 errors) ==== ++==== /a.js (2 errors) ==== /** @type {{ f(s: string): void } & Record }} */ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ f(s) { }, // "incorrect" implicit any on 's' ++ g(s) { } ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. - g(s) { } -+ ~ -+!!! error TS7006: Parameter 's' implicitly has an 'any' type. +- g(s) { } }); // This needs to not crash (outer node is not expression) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff index 27821645bc..37eef391a2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff @@ -7,13 +7,15 @@ ->obj : { f(s: string): void; } & Record ->({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: string): void; } & Record ->{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } -+>obj : { f: (s: any) => void; g: (s: any) => void; } -+>({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f: (s: any) => void; g: (s: any) => void; } -+>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f: (s: any) => void; g: (s: any) => void; } ++>obj : { f: (s: string) => void; } & Record ++>({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f: (s: string) => void; g: (s: any) => void; } ++>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f: (s: string) => void; g: (s: any) => void; } f(s) { }, // "incorrect" implicit any on 's' - >f : (s: any) => void - >s : any +->f : (s: any) => void +->s : any ++>f : (s: string) => void ++>s : string g(s) { } ->g : (s: string) => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff index 0dd7a74d2d..d4a0745ab7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff @@ -1,19 +1,24 @@ --- old.checkJsdocSatisfiesTag8.errors.txt +++ new.checkJsdocSatisfiesTag8.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -/a.js(6,5): error TS2322: Type 'string' is not assignable to type 'boolean'. -- -- ++/a.js(1,15): error TS2315: Type 'Object' is not generic. ++/a.js(1,21): error TS8020: JSDoc types can only be used inside documentation comments. + + -==== /a.js (1 errors) ==== -- /** @typedef {Object.} Facts */ -- -- // Should be able to detect a failure here -- const x = /** @satisfies {Facts} */ ({ -- m: true, -- s: "false" ++==== /a.js (2 errors) ==== + /** @typedef {Object.} Facts */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. + + // Should be able to detect a failure here + const x = /** @satisfies {Facts} */ ({ + m: true, + s: "false" - ~ -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. -- }) -- -@@= skipped --1, +1 lines =@@ -+ + }) + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff index 83c1f0f8bb..beb14a9d96 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff @@ -2,36 +2,48 @@ +++ new.checkJsdocTypeTag1.errors.txt @@= skipped -0, +0 lines =@@ -0.js(24,12): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -+0.js(10,1): error TS2322: Type 'string' is not assignable to type 'number'. -+0.js(14,1): error TS2322: Type 'string' is not assignable to type 'number'. ++0.js(20,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(24,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(28,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'props' must be of type 'object', but here has type 'Object'. -==== 0.js (1 errors) ==== -+==== 0.js (2 errors) ==== ++==== 0.js (4 errors) ==== // @ts-check /** @type {String} */ var S = "hello world"; -@@= skipped -11, +12 lines =@@ - /** @type {*} */ - var anyT = 2; - anyT = "hello"; -+ ~~~~ -+!!! error TS2322: Type 'string' is not assignable to type 'number'. +@@= skipped -21, +24 lines =@@ + x(1); - /** @type {?} */ - var anyT1 = 2; - anyT1 = "hi"; -+ ~~~~~ -+!!! error TS2322: Type 'string' is not assignable to type 'number'. - - /** @type {Function} */ - const x = (a) => a + 1; -@@= skipped -14, +18 lines =@@ + /** @type {function} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const y = (a) => a + 1; y(1); /** @type {function (number)} */ - ~~~~~~~~~~~~~~~~~ -!!! error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. const x1 = (a) => a + 1; x1(0); + /** @type {function (number): number} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const x2 = (a) => a + 1; + x2(0); + +@@= skipped -22, +29 lines =@@ + * @type {Object} + */ + var props = {}; ++ ~~~~~ ++!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'props' must be of type 'object', but here has type 'Object'. ++!!! related TS6203 0.js:35:5: 'props' was also declared here. + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.types.diff index a4fb6376c7..cb967e9d68 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.types.diff @@ -1,59 +1,29 @@ --- old.checkJsdocTypeTag1.types +++ new.checkJsdocTypeTag1.types -@@= skipped -13, +13 lines =@@ +@@= skipped -3, +3 lines =@@ + // @ts-check + /** @type {String} */ + var S = "hello world"; +->S : string ++>S : String + >"hello world" : "hello world" - /** @type {*} */ - var anyT = 2; -->anyT : any -+>anyT : number - >2 : 2 - - anyT = "hello"; - >anyT = "hello" : "hello" -->anyT : any -+>anyT : number - >"hello" : "hello" - - /** @type {?} */ - var anyT1 = 2; -->anyT1 : any -+>anyT1 : number - >2 : 2 - - anyT1 = "hi"; - >anyT1 = "hi" : "hi" -->anyT1 : any -+>anyT1 : number - >"hi" : "hi" - - /** @type {Function} */ - const x = (a) => a + 1; -->x : Function -+>x : (a: any) => any - >(a) => a + 1 : (a: any) => any - >a : any - >a + 1 : any -@@= skipped -29, +29 lines =@@ - - x(1); - >x(1) : any -->x : Function -+>x : (a: any) => any - >1 : 1 + /** @type {number} */ +@@= skipped -44, +44 lines =@@ /** @type {function} */ const y = (a) => a + 1; ->y : Function -+>y : (a: any) => any ++>y : function >(a) => a + 1 : (a: any) => any >a : any >a + 1 : any -@@= skipped -14, +14 lines =@@ +@@= skipped -9, +9 lines =@@ y(1); >y(1) : any ->y : Function -+>y : (a: any) => any ++>y : function >1 : 1 /** @type {function (number)} */ @@ -63,7 +33,7 @@ ->a : number ->a + 1 : number ->a : number -+>x1 : (a: any) => any ++>x1 : function +>(a) => a + 1 : (a: any) => any +>a : any +>a + 1 : any @@ -73,7 +43,7 @@ x1(0); >x1(0) : any ->x1 : (arg0: number) => any -+>x1 : (a: any) => any ++>x1 : function >0 : 0 /** @type {function (number): number} */ @@ -83,7 +53,7 @@ ->a : number ->a + 1 : number ->a : number -+>x2 : (a: any) => any ++>x2 : function +>(a) => a + 1 : (a: any) => any +>a : any +>a + 1 : any @@ -94,7 +64,7 @@ ->x2(0) : number ->x2 : (arg0: number) => number +>x2(0) : any -+>x2 : (a: any) => any ++>x2 : function >0 : 0 /** @@ -102,7 +72,7 @@ */ var props = {}; ->props : any -+>props : {} ++>props : object >{} : {} /** @@ -110,6 +80,6 @@ */ var props = {}; ->props : any -+>props : {} ++>props : object >{} : {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff index f06ecf6e93..a26d98f387 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff @@ -1,54 +1,71 @@ --- old.checkJsdocTypeTag2.errors.txt +++ new.checkJsdocTypeTag2.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -0.js(3,5): error TS2322: Type 'boolean' is not assignable to type 'string'. --0.js(6,5): error TS2322: Type 'string' is not assignable to type 'number'. ++0.js(3,5): error TS2322: Type 'boolean' is not assignable to type 'String'. + 0.js(6,5): error TS2322: Type 'string' is not assignable to type 'number'. -0.js(8,12): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -0.js(10,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -0.js(17,1): error TS2322: Type 'number' is not assignable to type 'string'. -0.js(20,21): error TS2339: Property 'concat' does not exist on type 'number'. -0.js(24,19): error TS2322: Type 'number' is not assignable to type 'string'. -- -- ++0.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(12,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(23,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + -==== 0.js (7 errors) ==== -- // @ts-check -- /** @type {String} */ -- var S = true; -- ~ ++==== 0.js (6 errors) ==== + // @ts-check + /** @type {String} */ + var S = true; + ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. -- -- /** @type {number} */ -- var n = "hello"; -- ~ --!!! error TS2322: Type 'string' is not assignable to type 'number'. -- -- /** @type {function (number)} */ ++!!! error TS2322: Type 'boolean' is not assignable to type 'String'. + + /** @type {number} */ + var n = "hello"; +@@= skipped -19, +18 lines =@@ + !!! error TS2322: Type 'string' is not assignable to type 'number'. + + /** @type {function (number)} */ - ~~~~~~~~~~~~~~~~~ -!!! error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -- const x1 = (a) => a + 1; -- x1("string"); ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const x1 = (a) => a + 1; + x1("string"); - ~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -- -- /** @type {function (number): number} */ -- const x2 = (a) => a + 1; -- -- /** @type {string} */ -- var a; -- a = x2(0); + + /** @type {function (number): number} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const x2 = (a) => a + 1; + + /** @type {string} */ + var a; + a = x2(0); - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- -- /** @type {function (number): number} */ -- const x3 = (a) => a.concat("hi"); + + /** @type {function (number): number} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const x3 = (a) => a.concat("hi"); - ~~~~~~ -!!! error TS2339: Property 'concat' does not exist on type 'number'. -- x3(0); -- -- /** @type {function (number): string} */ -- const x4 = (a) => a + 1; + x3(0); + + /** @type {function (number): string} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + const x4 = (a) => a + 1; - ~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- x4(0); -@@= skipped --1, +1 lines =@@ -+ + x4(0); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.types.diff index bd5e836f55..b30261a16e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.types.diff @@ -5,14 +5,11 @@ /** @type {String} */ var S = true; ->S : string -+>S : boolean ++>S : String >true : true /** @type {number} */ - var n = "hello"; -->n : number -+>n : string - >"hello" : "hello" +@@= skipped -10, +10 lines =@@ /** @type {function (number)} */ const x1 = (a) => a + 1; @@ -21,7 +18,7 @@ ->a : number ->a + 1 : number ->a : number -+>x1 : (a: any) => any ++>x1 : function +>(a) => a + 1 : (a: any) => any +>a : any +>a + 1 : any @@ -31,7 +28,7 @@ x1("string"); >x1("string") : any ->x1 : (arg0: number) => any -+>x1 : (a: any) => any ++>x1 : function >"string" : "string" /** @type {function (number): number} */ @@ -41,7 +38,7 @@ ->a : number ->a + 1 : number ->a : number -+>x2 : (a: any) => any ++>x2 : function +>(a) => a + 1 : (a: any) => any +>a : any +>a + 1 : any @@ -49,19 +46,17 @@ >1 : 1 /** @type {string} */ - var a; -->a : string -+>a : any +@@= skipped -26, +26 lines =@@ + >a : string a = x2(0); ->a = x2(0) : number -->a : string ++>a = x2(0) : any + >a : string ->x2(0) : number ->x2 : (arg0: number) => number -+>a = x2(0) : any -+>a : any +>x2(0) : any -+>x2 : (a: any) => any ++>x2 : function >0 : 0 /** @type {function (number): number} */ @@ -69,7 +64,7 @@ ->x3 : (arg0: number) => number ->(a) => a.concat("hi") : (a: number) => number ->a : number -+>x3 : (a: any) => any ++>x3 : function +>(a) => a.concat("hi") : (a: any) => any +>a : any >a.concat("hi") : any @@ -83,7 +78,7 @@ ->x3(0) : number ->x3 : (arg0: number) => number +>x3(0) : any -+>x3 : (a: any) => any ++>x3 : function >0 : 0 /** @type {function (number): string} */ @@ -93,7 +88,7 @@ ->a : number ->a + 1 : number ->a : number -+>x4 : (a: any) => any ++>x4 : function +>(a) => a + 1 : (a: any) => any +>a : any +>a + 1 : any @@ -104,6 +99,6 @@ ->x4(0) : string ->x4 : (arg0: number) => string +>x4(0) : any -+>x4 : (a: any) => any ++>x4 : function >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.types.diff deleted file mode 100644 index 74267b93fe..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.checkJsdocTypeTag3.types -+++ new.checkJsdocTypeTag3.types -@@= skipped -2, +2 lines =@@ - === test.js === - /** @type {Array} */ - var nns; -->nns : number[] -+>nns : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff index ffefc22db0..ecccd6f603 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff @@ -1,26 +1,21 @@ --- old.checkJsdocTypeTag4.errors.txt +++ new.checkJsdocTypeTag4.errors.txt -@@= skipped -0, +-1 lines =@@ --test.js(5,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. --test.js(7,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. -- -- --==== t.d.ts (0 errors) ==== -- type A = { a: T } -- +@@= skipped -0, +0 lines =@@ ++test.js(3,19): error TS2304: Cannot find name 'U'. + test.js(5,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. + test.js(7,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. + +@@= skipped -4, +5 lines =@@ + ==== t.d.ts (0 errors) ==== + type A = { a: T } + -==== test.js (2 errors) ==== -- /** Also should error for jsdoc typedefs -- * @template {string} U -- * @typedef {{ b: U }} B -- */ -- /** @type {A} */ -- ~~~~~~ --!!! error TS2344: Type 'number' does not satisfy the constraint 'string'. -- var a; -- /** @type {B} */ -- ~~~~~~ --!!! error TS2344: Type 'number' does not satisfy the constraint 'string'. -- var b; -- -@@= skipped --1, +1 lines =@@ -+ ++==== test.js (3 errors) ==== + /** Also should error for jsdoc typedefs + * @template {string} U + * @typedef {{ b: U }} B ++ ~ ++!!! error TS2304: Cannot find name 'U'. + */ + /** @type {A} */ + ~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff index d37413d440..eaeafa917c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff @@ -1,14 +1,9 @@ --- old.checkJsdocTypeTag4.types +++ new.checkJsdocTypeTag4.types -@@= skipped -11, +11 lines =@@ - */ - /** @type {A} */ - var a; -->a : A -+>a : any +@@= skipped -15, +15 lines =@@ /** @type {B} */ var b; ->b : B -+>b : any ++>b : { b: U; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff index ef88515543..aadaba2498 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff @@ -1,69 +1,73 @@ --- old.checkJsdocTypeTag5.errors.txt +++ new.checkJsdocTypeTag5.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -test.js(3,17): error TS2322: Type 'number' is not assignable to type 'string'. --test.js(5,14): error TS2322: Type 'number' is not assignable to type 'string'. + test.js(5,14): error TS2322: Type 'number' is not assignable to type 'string'. -test.js(7,24): error TS2322: Type 'number' is not assignable to type 'string'. -test.js(10,17): error TS2322: Type 'number' is not assignable to type 'string'. --test.js(12,14): error TS2322: Type 'number' is not assignable to type 'string'. ++test.js(7,5): error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. ++ Type 'number' is not assignable to type 'string'. + test.js(12,14): error TS2322: Type 'number' is not assignable to type 'string'. -test.js(14,24): error TS2322: Type 'number' is not assignable to type 'string'. -test.js(28,12): error TS8030: The type of a function declaration must match the function's signature. --test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. -- Type '1' is not assignable to type '2 | 3'. -- -- ++test.js(14,5): error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. ++ Type 'number' is not assignable to type 'string'. ++test.js(24,5): error TS2322: Type 'number' is not assignable to type '0 | 1 | 2'. + test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. + Type '1' is not assignable to type '2 | 3'. + + -==== test.js (8 errors) ==== -- // all 6 should error on return statement/expression -- /** @type {(x: number) => string} */ -- function h(x) { return x } ++==== test.js (6 errors) ==== + // all 6 should error on return statement/expression + /** @type {(x: number) => string} */ + function h(x) { return x } - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- /** @type {(x: number) => string} */ -- var f = x => x -- ~ --!!! error TS2322: Type 'number' is not assignable to type 'string'. -- /** @type {(x: number) => string} */ -- var g = function (x) { return x } + /** @type {(x: number) => string} */ + var f = x => x + ~ + !!! error TS2322: Type 'number' is not assignable to type 'string'. ++!!! related TS6502 test.js:4:12: The expected type comes from the return type of this signature. + /** @type {(x: number) => string} */ + var g = function (x) { return x } - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- -- /** @type {{ (x: number): string }} */ -- function i(x) { return x } ++ ~ ++!!! error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. ++!!! error TS2322: Type 'number' is not assignable to type 'string'. + + /** @type {{ (x: number): string }} */ + function i(x) { return x } - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- /** @type {{ (x: number): string }} */ -- var j = x => x -- ~ --!!! error TS2322: Type 'number' is not assignable to type 'string'. -- /** @type {{ (x: number): string }} */ -- var k = function (x) { return x } + /** @type {{ (x: number): string }} */ + var j = x => x + ~ + !!! error TS2322: Type 'number' is not assignable to type 'string'. ++!!! related TS6502 test.js:11:12: The expected type comes from the return type of this signature. + /** @type {{ (x: number): string }} */ + var k = function (x) { return x } - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- -- -- /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ -- /** @type {Argle} */ -- function blargle(s) { -- return 0; -- } -- -- /** @type {0 | 1 | 2} - assignment should not error */ -- var zeroonetwo = blargle('hi') -- -- /** @typedef {{(s: string): 0 | 1; (b: boolean): 2 | 3 }} Gioconda */ -- -- /** @type {Gioconda} */ ++ ~ ++!!! error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. ++!!! error TS2322: Type 'number' is not assignable to type 'string'. + + + /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ +@@= skipped -45, +45 lines =@@ + + /** @type {0 | 1 | 2} - assignment should not error */ + var zeroonetwo = blargle('hi') ++ ~~~~~~~~~~ ++!!! error TS2322: Type 'number' is not assignable to type '0 | 1 | 2'. + + /** @typedef {{(s: string): 0 | 1; (b: boolean): 2 | 3 }} Gioconda */ + + /** @type {Gioconda} */ - ~~~~~~~~ -!!! error TS8030: The type of a function declaration must match the function's signature. -- function monaLisa(sb) { -- return typeof sb === 'string' ? 1 : 2; -- } -- -- /** @type {2 | 3} - overloads are not supported, so there will be an error */ -- var twothree = monaLisa(false); -- ~~~~~~~~ --!!! error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. --!!! error TS2322: Type '1' is not assignable to type '2 | 3'. -- -@@= skipped --1, +1 lines =@@ -+ + function monaLisa(sb) { + return typeof sb === 'string' ? 1 : 2; + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.types.diff index b352fcd050..b7e2171439 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.types.diff @@ -13,25 +13,19 @@ /** @type {(x: number) => string} */ var f = x => x -->f : (x: number) => string + >f : (x: number) => string ->x => x : (x: number) => string -->x : number -->x : number -+>f : (x: any) => any -+>x => x : (x: any) => any -+>x : any -+>x : any ++>x => x : (x: number) => number + >x : number + >x : number /** @type {(x: number) => string} */ var g = function (x) { return x } -->g : (x: number) => string + >g : (x: number) => string ->function (x) { return x } : (x: number) => string -->x : number -->x : number -+>g : (x: any) => any -+>function (x) { return x } : (x: any) => any -+>x : any -+>x : any ++>function (x) { return x } : (x: number) => number + >x : number + >x : number /** @type {{ (x: number): string }} */ function i(x) { return x } @@ -44,27 +38,21 @@ /** @type {{ (x: number): string }} */ var j = x => x -->j : (x: number) => string + >j : (x: number) => string ->x => x : (x: number) => string -->x : number -->x : number -+>j : (x: any) => any -+>x => x : (x: any) => any -+>x : any -+>x : any ++>x => x : (x: number) => number + >x : number + >x : number /** @type {{ (x: number): string }} */ var k = function (x) { return x } -->k : (x: number) => string + >k : (x: number) => string ->function (x) { return x } : (x: number) => string -->x : number -->x : number -+>k : (x: any) => any -+>function (x) { return x } : (x: any) => any -+>x : any -+>x : any - ++>function (x) { return x } : (x: number) => number + >x : number + >x : number +@@= skipped -42, +42 lines =@@ /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ /** @type {Argle} */ function blargle(s) { @@ -75,25 +63,14 @@ return 0; >0 : 0 -@@= skipped -51, +51 lines =@@ - +@@= skipped -10, +10 lines =@@ /** @type {0 | 1 | 2} - assignment should not error */ var zeroonetwo = blargle('hi') -->zeroonetwo : 0 | 1 | 2 + >zeroonetwo : 0 | 1 | 2 ->blargle('hi') : 0 | 1 | 2 ->blargle : (x: "hi" | "bye") => 0 | 1 | 2 -+>zeroonetwo : number +>blargle('hi') : number +>blargle : (s: any) => number >'hi' : "hi" /** @typedef {{(s: string): 0 | 1; (b: boolean): 2 | 3 }} Gioconda */ -@@= skipped -24, +24 lines =@@ - - /** @type {2 | 3} - overloads are not supported, so there will be an error */ - var twothree = monaLisa(false); -->twothree : 2 | 3 -+>twothree : number - >monaLisa(false) : 1 | 2 - >monaLisa : (sb: any) => 1 | 2 - >false : false diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff index dc81be50ce..13763ae1a4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff @@ -1,71 +1,50 @@ --- old.checkJsdocTypeTag6.errors.txt +++ new.checkJsdocTypeTag6.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -test.js(1,12): error TS8030: The type of a function declaration must match the function's signature. --test.js(7,5): error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. + test.js(7,5): error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. -test.js(10,12): error TS8030: The type of a function declaration must match the function's signature. -test.js(23,12): error TS8030: The type of a function declaration must match the function's signature. --test.js(27,7): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. -- Target signature provides too few arguments. Expected 1 or more, but got 0. --test.js(30,7): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. -- Target signature provides too few arguments. Expected 1 or more, but got 0. + test.js(27,7): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. + Target signature provides too few arguments. Expected 1 or more, but got 0. + test.js(30,7): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. + Target signature provides too few arguments. Expected 1 or more, but got 0. -test.js(34,3): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. - Target signature provides too few arguments. Expected 1 or more, but got 0. -- -- + + -==== test.js (7 errors) ==== -- /** @type {number} */ ++==== test.js (3 errors) ==== + /** @type {number} */ - ~~~~~~ -!!! error TS8030: The type of a function declaration must match the function's signature. -- function f() { -- return 1 -- } -- -- /** @type {{ prop: string }} */ -- var g = function (prop) { -- ~ --!!! error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. -- } -- -- /** @type {(a: number) => number} */ + function f() { + return 1 + } +@@= skipped -24, +17 lines =@@ + } + + /** @type {(a: number) => number} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8030: The type of a function declaration must match the function's signature. -- function add1(a, b) { return a + b; } -- -- /** @type {(a: number, b: number) => number} */ -- function add2(a, b) { return a + b; } -- -- // TODO: Should be an error since signature doesn't match. -- /** @type {(a: number, b: number, c: number) => number} */ -- function add3(a, b) { return a + b; } -- -- // Confirm initializers are compatible. -- // They can't have more parameters than the type/context. -- -- /** @type {() => void} */ + function add1(a, b) { return a + b; } + + /** @type {(a: number, b: number) => number} */ +@@= skipped -15, +13 lines =@@ + // They can't have more parameters than the type/context. + + /** @type {() => void} */ - ~~~~~~~~~~ -!!! error TS8030: The type of a function declaration must match the function's signature. -- function funcWithMoreParameters(more) {} // error -- -- /** @type {() => void} */ -- const variableWithMoreParameters = function (more) {}; // error -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. --!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. -- -- /** @type {() => void} */ -- const arrowWithMoreParameters = (more) => {}; // error -- ~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. --!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. -- -- ({ -- /** @type {() => void} */ -- methodWithMoreParameters(more) {}, // error + function funcWithMoreParameters(more) {} // error + + /** @type {() => void} */ +@@= skipped -19, +17 lines =@@ + ({ + /** @type {() => void} */ + methodWithMoreParameters(more) {}, // error - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. -!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0. -- }); -- -@@= skipped --1, +1 lines =@@ -+ + }); + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.types.diff index 3e5cbc5ea3..ead935ec01 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.types.diff @@ -1,14 +1,6 @@ --- old.checkJsdocTypeTag6.types +++ new.checkJsdocTypeTag6.types -@@= skipped -10, +10 lines =@@ - - /** @type {{ prop: string }} */ - var g = function (prop) { -->g : { prop: string; } -+>g : (prop: any) => void - >function (prop) {} : (prop: any) => void - >prop : any - } +@@= skipped -17, +17 lines =@@ /** @type {(a: number) => number} */ function add1(a, b) { return a + b; } @@ -63,17 +55,7 @@ >more : any /** @type {() => void} */ - const variableWithMoreParameters = function (more) {}; // error -->variableWithMoreParameters : () => void -+>variableWithMoreParameters : (more: any) => void - >function (more) {} : (more: any) => void - >more : any - - /** @type {() => void} */ - const arrowWithMoreParameters = (more) => {}; // error -->arrowWithMoreParameters : () => void -+>arrowWithMoreParameters : (more: any) => void - >(more) => {} : (more: any) => void +@@= skipped -47, +47 lines =@@ >more : any ({ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.errors.txt.diff index b1b2b146a2..7aa3c6a048 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.errors.txt.diff @@ -3,11 +3,10 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+0.js(19,1): error TS2322: Type '"string"' is not assignable to type 'undefined'. -+0.js(21,1): error TS2322: Type 'undefined' is not assignable to type 'string'. ++0.js(16,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + -+==== 0.js (2 errors) ==== ++==== 0.js (1 errors) ==== + // @ts-check + var lol = "hello Lol" + const obj = { @@ -24,15 +23,14 @@ + /** @type {number} */ + ['b' + 'ar1']: 42, + /** @type {function(number): number} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + arrowFunc: (num) => num + 42 + } + obj.foo = 'string' -+ ~~~~~~~ -+!!! error TS2322: Type '"string"' is not assignable to type 'undefined'. + obj.lol + obj.bar = undefined; -+ ~~~~~~~ -+!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + var k = obj.method1(0); + obj.bar1 = "42"; + obj.arrowFunc(0); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.types.diff index 0339f07366..05d1ea34a0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty1.types.diff @@ -6,19 +6,19 @@ const obj = { ->obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } ->{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ arrowFunc: (num) => num + 42} : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } -+>obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } -+>{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ arrowFunc: (num) => num + 42} : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } ++>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } ++>{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ arrowFunc: (num) => num + 42} : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } /** @type {string|undefined} */ foo: undefined, -->foo : string | undefined -+>foo : undefined + >foo : string | undefined ++>undefined : string | undefined >undefined : undefined /** @type {string|undefined} */ bar: "42", -->bar : string | undefined -+>bar : string + >bar : string | undefined ++>"42" : string | undefined >"42" : "42" /** @type {function(number): number} */ @@ -36,7 +36,12 @@ >42 : 42 }, -@@= skipped -38, +38 lines =@@ +@@= skipped -34, +36 lines =@@ + >'b' + 'ar1' : string + >'b' : "b" + >'ar1' : "ar1" ++>42 : number + >42 : 42 /** @type {function(number): number} */ arrowFunc: (num) => num + 42 @@ -45,7 +50,8 @@ ->num : number ->num + 42 : number ->num : number -+>arrowFunc : (num: any) => any ++>arrowFunc : function ++>(num) => num + 42 : function +>(num) => num + 42 : (num: any) => any +>num : any +>num + 42 : any @@ -54,28 +60,24 @@ } obj.foo = 'string' >obj.foo = 'string' : "string" -->obj.foo : string | undefined + >obj.foo : string | undefined ->obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } -->foo : string | undefined -+>obj.foo : undefined -+>obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } -+>foo : undefined ++>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } + >foo : string | undefined >'string' : "string" obj.lol >obj.lol : string ->obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } -+>obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } ++>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } >lol : string obj.bar = undefined; >obj.bar = undefined : undefined -->obj.bar : string | undefined + >obj.bar : string | undefined ->obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } -->bar : string | undefined -+>obj.bar : string -+>obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } -+>bar : string ++>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } + >bar : string | undefined >undefined : undefined var k = obj.method1(0); @@ -87,7 +89,7 @@ +>k : any +>obj.method1(0) : any +>obj.method1 : (n1: any) => any -+>obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } ++>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } +>method1 : (n1: any) => any >0 : 0 @@ -96,9 +98,9 @@ ->obj.bar1 : string | number | ((arg0: number) => number) | undefined ->obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } ->bar1 : string | number | ((arg0: number) => number) | undefined -+>obj.bar1 : string | number | ((n1: any) => any) | undefined -+>obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } -+>bar1 : string | number | ((n1: any) => any) | undefined ++>obj.bar1 : any ++>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } ++>bar1 : any >"42" : "42" obj.arrowFunc(0); @@ -107,8 +109,8 @@ ->obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } ->arrowFunc : (arg0: number) => number +>obj.arrowFunc(0) : any -+>obj.arrowFunc : (num: any) => any -+>obj : { [x: string]: string | number | ((n1: any) => any) | undefined; foo: undefined; bar: string; method1: (n1: any) => any; lol: string; arrowFunc: (num: any) => any; } -+>arrowFunc : (num: any) => any ++>obj.arrowFunc : function ++>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1: (n1: any) => any; lol: string; arrowFunc: function; } ++>arrowFunc : function >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff index 015876ca90..efedccde18 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff @@ -1,6 +1,6 @@ --- old.checkJsdocTypeTagOnObjectProperty2.errors.txt +++ new.checkJsdocTypeTagOnObjectProperty2.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -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'. @@ -9,46 +9,56 @@ -0.js(19,5): error TS2322: Type 'number' is not assignable to type 'string'. -0.js(22,5): error TS2322: Type 'number' is not assignable to type 'string'. -0.js(22,22): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -- -- ++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'? + + -==== 0.js (8 errors) ==== -- // @ts-check -- var lol; -- const obj = { -- /** @type {string|undefined} */ -- bar: 42, ++==== 0.js (3 errors) ==== + // @ts-check + var lol; + const obj = { + /** @type {string|undefined} */ + bar: 42, - ~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- /** @type {function(number): number} */ -- method1(n1) { -- return "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. + /** @type {function(number): number} */ + method1(n1) { + return "42"; - ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. -- }, -- /** @type {function(number): number} */ -- method2: (n1) => "lol", + }, + /** @type {function(number): number} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + method2: (n1) => "lol", - ~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. -- /** @type {function(number): number} */ -- arrowFunc: (num="0") => num + 42, + /** @type {function(number): number} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + arrowFunc: (num="0") => num + 42, - ~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. -- /** @type {string} */ -- lol + /** @type {string} */ + lol - ~~~ -!!! error TS2322: Type 'undefined' is not assignable to type 'string'. -- } -- lol = "string" -- /** @type {string} */ -- var s = obj.method1(0); + } + lol = "string" + /** @type {string} */ + var s = obj.method1(0); - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- -- /** @type {string} */ -- var s1 = obj.method2("0"); + + /** @type {string} */ + var s1 = obj.method2("0"); - ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. - ~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.types.diff index 93082f1b63..49de36cefb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.types.diff @@ -6,13 +6,13 @@ 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: number; method1: (n1: any) => string; method2: (n1: any) => string; arrowFunc: (num?: string) => string; 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: number; method1: (n1: any) => string; method2: (n1: any) => string; arrowFunc: (num?: string) => string; lol: any; } ++>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; } /** @type {string|undefined} */ bar: 42, -->bar : string | undefined -+>bar : number + >bar : string | undefined ++>42 : string | undefined >42 : 42 /** @type {function(number): number} */ @@ -24,14 +24,15 @@ return "42"; >"42" : "42" -@@= skipped -19, +19 lines =@@ +@@= skipped -19, +20 lines =@@ }, /** @type {function(number): number} */ method2: (n1) => "lol", ->method2 : (arg0: number) => number ->(n1) => "lol" : (n1: number) => number ->n1 : number -+>method2 : (n1: any) => string ++>method2 : function ++>(n1) => "lol" : function +>(n1) => "lol" : (n1: any) => string +>n1 : any >"lol" : "lol" @@ -41,7 +42,8 @@ ->arrowFunc : (arg0: number) => number ->(num="0") => num + 42 : (num?: number) => number ->num : number -+>arrowFunc : (num?: string) => string ++>arrowFunc : function ++>(num="0") => num + 42 : function +>(num="0") => num + 42 : (num?: string) => string +>num : string >"0" : "0" @@ -58,7 +60,7 @@ } lol = "string" >lol = "string" : "string" -@@= skipped -27, +27 lines =@@ +@@= skipped -27, +29 lines =@@ /** @type {string} */ var s = obj.method1(0); >s : string @@ -68,7 +70,7 @@ ->method1 : (arg0: number) => number +>obj.method1(0) : string +>obj.method1 : (n1: any) => string -+>obj : { bar: number; method1: (n1: any) => string; method2: (n1: any) => string; arrowFunc: (num?: string) => string; lol: any; } ++>obj : { bar: string | undefined; method1: (n1: any) => string; method2: function; arrowFunc: function; lol: any; } +>method1 : (n1: any) => string >0 : 0 @@ -79,9 +81,9 @@ ->obj.method2 : (arg0: number) => number ->obj : { bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } ->method2 : (arg0: number) => number -+>obj.method2("0") : string -+>obj.method2 : (n1: any) => string -+>obj : { bar: number; method1: (n1: any) => string; method2: (n1: any) => string; arrowFunc: (num?: string) => string; lol: any; } -+>method2 : (n1: any) => string ++>obj.method2("0") : any ++>obj.method2 : function ++>obj : { bar: string | undefined; method1: (n1: any) => string; method2: function; arrowFunc: function; lol: any; } ++>method2 : function >"0" : "0" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff new file mode 100644 index 0000000000..d1d0f17779 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff @@ -0,0 +1,61 @@ +--- old.checkJsdocTypedefInParamTag1.errors.txt ++++ new.checkJsdocTypedefInParamTag1.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++0.js(15,5): error TS2739: Type '{ x: string; }' is missing the following properties from type 'Opts': y, z, w ++0.js(28,6): error TS2741: Property 'anotherY' is missing in type '{ anotherX: string; }' but required in type 'AnotherOpts'. ++0.js(42,6): error TS2739: Type '{ x: string; }' is missing the following properties from type 'Opts1': y, z, w ++ ++ ++==== 0.js (3 errors) ==== ++ // @ts-check ++ /** ++ * @typedef {Object} Opts ++ * @property {string} x ++ * @property {string=} y ++ * @property {string} [z] ++ * @property {string} [w="hi"] ++ * ++ * @param {Opts} opts ++ */ ++ function foo(opts) { ++ opts.x; ++ } ++ ++ foo({x: 'abc'}); ++ ~~~~~~~~~~ ++!!! error TS2739: Type '{ x: string; }' is missing the following properties from type 'Opts': y, z, w ++ ++ /** ++ * @typedef {Object} AnotherOpts ++ * @property anotherX {string} ++ * @property anotherY {string=} ++ * ++ * @param {AnotherOpts} opts ++ */ ++ function foo1(opts) { ++ opts.anotherX; ++ } ++ ++ foo1({anotherX: "world"}); ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS2741: Property 'anotherY' is missing in type '{ anotherX: string; }' but required in type 'AnotherOpts'. ++!!! related TS2728 0.js:20:14: 'anotherY' is declared here. ++ ++ /** ++ * @typedef {object} Opts1 ++ * @property {string} x ++ * @property {string=} y ++ * @property {string} [z] ++ * @property {string} [w="hi"] ++ * ++ * @param {Opts1} opts ++ */ ++ function foo2(opts) { ++ opts.x; ++ } ++ foo2({x: 'abc'}); ++ ~~~~~~~~~~ ++!!! error TS2739: Type '{ x: string; }' is missing the following properties from type 'Opts1': y, z, w ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.types.diff index 652317c001..3bc5d459e0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.types.diff @@ -1,76 +1,38 @@ --- old.checkJsdocTypedefInParamTag1.types +++ new.checkJsdocTypedefInParamTag1.types -@@= skipped -11, +11 lines =@@ - * @param {Opts} opts - */ - function foo(opts) { -->foo : (opts: Opts) => void -->opts : Opts -+>foo : (opts: any) => void -+>opts : any +@@= skipped -15, +15 lines =@@ + >opts : Opts opts.x; ->opts.x : string -->opts : Opts -->x : string +>opts.x : any -+>opts : any + >opts : Opts +->x : string +>x : any } foo({x: 'abc'}); - >foo({x: 'abc'}) : void -->foo : (opts: Opts) => void -+>foo : (opts: any) => void - >{x: 'abc'} : { x: string; } - >x : string - >'abc' : "abc" @@= skipped -24, +24 lines =@@ - * @param {AnotherOpts} opts - */ - function foo1(opts) { -->foo1 : (opts: AnotherOpts) => void -->opts : AnotherOpts -+>foo1 : (opts: any) => void -+>opts : any + >opts : AnotherOpts opts.anotherX; ->opts.anotherX : string -->opts : AnotherOpts -->anotherX : string +>opts.anotherX : any -+>opts : any + >opts : AnotherOpts +->anotherX : string +>anotherX : any } foo1({anotherX: "world"}); - >foo1({anotherX: "world"}) : void -->foo1 : (opts: AnotherOpts) => void -+>foo1 : (opts: any) => void - >{anotherX: "world"} : { anotherX: string; } - >anotherX : string - >"world" : "world" @@= skipped -26, +26 lines =@@ - * @param {Opts1} opts - */ - function foo2(opts) { -->foo2 : (opts: Opts1) => void -->opts : Opts1 -+>foo2 : (opts: any) => void -+>opts : any + >opts : Opts1 opts.x; ->opts.x : string -->opts : Opts1 -->x : string +>opts.x : any -+>opts : any + >opts : Opts1 +->x : string +>x : any } foo2({x: 'abc'}); >foo2({x: 'abc'}) : void -->foo2 : (opts: Opts1) => void -+>foo2 : (opts: any) => void - >{x: 'abc'} : { x: string; } - >x : string - >'abc' : "abc" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff index 948387c255..363f19a91b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff @@ -2,11 +2,20 @@ +++ new.checkJsdocTypedefOnlySourceFile.errors.txt @@= skipped -0, +0 lines =@@ -0.js(10,20): error TS2694: Namespace 'exports' has no exported member 'SomeName'. ++0.js(3,5): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. +0.js(8,9): error TS2339: Property 'SomeName' does not exist on type '{}'. ++0.js(10,12): error TS2503: Cannot find namespace 'exports'. - ==== 0.js (1 errors) ==== -@@= skipped -9, +9 lines =@@ +-==== 0.js (1 errors) ==== ++==== 0.js (3 errors) ==== + // @ts-check + + var exports = {}; ++ ~~~~~~~ ++!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. + + /** * @typedef {string} */ exports.SomeName; @@ -16,5 +25,7 @@ /** @type {exports.SomeName} */ - ~~~~~~~~ -!!! error TS2694: Namespace 'exports' has no exported member 'SomeName'. ++ ~~~~~~~ ++!!! error TS2503: Cannot find namespace 'exports'. const myString = 'str'; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.types.diff index 5082a1d261..20dfc9c055 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.types.diff @@ -5,6 +5,6 @@ /** @type {exports.SomeName} */ const myString = 'str'; ->myString : exports.SomeName -+>myString : "str" ++>myString : SomeName >'str' : "str" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff index ca5f8336d5..9788eb2be5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff @@ -1,12 +1,13 @@ --- old.checkSpecialPropertyAssignments.errors.txt +++ new.checkSpecialPropertyAssignments.errors.txt @@= skipped -0, +0 lines =@@ --bug24252.js(8,9): error TS2322: Type 'string[]' is not assignable to type 'number[]'. -- Type 'string' is not assignable to type 'number'. +bug24252.js(2,3): error TS2339: Property 'B' does not exist on type '{}'. + bug24252.js(8,9): error TS2322: Type 'string[]' is not assignable to type 'number[]'. + Type 'string' is not assignable to type 'number'. - ==== bug24252.js (1 errors) ==== +-==== bug24252.js (1 errors) ==== ++==== bug24252.js (2 errors) ==== var A = {}; A.B = class { + ~ @@ -14,12 +15,3 @@ m() { /** @type {string[]} */ var x = []; - /** @type {number[]} */ - var y; - y = x; -- ~ --!!! error TS2322: Type 'string[]' is not assignable to type 'number[]'. --!!! error TS2322: Type 'string' is not assignable to type 'number'. - } - }; - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.types.diff index 5bac2a6a22..e6cc8deaaa 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.types.diff @@ -19,26 +19,3 @@ >class { m() { /** @type {string[]} */ var x = []; /** @type {number[]} */ var y; y = x; }} : typeof B m() { -@@= skipped -15, +15 lines =@@ - - /** @type {string[]} */ - var x = []; -->x : string[] -+>x : any[] - >[] : undefined[] - - /** @type {number[]} */ - var y; -->y : number[] -+>y : any - - y = x; -->y = x : string[] -->y : number[] -->x : string[] -+>y = x : any[] -+>y : any -+>x : any[] - } - }; - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff index 183cf7367f..f31a7d73d3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff @@ -5,14 +5,15 @@ -first.js(31,5): error TS2416: Property 'load' in type 'Sql' is not assignable to the same property in base type 'Wagon'. - Type '(files: string[], format: "csv" | "json" | "xmlolololol") => void' is not assignable to type '(supplies?: any[]) => void'. - Target signature provides too few arguments. Expected 2 or more, but got 1. -+first.js(21,19): error TS2507: Type '{ (numberOxen: any): void; circle: (wagons: any) => any; }' is not a constructor function type. ++first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. +first.js(24,14): error TS2339: Property 'foonly' does not exist on type 'Sql'. ++first.js(27,21): error TS8020: JSDoc types can only be used inside documentation comments. +first.js(44,4): error TS2339: Property 'numberOxen' does not exist on type 'Sql'. +first.js(44,20): error TS2339: Property 'foonly' does not exist on type 'Sql'. first.js(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. -generic.js(19,19): error TS2554: Expected 1 arguments, but got 0. -generic.js(20,32): error TS2345: Argument of type 'number' is not assignable to parameter of type '{ claim: "ignorant" | "malicious"; }'. -+generic.js(9,23): error TS2507: Type '(flavour: any) => void' is not a constructor function type. ++generic.js(9,23): error TS2507: Type '(flavour: T) => void' is not a constructor function type. +generic.js(11,21): error TS2339: Property 'flavour' does not exist on type 'Chowder'. +generic.js(17,27): error TS2554: Expected 0 arguments, but got 1. +generic.js(18,9): error TS2339: Property 'flavour' does not exist on type 'Chowder'. @@ -25,21 +26,21 @@ - Type 'Wagon[]' is not assignable to type '(typeof Wagon)[]'. - Property 'circle' is missing in type 'Wagon' but required in type 'typeof Wagon'. -second.ts(17,15): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -+second.ts(14,25): error TS2507: Type '{ (numberOxen: any): void; circle: (wagons: any) => any; }' is not a constructor function type. ++second.ts(14,25): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. +second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== first.js (3 errors) ==== -+==== first.js (5 errors) ==== ++==== first.js (6 errors) ==== /** * @constructor * @param {number} numberOxen -@@= skipped -36, +34 lines =@@ +@@= skipped -36, +35 lines =@@ } // ok class Sql extends Wagon { + ~~~~~ -+!!! error TS2507: Type '{ (numberOxen: any): void; circle: (wagons: any) => any; }' is not a constructor function type. ++!!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. constructor() { super(); // error: not enough arguments - ~~~~~ @@ -51,7 +52,9 @@ } /** * @param {Array.} files -@@= skipped -13, +14 lines =@@ ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. + * @param {"csv" | "json" | "xmlolololol"} format * This is not assignable, so should have a type error */ load(files, format) { @@ -62,7 +65,7 @@ if (format === "xmlolololol") { throw new Error("please do not use XML. It was a joke."); } -@@= skipped -17, +13 lines =@@ +@@= skipped -30, +29 lines =@@ } var db = new Sql(); db.numberOxen = db.foonly @@ -86,7 +89,7 @@ -!!! error TS2417: Property 'circle' is missing in type 'Wagon' but required in type 'typeof Wagon'. -!!! related TS2728 first.js:9:1: 'circle' is declared here. + ~~~~~ -+!!! error TS2507: Type '{ (numberOxen: any): void; circle: (wagons: any) => any; }' is not a constructor function type. ++!!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. constructor(public drunkOO: true) { // error: wrong type super('nope'); @@ -112,7 +115,7 @@ /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { + ~~~~ -+!!! error TS2507: Type '(flavour: any) => void' is not a constructor function type. ++!!! error TS2507: Type '(flavour: T) => void' is not a constructor function type. log() { return this.flavour + ~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.types.diff index 8be3b12163..aacabb3616 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.types.diff @@ -5,19 +5,16 @@ */ function Wagon(numberOxen) { ->Wagon : typeof Wagon -->numberOxen : number -+>Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } -+>numberOxen : any ++>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } + >numberOxen : number this.numberOxen = numberOxen -->this.numberOxen = numberOxen : number -+>this.numberOxen = numberOxen : any + >this.numberOxen = numberOxen : number >this.numberOxen : any ->this : this +>this : any >numberOxen : any -->numberOxen : number -+>numberOxen : any + >numberOxen : number } /** @param {Wagon[]=} wagons */ Wagon.circle = function (wagons) { @@ -29,7 +26,7 @@ ->wagons : Wagon[] +>Wagon.circle = function (wagons) { return wagons ? wagons.length : 3.14;} : (wagons: any) => any +>Wagon.circle : (wagons: any) => any -+>Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } ++>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } +>circle : (wagons: any) => any +>function (wagons) { return wagons ? wagons.length : 3.14;} : (wagons: any) => any +>wagons : any @@ -54,7 +51,7 @@ >Wagon.prototype.load : any >Wagon.prototype : any ->Wagon : typeof Wagon -+>Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } ++>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } >prototype : any >load : any ->function (supplies) {} : (supplies?: any[] | undefined) => void @@ -69,7 +66,7 @@ >Wagon.prototype.weight : any >Wagon.prototype : any ->Wagon : typeof Wagon -+>Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } ++>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } >prototype : any >weight : any ->supplies => supplies ? supplies.length : -1 : (supplies?: any[] | undefined) => number @@ -94,7 +91,7 @@ >Wagon.prototype.speed : any >Wagon.prototype : any ->Wagon : typeof Wagon -+>Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } ++>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } >prototype : any >speed : any >function () { return this.numberOxen / this.weight()} : () => number @@ -120,7 +117,7 @@ class Sql extends Wagon { >Sql : Sql ->Wagon : Wagon -+>Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } ++>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } constructor() { super(); // error: not enough arguments @@ -135,19 +132,10 @@ */ load(files, format) { ->load : (files: Array, format: "csv" | "json" | "xmlolololol") => void -->files : string[] -->format : "csv" | "json" | "xmlolololol" -+>load : (files: any, format: any) => void -+>files : any -+>format : any ++>load : (files: string[], format: "csv" | "json" | "xmlolololol") => void + >files : string[] + >format : "csv" | "json" | "xmlolololol" - if (format === "xmlolololol") { - >format === "xmlolololol" : boolean -->format : "csv" | "json" | "xmlolololol" -+>format : any - >"xmlolololol" : "xmlolololol" - - throw new Error("please do not use XML. It was a joke."); @@= skipped -16, +16 lines =@@ } else { @@ -198,7 +186,7 @@ class Conestoga extends Wagon { >Conestoga : Conestoga ->Wagon : Wagon -+>Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } ++>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } constructor(public drunkOO: true) { >drunkOO : true @@ -215,14 +203,14 @@ ->circle : (others: (typeof Wagon)[]) => number ->others : (typeof Wagon)[] ->Wagon : typeof Wagon -+>circle : (others: { (numberOxen: any): void; circle: (wagons: any) => any; }[]) => number -+>others : { (numberOxen: any): void; circle: (wagons: any) => any; }[] -+>Wagon : { (numberOxen: any): void; circle: (wagons: any) => any; } ++>circle : (others: { (numberOxen: number): void; circle: (wagons: any) => any; }[]) => number ++>others : { (numberOxen: number): void; circle: (wagons: any) => any; }[] ++>Wagon : { (numberOxen: number): void; circle: (wagons: any) => any; } return others.length >others.length : number ->others : (typeof Wagon)[] -+>others : { (numberOxen: any): void; circle: (wagons: any) => any; }[] ++>others : { (numberOxen: number): void; circle: (wagons: any) => any; }[] >length : number } } @@ -243,25 +231,22 @@ */ function Soup(flavour) { ->Soup : typeof Soup -->flavour : T -+>Soup : (flavour: any) => void -+>flavour : any ++>Soup : (flavour: T) => void + >flavour : T this.flavour = flavour -->this.flavour = flavour : T -+>this.flavour = flavour : any + >this.flavour = flavour : T >this.flavour : any ->this : this +>this : any >flavour : any -->flavour : T -+>flavour : any + >flavour : T } /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { >Chowder : Chowder ->Soup : Soup<{ claim: "ignorant" | "malicious"; }> -+>Soup : (flavour: any) => void ++>Soup : (flavour: T) => void log() { ->log : () => { claim: "ignorant" | "malicious"; } @@ -282,7 +267,7 @@ ->Soup : typeof Soup +>soup : any +>new Soup(1) : any -+>Soup : (flavour: any) => void ++>Soup : (flavour: T) => void >1 : 1 soup.flavour diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.types.diff index f70259cdcd..9e2d6a0d55 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.types.diff @@ -11,16 +11,12 @@ >require : any >'./commonJSAliasedExport' : "./commonJSAliasedExport" - /** @type {boolean} */ - var diddy -->diddy : boolean -+>diddy : any +@@= skipped -11, +11 lines =@@ var diddy = funky(1) -->diddy : boolean + >diddy : boolean ->funky(1) : boolean ->funky : (declaration: any) => boolean -+>diddy : any +>funky(1) : any +>funky : any >1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff index b612cb10b5..d2f2ce6611 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff @@ -5,7 +5,7 @@ @@= skipped --1, +1 lines =@@ +main.js(1,9): error TS2451: Cannot redeclare block-scoped variable 'K'. +main.js(1,15): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+main.js(3,12): error TS7006: Parameter 'k' implicitly has an 'any' type. ++main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? +mod1.js(1,7): error TS2451: Cannot redeclare block-scoped variable 'K'. +mod1.js(6,1): error TS2304: Cannot find name 'exports'. + @@ -18,9 +18,9 @@ + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + /** @param {K} k */ ++ ~ ++!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? + function f(k) { -+ ~ -+!!! error TS7006: Parameter 'k' implicitly has an 'any' type. + k.values() + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.types.diff index 6155c712b1..74df8199ac 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.types.diff @@ -11,26 +11,21 @@ >require : any >"./mod1" : "./mod1" - /** @param {K} k */ - function f(k) { -->f : (k: K) => void -->k : K -+>f : (k: any) => void -+>k : any +@@= skipped -11, +11 lines =@@ + >k : K k.values() ->k.values() : K ->k.values : () => K -->k : K -->values : () => K +>k.values() : any +>k.values : any -+>k : any + >k : K +->values : () => K +>values : any } === mod1.js === -@@= skipped -22, +22 lines =@@ +@@= skipped -11, +11 lines =@@ >K : K values() { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.errors.txt.diff index f68ab74193..bf8c296755 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.errors.txt.diff @@ -4,7 +4,7 @@ - @@= skipped --1, +1 lines =@@ +main.js(1,15): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+main.js(3,12): error TS7006: Parameter 'k' implicitly has an 'any' type. ++main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? +mod1.js(1,1): error TS2304: Cannot find name 'exports'. + + @@ -13,9 +13,9 @@ + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + /** @param {K} k */ ++ ~ ++!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? + function f(k) { -+ ~ -+!!! error TS7006: Parameter 'k' implicitly has an 'any' type. + k.values() + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.types.diff index 5b5f42d6b2..48f2524416 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.types.diff @@ -11,21 +11,16 @@ >require : any >"./mod1" : "./mod1" - /** @param {K} k */ - function f(k) { -->f : (k: K) => void -->k : K -+>f : (k: any) => void -+>k : any +@@= skipped -11, +11 lines =@@ + >k : K k.values() ->k.values() : void ->k.values : () => void -->k : K -->values : () => void +>k.values() : any +>k.values : any -+>k : any + >k : K +->values : () => void +>values : any } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff index 0503956afc..89b004e1e7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff @@ -4,7 +4,7 @@ - @@= skipped --1, +1 lines =@@ +main.js(1,15): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+main.js(3,12): error TS7006: Parameter 'k' implicitly has an 'any' type. ++main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? +mod1.js(2,4): error TS2339: Property 'K' does not exist on type '{}'. +mod1.js(4,23): error TS2339: Property 'K' does not exist on type '{}'. +mod1.js(7,1): error TS2304: Cannot find name 'exports'. @@ -16,9 +16,9 @@ + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + /** @param {K} k */ ++ ~ ++!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? + function f(k) { -+ ~ -+!!! error TS7006: Parameter 'k' implicitly has an 'any' type. + k.values() + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.types.diff index 0cf1fd6601..448c40f37d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.types.diff @@ -11,21 +11,16 @@ >require : any >"./mod1" : "./mod1" - /** @param {K} k */ - function f(k) { -->f : (k: K) => void -->k : K -+>f : (k: any) => void -+>k : any +@@= skipped -11, +11 lines =@@ + >k : K k.values() ->k.values() : K ->k.values : () => K -->k : K -->values : () => K +>k.values() : any +>k.values : any -+>k : any + >k : K +->values : () => K +>values : any } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff new file mode 100644 index 0000000000..87f9c60ace --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff @@ -0,0 +1,48 @@ +--- old.constructorFunctionMethodTypeParameters.errors.txt ++++ new.constructorFunctionMethodTypeParameters.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++constructorFunctionMethodTypeParameters.js(22,16): error TS2304: Cannot find name 'T'. ++constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find name 'T'. ++ ++ ++==== constructorFunctionMethodTypeParameters.js (2 errors) ==== ++ /** ++ * @template {string} T ++ * @param {T} t ++ */ ++ function Cls(t) { ++ this.t = t; ++ } ++ ++ /** ++ * @template {string} V ++ * @param {T} t ++ * @param {V} v ++ * @return {V} ++ */ ++ Cls.prototype.topLevelComment = function (t, v) { ++ return v ++ }; ++ ++ Cls.prototype.nestedComment = ++ /** ++ * @template {string} U ++ * @param {T} t ++ ~ ++!!! error TS2304: Cannot find name 'T'. ++ * @param {U} u ++ * @return {T} ++ ~ ++!!! error TS2304: Cannot find name 'T'. ++ */ ++ function (t, u) { ++ return t ++ }; ++ ++ var c = new Cls('a'); ++ const s = c.topLevelComment('a', 'b'); ++ const t = c.nestedComment('a', 'b'); ++ ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.types.diff index 7101e98afa..ab018ef8ed 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.types.diff @@ -5,22 +5,17 @@ */ function Cls(t) { ->Cls : typeof Cls -->t : T -+>Cls : (t: any) => void -+>t : any ++>Cls : (t: T) => void + >t : T this.t = t; -->this.t = t : T -+>this.t = t : any + >this.t = t : T >this.t : any ->this : this +>this : any >t : any -->t : T -+>t : any + >t : T } - - /** @@= skipped -18, +18 lines =@@ * @return {V} */ @@ -30,7 +25,7 @@ >Cls.prototype.topLevelComment : any >Cls.prototype : any ->Cls : typeof Cls -+>Cls : (t: any) => void ++>Cls : (t: T) => void >prototype : any >topLevelComment : any ->function (t, v) { return v} : (t: T, v: V) => V @@ -46,31 +41,16 @@ }; - Cls.prototype.nestedComment = -->Cls.prototype.nestedComment = /** * @template {string} U * @param {T} t * @param {U} u * @return {T} */ function (t, u) { return t } : (t: T, u: U) => T -+>Cls.prototype.nestedComment = /** * @template {string} U * @param {T} t * @param {U} u * @return {T} */ function (t, u) { return t } : (t: any, u: any) => any +@@= skipped -19, +19 lines =@@ + >Cls.prototype.nestedComment = /** * @template {string} U * @param {T} t * @param {U} u * @return {T} */ function (t, u) { return t } : (t: T, u: U) => T >Cls.prototype.nestedComment : any >Cls.prototype : any ->Cls : typeof Cls -+>Cls : (t: any) => void ++>Cls : (t: T) => void >prototype : any >nestedComment : any -@@= skipped -30, +30 lines =@@ - * @return {T} - */ - function (t, u) { -->function (t, u) { return t } : (t: T, u: U) => T -->t : T -->u : U -+>function (t, u) { return t } : (t: any, u: any) => any -+>t : any -+>u : any - - return t -->t : T -+>t : any - +@@= skipped -21, +21 lines =@@ }; var c = new Cls('a'); @@ -79,7 +59,7 @@ ->Cls : typeof Cls +>c : any +>new Cls('a') : any -+>Cls : (t: any) => void ++>Cls : (t: T) => void >'a' : "a" const s = c.topLevelComment('a', 'b'); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.types.diff index 14a2f876d1..577ee0bbf4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.types.diff @@ -211,9 +211,8 @@ */ function C7(num) {} ->C7 : typeof C7 -->num : number -+>C7 : (num: any) => void -+>num : any ++>C7 : (num: number) => void + >num : number var c7_v1 = new C7(); ->c7_v1 : C7 @@ -221,5 +220,5 @@ ->C7 : typeof C7 +>c7_v1 : any +>new C7() : any -+>C7 : (num: any) => void ++>C7 : (num: number) => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff index 466a2b3581..b3511b4a8d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff @@ -2,22 +2,17 @@ +++ new.constructorFunctionsStrict.errors.txt @@= skipped -0, +0 lines =@@ -a.js(9,1): error TS2322: Type 'undefined' is not assignable to type 'number'. -+a.js(2,12): error TS7006: Parameter 'x' implicitly has an 'any' type. +a.js(8,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -+a.js(13,12): error TS7006: Parameter 'x' implicitly has an 'any' type. +a.js(15,16): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. +a.js(20,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -==== a.js (1 errors) ==== -+==== a.js (5 errors) ==== ++==== a.js (3 errors) ==== /** @param {number} x */ function C(x) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. this.x = x - } - C.prototype.m = function() { +@@= skipped -9, +11 lines =@@ this.y = 12 } var c = new C(1) @@ -30,8 +25,6 @@ /** @param {number} x */ function A(x) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. if (!(this instanceof A)) { return new A(x) + ~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.types.diff index 8061bff2b9..a65cbad88e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.types.diff @@ -5,26 +5,23 @@ /** @param {number} x */ function C(x) { ->C : typeof C -->x : number -+>C : (x: any) => void -+>x : any ++>C : (x: number) => void + >x : number this.x = x -->this.x = x : number -+>this.x = x : any + >this.x = x : number >this.x : any ->this : this +>this : any >x : any -->x : number -+>x : any + >x : number } - C.prototype.m = function() { +@@= skipped -14, +14 lines =@@ >C.prototype.m = function() { this.y = 12} : () => void >C.prototype.m : any >C.prototype : any ->C : typeof C -+>C : (x: any) => void ++>C : (x: number) => void >prototype : any >m : any >function() { this.y = 12} : () => void @@ -45,7 +42,7 @@ ->C : typeof C +>c : any +>new C(1) : any -+>C : (x: any) => void ++>C : (x: number) => void >1 : 1 c.x = undefined // should error @@ -71,9 +68,8 @@ /** @param {number} x */ function A(x) { ->A : typeof A -->x : number -+>A : (x: any) => any -+>x : any ++>A : (x: number) => any + >x : number if (!(this instanceof A)) { >!(this instanceof A) : boolean @@ -82,25 +78,22 @@ ->this : this ->A : typeof A +>this : any -+>A : (x: any) => any ++>A : (x: number) => any return new A(x) ->new A(x) : A ->A : typeof A -->x : number +>new A(x) : any -+>A : (x: any) => any -+>x : any ++>A : (x: number) => any + >x : number } this.x = x -->this.x = x : number -+>this.x = x : any + >this.x = x : number >this.x : any ->this : this +>this : any >x : any -->x : number -+>x : any + >x : number } var k = A(1) ->k : A @@ -108,7 +101,7 @@ ->A : typeof A +>k : any +>A(1) : any -+>A : (x: any) => any ++>A : (x: number) => any >1 : 1 var j = new A(2) @@ -117,7 +110,7 @@ ->A : typeof A +>j : any +>new A(2) : any -+>A : (x: any) => any ++>A : (x: number) => any >2 : 2 k.x === j.x diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.types.diff index 3e2b213111..4dbe891295 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.types.diff @@ -1,81 +1,11 @@ --- old.contextualTypeFromJSDoc.types +++ new.contextualTypeFromJSDoc.types -@@= skipped -2, +2 lines =@@ - === index.js === - /** @type {Array<[string, {x?:number, y?:number}]>} */ - const arr = [ -->arr : [string, { x?: number; y?: number; }][] -->[ ['a', { x: 1 }], ['b', { y: 2 }]] : ([string, { x: number; }] | [string, { y: number; }])[] -+>arr : ((string | { x: number; })[] | (string | { y: number; })[])[] -+>[ ['a', { x: 1 }], ['b', { y: 2 }]] : ((string | { x: number; })[] | (string | { y: number; })[])[] - - ['a', { x: 1 }], -->['a', { x: 1 }] : [string, { x: number; }] -+>['a', { x: 1 }] : (string | { x: number; })[] - >'a' : "a" - >{ x: 1 } : { x: number; } - >x : number - >1 : 1 - - ['b', { y: 2 }] -->['b', { y: 2 }] : [string, { y: number; }] -+>['b', { y: 2 }] : (string | { y: number; })[] - >'b' : "b" - >{ y: 2 } : { y: number; } - >y : number -@@= skipped -21, +21 lines =@@ +@@= skipped -23, +23 lines =@@ /** @return {Array<[string, {x?:number, y?:number}]>} */ function f() { ->f : () => Array<[string, { x?: number; y?: number; }]> -+>f : () => ((string | { x: number; })[] | (string | { y: number; })[])[] ++>f : () => [string, { x?: number; y?: number; }][] return [ -->[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ([string, { x: number; }] | [string, { y: number; }])[] -+>[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ((string | { x: number; })[] | (string | { y: number; })[])[] - - ['a', { x: 1 }], -->['a', { x: 1 }] : [string, { x: number; }] -+>['a', { x: 1 }] : (string | { x: number; })[] - >'a' : "a" - >{ x: 1 } : { x: number; } - >x : number - >1 : 1 - - ['b', { y: 2 }] -->['b', { y: 2 }] : [string, { y: number; }] -+>['b', { y: 2 }] : (string | { y: number; })[] - >'b' : "b" - >{ y: 2 } : { y: number; } - >y : number -@@= skipped -27, +27 lines =@@ - - /** @param {Array<[string, {x?:number, y?:number}]>} value */ - set x(value) { } -->x : [string, { x?: number; y?: number; }][] -->value : [string, { x?: number; y?: number; }][] -+>x : ((string | { x: number; })[] | (string | { y: number; })[])[] -+>value : ((string | { x: number; })[] | (string | { y: number; })[])[] - - get x() { -->x : [string, { x?: number; y?: number; }][] -+>x : ((string | { x: number; })[] | (string | { y: number; })[])[] - - return [ -->[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ([string, { x: number; }] | [string, { y: number; }])[] -+>[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ((string | { x: number; })[] | (string | { y: number; })[])[] - - ['a', { x: 1 }], -->['a', { x: 1 }] : [string, { x: number; }] -+>['a', { x: 1 }] : (string | { x: number; })[] - >'a' : "a" - >{ x: 1 } : { x: number; } - >x : number - >1 : 1 - - ['b', { y: 2 }] -->['b', { y: 2 }] : [string, { y: number; }] -+>['b', { y: 2 }] : (string | { y: number; })[] - >'b' : "b" - >{ y: 2 } : { y: number; } - >y : number + >[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ([string, { x: number; }] | [string, { y: number; }])[] diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff index 5334a1f85a..62b9f20755 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff @@ -3,11 +3,15 @@ @@= skipped -0, +0 lines =@@ -a.js(6,5): error TS2322: Type 'number' is not assignable to type 'string'. -a.js(12,5): error TS2322: Type 'string' is not assignable to type 'number'. ++a.js(24,13): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? ++a.js(25,12): error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? ++a.js(26,12): error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? ++a.js(35,16): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? a.js(37,16): error TS2339: Property 'UNKNOWN' does not exist on type '{ START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; }'. -==== a.js (3 errors) ==== -+==== a.js (1 errors) ==== ++==== a.js (5 errors) ==== /** @enum {string} */ const Target = { START: "start", @@ -27,3 +31,27 @@ OK: 1, /** @type {number} */ FINE: 2, +@@= skipped -31, +29 lines =@@ + } + + /** @param {Target} t ++ ~~~~~~ ++!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? + * @param {Second} s ++ ~~~~~~ ++!!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? + * @param {Fs} f ++ ~~ ++!!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? + */ + function consume(t,s,f) { + /** @type {string} */ +@@= skipped -11, +17 lines =@@ + /** @type {(n: number) => number} */ + var fun = f + /** @type {Target} */ ++ ~~~~~~ ++!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? + var v = Target.START + v = Target.UNKNOWN // error, can't find 'UNKNOWN' + ~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.types.diff index 936529296d..936126cc00 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.types.diff @@ -1,66 +1,75 @@ --- old.enumTag.types +++ new.enumTag.types -@@= skipped -77, +77 lines =@@ - * @param {Fs} f +@@= 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 =@@ */ function consume(t,s,f) { -->consume : (t: Target, s: Second, f: Fs) => void + >consume : (t: Target, s: Second, f: Fs) => void ->t : string ->s : number -->f : Fs -+>consume : (t: any, s: any, f: any) => void -+>t : any -+>s : any -+>f : any ++>t : Target ++>s : Second + >f : Fs /** @type {string} */ var str = t -->str : string + >str : string ->t : string -+>str : any -+>t : any ++>t : Target /** @type {number} */ var num = s -->num : number + >num : number ->s : number -+>num : any -+>s : any ++>s : Second /** @type {(n: number) => number} */ var fun = f -->fun : (n: number) => number -->f : Fs -+>fun : any -+>f : any +@@= skipped -21, +21 lines =@@ /** @type {Target} */ var v = Target.START -@@= skipped -48, +48 lines =@@ - } - /** @param {string} s */ - function ff(s) { -->ff : (s: string) => any -->s : string -+>ff : (s: any) => any -+>s : any - - // element access with arbitrary string is an error only with noImplicitAny - if (!Target[s]) { - >!Target[s] : boolean - >Target[s] : any +->v : string ++>v : Target + >Target.START : string >Target : { START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; } -->s : string -+>s : any + >START : string - return null - } -@@= skipped -16, +16 lines =@@ - return Target[s] - >Target[s] : any + v = Target.UNKNOWN // error, can't find 'UNKNOWN' + >v = Target.UNKNOWN : any +->v : string ++>v : Target + >Target.UNKNOWN : any >Target : { START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; } -->s : string -+>s : any - } - } + >UNKNOWN : any + + v = Second.MISTAKE // meh..ok, I guess? + >v = Second.MISTAKE : string +->v : string ++>v : Target + >Second.MISTAKE : string + >Second : { MISTAKE: string; OK: number; FINE: number; } + >MISTAKE : string + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums + >v = 'something else' : "something else" +->v : string ++>v : Target + >'something else' : "something else" + } + /** @param {string} s */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff new file mode 100644 index 0000000000..5d55a947a0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff @@ -0,0 +1,36 @@ +--- old.enumTagImported.errors.txt ++++ new.enumTagImported.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++type.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. ++type.js(4,29): error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. ++value.js(2,12): error TS2749: 'TestEnum' refers to a value, but is being used as a type here. Did you mean 'typeof TestEnum'? ++ ++ ++==== type.js (2 errors) ==== ++ /** @typedef {import("./mod1").TestEnum} TE */ ++ ~~~~~~~~ ++!!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. ++ /** @type {TE} */ ++ const test = 'add' ++ /** @type {import("./mod1").TestEnum} */ ++ ~~~~~~~~ ++!!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. ++ const tost = 'remove' ++ ++==== value.js (1 errors) ==== ++ import { TestEnum } from "./mod1" ++ /** @type {TestEnum} */ ++ ~~~~~~~~ ++!!! error TS2749: 'TestEnum' refers to a value, but is being used as a type here. Did you mean 'typeof TestEnum'? ++ const tist = TestEnum.ADD ++ ++ ++==== mod1.js (0 errors) ==== ++ /** @enum {string} */ ++ export const TestEnum = { ++ ADD: 'add', ++ REMOVE: 'remove' ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.types.diff index 7dc569295f..005b72b658 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.types.diff @@ -5,13 +5,22 @@ /** @type {TE} */ const test = 'add' ->test : string -+>test : "add" ++>test : any >'add' : "add" /** @type {import("./mod1").TestEnum} */ const tost = 'remove' ->tost : string -+>tost : "remove" ++>tost : any >'remove' : "remove" === value.js === +@@= skipped -14, +14 lines =@@ + + /** @type {TestEnum} */ + const tist = TestEnum.ADD +->tist : string ++>tist : TestEnum + >TestEnum.ADD : string + >TestEnum : { ADD: string; REMOVE: string; } + >ADD : string diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff new file mode 100644 index 0000000000..732a57f4c7 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.enumTagUseBeforeDefCrash.errors.txt ++++ new.enumTagUseBeforeDefCrash.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++bug27134.js(7,11): error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? ++ ++ ++==== bug27134.js (1 errors) ==== ++ /** ++ * @enum {number} ++ */ ++ var foo = { }; ++ ++ /** ++ * @type {foo} ++ ~~~ ++!!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? ++ */ ++ var s; ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.types.diff index 7469ec5e2f..7e3ef556d6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.types.diff @@ -5,5 +5,5 @@ */ var s; ->s : number -+>s : any ++>s : foo diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff index bf618fbdbf..a85247a036 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff @@ -1,6 +1,6 @@ --- old.errorOnFunctionReturnType.errors.txt +++ new.errorOnFunctionReturnType.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -foo.js(7,10): error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. -foo.js(11,12): error TS2705: An async function or method in ES5 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -foo.js(13,5): error TS2322: Type 'string' is not assignable to type 'number'. @@ -11,76 +11,78 @@ -foo.js(37,5): error TS2322: Type '"asd"' is not assignable to type 'never'. -foo.js(40,56): error TS2534: A function returning 'never' cannot have a reachable end point. -foo.js(45,18): error TS2534: A function returning 'never' cannot have a reachable end point. -- -- ++foo.js(20,12): error TS2304: Cannot find name 'FunctionReturningPromise'. ++foo.js(44,12): error TS2304: Cannot find name 'FunctionReturningNever'. + + -==== foo.js (10 errors) ==== -- /** -- * @callback FunctionReturningPromise -- * @returns {Promise} -- */ -- -- /** @type {FunctionReturningPromise} */ -- function testPromise1() { ++==== foo.js (2 errors) ==== + /** + * @callback FunctionReturningPromise + * @returns {Promise} +@@= skipped -17, +9 lines =@@ + + /** @type {FunctionReturningPromise} */ + function testPromise1() { - ~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. -- console.log("Nope"); -- } -- -- /** @type {FunctionReturningPromise} */ + console.log("Nope"); + } + + /** @type {FunctionReturningPromise} */ - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2705: An async function or method in ES5 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -- async function testPromise2() { -- return "asd"; + async function testPromise2() { + return "asd"; - ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. -- } -- -- var testPromise3 = /** @type {FunctionReturningPromise} */ function() { + } + + var testPromise3 = /** @type {FunctionReturningPromise} */ function() { - ~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. -- console.log("test") -- } -- -- /** @type {FunctionReturningPromise} */ -- var testPromise4 = function() { + console.log("test") + } + + /** @type {FunctionReturningPromise} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2304: Cannot find name 'FunctionReturningPromise'. + var testPromise4 = function() { - ~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. -- console.log("test") -- } -- -- /** -- * @callback FunctionReturningNever -- * @returns {never} -- */ -- -- /** @type {FunctionReturningNever} */ -- function testNever1() { + console.log("test") + } + +@@= skipped -34, +26 lines =@@ + + /** @type {FunctionReturningNever} */ + function testNever1() { - ~~~~~~~~~~ -!!! error TS2534: A function returning 'never' cannot have a reachable end point. -- -- } -- -- /** @type {FunctionReturningNever} */ + + } + + /** @type {FunctionReturningNever} */ - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1065: The return type of an async function or method must be the global Promise type. -!!! related TS1055 foo.js:27:14: Type 'never' is not a valid async function return type in ES5 because it does not refer to a Promise-compatible constructor value. -- async function testNever2() { -- return "asd"; + async function testNever2() { + return "asd"; - ~~~~~~ -!!! error TS2322: Type '"asd"' is not assignable to type 'never'. -- } -- -- var testNever3 = /** @type {FunctionReturningNever} */ function() { + } + + var testNever3 = /** @type {FunctionReturningNever} */ function() { - ~~~~~~~~ -!!! error TS2534: A function returning 'never' cannot have a reachable end point. -- console.log("test") -- } -- -- /** @type {FunctionReturningNever} */ -- var testNever4 = function() { + console.log("test") + } + + /** @type {FunctionReturningNever} */ ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2304: Cannot find name 'FunctionReturningNever'. + var testNever4 = function() { - ~~~~~~~~ -!!! error TS2534: A function returning 'never' cannot have a reachable end point. -- console.log("test") -- } -@@= skipped --1, +1 lines =@@ -+ + console.log("test") + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.types.diff index dd2a3b70df..13c5f7a1b6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.types.diff @@ -28,18 +28,16 @@ console.log("test") >console.log("test") : void -@@= skipped -20, +20 lines =@@ - +@@= skipped -21, +21 lines =@@ /** @type {FunctionReturningPromise} */ var testPromise4 = function() { -->testPromise4 : FunctionReturningPromise + >testPromise4 : FunctionReturningPromise ->function() { console.log("test")} : () => Promise -+>testPromise4 : () => void +>function() { console.log("test")} : () => void console.log("test") >console.log("test") : void -@@= skipped -18, +18 lines =@@ +@@= skipped -17, +17 lines =@@ /** @type {FunctionReturningNever} */ function testNever1() { @@ -65,13 +63,11 @@ console.log("test") >console.log("test") : void -@@= skipped -26, +26 lines =@@ - +@@= skipped -27, +27 lines =@@ /** @type {FunctionReturningNever} */ var testNever4 = function() { -->testNever4 : FunctionReturningNever + >testNever4 : FunctionReturningNever ->function() { console.log("test")} : () => never -+>testNever4 : () => void +>function() { console.log("test")} : () => void console.log("test") diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.types.diff index 5695e85f5e..ab20ffea84 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.types.diff @@ -97,18 +97,16 @@ @param {s.Classic} classic */ function f(c, classic) { ->f : (c: K, classic: s.Classic) => void -->c : K ++>f : (c: K, classic: Classic) => void + >c : K ->classic : s.Classic -+>f : (c: any, classic: any) => void -+>c : any -+>classic : any ++>classic : Classic c.x ->c.x : number -->c : K -->x : number +>c.x : any -+>c : any + >c : K +->x : number +>x : any classic.p @@ -116,7 +114,7 @@ ->classic : s.Classic ->p : number +>classic.p : any -+>classic : any ++>classic : Classic +>p : any } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff new file mode 100644 index 0000000000..a8138db37b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.exportedEnumTypeAndValue.errors.txt ++++ new.exportedEnumTypeAndValue.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++use.js(3,12): error TS2749: 'MyEnum' refers to a value, but is being used as a type here. Did you mean 'typeof MyEnum'? ++ ++ ++==== def.js (0 errors) ==== ++ /** @enum {number} */ ++ const MyEnum = { ++ a: 1, ++ b: 2 ++ }; ++ export default MyEnum; ++ ++==== use.js (1 errors) ==== ++ import MyEnum from "./def"; ++ ++ /** @type {MyEnum} */ ++ ~~~~~~ ++!!! error TS2749: 'MyEnum' refers to a value, but is being used as a type here. Did you mean 'typeof MyEnum'? ++ const v = MyEnum.b; ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.types.diff index 38f4bbc212..b829425316 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.types.diff @@ -9,3 +9,12 @@ === use.js === import MyEnum from "./def"; +@@= skipped -8, +8 lines =@@ + + /** @type {MyEnum} */ + const v = MyEnum.b; +->v : number ++>v : MyEnum + >MyEnum.b : number + >MyEnum : { a: number; b: number; } + >b : number diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.types.diff index 0fb9e89c63..4fadde1870 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.types.diff @@ -1,11 +1,9 @@ --- old.extendsTag1.types +++ new.extendsTag1.types -@@= skipped -5, +5 lines =@@ - * @extends {Set} Should prefer this Set, not the Set in the heritage clause +@@= skipped -6, +6 lines =@@ */ class My extends Set {} -->My : My + >My : My ->Set : Set -+>My : My +>Set : Set diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff index 536d568237..02e24c467a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff @@ -1,70 +1,62 @@ --- old.extendsTag5.errors.txt +++ new.extendsTag5.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -/a.js(29,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. - Types of property 'b' are incompatible. - Type 'string' is not assignable to type 'boolean | string[]'. -/a.js(42,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. - Types of property 'b' are incompatible. - Type 'string' is not assignable to type 'boolean | string[]'. -- -- ++/a.js(26,17): error TS2314: Generic type 'A' requires 1 type argument(s). ++/a.js(34,17): error TS2314: Generic type 'A' requires 1 type argument(s). ++/a.js(39,17): error TS2314: Generic type 'A' requires 1 type argument(s). ++/a.js(44,17): error TS2314: Generic type 'A' requires 1 type argument(s). + + -==== /a.js (2 errors) ==== -- /** -- * @typedef {{ -- * a: number | string; -- * b: boolean | string[]; -- * }} Foo -- */ -- -- /** -- * @template {Foo} T -- */ -- class A { -- /** -- * @param {T} a -- */ -- constructor(a) { -- return a -- } -- } -- -- /** -- * @extends {A<{ -- * a: string, -- * b: string[] -- * }>} -- */ -- class B extends A {} -- -- /** -- * @extends {A<{ ++==== /a.js (4 errors) ==== + /** + * @typedef {{ + * a: number | string; +@@= skipped -32, +30 lines =@@ + * }>} + */ + class B extends A {} ++ ~ ++!!! error TS2314: Generic type 'A' requires 1 type argument(s). + + /** + * @extends {A<{ - ~ -- * a: string, + * a: string, - ~~~~~~~~~~~~~~~~~ -- * b: string + * b: string - ~~~~~~~~~~~~~~~~ -- * }>} + * }>} - ~~~~ -!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. -!!! error TS2344: Types of property 'b' are incompatible. -!!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. -- */ -- class C extends A {} -- -- /** -- * @extends {A<{a: string, b: string[]}>} -- */ -- class D extends A {} -- -- /** -- * @extends {A<{a: string, b: string}>} + */ + class C extends A {} ++ ~ ++!!! error TS2314: Generic type 'A' requires 1 type argument(s). + + /** + * @extends {A<{a: string, b: string[]}>} + */ + class D extends A {} ++ ~ ++!!! error TS2314: Generic type 'A' requires 1 type argument(s). + + /** + * @extends {A<{a: string, b: string}>} - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. -!!! error TS2344: Types of property 'b' are incompatible. -!!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. -- */ -- class E extends A {} -- -@@= skipped --1, +1 lines =@@ -+ + */ + class E extends A {} ++ ~ ++!!! error TS2314: Generic type 'A' requires 1 type argument(s). + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.types.diff index 07ee706aa1..816f253a62 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.types.diff @@ -1,31 +1,11 @@ --- old.extendsTag5.types +++ new.extendsTag5.types -@@= skipped -11, +11 lines =@@ - * @template {Foo} T - */ - class A { -->A : A -+>A : A - - /** - * @param {T} a - */ - constructor(a) { -->a : T -+>a : any - - return a -->a : T -+>a : any - } - } - -@@= skipped -21, +21 lines =@@ +@@= skipped -32, +32 lines =@@ */ class B extends A {} >B : B ->A : A<{ a: string; b: string[]; }> -+>A : A ++>A : typeof A /** * @extends {A<{ @@ -34,7 +14,7 @@ class C extends A {} >C : C ->A : A<{ a: string; b: string; }> -+>A : A ++>A : typeof A /** * @extends {A<{a: string, b: string[]}>} @@ -42,7 +22,7 @@ class D extends A {} >D : D ->A : A<{ a: string; b: string[]; }> -+>A : A ++>A : typeof A /** * @extends {A<{a: string, b: string}>} @@ -50,5 +30,5 @@ class E extends A {} >E : E ->A : A<{ a: string; b: string; }> -+>A : A ++>A : typeof A diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.types.diff index 266cfe8dc9..40a70fe190 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.types.diff @@ -1,11 +1,7 @@ --- old.genericSetterInClassTypeJsDoc.types +++ new.genericSetterInClassTypeJsDoc.types -@@= skipped -4, +4 lines =@@ - * @template T - */ - class Box { -->Box : Box -+>Box : Box +@@= skipped -7, +7 lines =@@ + >Box : Box #value; ->#value : T @@ -13,17 +9,14 @@ /** @param {T} initialValue */ constructor(initialValue) { -->initialValue : T -+>initialValue : any +@@= skipped -8, +8 lines =@@ this.#value = initialValue; -->this.#value = initialValue : T + >this.#value = initialValue : T ->this.#value : T -+>this.#value = initialValue : any +>this.#value : any >this : this -->initialValue : T -+>initialValue : any + >initialValue : T } /** @type {T} */ @@ -57,9 +50,8 @@ new Box(3).value = 3; >new Box(3).value = 3 : 3 ->new Box(3).value : number -->new Box(3) : Box +>new Box(3).value : any -+>new Box(3) : Box + >new Box(3) : Box >Box : typeof Box >3 : 3 ->value : number diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.errors.txt.diff new file mode 100644 index 0000000000..045636af04 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.importTag1.errors.txt ++++ new.importTag1.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/foo.js(6,13): error TS2304: Cannot find name 'Foo'. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface Foo { ++ a: number; ++ } ++ ++==== /foo.js (1 errors) ==== ++ /** ++ * @import { Foo } from "./types" ++ */ ++ ++ /** ++ * @param { Foo } foo ++ ~~~ ++!!! error TS2304: Cannot find name 'Foo'. ++ */ ++ function f(foo) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.types.diff deleted file mode 100644 index 17fbfed2ff..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importTag1.types -+++ new.importTag1.types -@@= skipped -14, +14 lines =@@ - * @param { Foo } foo - */ - function f(foo) {} -->f : (foo: Foo) => void -->foo : Foo -+>f : (foo: any) => void -+>foo : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).errors.txt.diff index fe54c81fd5..619cb1400c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).errors.txt.diff @@ -1,23 +1,25 @@ --- old.importTag15(module=es2015).errors.txt +++ new.importTag15(module=es2015).errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -1.js(1,30): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. -1.js(2,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. -- -- --==== 0.ts (0 errors) ==== -- export interface I { } -- ++1.js(4,13): error TS2304: Cannot find name 'I'. + + + ==== 0.ts (0 errors) ==== + export interface I { } + -==== 1.js (2 errors) ==== -- /** @import { I } from './0' with { type: "json" } */ ++==== 1.js (1 errors) ==== + /** @import { I } from './0' with { type: "json" } */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. -- /** @import * as foo from './0' with { type: "json" } */ + /** @import * as foo from './0' with { type: "json" } */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. -- -- /** @param {I} a */ -- function f(a) {} -- -@@= skipped --1, +1 lines =@@ -+ + + /** @param {I} a */ ++ ~ ++!!! error TS2304: Cannot find name 'I'. + function f(a) {} + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).types.diff deleted file mode 100644 index d69c0efeac..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importTag15(module=es2015).types -+++ new.importTag15(module=es2015).types -@@= skipped -9, +9 lines =@@ - - /** @param {I} a */ - function f(a) {} -->f : (a: I) => void -->a : I -+>f : (a: any) => void -+>a : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).errors.txt.diff index 89c48b23da..3f390debf8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).errors.txt.diff @@ -1,23 +1,25 @@ --- old.importTag15(module=esnext).errors.txt +++ new.importTag15(module=esnext).errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -1.js(1,30): error TS2857: Import attributes cannot be used with type-only imports or exports. -1.js(2,33): error TS2857: Import attributes cannot be used with type-only imports or exports. -- -- --==== 0.ts (0 errors) ==== -- export interface I { } -- ++1.js(4,13): error TS2304: Cannot find name 'I'. + + + ==== 0.ts (0 errors) ==== + export interface I { } + -==== 1.js (2 errors) ==== -- /** @import { I } from './0' with { type: "json" } */ ++==== 1.js (1 errors) ==== + /** @import { I } from './0' with { type: "json" } */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2857: Import attributes cannot be used with type-only imports or exports. -- /** @import * as foo from './0' with { type: "json" } */ + /** @import * as foo from './0' with { type: "json" } */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2857: Import attributes cannot be used with type-only imports or exports. -- -- /** @param {I} a */ -- function f(a) {} -- -@@= skipped --1, +1 lines =@@ -+ + + /** @param {I} a */ ++ ~ ++!!! error TS2304: Cannot find name 'I'. + function f(a) {} + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).types.diff deleted file mode 100644 index d0ba8678b7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importTag15(module=esnext).types -+++ new.importTag15(module=esnext).types -@@= skipped -9, +9 lines =@@ - - /** @param {I} a */ - function f(a) {} -->f : (a: I) => void -->a : I -+>f : (a: any) => void -+>a : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.errors.txt.diff new file mode 100644 index 0000000000..a2ed8030b1 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.errors.txt.diff @@ -0,0 +1,26 @@ +--- old.importTag16.errors.txt ++++ new.importTag16.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++b.js(4,12): error TS2304: Cannot find name 'Foo'. ++b.js(5,12): error TS2304: Cannot find name 'I'. ++ ++ ++==== a.ts (0 errors) ==== ++ export default interface Foo {} ++ export interface I {} ++ ++==== b.js (2 errors) ==== ++ /** @import Foo, { I } from "./a" */ ++ ++ /** ++ * @param {Foo} a ++ ~~~ ++!!! error TS2304: Cannot find name 'Foo'. ++ * @param {I} b ++ ~ ++!!! error TS2304: Cannot find name 'I'. ++ */ ++ export function foo(a, b) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.types.diff deleted file mode 100644 index dc2234939f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.importTag16.types -+++ new.importTag16.types -@@= skipped -12, +12 lines =@@ - * @param {I} b - */ - export function foo(a, b) {} -->foo : (a: Foo, b: I) => void -->a : Foo -->b : I -+>foo : (a: any, b: any) => void -+>a : any -+>b : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff index ec2074c7cf..3dba612b3e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff @@ -1,49 +1,34 @@ --- old.importTag17.errors.txt +++ new.importTag17.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -/a.js(8,5): error TS2322: Type '1' is not assignable to type '"module"'. -/a.js(15,5): error TS2322: Type '1' is not assignable to type '"script"'. -- -- --==== /node_modules/@types/foo/package.json (0 errors) ==== -- { -- "name": "@types/foo", -- "version": "1.0.0", -- "exports": { -- ".": { -- "import": "./index.d.mts", -- "require": "./index.d.cts" -- } -- } -- } -- --==== /node_modules/@types/foo/index.d.mts (0 errors) ==== -- export declare const Import: "module"; -- --==== /node_modules/@types/foo/index.d.cts (0 errors) ==== -- export declare const Require: "script"; -- --==== /a.js (2 errors) ==== -- /** @import { Import } from 'foo' with { 'resolution-mode': 'import' } */ -- /** @import { Require } from 'foo' with { 'resolution-mode': 'require' } */ -- -- /** -- * @returns { Import } -- */ -- export function f1() { -- return 1; ++/a.js(5,15): error TS2304: Cannot find name 'Import'. ++/a.js(12,15): error TS2552: Cannot find name 'Require'. Did you mean 'Required'? + + + ==== /node_modules/@types/foo/package.json (0 errors) ==== +@@= skipped -25, +25 lines =@@ + + /** + * @returns { Import } ++ ~~~~~~ ++!!! error TS2304: Cannot find name 'Import'. + */ + export function f1() { + return 1; - ~~~~~~ -!!! error TS2322: Type '1' is not assignable to type '"module"'. -- } -- -- /** -- * @returns { Require } -- */ -- export function f2() { -- return 1; + } + + /** + * @returns { Require } ++ ~~~~~~~ ++!!! error TS2552: Cannot find name 'Require'. Did you mean 'Required'? + */ + export function f2() { + return 1; - ~~~~~~ -!!! error TS2322: Type '1' is not assignable to type '"script"'. -- } -- -@@= skipped --1, +1 lines =@@ -+ + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.types.diff index d2e7715edc..91ff3e5da5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.types.diff @@ -5,7 +5,7 @@ */ export function f1() { ->f1 : () => "module" -+>f1 : () => number ++>f1 : () => Import return 1; >1 : 1 @@ -14,7 +14,7 @@ */ export function f2() { ->f2 : () => "script" -+>f2 : () => number ++>f2 : () => Require return 1; >1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.errors.txt.diff new file mode 100644 index 0000000000..8895183edb --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.importTag18.errors.txt ++++ new.importTag18.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++b.js(8,12): error TS2304: Cannot find name 'Foo'. ++ ++ ++==== a.ts (0 errors) ==== ++ export interface Foo {} ++ ++==== b.js (1 errors) ==== ++ /** ++ * @import { ++ * Foo ++ * } from "./a" ++ */ ++ ++ /** ++ * @param {Foo} a ++ ~~~ ++!!! error TS2304: Cannot find name 'Foo'. ++ */ ++ export function foo(a) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.types.diff deleted file mode 100644 index c1977a12ed..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importTag18.types -+++ new.importTag18.types -@@= skipped -14, +14 lines =@@ - * @param {Foo} a - */ - export function foo(a) {} -->foo : (a: Foo) => void -->a : Foo -+>foo : (a: any) => void -+>a : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.errors.txt.diff new file mode 100644 index 0000000000..8839708644 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.importTag19.errors.txt ++++ new.importTag19.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++b.js(7,12): error TS2304: Cannot find name 'Foo'. ++ ++ ++==== a.ts (0 errors) ==== ++ export interface Foo {} ++ ++==== b.js (1 errors) ==== ++ /** ++ * @import { Foo } ++ * from "./a" ++ */ ++ ++ /** ++ * @param {Foo} a ++ ~~~ ++!!! error TS2304: Cannot find name 'Foo'. ++ */ ++ export function foo(a) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.types.diff deleted file mode 100644 index 86aa75f19c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importTag19.types -+++ new.importTag19.types -@@= skipped -13, +13 lines =@@ - * @param {Foo} a - */ - export function foo(a) {} -->foo : (a: Foo) => void -->a : Foo -+>foo : (a: any) => void -+>a : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.errors.txt.diff new file mode 100644 index 0000000000..68b2074596 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.importTag2.errors.txt ++++ new.importTag2.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/foo.js(6,13): error TS2503: Cannot find namespace 'types'. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface Foo { ++ a: number; ++ } ++ ++==== /foo.js (1 errors) ==== ++ /** ++ * @import * as types from "./types" ++ */ ++ ++ /** ++ * @param { types.Foo } foo ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'types'. ++ */ ++ export function f(foo) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.types.diff index 415341d645..1a2653c0a1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.types.diff @@ -6,6 +6,6 @@ export function f(foo) {} ->f : (foo: types.Foo) => void ->foo : types.Foo -+>f : (foo: any) => void -+>foo : any ++>f : (foo: Foo) => void ++>foo : Foo diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.errors.txt.diff new file mode 100644 index 0000000000..3001e176c7 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.importTag20.errors.txt ++++ new.importTag20.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++b.js(8,12): error TS2304: Cannot find name 'Foo'. ++ ++ ++==== a.ts (0 errors) ==== ++ export interface Foo {} ++ ++==== b.js (1 errors) ==== ++ /** ++ * @import ++ * { Foo ++ * } from './a' ++ */ ++ ++ /** ++ * @param {Foo} a ++ ~~~ ++!!! error TS2304: Cannot find name 'Foo'. ++ */ ++ export function foo(a) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.types.diff deleted file mode 100644 index 6d8880355f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importTag20.types -+++ new.importTag20.types -@@= skipped -14, +14 lines =@@ - * @param {Foo} a - */ - export function foo(a) {} -->foo : (a: Foo) => void -->a : Foo -+>foo : (a: any) => void -+>a : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff new file mode 100644 index 0000000000..31d34ac710 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.importTag3.errors.txt ++++ new.importTag3.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/foo.js(6,13): error TS2304: Cannot find name 'Foo'. ++ ++ ++==== /types.ts (0 errors) ==== ++ export default interface Foo { ++ a: number; ++ } ++ ++==== /foo.js (1 errors) ==== ++ /** ++ * @import Foo from "./types" ++ */ ++ ++ /** ++ * @param { Foo } foo ++ ~~~ ++!!! error TS2304: Cannot find name 'Foo'. ++ */ ++ export function f(foo) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.types.diff deleted file mode 100644 index d7bc1b030e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importTag3.types -+++ new.importTag3.types -@@= skipped -14, +14 lines =@@ - * @param { Foo } foo - */ - export function f(foo) {} -->f : (foo: Foo) => void -->foo : Foo -+>f : (foo: any) => void -+>foo : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff index 816497509b..8f00ca389e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff @@ -1,32 +1,34 @@ --- old.importTag4.errors.txt +++ new.importTag4.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -/foo.js(2,14): error TS2300: Duplicate identifier 'Foo'. -/foo.js(6,14): error TS2300: Duplicate identifier 'Foo'. -- -- --==== /types.ts (0 errors) ==== -- export interface Foo { -- a: number; -- } -- ++/foo.js(10,13): error TS2304: Cannot find name 'Foo'. + + + ==== /types.ts (0 errors) ==== +@@= skipped -6, +5 lines =@@ + a: number; + } + -==== /foo.js (2 errors) ==== -- /** -- * @import { Foo } from "./types" ++==== /foo.js (1 errors) ==== + /** + * @import { Foo } from "./types" - ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. -- */ -- -- /** -- * @import { Foo } from "./types" + */ + + /** + * @import { Foo } from "./types" - ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. -- */ -- -- /** -- * @param { Foo } foo -- */ -- function f(foo) {} -- -@@= skipped --1, +1 lines =@@ -+ + */ + + /** + * @param { Foo } foo ++ ~~~ ++!!! error TS2304: Cannot find name 'Foo'. + */ + function f(foo) {} + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.types.diff deleted file mode 100644 index e5a87a9213..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importTag4.types -+++ new.importTag4.types -@@= skipped -18, +18 lines =@@ - * @param { Foo } foo - */ - function f(foo) {} -->f : (foo: Foo) => void -->foo : Foo -+>f : (foo: any) => void -+>foo : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.errors.txt.diff new file mode 100644 index 0000000000..25bcd83984 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.importTag5.errors.txt ++++ new.importTag5.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/foo.js(6,13): error TS2304: Cannot find name 'Foo'. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface Foo { ++ a: number; ++ } ++ ++==== /foo.js (1 errors) ==== ++ /** ++ * @import { Foo } from "./types" ++ */ ++ ++ /** ++ * @param { Foo } foo ++ ~~~ ++!!! error TS2304: Cannot find name 'Foo'. ++ */ ++ function f(foo) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.types.diff deleted file mode 100644 index fc57194afc..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.importTag5.types -+++ new.importTag5.types -@@= skipped -14, +14 lines =@@ - * @param { Foo } foo - */ - function f(foo) {} -->f : (foo: Foo) => void -->foo : Foo -+>f : (foo: any) => void -+>foo : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.errors.txt.diff new file mode 100644 index 0000000000..51eb4dfd60 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.errors.txt.diff @@ -0,0 +1,35 @@ +--- old.importTag6.errors.txt ++++ new.importTag6.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/foo.js(9,13): error TS2304: Cannot find name 'A'. ++/foo.js(10,13): error TS2304: Cannot find name 'B'. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface A { ++ a: number; ++ } ++ export interface B { ++ a: number; ++ } ++ ++==== /foo.js (2 errors) ==== ++ /** ++ * @import { ++ * A, ++ * B, ++ * } from "./types" ++ */ ++ ++ /** ++ * @param { A } a ++ ~ ++!!! error TS2304: Cannot find name 'A'. ++ * @param { B } b ++ ~ ++!!! error TS2304: Cannot find name 'B'. ++ */ ++ function f(a, b) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.types.diff deleted file mode 100644 index 9e41357a2d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.importTag6.types -+++ new.importTag6.types -@@= skipped -22, +22 lines =@@ - * @param { B } b - */ - function f(a, b) {} -->f : (a: A, b: B) => void -->a : A -->b : B -+>f : (a: any, b: any) => void -+>a : any -+>b : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.errors.txt.diff new file mode 100644 index 0000000000..7e454e8a8a --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.importTag7.errors.txt ++++ new.importTag7.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/foo.js(8,13): error TS2304: Cannot find name 'A'. ++/foo.js(9,13): error TS2304: Cannot find name 'B'. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface A { ++ a: number; ++ } ++ export interface B { ++ a: number; ++ } ++ ++==== /foo.js (2 errors) ==== ++ /** ++ * @import { ++ * A, ++ * B } from "./types" ++ */ ++ ++ /** ++ * @param { A } a ++ ~ ++!!! error TS2304: Cannot find name 'A'. ++ * @param { B } b ++ ~ ++!!! error TS2304: Cannot find name 'B'. ++ */ ++ function f(a, b) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.types.diff deleted file mode 100644 index 44f05adfce..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.importTag7.types -+++ new.importTag7.types -@@= skipped -21, +21 lines =@@ - * @param { B } b - */ - function f(a, b) {} -->f : (a: A, b: B) => void -->a : A -->b : B -+>f : (a: any, b: any) => void -+>a : any -+>b : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.errors.txt.diff new file mode 100644 index 0000000000..9bb7bbb81c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.importTag8.errors.txt ++++ new.importTag8.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/foo.js(8,13): error TS2304: Cannot find name 'A'. ++/foo.js(9,13): error TS2304: Cannot find name 'B'. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface A { ++ a: number; ++ } ++ export interface B { ++ a: number; ++ } ++ ++==== /foo.js (2 errors) ==== ++ /** ++ * @import ++ * { A, B } ++ * from "./types" ++ */ ++ ++ /** ++ * @param { A } a ++ ~ ++!!! error TS2304: Cannot find name 'A'. ++ * @param { B } b ++ ~ ++!!! error TS2304: Cannot find name 'B'. ++ */ ++ function f(a, b) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.types.diff deleted file mode 100644 index 0755b706a9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.importTag8.types -+++ new.importTag8.types -@@= skipped -21, +21 lines =@@ - * @param { B } b - */ - function f(a, b) {} -->f : (a: A, b: B) => void -->a : A -->b : B -+>f : (a: any, b: any) => void -+>a : any -+>b : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.errors.txt.diff new file mode 100644 index 0000000000..047a55a6c9 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.importTag9.errors.txt ++++ new.importTag9.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/foo.js(8,13): error TS2503: Cannot find namespace 'types'. ++/foo.js(9,13): error TS2503: Cannot find namespace 'types'. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface A { ++ a: number; ++ } ++ export interface B { ++ a: number; ++ } ++ ++==== /foo.js (2 errors) ==== ++ /** ++ * @import ++ * * as types ++ * from "./types" ++ */ ++ ++ /** ++ * @param { types.A } a ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'types'. ++ * @param { types.B } b ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'types'. ++ */ ++ function f(a, b) {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.types.diff index 2a7f6d4ead..a9af23b03a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.types.diff @@ -7,7 +7,7 @@ ->f : (a: types.A, b: types.B) => void ->a : types.A ->b : types.B -+>f : (a: any, b: any) => void -+>a : any -+>b : any ++>f : (a: A, b: B) => void ++>a : A ++>b : B diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.types.diff index 89ded2bbed..547a186f41 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.types.diff @@ -15,10 +15,11 @@ let a = /** @type {Foo} */(/** @type {*} */(undefined)); ->a : import("externs") ->(/** @type {*} */(undefined)) : import("externs") -->(undefined) : any -+>a : any -+>(/** @type {*} */(undefined)) : undefined -+>(undefined) : undefined ++>a : MyClass ++>(/** @type {*} */(undefined)) : MyClass ++>(undefined) : MyClass + >(undefined) : any ++>undefined : any >undefined : undefined a = new Foo({doer: Foo.Bar}); @@ -27,7 +28,7 @@ ->new Foo({doer: Foo.Bar}) : import("externs") ->Foo : typeof import("externs") +>a = new Foo({doer: Foo.Bar}) : MyClass -+>a : any ++>a : MyClass +>new Foo({doer: Foo.Bar}) : MyClass +>Foo : typeof MyClass >{doer: Foo.Bar} : { doer: (x: string, y?: number) => void; } @@ -40,28 +41,17 @@ const q = /** @type {import("./externs").Bar} */({ doer: q => q }); ->q : import("externs").Bar ->({ doer: q => q }) : import("externs").Bar -->{ doer: q => q } : { doer: (q: string) => string; } -->doer : (q: string) => string -->q => q : (q: string) => string -->q : string -->q : string -+>q : { doer: (q: any) => any; } -+>({ doer: q => q }) : { doer: (q: any) => any; } -+>{ doer: q => q } : { doer: (q: any) => any; } -+>doer : (q: any) => any -+>q => q : (q: any) => any -+>q : any -+>q : any - ++>q : Bar ++>({ doer: q => q }) : Bar ++>{ doer: q => q } : Bar + >{ doer: q => q } : { doer: (q: string) => string; } + >doer : (q: string) => string + >q => q : (q: string) => string +@@= skipped -28, +31 lines =@@ const r = /** @type {typeof import("./externs").Bar} */(r => r); -->r : (x: string, y?: number) => void -->(r => r) : (x: string, y?: number) => void -->r => r : (r: string) => string -->r : string -->r : string -+>r : (r: any) => any -+>(r => r) : (r: any) => any -+>r => r : (r: any) => any -+>r : any -+>r : any - + >r : (x: string, y?: number) => void + >(r => r) : (x: string, y?: number) => void ++>r => r : (x: string, y?: number) => void + >r => r : (r: string) => string + >r : string + >r : string diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importingExportingTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importingExportingTypes.errors.txt.diff index 409f61b696..c7f4d7ee38 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importingExportingTypes.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importingExportingTypes.errors.txt.diff @@ -6,17 +6,16 @@ -/index.js(5,10): error TS18043: Types cannot appear in export declarations in JavaScript files. -/index.js(6,10): error TS18043: Types cannot appear in export declarations in JavaScript files. -/index.js(7,10): error TS18043: Types cannot appear in export declarations in JavaScript files. -+/index.js(5,10): error TS2304: Cannot find name 'JSDocType'. -+/index.js(6,10): error TS2304: Cannot find name 'JSDocType'. ++/index.js(5,10): error TS2484: Export declaration conflicts with exported declaration of 'JSDocType'. ==== /node_modules/@types/node/index.d.ts (0 errors) ==== -@@= skipped -10, +7 lines =@@ +@@= skipped -10, +6 lines =@@ export function writeFile(path: string, data: any, options: WriteFileOptions, callback: (err: Error) => void): void; } -==== /index.js (5 errors) ==== -+==== /index.js (2 errors) ==== ++==== /index.js (1 errors) ==== import { writeFile, WriteFileOptions, WriteFileOptions as OtherName } from "fs"; - ~~~~~~~~~~~~~~~~ -!!! error TS18042: 'WriteFileOptions' is a type and cannot be imported in JavaScript files. Use 'import("fs").WriteFileOptions' in a JSDoc type annotation. @@ -29,12 +28,11 @@ ~~~~~~~~~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -!!! related TS18044 /index.js:3:5: 'JSDocType' is automatically exported here. -+!!! error TS2304: Cannot find name 'JSDocType'. ++!!! error TS2484: Export declaration conflicts with exported declaration of 'JSDocType'. export { JSDocType as ThisIsFine }; - ~~~~~~~~~ +- ~~~~~~~~~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -!!! related TS18044 /index.js:3:5: 'JSDocType' is automatically exported here. -+!!! error TS2304: Cannot find name 'JSDocType'. export { WriteFileOptions }; - ~~~~~~~~~~~~~~~~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff new file mode 100644 index 0000000000..6e04c6303d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff @@ -0,0 +1,45 @@ +--- old.inferThis.errors.txt ++++ new.inferThis.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++/a.js(8,9): error TS2322: Type 'typeof C' is not assignable to type 'T'. ++ 'T' could be instantiated with an arbitrary type which could be unrelated to 'typeof C'. ++/a.js(17,9): error TS2322: Type 'this' is not assignable to type 'T'. ++ 'T' could be instantiated with an arbitrary type which could be unrelated to 'this'. ++ ++ ++==== /a.js (2 errors) ==== ++ export class C { ++ /** ++ * @template T ++ * @this {T} ++ * @return {T} ++ */ ++ static a() { ++ return this; ++ ~~~~~~ ++!!! error TS2322: Type 'typeof C' is not assignable to type 'T'. ++!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'typeof C'. ++ } ++ ++ /** ++ * @template T ++ * @this {T} ++ * @return {T} ++ */ ++ b() { ++ return this; ++ ~~~~~~ ++!!! error TS2322: Type 'this' is not assignable to type 'T'. ++!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'this'. ++ } ++ } ++ ++ const a = C.a(); ++ a; // typeof C ++ ++ const c = new C(); ++ const b = c.b(); ++ b; // C ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.types.diff index 7444ed2873..d4b30d42ba 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.types.diff @@ -5,7 +5,7 @@ */ static a() { ->a : (this: T) => T -+>a : () => typeof C ++>a : () => T return this; ->this : T @@ -18,7 +18,7 @@ */ b() { ->b : (this: T) => T -+>b : () => this ++>b : () => T return this; ->this : T @@ -27,25 +27,37 @@ } const a = C.a(); - >a : typeof C - >C.a() : typeof C +->a : typeof C +->C.a() : typeof C ->C.a : (this: T) => T -+>C.a : () => typeof C ++>a : unknown ++>C.a() : unknown ++>C.a : () => T >C : typeof C ->a : (this: T) => T -+>a : () => typeof C ++>a : () => T a; // typeof C - >a : typeof C -@@= skipped -25, +25 lines =@@ +->a : typeof C ++>a : unknown + + const c = new C(); + >c : C +@@= skipped -23, +23 lines =@@ + >C : typeof C + const b = c.b(); - >b : C - >c.b() : C +->b : C +->c.b() : C ->c.b : (this: T) => T -+>c.b : () => C ++>b : unknown ++>c.b() : unknown ++>c.b : () => T >c : C ->b : (this: T) => T -+>b : () => C ++>b : () => T b; // C - >b : C +->b : C ++>b : unknown + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types.diff deleted file mode 100644 index 6194ff1bf7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.instantiateTemplateTagTypeParameterOnVariableStatement.types -+++ new.instantiateTemplateTagTypeParameterOnVariableStatement.types -@@= skipped -6, +6 lines =@@ - * @returns {(b: T) => T} - */ - const seq = a => b => b; -->seq : (a: T) => (b: T) => T -->a => b => b : (a: T) => (b: T) => T -->a : T -->b => b : (b: T) => T -->b : T -->b : T -+>seq : (a: any) => (b: any) => any -+>a => b => b : (a: any) => (b: any) => any -+>a : any -+>b => b : (b: any) => any -+>b : any -+>b : any - - const text1 = "hello"; - >text1 : "hello" -@@= skipped -17, +17 lines =@@ - - /** @type {string} */ - var text3 = seq(text1)(text2); -->text3 : string -->seq(text1)(text2) : string -->seq(text1) : (b: string) => string -->seq : (a: T) => (b: T) => T -+>text3 : any -+>seq(text1)(text2) : any -+>seq(text1) : (b: any) => any -+>seq : (a: any) => (b: any) => any - >text1 : "hello" - >text2 : "world" - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.types.diff index 640e6a870a..7ad9860f66 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.types.diff @@ -9,21 +9,3 @@ >value : T } === lib.js === -@@= skipped -9, +9 lines =@@ - * @implements {IEncoder} - */ - export class Encoder { -->Encoder : Encoder -+>Encoder : Encoder - - /** - * @param {T} value - */ - encode(value) { -->encode : (value: T) => Uint8Array -->value : T -+>encode : (value: any) => Uint8Array -+>value : any - - return new Uint8Array(0) - >new Uint8Array(0) : Uint8Array diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff index 37162d94ba..2709e219d9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff @@ -9,8 +9,6 @@ +jsDeclarationsClassMethod.js(19,36): error TS7006: Parameter 'y' implicitly has an 'any' type. +jsDeclarationsClassMethod.js(29,27): error TS7006: Parameter 'x' implicitly has an 'any' type. +jsDeclarationsClassMethod.js(29,30): error TS7006: Parameter 'y' implicitly has an 'any' type. -+jsDeclarationsClassMethod.js(40,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -+jsDeclarationsClassMethod.js(40,16): error TS7006: Parameter 'y' implicitly has an 'any' type. +jsDeclarationsClassMethod.js(51,14): error TS2551: Property 'method2' does not exist on type 'C2'. Did you mean 'method1'? +jsDeclarationsClassMethod.js(51,34): error TS7006: Parameter 'x' implicitly has an 'any' type. +jsDeclarationsClassMethod.js(51,37): error TS7006: Parameter 'y' implicitly has an 'any' type. @@ -19,7 +17,7 @@ +jsDeclarationsClassMethod.js(61,30): error TS7006: Parameter 'y' implicitly has an 'any' type. + + -+==== jsDeclarationsClassMethod.js (14 errors) ==== ++==== jsDeclarationsClassMethod.js (12 errors) ==== + function C1() { + /** + * A comment prop @@ -72,10 +70,6 @@ + * @returns {number} + */ + method1(x, y) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'y' implicitly has an 'any' type. + return x + y; + } + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.types.diff index 58a8213d60..5da9370558 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.types.diff @@ -94,28 +94,7 @@ } class C2 { -@@= skipped -24, +24 lines =@@ - * @returns {number} - */ - method1(x, y) { -->method1 : (x: number, y: number) => number -->x : number -->y : number -+>method1 : (x: any, y: any) => any -+>x : any -+>y : any - - return x + y; -->x + y : number -->x : number -->y : number -+>x + y : any -+>x : any -+>y : any - } - } - -@@= skipped -18, +18 lines =@@ +@@= skipped -42, +42 lines =@@ * @returns {number} */ C2.prototype.method2 = function (x, y) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff index 4389d4e7fc..1bec95b21f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff @@ -7,11 +7,12 @@ +index.js(139,14): error TS2339: Property 'p2' does not exist on type 'K'. +index.js(143,21): error TS2339: Property 'p1' does not exist on type 'K'. +index.js(151,14): error TS2339: Property 'prop' does not exist on type 'M'. -+index.js(165,14): error TS2339: Property 'another' does not exist on type 'N'. -+index.js(179,14): error TS2339: Property 'another2' does not exist on type 'O'. ++index.js(165,14): error TS2339: Property 'another' does not exist on type 'N'. ++index.js(173,24): error TS2314: Generic type 'N' requires 1 type argument(s). ++index.js(179,14): error TS2339: Property 'another2' does not exist on type 'O'. + + -+==== index.js (6 errors) ==== ++==== index.js (7 errors) ==== + export class A {} + + export class B { @@ -186,7 +187,7 @@ + super(); + this.another = param; + ~~~~~~~ -+!!! error TS2339: Property 'another' does not exist on type 'N'. ++!!! error TS2339: Property 'another' does not exist on type 'N'. + } + } + @@ -195,6 +196,8 @@ + * @extends {N} + */ + export class O extends N { ++ ~ ++!!! error TS2314: Generic type 'N' requires 1 type argument(s). + /** + * @param {U} param + */ @@ -202,7 +205,7 @@ + super(param); + this.another2 = param; + ~~~~~~~~ -+!!! error TS2339: Property 'another2' does not exist on type 'O'. ++!!! error TS2339: Property 'another2' does not exist on type 'O'. + } + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.types.diff index f0d3a6abed..0d9c718bdb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.types.diff @@ -1,162 +1,22 @@ --- old.jsDeclarationsClasses.types +++ new.jsDeclarationsClasses.types -@@= skipped -27, +27 lines =@@ - * @param {number} b - */ - constructor(a, b) {} -->a : number -->b : number -+>a : any -+>b : any - } - - /** - * @template T,U - */ - export class E { -->E : E -+>E : E - - /** - * @type {T & U} - */ - field; -->field : T & U -+>field : any - - // @readonly is currently unsupported, it seems - included here just in case that changes - /** -@@= skipped -22, +22 lines =@@ - * @readonly - */ - readonlyField; -->readonlyField : T & U -+>readonlyField : any - - initializedField = 12; - >initializedField : number -@@= skipped -10, +10 lines =@@ - * @return {U} - */ +@@= skipped -61, +61 lines =@@ get f1() { return /** @type {*} */(null); } -->f1 : U -->(null) : any -+>f1 : any -+>(null) : null + >f1 : U + >(null) : any ++>null : any /** * @param {U} _p - */ - set f1(_p) {} -->f1 : U -->_p : U -+>f1 : any -+>_p : any - - /** - * @return {U} - */ +@@= skipped -14, +15 lines =@@ get f2() { return /** @type {*} */(null); } -->f2 : U -->(null) : any -+>f2 : any -+>(null) : null + >f2 : U + >(null) : any ++>null : any /** * @param {U} _p - */ - set f3(_p) {} -->f3 : U -->_p : U -+>f3 : any -+>_p : any - - /** - * @param {T} a - * @param {U} b - */ - constructor(a, b) {} -->a : T -->b : U -+>a : any -+>b : any - - - /** - * @type {string} - */ - static staticField; -->staticField : string -+>staticField : any - - // @readonly is currently unsupported, it seems - included here just in case that changes - /** -@@= skipped -45, +45 lines =@@ - * @readonly - */ - static staticReadonlyField; -->staticReadonlyField : string -+>staticReadonlyField : any - - static staticInitializedField = 12; - >staticInitializedField : number -@@= skipped -31, +31 lines =@@ - * @param {string} _p - */ - static set s3(_p) {} -->s3 : string -->_p : string -+>s3 : any -+>_p : any - } - - /** - * @template T,U - */ - export class F { -->F : F -+>F : F - - /** - * @type {T & U} - */ - field; -->field : T & U -+>field : any - - /** - * @param {T} a - * @param {U} b - */ - constructor(a, b) {} -->a : T -->b : U -+>a : any -+>b : any - - /** - * @template A,B -@@= skipped -30, +30 lines =@@ - * @param {B} b - */ - static create(a, b) { return new F(a, b); } -->create : (a: A, b: B) => F -->a : A -->b : B -->new F(a, b) : F -+>create : (a: any, b: any) => F -+>a : any -+>b : any -+>new F(a, b) : F - >F : typeof F -->a : A -->b : B -+>a : any -+>b : any - } - - class G {} -@@= skipped -57, +57 lines =@@ +@@= skipped -147, +148 lines =@@ } method() { @@ -172,73 +32,29 @@ } } -@@= skipped -31, +31 lines =@@ - * @template T - */ - export class N extends L { -->N : N -+>N : N - >L : L - - /** - * @param {T} param - */ - constructor(param) { -->param : T -+>param : any - - super(); - >super() : void - >super : typeof L - - this.another = param; -->this.another = param : T -+>this.another = param : any - >this.another : any - >this : this - >another : any -->param : T -+>param : any - } - } - -@@= skipped -27, +27 lines =@@ - * @extends {N} +@@= skipped -59, +59 lines =@@ */ export class O extends N { -->O : O + >O : O ->N : N -+>O : O -+>N : N ++>N : typeof N /** * @param {U} param - */ - constructor(param) { -->param : U -+>param : any +@@= skipped -10, +10 lines =@@ super(param); >super(param) : void - >super : typeof N -->param : U -+>param : any +->super : typeof N ++>super : any + >param : U this.another2 = param; -->this.another2 = param : U -+>this.another2 = param : any - >this.another2 : any - >this : this - >another2 : any -->param : U -+>param : any - } - } - +@@= skipped -15, +15 lines =@@ var x = /** @type {*} */(null); >x : any -->(null) : any -+>(null) : null + >(null) : any ++>null : any export class VariableBase extends x {} >VariableBase : VariableBase diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.types.diff index 9ec76f7d12..7b4fcb9acf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.types.diff @@ -17,12 +17,3 @@ [TopLevelSym](x = 12) { >[TopLevelSym] : (x?: number) => number -@@= skipped -62, +62 lines =@@ - * @param {typeof TopLevelSym | typeof InnerSym} _p - */ - constructor(_p = InnerSym) { -->_p : unique symbol | unique symbol -+>_p : symbol - >InnerSym : unique symbol - - // switch on _p diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.types.diff index 5617dbbfd8..08d47101d6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.types.diff @@ -31,8 +31,9 @@ a = /** @type {Foo} */(null); ->a : Foo ->(null) : Foo -+>a : any -+>(null) : null ++>a : default ++>(null) : default ++>null : default }; export const X = Foo; @@ -58,10 +59,9 @@ +>Fab : default x = /** @type {Bar} */(null); -->x : Bar -->(null) : Bar -+>x : any -+>(null) : null + >x : Bar + >(null) : Bar ++>null : Bar } export default Bar; >Bar : Bar diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff new file mode 100644 index 0000000000..0926175c08 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff @@ -0,0 +1,68 @@ +--- old.jsDeclarationsEnumTag.errors.txt ++++ new.jsDeclarationsEnumTag.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++index.js(23,12): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? ++index.js(24,12): error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? ++index.js(25,12): error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? ++index.js(34,16): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? ++ ++ ++==== index.js (4 errors) ==== ++ /** @enum {string} */ ++ export const Target = { ++ START: "start", ++ MIDDLE: "middle", ++ END: "end", ++ /** @type {number} */ ++ OK_I_GUESS: 2 ++ } ++ /** @enum number */ ++ export const Second = { ++ OK: 1, ++ /** @type {number} */ ++ FINE: 2, ++ } ++ /** @enum {function(number): number} */ ++ export const Fs = { ++ ADD1: n => n + 1, ++ ID: n => n, ++ SUB1: n => n - 1 ++ } ++ ++ /** ++ * @param {Target} t ++ ~~~~~~ ++!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? ++ * @param {Second} s ++ ~~~~~~ ++!!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? ++ * @param {Fs} f ++ ~~ ++!!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? ++ */ ++ export function consume(t,s,f) { ++ /** @type {string} */ ++ var str = t ++ /** @type {number} */ ++ var num = s ++ /** @type {(n: number) => number} */ ++ var fun = f ++ /** @type {Target} */ ++ ~~~~~~ ++!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? ++ var v = Target.START ++ v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums ++ } ++ /** @param {string} s */ ++ export function ff(s) { ++ // element access with arbitrary string is an error only with noImplicitAny ++ if (!Target[s]) { ++ return null ++ } ++ else { ++ return Target[s] ++ } ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.types.diff index de5d84b5c4..adcfae58f2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.types.diff @@ -1,68 +1,77 @@ --- old.jsDeclarationsEnumTag.types +++ new.jsDeclarationsEnumTag.types -@@= skipped -70, +70 lines =@@ - * @param {Fs} f +@@= 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 =@@ */ export function consume(t,s,f) { -->consume : (t: Target, s: Second, f: Fs) => void + >consume : (t: Target, s: Second, f: Fs) => void ->t : string ->s : number -->f : Fs -+>consume : (t: any, s: any, f: any) => void -+>t : any -+>s : any -+>f : any ++>t : Target ++>s : Second + >f : Fs /** @type {string} */ var str = t -->str : string + >str : string ->t : string -+>str : any -+>t : any ++>t : Target /** @type {number} */ var num = s -->num : number + >num : number ->s : number -+>num : any -+>s : any ++>s : Second /** @type {(n: number) => number} */ var fun = f -->fun : (n: number) => number -->f : Fs -+>fun : any -+>f : any +@@= skipped -21, +21 lines =@@ /** @type {Target} */ var v = Target.START -@@= skipped -34, +34 lines =@@ +->v : string ++>v : Target + >Target.START : string + >Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } + >START : string + + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums + >v = 'something else' : "something else" +->v : string ++>v : Target + >'something else' : "something else" } /** @param {string} s */ - export function ff(s) { -->ff : (s: string) => any -->s : string -+>ff : (s: any) => any -+>s : any - +@@= skipped -18, +18 lines =@@ // element access with arbitrary string is an error only with noImplicitAny if (!Target[s]) { >!Target[s] : boolean ->Target[s] : error +>Target[s] : any >Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } -->s : string -+>s : any + >s : string - return null +@@= skipped -8, +8 lines =@@ } else { return Target[s] ->Target[s] : error +>Target[s] : any >Target : { START: string; MIDDLE: string; END: string; OK_I_GUESS: number; } -->s : string -+>s : any + >s : string } - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.types.diff index 1f0c43d581..c83a1e0bdf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.types.diff @@ -19,21 +19,3 @@ /** * @param {number} p - */ - constructor(p) { -->p : number -+>p : any - - this.t = 12 + p; -->this.t = 12 + p : number -+>this.t = 12 + p : any - >this.t : any - >this : this - >t : any -->12 + p : number -+>12 + p : any - >12 : 12 -->p : number -+>p : any - } - } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.types.diff index f4d30b0c9c..2278b6ed71 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.types.diff @@ -17,21 +17,3 @@ /** * @param {number} p - */ - constructor(p) { -->p : number -+>p : any - - this.t = 12 + p; -->this.t = 12 + p : number -+>this.t = 12 + p : any - >this.t : any - >this : this - >t : any -->12 + p : number -+>12 + p : any - >12 : 12 -->p : number -+>p : any - } - } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types.diff index 90f034adfa..6472276902 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types.diff @@ -17,23 +17,7 @@ /** * @param {number} p - */ - constructor(p) { -->p : number -+>p : any - - this.t = 12 + p; -->this.t = 12 + p : number -+>this.t = 12 + p : any - >this.t : any - >this : this - >t : any -->12 + p : number -+>12 + p : any - >12 : 12 -->p : number -+>p : any - } +@@= skipped -24, +24 lines =@@ } module.exports.Sub = class { >module.exports.Sub = class { constructor() { this.instance = new module.exports(10); }} : typeof Sub diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff index 566f77664d..18a693aea2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff @@ -11,7 +11,9 @@ +index.js(31,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(32,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(32,58): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++index.js(36,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(41,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(46,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(51,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(53,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(54,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -21,7 +23,7 @@ +index.js(58,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 (16 errors) ==== ++==== index.js (18 errors) ==== + Object.defineProperty(module.exports, "a", { value: function a() {} }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -74,6 +76,8 @@ + /** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b ++ ~~~~~~ ++!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ + function g(a, b) { + return a.x && b.y(); @@ -86,6 +90,8 @@ + /** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b ++ ~~~~~~ ++!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ + function hh(a, b) { + return a.x && b.y(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.types.diff index 8e71a2b205..29907290e2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.types.diff @@ -58,18 +58,11 @@ >"cat" : "cat" >{ value: "cat" } : { value: string; } >value : string -@@= skipped -20, +20 lines =@@ - * @return {string} - */ - function d(a, b) { return /** @type {*} */(null); } -->d : (a: number, b: number) => string -->a : number -->b : number -->(null) : any -+>d : (a: any, b: any) => any -+>a : any -+>b : any -+>(null) : null +@@= skipped -24, +24 lines =@@ + >a : number + >b : number + >(null) : any ++>null : any Object.defineProperty(module.exports, "d", { value: d }); ->Object.defineProperty(module.exports, "d", { value: d }) : typeof module.exports @@ -84,27 +77,13 @@ +>module : any +>exports : any >"d" : "d" -->{ value: d } : { value: (a: number, b: number) => string; } -->value : (a: number, b: number) => string -->d : (a: number, b: number) => string -+>{ value: d } : { value: (a: any, b: any) => any; } -+>value : (a: any, b: any) => any -+>d : (a: any, b: any) => any - - - /** -@@= skipped -26, +26 lines =@@ - * @return {T & U} - */ - function e(a, b) { return /** @type {*} */(null); } -->e : (a: T, b: U) => T & U -->a : T -->b : U -->(null) : any -+>e : (a: any, b: any) => any -+>a : any -+>b : any -+>(null) : null + >{ value: d } : { value: (a: number, b: number) => string; } + >value : (a: number, b: number) => string +@@= skipped -26, +27 lines =@@ + >a : T + >b : U + >(null) : any ++>null : any Object.defineProperty(module.exports, "e", { value: e }); ->Object.defineProperty(module.exports, "e", { value: e }) : typeof module.exports @@ -119,26 +98,10 @@ +>module : any +>exports : any >"e" : "e" -->{ value: e } : { value: (a: T, b: U) => T & U; } -->value : (a: T, b: U) => T & U -->e : (a: T, b: U) => T & U -+>{ value: e } : { value: (a: any, b: any) => any; } -+>value : (a: any, b: any) => any -+>e : (a: any, b: any) => any - - /** - * @template T - * @param {T} a - */ - function f(a) { -->f : (a: T) => T -->a : T -+>f : (a: any) => any -+>a : any - - return a; -->a : T -+>a : any + >{ value: e } : { value: (a: T, b: U) => T & U; } + >value : (a: T, b: U) => T & U +@@= skipped -26, +27 lines =@@ + >a : T } Object.defineProperty(module.exports, "f", { value: f }); ->Object.defineProperty(module.exports, "f", { value: f }) : typeof module.exports @@ -153,12 +116,9 @@ +>module : any +>exports : any >"f" : "f" -->{ value: f } : { value: (a: T) => T; } -->value : (a: T) => T -->f : (a: T) => T -+>{ value: f } : { value: (a: any) => any; } -+>value : (a: any) => any -+>f : (a: any) => any + >{ value: f } : { value: (a: T) => T; } + >value : (a: T) => T + >f : (a: T) => T Object.defineProperty(module.exports.f, "self", { value: module.exports.f }); ->Object.defineProperty(module.exports.f, "self", { value: module.exports.f }) : (a: T) => T @@ -198,28 +158,24 @@ */ function g(a, b) { ->g : (a: { x: string; }, b: { y: () => void; }) => void -->a : { x: string; } ++>g : (a: { x: string; }, b: { y: any; }) => any + >a : { x: string; } ->b : { y: () => void; } -+>g : (a: any, b: any) => any -+>a : any -+>b : any ++>b : { y: any; } return a.x && b.y(); ->a.x && b.y() : void -->a.x : string -->a : { x: string; } -->x : string ++>a.x && b.y() : any + >a.x : string + >a : { x: string; } + >x : string ->b.y() : void ->b.y : () => void ->b : { y: () => void; } ->y : () => void -+>a.x && b.y() : any -+>a.x : any -+>a : any -+>x : any +>b.y() : any +>b.y : any -+>b : any ++>b : { y: any; } +>y : any } Object.defineProperty(module.exports, "g", { value: g }); @@ -238,39 +194,35 @@ ->{ value: g } : { value: (a: { x: string; }, b: { y: () => void; }) => void; } ->value : (a: { x: string; }, b: { y: () => void; }) => void ->g : (a: { x: string; }, b: { y: () => void; }) => void -+>{ value: g } : { value: (a: any, b: any) => any; } -+>value : (a: any, b: any) => any -+>g : (a: any, b: any) => any ++>{ value: g } : { value: (a: { x: string; }, b: { y: any; }) => any; } ++>value : (a: { x: string; }, b: { y: any; }) => any ++>g : (a: { x: string; }, b: { y: any; }) => any /** -@@= skipped -99, +99 lines =@@ +@@= skipped -69, +69 lines =@@ * @param {{y: typeof module.exports.b}} b */ function hh(a, b) { ->hh : (a: { x: string; }, b: { y: () => void; }) => void -->a : { x: string; } ++>hh : (a: { x: string; }, b: { y: any; }) => any + >a : { x: string; } ->b : { y: () => void; } -+>hh : (a: any, b: any) => any -+>a : any -+>b : any ++>b : { y: any; } return a.x && b.y(); ->a.x && b.y() : void -->a.x : string -->a : { x: string; } -->x : string ++>a.x && b.y() : any + >a.x : string + >a : { x: string; } + >x : string ->b.y() : void ->b.y : () => void ->b : { y: () => void; } ->y : () => void -+>a.x && b.y() : any -+>a.x : any -+>a : any -+>x : any +>b.y() : any +>b.y : any -+>b : any ++>b : { y: any; } +>y : any } Object.defineProperty(module.exports, "h", { value: hh }); @@ -289,9 +241,9 @@ ->{ value: hh } : { value: (a: { x: string; }, b: { y: () => void; }) => void; } ->value : (a: { x: string; }, b: { y: () => void; }) => void ->hh : (a: { x: string; }, b: { y: () => void; }) => void -+>{ value: hh } : { value: (a: any, b: any) => any; } -+>value : (a: any, b: any) => any -+>hh : (a: any, b: any) => any ++>{ value: hh } : { value: (a: { x: string; }, b: { y: any; }) => any; } ++>value : (a: { x: string; }, b: { y: any; }) => any ++>hh : (a: { x: string; }, b: { y: any; }) => any Object.defineProperty(module.exports, "i", { value: function i(){} }); ->Object.defineProperty(module.exports, "i", { value: function i(){} }) : typeof module.exports diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff index 908a49bb28..6f27b694f5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff @@ -3,8 +3,11 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++context.js(4,21): error TS2306: File 'timer.js' is not a module. ++context.js(5,14): error TS1340: Module './hook' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./hook')'? +context.js(34,14): error TS2350: Only a void function can be called with the 'new' keyword. +context.js(48,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++hook.js(2,20): error TS1340: Module './context' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./context')'? +hook.js(10,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +timer.js(7,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + @@ -19,9 +22,11 @@ + module.exports = Timer; + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+==== hook.js (1 errors) ==== ++==== hook.js (2 errors) ==== + /** + * @typedef {(arg: import("./context")) => void} HookHandler ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS1340: Module './context' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./context')'? + */ + /** + * @param {HookHandler} handle @@ -33,12 +38,16 @@ + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + -+==== context.js (2 errors) ==== ++==== context.js (4 errors) ==== + /** + * Imports + * + * @typedef {import("./timer")} Timer ++ ~~~~~~~~~ ++!!! error TS2306: File 'timer.js' is not a module. + * @typedef {import("./hook")} Hook ++ ~~~~~~~~~~~~~~~~ ++!!! error TS1340: Module './hook' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./hook')'? + * @typedef {import("./hook").HookHandler} HookHandler + */ + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff index 955ca39a63..e0c212aa58 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff @@ -5,19 +5,16 @@ */ function Timer(timeout) { ->Timer : typeof Timer -->timeout : number -+>Timer : (timeout: any) => void -+>timeout : any ++>Timer : (timeout: number) => void + >timeout : number this.timeout = timeout; -->this.timeout = timeout : number -+>this.timeout = timeout : any + >this.timeout = timeout : number >this.timeout : any ->this : this +>this : any >timeout : any -->timeout : number -+>timeout : any + >timeout : number } module.exports = Timer; ->module.exports = Timer : typeof Timer @@ -25,11 +22,11 @@ ->module : { exports: typeof Timer; } ->exports : typeof Timer ->Timer : typeof Timer -+>module.exports = Timer : (timeout: any) => void ++>module.exports = Timer : (timeout: number) => void +>module.exports : any +>module : any +>exports : any -+>Timer : (timeout: any) => void ++>Timer : (timeout: number) => void === hook.js === /** @@ -38,19 +35,16 @@ */ function Hook(handle) { ->Hook : typeof Hook -->handle : HookHandler -+>Hook : (handle: any) => void -+>handle : any ++>Hook : (handle: HookHandler) => void + >handle : HookHandler this.handle = handle; -->this.handle = handle : HookHandler -+>this.handle = handle : any + >this.handle = handle : HookHandler >this.handle : any ->this : this +>this : any >handle : any -->handle : HookHandler -+>handle : any + >handle : HookHandler } module.exports = Hook; ->module.exports = Hook : typeof Hook @@ -58,11 +52,11 @@ ->module : { exports: typeof Hook; } ->exports : typeof Hook ->Hook : typeof Hook -+>module.exports = Hook : (handle: any) => void ++>module.exports = Hook : (handle: HookHandler) => void +>module.exports : any +>module : any +>exports : any -+>Hook : (handle: any) => void ++>Hook : (handle: HookHandler) => void === context.js === /** @@ -71,9 +65,8 @@ function Context(input) { ->Context : typeof Context -->input : Input -+>Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } -+>input : any ++>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } + >input : Input if (!(this instanceof Context)) { >!(this instanceof Context) : boolean @@ -82,15 +75,14 @@ ->this : this ->Context : typeof Context +>this : any -+>Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } ++>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } return new Context(input) ->new Context(input) : Context ->Context : typeof Context -->input : Input +>new Context(input) : any -+>Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } -+>input : any ++>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } + >input : Input } this.state = this.construct(input); ->this.state = this.construct(input) : State @@ -103,12 +95,11 @@ ->this.construct : (input: Input, handle?: HookHandler | undefined) => State ->this : this & { construct(input: Input, handle?: HookHandler | undefined): State; } ->construct : (input: Input, handle?: HookHandler | undefined) => State -->input : Input +>this.construct(input) : any +>this.construct : any +>this : any +>construct : any -+>input : any + >input : Input } Context.prototype = { ->Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: HookHandler | undefined): State; } @@ -116,11 +107,11 @@ ->Context : typeof Context ->prototype : { construct(input: Input, handle?: HookHandler | undefined): State; } ->{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: HookHandler | undefined): State; } -+>Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct: (input: any, handle?: () => any) => any; } -+>Context.prototype : { construct: (input: any, handle?: () => any) => any; } -+>Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } -+>prototype : { construct: (input: any, handle?: () => any) => any; } -+>{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct: (input: any, handle?: () => any) => any; } ++>Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct: (input: Input, handle?: HookHandler) => State; } ++>Context.prototype : { construct: (input: Input, handle?: HookHandler) => State; } ++>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } ++>prototype : { construct: (input: Input, handle?: HookHandler) => State; } ++>{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct: (input: Input, handle?: HookHandler) => State; } /** * @param {Input} input @@ -129,18 +120,14 @@ */ construct(input, handle = () => void 0) { ->construct : (input: Input, handle?: HookHandler | undefined) => State -->input : Input ++>construct : (input: Input, handle?: HookHandler) => State + >input : Input ->handle : import("hook").HookHandler -+>construct : (input: any, handle?: () => any) => any -+>input : any -+>handle : () => any ++>handle : HookHandler >() => void 0 : () => any >void 0 : undefined >0 : 0 - - return input; -->input : Input -+>input : any +@@= skipped -12, +12 lines =@@ } } module.exports = Context; @@ -149,9 +136,9 @@ ->module : { exports: { (input: Input): Context; new (input: Input): Context; prototype: { construct(input: Input, handle?: HookHandler | undefined): State; }; }; } ->exports : { (input: Input): Context; new (input: Input): Context; prototype: { construct(input: Input, handle?: HookHandler | undefined): State; }; } ->Context : typeof Context -+>module.exports = Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } ++>module.exports = Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } +>module.exports : any +>module : any +>exports : any -+>Context : { (input: any): any; prototype: { construct: (input: any, handle?: () => any) => any; }; } ++>Context : { (input: Input): any; prototype: { construct: (input: Input, handle?: HookHandler) => State; }; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.types.diff deleted file mode 100644 index 8535bd4174..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.types.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.jsDeclarationsFunctionJSDoc.types -+++ new.jsDeclarationsFunctionJSDoc.types -@@= skipped -6, +6 lines =@@ - * @param {string} b - */ - export function foo(a, b) {} -->foo : (a: number, b: string) => void -->a : number -->b : string -+>foo : (a: any, b: any) => void -+>a : any -+>b : any - - /** - * Legacy - DO NOT USE -@@= skipped -16, +16 lines =@@ - * @param {null} b - */ - constructor(a, b) { -->a : Aleph -->b : null -+>a : any -+>b : any - - /** - * Field is always null - */ - this.field = b; -->this.field = b : null -+>this.field = b : any - >this.field : any - >this : this - >field : any -->b : null -+>b : any - } - - /** diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff index 3ea0bd366c..142d50e852 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++referencer.js(4,12): error TS2749: 'Point' refers to a value, but is being used as a type here. Did you mean 'typeof Point'? +source.js(7,16): error TS2350: Only a void function can be called with the 'new' keyword. + + @@ -21,11 +22,13 @@ + this.y = y; + } + -+==== referencer.js (0 errors) ==== ++==== referencer.js (1 errors) ==== + import {Point} from "./source"; + + /** + * @param {Point} p ++ ~~~~~ ++!!! error TS2749: 'Point' refers to a value, but is being used as a type here. Did you mean 'typeof Point'? + */ + export function magnitude(p) { + return Math.sqrt(p.x ** 2 + p.y ** 2); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.types.diff index d8b300e95f..a0d16ed5f0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.types.diff @@ -5,85 +5,66 @@ */ export function Point(x, y) { ->Point : typeof Point -->x : number -->y : number -+>Point : (x: any, y: any) => any -+>x : any -+>y : any ++>Point : (x: number, y: number) => any + >x : number + >y : number - if (!(this instanceof Point)) { +@@= skipped -8, +8 lines =@@ >!(this instanceof Point) : boolean >(this instanceof Point) : boolean >this instanceof Point : boolean ->this : this ->Point : typeof Point +>this : any -+>Point : (x: any, y: any) => any ++>Point : (x: number, y: number) => any return new Point(x, y); ->new Point(x, y) : Point ->Point : typeof Point -->x : number -->y : number +>new Point(x, y) : any -+>Point : (x: any, y: any) => any -+>x : any -+>y : any ++>Point : (x: number, y: number) => any + >x : number + >y : number } this.x = x; -->this.x = x : number -+>this.x = x : any + >this.x = x : number >this.x : any ->this : this +>this : any >x : any -->x : number -+>x : any + >x : number this.y = y; -->this.y = y : number -+>this.y = y : any + >this.y = y : number >this.y : any ->this : this +>this : any >y : any -->y : number -+>y : any + >y : number } === referencer.js === import {Point} from "./source"; ->Point : typeof Point -+>Point : (x: any, y: any) => any ++>Point : (x: number, y: number) => any /** * @param {Point} p - */ - export function magnitude(p) { -->magnitude : (p: Point) => number -->p : Point -+>magnitude : (p: any) => number -+>p : any - - return Math.sqrt(p.x ** 2 + p.y ** 2); - >Math.sqrt(p.x ** 2 + p.y ** 2) : number -@@= skipped -50, +50 lines =@@ +@@= skipped -42, +42 lines =@@ >sqrt : (x: number) => number >p.x ** 2 + p.y ** 2 : number >p.x ** 2 : number ->p.x : number -->p : Point -->x : number +>p.x : any -+>p : any + >p : Point +->x : number +>x : any >2 : 2 >p.y ** 2 : number ->p.y : number -->p : Point -->y : number +>p.y : any -+>p : any + >p : Point +->y : number +>y : any >2 : 2 } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff index 88d60fa3dd..123f6c5506 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff @@ -4,10 +4,11 @@ - @@= skipped --1, +1 lines =@@ +referencer.js(3,23): error TS2350: Only a void function can be called with the 'new' keyword. ++source.js(13,16): error TS2749: 'Vec' refers to a value, but is being used as a type here. Did you mean 'typeof Vec'? +source.js(40,16): error TS2350: Only a void function can be called with the 'new' keyword. + + -+==== source.js (1 errors) ==== ++==== source.js (2 errors) ==== + /** + * @param {number} len + */ @@ -21,6 +22,8 @@ + Vec.prototype = { + /** + * @param {Vec} other ++ ~~~ ++!!! error TS2749: 'Vec' refers to a value, but is being used as a type here. Did you mean 'typeof Vec'? + */ + dot(other) { + if (other.storage.length !== this.storage.length) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.types.diff index 531cb5ac22..619f5db210 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.types.diff @@ -5,12 +5,11 @@ */ export function Vec(len) { ->Vec : typeof Vec -->len : number -+>Vec : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } -+>len : any ++>Vec : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } + >len : number /** - * @type {number[]} +@@= skipped -8, +8 lines =@@ */ this.storage = new Array(len); >this.storage = new Array(len) : any[] @@ -22,8 +21,7 @@ +>storage : any >new Array(len) : any[] >Array : ArrayConstructor -->len : number -+>len : any + >len : number } Vec.prototype = { @@ -32,26 +30,23 @@ ->Vec : typeof Vec ->prototype : { dot(other: Vec): number; magnitude(): number; } ->{ /** * @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 = { /** * @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: any) => number; magnitude: () => number; } -+>Vec.prototype : { dot: (other: any) => number; magnitude: () => number; } -+>Vec : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } -+>prototype : { dot: (other: any) => number; magnitude: () => number; } -+>{ /** * @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: any) => number; magnitude: () => number; } ++>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; } ++>Vec : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } ++>prototype : { dot: (other: Vec) => number; magnitude: () => number; } ++>{ /** * @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; } /** * @param {Vec} other - */ - dot(other) { -->dot : (other: Vec) => number -->other : Vec -+>dot : (other: any) => number -+>other : any +@@= skipped -24, +24 lines =@@ if (other.storage.length !== this.storage.length) { >other.storage.length !== this.storage.length : boolean ->other.storage.length : number ->other.storage : number[] -->other : Vec ++>other.storage.length : any ++>other.storage : any + >other : Vec ->storage : number[] ->length : number ->this.storage.length : number @@ -59,9 +54,6 @@ ->this : this ->storage : number[] ->length : number -+>other.storage.length : any -+>other.storage : any -+>other : any +>storage : any +>length : any +>this.storage.length : any @@ -72,7 +64,7 @@ throw new Error(`Dot product only applicable for vectors of equal length`); >new Error(`Dot product only applicable for vectors of equal length`) : Error -@@= skipped -57, +57 lines =@@ +@@= skipped -25, +25 lines =@@ >0 : 0 >i < this.storage.length : boolean >i : number @@ -104,11 +96,10 @@ >i : number ->other.storage[i] : number ->other.storage : number[] -->other : Vec -->storage : number[] +>other.storage[i] : any +>other.storage : any -+>other : any + >other : Vec +->storage : number[] +>storage : any >i : number } @@ -150,64 +141,56 @@ */ export function Point2D(x, y) { ->Point2D : typeof Point2D -->x : number -->y : number -+>Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } -+>x : any -+>y : any ++>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } + >x : number + >y : number - if (!(this instanceof Point2D)) { +@@= skipped -8, +8 lines =@@ >!(this instanceof Point2D) : boolean >(this instanceof Point2D) : boolean >this instanceof Point2D : boolean ->this : this ->Point2D : typeof Point2D +>this : any -+>Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } ++>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } return new Point2D(x, y); ->new Point2D(x, y) : Point2D ->Point2D : typeof Point2D -->x : number -->y : number +>new Point2D(x, y) : any -+>Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } -+>x : any -+>y : any ++>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } + >x : number + >y : number } Vec.call(this, 2); >Vec.call(this, 2) : any >Vec.call : (this: Function, thisArg: any, ...argArray: any[]) => any ->Vec : typeof Vec -+>Vec : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } ++>Vec : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } >call : (this: Function, thisArg: any, ...argArray: any[]) => any ->this : this +>this : any >2 : 2 this.x = x; -->this.x = x : number + >this.x = x : number ->this.x : number ->this : this -->x : number -->x : number -+>this.x = x : any +>this.x : any +>this : any +>x : any -+>x : any + >x : number +->x : number this.y = y; -->this.y = y : number + >this.y = y : number ->this.y : number ->this : this -->y : number -->y : number -+>this.y = y : any +>this.y : any +>this : any +>y : any -+>y : any + >y : number +->y : number } Point2D.prototype = { @@ -216,22 +199,21 @@ ->Point2D : typeof Point2D ->prototype : { x: number; y: number; __proto__: typeof Vec; } ->{ __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { x: number; y: number; __proto__: typeof Vec; } -+>Point2D.prototype = { __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; } -+>Point2D.prototype : { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; } -+>Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } -+>prototype : { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; } -+>{ __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; } ++>Point2D.prototype = { __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; } ++>Point2D.prototype : { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; } ++>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } ++>prototype : { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; } ++>{ __proto__: Vec, get x() { return this.storage[0]; }, /** * @param {number} x */ set x(x) { this.storage[0] = x; }, get y() { return this.storage[1]; }, /** * @param {number} y */ set y(y) { this.storage[1] = y; }} : { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; } __proto__: Vec, ->__proto__ : typeof Vec ->Vec : typeof Vec -+>__proto__ : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } -+>Vec : { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; } ++>__proto__ : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } ++>Vec : { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; } get x() { -->x : number -+>x : any - + >x : number +@@= skipped -49, +49 lines =@@ return this.storage[0]; >this.storage[0] : any >this.storage : any @@ -240,32 +222,16 @@ >storage : any >0 : 0 -@@= skipped -66, +66 lines =@@ - * @param {number} x - */ - set x(x) { -->x : number -->x : number -+>x : any -+>x : any - - this.storage[0] = x; -->this.storage[0] = x : number -+>this.storage[0] = x : any +@@= skipped -16, +16 lines =@@ + >this.storage[0] = x : number >this.storage[0] : any >this.storage : any ->this : { x: number; y: number; __proto__: typeof Vec; } +>this : any >storage : any >0 : 0 -->x : number -+>x : any - - }, - get y() { -->y : number -+>y : any - + >x : number +@@= skipped -12, +12 lines =@@ return this.storage[1]; >this.storage[1] : any >this.storage : any @@ -274,33 +240,21 @@ >storage : any >1 : 1 -@@= skipped -28, +28 lines =@@ - * @param {number} y - */ - set y(y) { -->y : number -->y : number -+>y : any -+>y : any - - this.storage[1] = y; -->this.storage[1] = y : number -+>this.storage[1] = y : any +@@= skipped -16, +16 lines =@@ + >this.storage[1] = y : number >this.storage[1] : any >this.storage : any ->this : { x: number; y: number; __proto__: typeof Vec; } +>this : any >storage : any >1 : 1 -->y : number -+>y : any - } - }; + >y : number +@@= skipped -9, +9 lines =@@ === referencer.js === import {Point2D} from "./source"; ->Point2D : typeof Point2D -+>Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } ++>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } export const origin = new Point2D(0, 0); ->origin : Point2D @@ -308,7 +262,7 @@ ->Point2D : typeof Point2D +>origin : any +>new Point2D(0, 0) : any -+>Point2D : { (x: any, y: any): any; prototype: { __proto__: { (len: any): void; prototype: { dot: (other: any) => number; magnitude: () => number; }; }; x: any; y: any; }; } ++>Point2D : { (x: number, y: number): any; prototype: { __proto__: { (len: number): void; prototype: { dot: (other: Vec) => number; magnitude: () => number; }; }; x: number; y: number; }; } >0 : 0 >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff new file mode 100644 index 0000000000..cd02080146 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff @@ -0,0 +1,76 @@ +--- old.jsDeclarationsFunctions.errors.txt ++++ new.jsDeclarationsFunctions.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++index.js(38,21): error TS2349: This expression is not callable. ++ Type '{ y: ???; }' has no call signatures. ++index.js(48,21): error TS2349: This expression is not callable. ++ Type '{ y: ???; }' has no call signatures. ++ ++ ++==== index.js (2 errors) ==== ++ export function a() {} ++ ++ export function b() {} ++ b.cat = "cat"; ++ ++ export function c() {} ++ c.Cls = class {} ++ ++ /** ++ * @param {number} a ++ * @param {number} b ++ * @return {string} ++ */ ++ export function d(a, b) { return /** @type {*} */(null); } ++ ++ /** ++ * @template T,U ++ * @param {T} a ++ * @param {U} b ++ * @return {T & U} ++ */ ++ export function e(a, b) { return /** @type {*} */(null); } ++ ++ /** ++ * @template T ++ * @param {T} a ++ */ ++ export function f(a) { ++ return a; ++ } ++ f.self = f; ++ ++ /** ++ * @param {{x: string}} a ++ * @param {{y: typeof b}} b ++ */ ++ function g(a, b) { ++ return a.x && b.y(); ++ ~ ++!!! error TS2349: This expression is not callable. ++!!! error TS2349: Type '{ y: ???; }' has no call signatures. ++ } ++ ++ export { g }; ++ ++ /** ++ * @param {{x: string}} a ++ * @param {{y: typeof b}} b ++ */ ++ function hh(a, b) { ++ return a.x && b.y(); ++ ~ ++!!! error TS2349: This expression is not callable. ++!!! error TS2349: Type '{ y: ???; }' has no call signatures. ++ } ++ ++ export { hh as h }; ++ ++ export function i() {} ++ export { i as ii }; ++ ++ export { j as jj }; ++ export function j() {} ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.types.diff index b85b33f237..293446ff19 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.types.diff @@ -27,33 +27,19 @@ >Cls : typeof Cls >class {} : typeof Cls -@@= skipped -25, +25 lines =@@ - * @return {string} - */ - export function d(a, b) { return /** @type {*} */(null); } -->d : (a: number, b: number) => string -->a : number -->b : number -->(null) : any -+>d : (a: any, b: any) => any -+>a : any -+>b : any -+>(null) : null +@@= skipped -29, +29 lines =@@ + >a : number + >b : number + >(null) : any ++>null : any /** * @template T,U -@@= skipped -12, +12 lines =@@ - * @return {T & U} - */ - export function e(a, b) { return /** @type {*} */(null); } -->e : (a: T, b: U) => T & U -->a : T -->b : U -->(null) : any -+>e : (a: any, b: any) => any -+>a : any -+>b : any -+>(null) : null +@@= skipped -12, +13 lines =@@ + >a : T + >b : U + >(null) : any ++>null : any /** * @template T @@ -61,13 +47,11 @@ */ export function f(a) { ->f : typeof f -->a : T -+>f : { (a: any): any; self: ???; } -+>a : any ++>f : { (a: T): T; self: ???; } + >a : T return a; -->a : T -+>a : any + >a : T } f.self = f; ->f.self = f : typeof f @@ -75,11 +59,11 @@ ->f : typeof f ->self : typeof f ->f : typeof f -+>f.self = f : { (a: any): any; self: ???; } -+>f.self : { (a: any): any; self: ???; } -+>f : { (a: any): any; self: ???; } -+>self : { (a: any): any; self: ???; } -+>f : { (a: any): any; self: ???; } ++>f.self = f : { (a: T): T; self: ???; } ++>f.self : { (a: T): T; self: ???; } ++>f : { (a: T): T; self: ???; } ++>self : { (a: T): T; self: ???; } ++>f : { (a: T): T; self: ???; } /** * @param {{x: string}} a @@ -87,34 +71,30 @@ */ function g(a, b) { ->g : (a: { x: string; }, b: { y: typeof import("index").b; }) => void -->a : { x: string; } ++>g : (a: { x: string; }, b: { y: ???; }) => any + >a : { x: string; } ->b : { y: typeof import("index").b; } -+>g : (a: any, b: any) => any -+>a : any -+>b : any ++>b : { y: ???; } return a.x && b.y(); ->a.x && b.y() : void -->a.x : string -->a : { x: string; } -->x : string ++>a.x && b.y() : any + >a.x : string + >a : { x: string; } + >x : string ->b.y() : void ->b.y : typeof import("index").b ->b : { y: typeof import("index").b; } ->y : typeof import("index").b -+>a.x && b.y() : any -+>a.x : any -+>a : any -+>x : any +>b.y() : any -+>b.y : any -+>b : any -+>y : any ++>b.y : { y: ???; } ++>b : { y: ???; } ++>y : { y: ???; } } export { g }; ->g : (a: { x: string; }, b: { y: typeof import("index").b; }) => void -+>g : (a: any, b: any) => any ++>g : (a: { x: string; }, b: { y: ???; }) => any /** * @param {{x: string}} a @@ -122,36 +102,32 @@ */ function hh(a, b) { ->hh : (a: { x: string; }, b: { y: typeof import("index").b; }) => void -->a : { x: string; } ++>hh : (a: { x: string; }, b: { y: ???; }) => any + >a : { x: string; } ->b : { y: typeof import("index").b; } -+>hh : (a: any, b: any) => any -+>a : any -+>b : any ++>b : { y: ???; } return a.x && b.y(); ->a.x && b.y() : void -->a.x : string -->a : { x: string; } -->x : string ++>a.x && b.y() : any + >a.x : string + >a : { x: string; } + >x : string ->b.y() : void ->b.y : typeof import("index").b ->b : { y: typeof import("index").b; } ->y : typeof import("index").b -+>a.x && b.y() : any -+>a.x : any -+>a : any -+>x : any +>b.y() : any -+>b.y : any -+>b : any -+>y : any ++>b.y : { y: ???; } ++>b : { y: ???; } ++>y : { y: ???; } } export { hh as h }; ->hh : (a: { x: string; }, b: { y: typeof import("index").b; }) => void ->h : (a: { x: string; }, b: { y: typeof import("index").b; }) => void -+>hh : (a: any, b: any) => any -+>h : (a: any, b: any) => any ++>hh : (a: { x: string; }, b: { y: ???; }) => any ++>h : (a: { x: string; }, b: { y: ???; }) => any export function i() {} >i : () => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff index a627695439..1d33520fdf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff @@ -13,7 +13,9 @@ +index.js(28,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +index.js(31,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +index.js(31,25): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++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(41,1): 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(51,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +index.js(53,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +index.js(54,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -23,7 +25,7 @@ +index.js(58,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + -+==== index.js (18 errors) ==== ++==== index.js (20 errors) ==== + module.exports.a = function a() {} + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -79,6 +81,8 @@ + /** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b ++ ~~~~~~ ++!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ + function g(a, b) { + return a.x && b.y(); @@ -91,6 +95,8 @@ + /** + * @param {{x: string}} a + * @param {{y: typeof module.exports.b}} b ++ ~~~~~~ ++!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ + function hh(a, b) { + return a.x && b.y(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff index 1b721e10f3..9709f467ba 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff @@ -104,7 +104,6 @@ ->d : (a: number, b: number) => string ->a : number ->b : number -->(null) : any +>module.exports.d = function d(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any +>module.exports.d : any +>module.exports : any @@ -115,11 +114,12 @@ +>d : (a: any, b: any) => any +>a : any +>b : any -+>(null) : null + >(null) : any ++>null : any /** * @template T,U -@@= skipped -19, +19 lines =@@ +@@= skipped -19, +20 lines =@@ * @return {T & U} */ module.exports.e = function e(a, b) { return /** @type {*} */(null); } @@ -133,7 +133,6 @@ ->e : (a: T, b: U) => T & U ->a : T ->b : U -->(null) : any +>module.exports.e = function e(a, b) { return /** @type {*} */(null); } : (a: any, b: any) => any +>module.exports.e : any +>module.exports : any @@ -144,7 +143,8 @@ +>e : (a: any, b: any) => any +>a : any +>b : any -+>(null) : null + >(null) : any ++>null : any /** * @template T @@ -208,28 +208,24 @@ */ function g(a, b) { ->g : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void -->a : { x: string; } ++>g : (a: { x: string; }, b: { y: any; }) => any + >a : { x: string; } ->b : { y: { (): void; cat: string; }; } -+>g : (a: any, b: any) => any -+>a : any -+>b : any ++>b : { y: any; } return a.x && b.y(); ->a.x && b.y() : void -->a.x : string -->a : { x: string; } -->x : string ++>a.x && b.y() : any + >a.x : string + >a : { x: string; } + >x : string ->b.y() : void ->b.y : { (): void; cat: string; } ->b : { y: { (): void; cat: string; }; } ->y : { (): void; cat: string; } -+>a.x && b.y() : any -+>a.x : any -+>a : any -+>x : any +>b.y() : any +>b.y : any -+>b : any ++>b : { y: any; } +>y : any } @@ -241,13 +237,13 @@ ->exports : typeof module.exports ->g : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void ->g : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void -+>module.exports.g = g : (a: any, b: any) => any ++>module.exports.g = g : (a: { x: string; }, b: { y: any; }) => any +>module.exports.g : any +>module.exports : any +>module : any +>exports : any +>g : any -+>g : (a: any, b: any) => any ++>g : (a: { x: string; }, b: { y: any; }) => any /** * @param {{x: string}} a @@ -255,28 +251,24 @@ */ function hh(a, b) { ->hh : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void -->a : { x: string; } ++>hh : (a: { x: string; }, b: { y: any; }) => any + >a : { x: string; } ->b : { y: { (): void; cat: string; }; } -+>hh : (a: any, b: any) => any -+>a : any -+>b : any ++>b : { y: any; } return a.x && b.y(); ->a.x && b.y() : void -->a.x : string -->a : { x: string; } -->x : string ++>a.x && b.y() : any + >a.x : string + >a : { x: string; } + >x : string ->b.y() : void ->b.y : { (): void; cat: string; } ->b : { y: { (): void; cat: string; }; } ->y : { (): void; cat: string; } -+>a.x && b.y() : any -+>a.x : any -+>a : any -+>x : any +>b.y() : any +>b.y : any -+>b : any ++>b : { y: any; } +>y : any } @@ -288,13 +280,13 @@ ->exports : typeof module.exports ->h : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void ->hh : (a: { x: string; }, b: { y: { (): void; cat: string; }; }) => void -+>module.exports.h = hh : (a: any, b: any) => any ++>module.exports.h = hh : (a: { x: string; }, b: { y: any; }) => any +>module.exports.h : any +>module.exports : any +>module : any +>exports : any +>h : any -+>hh : (a: any, b: any) => any ++>hh : (a: { x: string; }, b: { y: any; }) => any module.exports.i = function i() {} >module.exports.i = function i() {} : () => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.types.diff index 85bcdf9c5c..82db53808c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.types.diff @@ -1,17 +1,6 @@ --- old.jsDeclarationsGetterSetter.types +++ new.jsDeclarationsGetterSetter.types -@@= skipped -18, +18 lines =@@ - * @param {number} _arg - */ - set x(_arg) { -->x : number -->_arg : number -+>x : any -+>_arg : any - } - } - -@@= skipped -32, +32 lines =@@ +@@= skipped -50, +50 lines =@@ >D : typeof D >prototype : D >"x" : "x" @@ -25,57 +14,28 @@ >prototype : E >"x" : "x" ->{ /** * @param {number} _arg */ set(_arg) {}} : { set(_arg: number): void; } -+>{ /** * @param {number} _arg */ set(_arg) {}} : { set: (_arg: any) => void; } ++>{ /** * @param {number} _arg */ set(_arg) {}} : { set: (_arg: number) => void; } /** * @param {number} _arg - */ - set(_arg) {} -->set : (_arg: number) => void -->_arg : number -+>set : (_arg: any) => void -+>_arg : any - - }); - @@= skipped -23, +23 lines =@@ >F : typeof F >prototype : F >"x" : "x" ->{ get() { return 12; }, /** * @param {number} _arg */ set(_arg) {}} : { get(): number; set(_arg: number): void; } -+>{ get() { return 12; }, /** * @param {number} _arg */ set(_arg) {}} : { get: () => number; set: (_arg: any) => void; } ++>{ get() { return 12; }, /** * @param {number} _arg */ set(_arg) {}} : { get: () => number; set: (_arg: number) => void; } get() { >get : () => number -@@= skipped -13, +13 lines =@@ - * @param {number} _arg - */ - set(_arg) {} -->set : (_arg: number) => void -->_arg : number -+>set : (_arg: any) => void -+>_arg : any - - }); - -@@= skipped -17, +17 lines =@@ +@@= skipped -30, +30 lines =@@ >G : typeof G >prototype : G >"x" : "x" ->{ /** * @param {number[]} args */ set(...args) {}} : { set(...args: number[]): void; } -+>{ /** * @param {number[]} args */ set(...args) {}} : { set: (v: any) => void; } ++>{ /** * @param {number[]} args */ set(...args) {}} : { set: (...args: number[]) => void; } /** * @param {number[]} args - */ - set(...args) {} -->set : (...args: number[]) => void -->args : number[] -+>set : (v: any) => void -+>args : [v: any] - - }); - @@= skipped -23, +23 lines =@@ >H : typeof H >prototype : H @@ -85,192 +45,3 @@ set() {} >set : () => void -@@= skipped -20, +20 lines =@@ - >I : typeof I - >prototype : I - >"x" : "x" -->{ /** * @param {number} v */ set: (v) => {}} : { set: (v: number) => void; } -+>{ /** * @param {number} v */ set: (v) => {}} : { set: (v: any) => void; } - - /** - * @param {number} v - */ - set: (v) => {} -->set : (v: number) => void -->(v) => {} : (v: number) => void -->v : number -+>set : (v: any) => void -+>(v) => {} : (v: any) => void -+>v : any - - }); - -@@= skipped -16, +16 lines =@@ - * @param {number} v - */ - const jSetter = (v) => {} -->jSetter : (v: number) => void -->(v) => {} : (v: number) => void -->v : number -+>jSetter : (v: any) => void -+>(v) => {} : (v: any) => void -+>v : any - - export class J {} - >J : J -@@= skipped -16, +16 lines =@@ - >J : typeof J - >prototype : J - >"x" : "x" -->{ set: jSetter} : { set: (v: number) => void; } -+>{ set: jSetter} : { set: (v: any) => void; } - - set: jSetter -->set : (v: number) => void -->jSetter : (v: number) => void -+>set : (v: any) => void -+>jSetter : (v: any) => void - - }); - -@@= skipped -12, +12 lines =@@ - * @param {number} v - */ - const kSetter1 = (v) => {} -->kSetter1 : (v: number) => void -->(v) => {} : (v: number) => void -->v : number -+>kSetter1 : (v: any) => void -+>(v) => {} : (v: any) => void -+>v : any - - /** - * @param {number} v - */ - const kSetter2 = (v) => {} -->kSetter2 : (v: number) => void -->(v) => {} : (v: number) => void -->v : number -+>kSetter2 : (v: any) => void -+>(v) => {} : (v: any) => void -+>v : any - - export class K {} - >K : K -@@= skipped -24, +24 lines =@@ - >K : typeof K - >prototype : K - >"x" : "x" -->{ set: Math.random() ? kSetter1 : kSetter2} : { set: (v: number) => void; } -+>{ set: Math.random() ? kSetter1 : kSetter2} : { set: (v: any) => void; } - - set: Math.random() ? kSetter1 : kSetter2 -->set : (v: number) => void -->Math.random() ? kSetter1 : kSetter2 : (v: number) => void -+>set : (v: any) => void -+>Math.random() ? kSetter1 : kSetter2 : (v: any) => void - >Math.random() : number - >Math.random : () => number - >Math : Math - >random : () => number -->kSetter1 : (v: number) => void -->kSetter2 : (v: number) => void -+>kSetter1 : (v: any) => void -+>kSetter2 : (v: any) => void - - }); - -@@= skipped -18, +18 lines =@@ - * @param {number} v - */ - const lSetter1 = (v) => {} -->lSetter1 : (v: number) => void -->(v) => {} : (v: number) => void -->v : number -+>lSetter1 : (v: any) => void -+>(v) => {} : (v: any) => void -+>v : any - - /** - * @param {string} v - */ - const lSetter2 = (v) => {} -->lSetter2 : (v: string) => void -->(v) => {} : (v: string) => void -->v : string -+>lSetter2 : (v: any) => void -+>(v) => {} : (v: any) => void -+>v : any - - export class L {} - >L : L -@@= skipped -24, +24 lines =@@ - >L : typeof L - >prototype : L - >"x" : "x" -->{ set: Math.random() ? lSetter1 : lSetter2} : { set: ((v: number) => void) | ((v: string) => void); } -+>{ set: Math.random() ? lSetter1 : lSetter2} : { set: (v: any) => void; } - - set: Math.random() ? lSetter1 : lSetter2 -->set : ((v: number) => void) | ((v: string) => void) -->Math.random() ? lSetter1 : lSetter2 : ((v: number) => void) | ((v: string) => void) -+>set : (v: any) => void -+>Math.random() ? lSetter1 : lSetter2 : (v: any) => void - >Math.random() : number - >Math.random : () => number - >Math : Math - >random : () => number -->lSetter1 : (v: number) => void -->lSetter2 : (v: string) => void -+>lSetter1 : (v: any) => void -+>lSetter2 : (v: any) => void - - }); - -@@= skipped -18, +18 lines =@@ - * @param {number | boolean} v - */ - const mSetter1 = (v) => {} -->mSetter1 : (v: number | boolean) => void -->(v) => {} : (v: number | boolean) => void -->v : number | boolean -+>mSetter1 : (v: any) => void -+>(v) => {} : (v: any) => void -+>v : any - - /** - * @param {string | boolean} v - */ - const mSetter2 = (v) => {} -->mSetter2 : (v: string | boolean) => void -->(v) => {} : (v: string | boolean) => void -->v : string | boolean -+>mSetter2 : (v: any) => void -+>(v) => {} : (v: any) => void -+>v : any - - export class M {} - >M : M -@@= skipped -24, +24 lines =@@ - >M : typeof M - >prototype : M - >"x" : "x" -->{ set: Math.random() ? mSetter1 : mSetter2} : { set: ((v: number | boolean) => void) | ((v: string | boolean) => void); } -+>{ set: Math.random() ? mSetter1 : mSetter2} : { set: (v: any) => void; } - - set: Math.random() ? mSetter1 : mSetter2 -->set : ((v: number | boolean) => void) | ((v: string | boolean) => void) -->Math.random() ? mSetter1 : mSetter2 : ((v: number | boolean) => void) | ((v: string | boolean) => void) -+>set : (v: any) => void -+>Math.random() ? mSetter1 : mSetter2 : (v: any) => void - >Math.random() : number - >Math.random : () => number - >Math : Math - >random : () => number -->mSetter1 : (v: number | boolean) => void -->mSetter2 : (v: string | boolean) => void -+>mSetter1 : (v: any) => void -+>mSetter2 : (v: any) => void - - }); - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff index 818f900585..53d5cc4eb9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff @@ -1,60 +1,76 @@ --- old.jsDeclarationsImportAliasExposedWithinNamespace.errors.txt +++ new.jsDeclarationsImportAliasExposedWithinNamespace.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -file2.js(1,9): error TS18042: 'myTypes' is a type and cannot be imported in JavaScript files. Use 'import("./file.js").myTypes' in a JSDoc type annotation. -- -- ++file.js(4,11): error TS2315: Type 'Object' is not generic. ++file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. ++file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. ++file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. ++file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. ++file2.js(6,11): error TS2315: Type 'Object' is not generic. ++file2.js(12,23): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. ++file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. + + -==== file.js (0 errors) ==== -- /** -- * @namespace myTypes -- * @global -- * @type {Object} -- */ -- const myTypes = { -- // SOME PROPS HERE -- }; -- -- /** @typedef {string|RegExp|Array} myTypes.typeA */ -- -- /** -- * @typedef myTypes.typeB -- * @property {myTypes.typeA} prop1 - Prop 1. -- * @property {string} prop2 - Prop 2. -- */ -- -- /** @typedef {myTypes.typeB|Function} myTypes.typeC */ -- -- export {myTypes}; ++==== file.js (5 errors) ==== + /** + * @namespace myTypes + * @global + * @type {Object} ++ ~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. + */ + const myTypes = { + // SOME PROPS HERE + }; + + /** @typedef {string|RegExp|Array} myTypes.typeA */ ++ ~~~~~~~ ++!!! error TS2300: Duplicate identifier 'myTypes'. + + /** + * @typedef myTypes.typeB ++ ~~~~~~~ ++!!! error TS2300: Duplicate identifier 'myTypes'. + * @property {myTypes.typeA} prop1 - Prop 1. + * @property {string} prop2 - Prop 2. + */ + + /** @typedef {myTypes.typeB|Function} myTypes.typeC */ ++ ~~~~~~~ ++!!! error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. ++ ~~~~~~~ ++!!! error TS2300: Duplicate identifier 'myTypes'. + + export {myTypes}; -==== file2.js (1 errors) ==== -- import {myTypes} from './file.js'; ++==== file2.js (3 errors) ==== + import {myTypes} from './file.js'; - ~~~~~~~ -!!! error TS18042: 'myTypes' is a type and cannot be imported in JavaScript files. Use 'import("./file.js").myTypes' in a JSDoc type annotation. -- -- /** -- * @namespace testFnTypes -- * @global -- * @type {Object} -- */ -- const testFnTypes = { -- // SOME PROPS HERE -- }; -- -- /** @typedef {boolean|myTypes.typeC} testFnTypes.input */ -- -- /** -- * @function testFn -- * @description A test function. -- * @param {testFnTypes.input} input - Input. -- * @returns {number|null} Result. -- */ -- function testFn(input) { -- if (typeof input === 'number') { -- return 2 * input; -- } else { -- return null; -- } -- } -- -- export {testFn, testFnTypes}; -@@= skipped --1, +1 lines =@@ -+ + + /** + * @namespace testFnTypes + * @global + * @type {Object} ++ ~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. + */ + const testFnTypes = { + // SOME PROPS HERE + }; + + /** @typedef {boolean|myTypes.typeC} testFnTypes.input */ ++ ~~~~~~~ ++!!! error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. + + /** + * @function testFn + * @description A test function. + * @param {testFnTypes.input} input - Input. ++ ~~~~~~~~~~~ ++!!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. + * @returns {number|null} Result. + */ + function testFn(input) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.types.diff index fb0393b31e..3d9e96f949 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.types.diff @@ -5,7 +5,7 @@ */ const myTypes = { ->myTypes : { [x: string]: any; } -+>myTypes : {} ++>myTypes : any >{ // SOME PROPS HERE} : {} // SOME PROPS HERE @@ -14,12 +14,12 @@ export {myTypes}; ->myTypes : { [x: string]: any; } -+>myTypes : {} ++>myTypes : any === file2.js === import {myTypes} from './file.js'; ->myTypes : { [x: string]: any; } -+>myTypes : {} ++>myTypes : any /** * @namespace testFnTypes @@ -28,7 +28,7 @@ */ const testFnTypes = { ->testFnTypes : { [x: string]: any; } -+>testFnTypes : {} ++>testFnTypes : any >{ // SOME PROPS HERE} : {} // SOME PROPS HERE @@ -38,14 +38,14 @@ function testFn(input) { ->testFn : (input: testFnTypes.input) => number | null ->input : import("file2").testFnTypes.input -+>testFn : (input: any) => number -+>input : any ++>testFn : (input: input) => number ++>input : input if (typeof input === 'number') { >typeof input === 'number' : boolean >typeof input : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->input : import("file2").testFnTypes.input -+>input : any ++>input : input >'number' : "number" return 2 * input; @@ -62,6 +62,6 @@ export {testFn, testFnTypes}; ->testFn : (input: testFnTypes.input) => number | null ->testFnTypes : { [x: string]: any; } -+>testFn : (input: any) => number -+>testFnTypes : {} ++>testFn : (input: input) => number ++>testFnTypes : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff index eec1b597c4..0153236330 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff @@ -4,10 +4,13 @@ - @@= skipped --1, +1 lines =@@ +file2.js(1,19): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++file2.js(6,11): error TS2315: Type 'Object' is not generic. ++file2.js(12,23): error TS2503: Cannot find namespace 'myTypes'. ++file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. +file2.js(28,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + -+==== file2.js (2 errors) ==== ++==== file2.js (5 errors) ==== + const {myTypes} = require('./file.js'); + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -16,17 +19,23 @@ + * @namespace testFnTypes + * @global + * @type {Object} ++ ~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. + */ + const testFnTypes = { + // SOME PROPS HERE + }; + + /** @typedef {boolean|myTypes.typeC} testFnTypes.input */ ++ ~~~~~~~ ++!!! error TS2503: Cannot find namespace 'myTypes'. + + /** + * @function testFn + * @description A test function. + * @param {testFnTypes.input} input - Input. ++ ~~~~~~~~~~~ ++!!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. + * @returns {number|null} Result. + */ + function testFn(input) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types.diff index de5864c7f9..e4b4d3e25a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types.diff @@ -16,7 +16,7 @@ */ const testFnTypes = { ->testFnTypes : { [x: string]: any; } -+>testFnTypes : {} ++>testFnTypes : any >{ // SOME PROPS HERE} : {} // SOME PROPS HERE @@ -26,14 +26,14 @@ function testFn(input) { ->testFn : (input: testFnTypes.input) => number | null ->input : boolean | myTypes.typeC -+>testFn : (input: any) => number -+>input : any ++>testFn : (input: input) => number ++>input : input if (typeof input === 'number') { >typeof input === 'number' : boolean >typeof input : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->input : boolean | myTypes.typeC -+>input : any ++>input : input >'number' : "number" return 2 * input; @@ -55,13 +55,13 @@ ->{testFn, testFnTypes} : { testFn: (input: testFnTypes.input) => number | null; testFnTypes: { [x: string]: any; }; } ->testFn : (input: testFnTypes.input) => number | null ->testFnTypes : { [x: string]: any; } -+>module.exports = {testFn, testFnTypes} : { testFn: (input: any) => number; testFnTypes: {}; } ++>module.exports = {testFn, testFnTypes} : { testFn: (input: input) => number; testFnTypes: any; } +>module.exports : any +>module : any +>exports : any -+>{testFn, testFnTypes} : { testFn: (input: any) => number; testFnTypes: {}; } -+>testFn : (input: any) => number -+>testFnTypes : {} ++>{testFn, testFnTypes} : { testFn: (input: input) => number; testFnTypes: any; } ++>testFn : (input: input) => number ++>testFnTypes : any -=== file.js === -/** diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff new file mode 100644 index 0000000000..ce41044958 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.jsDeclarationsImportNamespacedType.errors.txt ++++ new.jsDeclarationsImportNamespacedType.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++file.js(2,29): error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. ++ ++ ++==== file.js (1 errors) ==== ++ import { dummy } from './mod1' ++ /** @type {import('./mod1').Dotted.Name} - should work */ ++ ~~~~~~ ++!!! error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. ++ var dot2 ++ ++==== mod1.js (0 errors) ==== ++ /** @typedef {number} Dotted.Name */ ++ export var dummy = 1 ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.types.diff index 78dc2a90d6..9f3ba05a86 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.types.diff @@ -25,7 +25,7 @@ /** @type {(typeof import("./folder/mod1"))[]} */ const items = [{x: 12}]; ->items : import("folder/mod1").Item[] -+>items : { x: number; }[] ++>items : typeof import("folder/mod1")[] >[{x: 12}] : { x: number; }[] >{x: 12} : { x: number; } >x : number @@ -37,9 +37,9 @@ ->module : { exports: import("folder/mod1").Item[]; } ->exports : import("folder/mod1").Item[] ->items : import("folder/mod1").Item[] -+>module.exports = items : { x: number; }[] ++>module.exports = items : typeof import("folder/mod1")[] +>module.exports : any +>module : any +>exports : any -+>items : { x: number; }[] ++>items : typeof import("folder/mod1")[] diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff new file mode 100644 index 0000000000..fd7f1f4724 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff @@ -0,0 +1,65 @@ +--- old.jsDeclarationsJSDocRedirectedLookups.errors.txt ++++ new.jsDeclarationsJSDocRedirectedLookups.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++index.js(5,12): error TS2304: Cannot find name 'Void'. ++index.js(6,12): error TS2304: Cannot find name 'Undefined'. ++index.js(7,12): error TS2304: Cannot find name 'Null'. ++index.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++index.js(11,12): error TS2552: Cannot find name 'array'. Did you mean 'Array'? ++index.js(12,12): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? ++index.js(13,12): error TS2315: Type 'Object' is not generic. ++index.js(30,12): error TS2749: 'event' refers to a value, but is being used as a type here. Did you mean 'typeof event'? ++ ++ ++==== index.js (8 errors) ==== ++ // these are recognized as TS concepts by the checker ++ /** @type {String} */const a = ""; ++ /** @type {Number} */const b = 0; ++ /** @type {Boolean} */const c = true; ++ /** @type {Void} */const d = undefined; ++ ~~~~ ++!!! error TS2304: Cannot find name 'Void'. ++ /** @type {Undefined} */const e = undefined; ++ ~~~~~~~~~ ++!!! error TS2304: Cannot find name 'Undefined'. ++ /** @type {Null} */const f = null; ++ ~~~~ ++!!! error TS2304: Cannot find name 'Null'. ++ ++ /** @type {Function} */const g = () => void 0; ++ /** @type {function} */const h = () => void 0; ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ /** @type {array} */const i = []; ++ ~~~~~ ++!!! error TS2552: Cannot find name 'array'. Did you mean 'Array'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Array' is declared here. ++ /** @type {promise} */const j = Promise.resolve(0); ++ ~~~~~~~ ++!!! error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? ++!!! related TS2728 lib.es2015.promise.d.ts:--:--: 'Promise' is declared here. ++ /** @type {Object} */const k = {x: "x"}; ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ ++ ++ // these are not recognized as anything and should just be lookup failures ++ // ignore the errors to try to ensure they're emitted as `any` in declaration emit ++ // @ts-ignore ++ /** @type {class} */const l = true; ++ // @ts-ignore ++ /** @type {bool} */const m = true; ++ // @ts-ignore ++ /** @type {int} */const n = true; ++ // @ts-ignore ++ /** @type {float} */const o = true; ++ // @ts-ignore ++ /** @type {integer} */const p = true; ++ ++ // or, in the case of `event` likely erroneously refers to the type of the global Event object ++ /** @type {event} */const q = undefined; ++ ~~~~~ ++!!! error TS2749: 'event' refers to a value, but is being used as a type here. Did you mean 'typeof event'? diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.types.diff index dcd308c317..8de5245bea 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.types.diff @@ -5,59 +5,62 @@ // these are recognized as TS concepts by the checker /** @type {String} */const a = ""; ->a : string -+>a : "" ++>a : String >"" : "" /** @type {Number} */const b = 0; ->b : number -+>b : 0 ++>b : Number >0 : 0 /** @type {Boolean} */const c = true; ->c : boolean -+>c : true ++>c : Boolean >true : true /** @type {Void} */const d = undefined; ->d : void -+>d : undefined ++>d : Void >undefined : undefined /** @type {Undefined} */const e = undefined; -@@= skipped -23, +23 lines =@@ - >f : null +->e : undefined ++>e : Undefined + >undefined : undefined + + /** @type {Null} */const f = null; +->f : null ++>f : Null /** @type {Function} */const g = () => void 0; -->g : Function -+>g : () => undefined - >() => void 0 : () => undefined - >void 0 : undefined + >g : Function +@@= skipped -29, +29 lines =@@ >0 : 0 /** @type {function} */const h = () => void 0; ->h : Function -+>h : () => undefined ++>h : function >() => void 0 : () => undefined >void 0 : undefined >0 : 0 /** @type {array} */const i = []; ->i : any[] -+>i : never[] ++>i : array >[] : never[] /** @type {promise} */const j = Promise.resolve(0); ->j : Promise -+>j : Promise ++>j : promise >Promise.resolve(0) : Promise >Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } >Promise : PromiseConstructor -@@= skipped -24, +24 lines =@@ +@@= skipped -18, +18 lines =@@ >0 : 0 /** @type {Object} */const k = {x: "x"}; ->k : { [x: string]: string; } -+>k : { x: string; } ++>k : any >{x: "x"} : { x: string; } >x : string >"x" : "x" @@ -66,36 +69,36 @@ // @ts-ignore /** @type {class} */const l = true; ->l : error -+>l : true ++>l : class >true : true // @ts-ignore /** @type {bool} */const m = true; ->m : error -+>m : true ++>m : bool >true : true // @ts-ignore /** @type {int} */const n = true; ->n : error -+>n : true ++>n : int >true : true // @ts-ignore /** @type {float} */const o = true; ->o : error -+>o : true ++>o : float >true : true // @ts-ignore /** @type {integer} */const p = true; ->p : error -+>p : true ++>p : integer >true : true // or, in the case of `event` likely erroneously refers to the type of the global Event object /** @type {event} */const q = undefined; ->q : Event | undefined -+>q : undefined ++>q : event >undefined : undefined diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingGenerics.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingGenerics.errors.txt.diff new file mode 100644 index 0000000000..83d2307f9d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingGenerics.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.jsDeclarationsMissingGenerics.errors.txt ++++ new.jsDeclarationsMissingGenerics.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++file.js(2,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). ++file.js(6,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ ++ ++==== file.js (2 errors) ==== ++ /** ++ * @param {Array} x ++ ~~~~~ ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). ++ */ ++ function x(x) {} ++ /** ++ * @param {Promise} x ++ ~~~~~~~ ++!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ */ ++ function y(x) {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff new file mode 100644 index 0000000000..9fa727f35c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff @@ -0,0 +1,43 @@ +--- old.jsDeclarationsMissingTypeParameters.errors.txt ++++ new.jsDeclarationsMissingTypeParameters.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++file.js(2,13): error TS2314: Generic type 'T[]' requires 1 type argument(s). ++file.js(12,14): error TS2314: Generic type 'T[]' requires 1 type argument(s). ++file.js(12,19): error TS8020: JSDoc types can only be used inside documentation comments. ++file.js(12,20): error TS1099: Type argument list cannot be empty. ++file.js(18,14): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ ++ ++==== file.js (5 errors) ==== ++ /** ++ * @param {Array=} y desc ++ ~~~~~ ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). ++ */ ++ function x(y) { } ++ ++ // @ts-ignore ++ /** @param {function (Array)} func Invoked ++ */ ++ function y(func) { return; } ++ ++ /** ++ * @return {(Array.<> | null)} list of devices ++ ~~~~~~~~ ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. ++ ~~ ++!!! error TS1099: Type argument list cannot be empty. ++ */ ++ function z() { return null ;} ++ ++ /** ++ * ++ * @return {?Promise} A promise ++ ~~~~~~~ ++!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ */ ++ function w() { return null; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.types.diff index 3b61d0a996..d4a01d6813 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.types.diff @@ -6,7 +6,7 @@ function x(y) { } ->x : (y?: any[] | undefined) => void ->y : any[] -+>x : (y: any) => void ++>x : (y?: any) => void +>y : any // @ts-ignore diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff new file mode 100644 index 0000000000..0b455a33c0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.jsDeclarationsModuleReferenceHasEmit.errors.txt ++++ new.jsDeclarationsModuleReferenceHasEmit.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++index.js(9,11): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++ ++ ++==== index.js (1 errors) ==== ++ /** ++ * @module A ++ */ ++ class A {} ++ ++ ++ /** ++ * Target element ++ * @type {module:A} ++ ~~~~~~ ++!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++ */ ++ export let el = null; ++ ++ export default A; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.types.diff index ed86842dcc..0a0c71baee 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.types.diff @@ -5,7 +5,7 @@ */ export let el = null; ->el : error -+>el : any ++>el : module export default A; >A : A diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff new file mode 100644 index 0000000000..67afcc4341 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.jsDeclarationsNestedParams.errors.txt ++++ new.jsDeclarationsNestedParams.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++file.js(7,26): error TS8020: JSDoc types can only be used inside documentation comments. ++file.js(20,26): error TS8020: JSDoc types can only be used inside documentation comments. ++ ++ ++==== file.js (2 errors) ==== ++ class X { ++ /** ++ * Cancels the request, sending a cancellation to the other party ++ * @param {Object} error __auto_generated__ ++ * @param {string?} error.reason the error reason to send the cancellation with ++ * @param {string?} error.code the error code to send the cancellation with ++ * @returns {Promise.<*>} resolves when the event has been sent. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. ++ */ ++ async cancel({reason, code}) {} ++ } ++ ++ class Y { ++ /** ++ * Cancels the request, sending a cancellation to the other party ++ * @param {Object} error __auto_generated__ ++ * @param {string?} error.reason the error reason to send the cancellation with ++ * @param {Object} error.suberr ++ * @param {string?} error.suberr.reason the error reason to send the cancellation with ++ * @param {string?} error.suberr.code the error code to send the cancellation with ++ * @returns {Promise.<*>} resolves when the event has been sent. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. ++ */ ++ async cancel({reason, suberr}) {} ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.types.diff index 47dd234c84..955c308339 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.types.diff @@ -7,7 +7,7 @@ ->cancel : ({ reason, code }: { reason: string | null; code: string | null;}) => Promise ->reason : string ->code : string -+>cancel : (__0: { code: any; reason: any; }) => Promise ++>cancel : (__0: { code: any; reason: any; }) => Promise +>reason : any +>code : any } @@ -20,7 +20,7 @@ ->cancel : ({ reason, suberr }: { reason: string | null; suberr: { reason: string | null; code: string | null; };}) => Promise ->reason : string ->suberr : { reason: string | null; code: string | null; } -+>cancel : (__0: { reason: any; suberr: any; }) => Promise ++>cancel : (__0: { reason: any; suberr: any; }) => Promise +>reason : any +>suberr : any } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.types.diff index 2de115c9e7..cb81720b04 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.types.diff @@ -8,7 +8,7 @@ ->a : number ->b : number ->c : number -+>foo : (__0: { a: any; b: any; c: any; }) => any ++>foo : (__0: { a: any; b: any; c: any; }) => number +>a : any +>b : any +>c : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.types.diff index d1670d2eaf..076b5af32a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.types.diff @@ -8,7 +8,7 @@ ->a : number ->b : number | undefined ->c : number | undefined -+>foo : (__0: { a: any; b: any; c: any; }) => any ++>foo : (__0: { a: any; b: any; c: any; }) => number +>a : any +>b : any +>c : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff index 17b4baf21c..ab6b8594d0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff @@ -4,6 +4,7 @@ - @@= skipped --1, +1 lines =@@ +base.js(11,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++file.js(1,22): error TS2306: File 'base.js' is not a module. + + +==== base.js (1 errors) ==== @@ -21,8 +22,10 @@ + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + -+==== file.js (0 errors) ==== ++==== file.js (1 errors) ==== + /** @typedef {import('./base')} BaseFactory */ ++ ~~~~~~~~ ++!!! error TS2306: File 'base.js' is not a module. + /** + * @callback BaseFactoryFactory + * @param {import('./base')} factory diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff index 88e0ccb660..bc3ee2343a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff @@ -4,6 +4,7 @@ - @@= skipped --1, +1 lines =@@ +base.js(11,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++file.js(1,29): error TS2306: File 'base.js' is not a module. + + +==== base.js (1 errors) ==== @@ -21,8 +22,10 @@ + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + -+==== file.js (0 errors) ==== ++==== file.js (1 errors) ==== + /** @typedef {typeof import('./base')} BaseFactory */ ++ ~~~~~~~~ ++!!! error TS2306: File 'base.js' is not a module. + + /** + * diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.types.diff index bb6d1ed2ae..f9922a48d4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.types.diff @@ -73,7 +73,7 @@ const TabbedShowLayout = () => { ->TabbedShowLayout : React.SFC<{}> ->() => { return (

ok
);} : { (): JSX.Element; defaultProps: Partial<{}> | undefined; } -+>TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } ++>TabbedShowLayout : SFC<{}> +>() => { return (
ok
);} : { (): Element; defaultProps: { tabs: string; }; } return ( @@ -86,25 +86,21 @@ >div : any >className : string >key : string -@@= skipped -21, +21 lines =@@ - +@@= skipped -22, +22 lines =@@ TabbedShowLayout.defaultProps = { >TabbedShowLayout.defaultProps = { tabs: "default value"} : { tabs: string; } -->TabbedShowLayout.defaultProps : Partial<{}> | undefined + >TabbedShowLayout.defaultProps : Partial<{}> | undefined ->TabbedShowLayout : React.SFC<{}> -->defaultProps : Partial<{}> | undefined -+>TabbedShowLayout.defaultProps : { tabs: string; } -+>TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } -+>defaultProps : { tabs: string; } ++>TabbedShowLayout : SFC<{}> + >defaultProps : Partial<{}> | undefined >{ tabs: "default value"} : { tabs: string; } - tabs: "default value" -@@= skipped -12, +12 lines =@@ +@@= skipped -11, +11 lines =@@ }; export default TabbedShowLayout; ->TabbedShowLayout : React.SFC<{}> -+>TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } ++>TabbedShowLayout : SFC<{}> === jsDeclarationsReactComponents3.jsx === import React from "react"; @@ -114,7 +110,7 @@ const TabbedShowLayout = () => { ->TabbedShowLayout : { defaultProps: { tabs: string; }; } & ((props?: { elem: string; }) => JSX.Element) ->() => { return (
ok
);} : { (): JSX.Element; defaultProps: { tabs: string; }; } -+>TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } ++>TabbedShowLayout : { defaultProps: { tabs: string; }; } & ((props?: { elem: string; } | undefined) => Element) +>() => { return (
ok
);} : { (): Element; defaultProps: { tabs: string; }; } return ( @@ -132,7 +128,7 @@ >TabbedShowLayout.defaultProps = { tabs: "default value"} : { tabs: string; } >TabbedShowLayout.defaultProps : { tabs: string; } ->TabbedShowLayout : { defaultProps: { tabs: string; }; } & ((props?: { elem: string; }) => JSX.Element) -+>TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } ++>TabbedShowLayout : { defaultProps: { tabs: string; }; } & ((props?: { elem: string; } | undefined) => Element) >defaultProps : { tabs: string; } >{ tabs: "default value"} : { tabs: string; } @@ -141,7 +137,7 @@ export default TabbedShowLayout; ->TabbedShowLayout : { defaultProps: { tabs: string; }; } & ((props?: { elem: string; }) => JSX.Element) -+>TabbedShowLayout : { (): Element; defaultProps: { tabs: string; }; } ++>TabbedShowLayout : { defaultProps: { tabs: string; }; } & ((props?: { elem: string; } | undefined) => Element) === jsDeclarationsReactComponents4.jsx === import React from "react"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff new file mode 100644 index 0000000000..857b84e064 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff @@ -0,0 +1,46 @@ +--- old.jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt ++++ new.jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++index.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++index.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++index.js(22,12): error TS2315: Type 'Object' is not generic. ++index.js(22,18): error TS8020: JSDoc types can only be used inside documentation comments. ++ ++ ++==== index.js (4 errors) ==== ++ /** @type {?} */ ++ export const a = null; ++ ++ /** @type {*} */ ++ export const b = null; ++ ++ /** @type {string?} */ ++ export const c = null; ++ ++ /** @type {string=} */ ++ export const d = null; ++ ++ /** @type {string!} */ ++ export const e = null; ++ ++ /** @type {function(string, number): object} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ export const f = null; ++ ++ /** @type {function(new: object, string, number)} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ export const g = null; ++ ++ /** @type {Object.} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. ++ export const h = null; ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types.diff index 947063abd7..09e984f0b1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.types.diff @@ -1,31 +1,16 @@ --- old.jsDeclarationsReusesExistingNodesMappingJSDocTypes.types +++ new.jsDeclarationsReusesExistingNodesMappingJSDocTypes.types -@@= skipped -10, +10 lines =@@ - - /** @type {string?} */ - export const c = null; -->c : string -+>c : any - - /** @type {string=} */ - export const d = null; -->d : string -+>d : any - - /** @type {string!} */ - export const e = null; -->e : string -+>e : any +@@= skipped -22, +22 lines =@@ /** @type {function(string, number): object} */ export const f = null; ->f : (arg0: string, arg1: number) => object -+>f : any ++>f : function /** @type {function(new: object, string, number)} */ export const g = null; ->g : new (arg1: string, arg2: number) => any -+>g : any ++>g : function /** @type {Object.} */ export const h = null; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt.diff index fdadf3dc09..c0de87cea9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt.diff @@ -3,17 +3,11 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+index.js(83,9): error TS7032: Property 'p1' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+index.js(83,12): error TS7006: Parameter 'value' implicitly has an 'any' type. -+index.js(88,9): error TS7032: Property 'p2' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+index.js(88,12): error TS7006: Parameter 'value' implicitly has an 'any' type. -+index.js(93,9): error TS7032: Property 'p3' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+index.js(93,12): error TS7006: Parameter 'value' implicitly has an 'any' type. -+index.js(98,9): error TS7032: Property 'p4' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+index.js(98,12): error TS7006: Parameter 'value' implicitly has an 'any' type. ++index.js(45,17): error TS1051: A 'set' accessor cannot have an optional parameter. ++index.js(83,17): error TS1051: A 'set' accessor cannot have an optional parameter. + + -+==== index.js (8 errors) ==== ++==== index.js (2 errors) ==== + class С1 { + /** @type {string=} */ + p1 = undefined; @@ -59,6 +53,8 @@ + + /** @param {string=} value */ + set p1(value) { ++ ++!!! error TS1051: A 'set' accessor cannot have an optional parameter. + this.p1 = value; + } + @@ -97,37 +93,23 @@ + class С4 { + /** @param {string=} value */ + set p1(value) { -+ ~~ -+!!! error TS7032: Property 'p1' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+ ~~~~~ -+!!! error TS7006: Parameter 'value' implicitly has an 'any' type. ++ ++!!! error TS1051: A 'set' accessor cannot have an optional parameter. + this.p1 = value; + } + + /** @param {string | undefined} value */ + set p2(value) { -+ ~~ -+!!! error TS7032: Property 'p2' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+ ~~~~~ -+!!! error TS7006: Parameter 'value' implicitly has an 'any' type. + this.p2 = value; + } + + /** @param {?string} value */ + set p3(value) { -+ ~~ -+!!! error TS7032: Property 'p3' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+ ~~~~~ -+!!! error TS7006: Parameter 'value' implicitly has an 'any' type. + this.p3 = value; + } + + /** @param {string | null} value */ + set p4(value) { -+ ~~ -+!!! error TS7032: Property 'p4' implicitly has type 'any', because its set accessor lacks a parameter type annotation. -+ ~~~~~ -+!!! error TS7006: Parameter 'value' implicitly has an 'any' type. + this.p4 = value; + } + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.types.diff index c5ece9463c..3b34f975c9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.types.diff @@ -1,32 +1,6 @@ --- old.jsDeclarationsReusesExistingTypeAnnotations.types +++ new.jsDeclarationsReusesExistingTypeAnnotations.types -@@= skipped -5, +5 lines =@@ - - /** @type {string=} */ - p1 = undefined; -->p1 : string | undefined -+>p1 : undefined - >undefined : undefined - - /** @type {string | undefined} */ - p2 = undefined; -->p2 : string | undefined -+>p2 : undefined - >undefined : undefined - - /** @type {?string} */ - p3 = null; -->p3 : string | null -+>p3 : null - - /** @type {string | null} */ - p4 = null; -->p4 : string | null -+>p4 : null - } - - class С2 { -@@= skipped -22, +22 lines =@@ +@@= skipped -27, +27 lines =@@ /** @type {string=} */ get p1() { @@ -61,195 +35,3 @@ return null; } -@@= skipped -19, +19 lines =@@ - - /** @type {string=} */ - get p1() { -->p1 : string | undefined -+>p1 : undefined - - return undefined; - >undefined : undefined -@@= skipped -8, +8 lines =@@ - - /** @param {string=} value */ - set p1(value) { -->p1 : string | undefined -->value : string | undefined -+>p1 : undefined -+>value : undefined - - this.p1 = value; -->this.p1 = value : string | undefined -->this.p1 : string | undefined -+>this.p1 = value : undefined -+>this.p1 : undefined - >this : this -->p1 : string | undefined -->value : string | undefined -+>p1 : undefined -+>value : undefined - } - - /** @type {string | undefined} */ - get p2() { -->p2 : string | undefined -+>p2 : undefined - - return undefined; - >undefined : undefined -@@= skipped -21, +21 lines =@@ - - /** @param {string | undefined} value */ - set p2(value) { -->p2 : string | undefined -->value : string | undefined -+>p2 : undefined -+>value : undefined - - this.p2 = value; -->this.p2 = value : string | undefined -->this.p2 : string | undefined -+>this.p2 = value : undefined -+>this.p2 : undefined - >this : this -->p2 : string | undefined -->value : string | undefined -+>p2 : undefined -+>value : undefined - } - - /** @type {?string} */ - get p3() { -->p3 : string | null -+>p3 : null - - return null; - } - - /** @param {?string} value */ - set p3(value) { -->p3 : string | null -->value : string | null -+>p3 : null -+>value : null - - this.p3 = value; -->this.p3 = value : string | null -->this.p3 : string | null -+>this.p3 = value : null -+>this.p3 : null - >this : this -->p3 : string | null -->value : string | null -+>p3 : null -+>value : null - } - - /** @type {string | null} */ - get p4() { -->p4 : string | null -+>p4 : null - - return null; - } - - /** @param {string | null} value */ - set p4(value) { -->p4 : string | null -->value : string | null -+>p4 : null -+>value : null - - this.p4 = value; -->this.p4 = value : string | null -->this.p4 : string | null -+>this.p4 = value : null -+>this.p4 : null - >this : this -->p4 : string | null -->value : string | null -+>p4 : null -+>value : null - } - } - -@@= skipped -58, +58 lines =@@ - - /** @param {string=} value */ - set p1(value) { -->p1 : string | undefined -->value : string | undefined -+>p1 : any -+>value : any - - this.p1 = value; -->this.p1 = value : string | undefined -->this.p1 : string | undefined -+>this.p1 = value : any -+>this.p1 : any - >this : this -->p1 : string | undefined -->value : string | undefined -+>p1 : any -+>value : any - } - - /** @param {string | undefined} value */ - set p2(value) { -->p2 : string | undefined -->value : string | undefined -+>p2 : any -+>value : any - - this.p2 = value; -->this.p2 = value : string | undefined -->this.p2 : string | undefined -+>this.p2 = value : any -+>this.p2 : any - >this : this -->p2 : string | undefined -->value : string | undefined -+>p2 : any -+>value : any - } - - /** @param {?string} value */ - set p3(value) { -->p3 : string | null -->value : string | null -+>p3 : any -+>value : any - - this.p3 = value; -->this.p3 = value : string | null -->this.p3 : string | null -+>this.p3 = value : any -+>this.p3 : any - >this : this -->p3 : string | null -->value : string | null -+>p3 : any -+>value : any - } - - /** @param {string | null} value */ - set p4(value) { -->p4 : string | null -->value : string | null -+>p4 : any -+>value : any - - this.p4 = value; -->this.p4 = value : string | null -->this.p4 : string | null -+>this.p4 = value : any -+>this.p4 : any - >this : this -->p4 : string | null -->value : string | null -+>p4 : any -+>value : any - } - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.types.diff deleted file mode 100644 index 7eb7b1df94..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.types -+++ new.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.types -@@= skipped -8, +8 lines =@@ - * @param {string} secondArg - */ - constructor(firstArg, secondArg) { } -->firstArg : string -->secondArg : string -+>firstArg : any -+>secondArg : any - } - - export class Sub extends Super { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.types.diff index 43134007da..294b6a424b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.types.diff @@ -1,25 +1,6 @@ --- old.jsDeclarationsTypeAliases.types +++ new.jsDeclarationsTypeAliases.types -@@= skipped -37, +37 lines =@@ - * @returns {SomeType} - */ - function doTheThing(x) { -->doTheThing : (x: number) => SomeType -->x : number -+>doTheThing : (x: any) => { x: string; } -+>x : any - - return {x: ""+x}; - >{x: ""+x} : { x: string; } - >x : string - >""+x : string - >"" : "" -->x : number -+>x : any - } - class ExportedThing { - >ExportedThing : ExportedThing -@@= skipped -18, +18 lines =@@ +@@= skipped -55, +55 lines =@@ >"ok" : "ok" } module.exports = { @@ -27,16 +8,10 @@ ->module.exports : typeof module.exports ->module : { exports: typeof module.exports; } ->exports : typeof module.exports -->{ doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } -+>module.exports = { doTheThing, ExportedThing,} : { doTheThing: (x: any) => { x: string; }; ExportedThing: typeof ExportedThing; } ++>module.exports = { doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } +>module.exports : any +>module : any +>exports : any -+>{ doTheThing, ExportedThing,} : { doTheThing: (x: any) => { x: string; }; ExportedThing: typeof ExportedThing; } + >{ doTheThing, ExportedThing,} : { doTheThing: (x: number) => SomeType; ExportedThing: typeof ExportedThing; } doTheThing, -->doTheThing : (x: number) => SomeType -+>doTheThing : (x: any) => { x: string; } - - ExportedThing, - >ExportedThing : typeof ExportedThing diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.types.diff index 974ec8181e..9cac2c44f6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.types.diff @@ -1,22 +1,14 @@ --- old.jsDeclarationsTypeReassignmentFromDeclaration.types +++ new.jsDeclarationsTypeReassignmentFromDeclaration.types -@@= skipped -13, +13 lines =@@ - === index.js === - /** @type {typeof import("/some-mod")} */ - const items = []; -->items : Item[] -+>items : any[] - >[] : undefined[] +@@= skipped -18, +18 lines =@@ module.exports = items; -->module.exports = items : Item[] + >module.exports = items : Item[] ->module.exports : Item[] ->module : { exports: Item[]; } ->exports : Item[] -->items : Item[] -+>module.exports = items : any[] +>module.exports : any +>module : any +>exports : any -+>items : any[] + >items : Item[] diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff index 4e172cc4ee..f71263fffb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff @@ -4,6 +4,7 @@ - @@= skipped --1, +1 lines =@@ +conn.js(11,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++usage.js(2,14): error TS1340: Module './conn' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./conn')'? +usage.js(10,14): error TS2339: Property 'connItem' does not exist on type 'Wrap'. +usage.js(12,14): error TS2339: Property 'another' does not exist on type 'Wrap'. +usage.js(16,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -24,9 +25,11 @@ + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + -+==== usage.js (3 errors) ==== ++==== usage.js (4 errors) ==== + /** + * @typedef {import("./conn")} Conn ++ ~~~~~~~~~~~~~~~~ ++!!! error TS1340: Module './conn' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./conn')'? + */ + + class Wrap { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff index abc353929c..e8f0b635bd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff @@ -3,34 +3,29 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+LazySet.js(5,7): error TS2451: Cannot redeclare block-scoped variable 'LazySet'. +LazySet.js(13,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+index.js(1,7): error TS2451: Cannot redeclare block-scoped variable 'LazySet'. +index.js(1,17): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++index.js(3,12): error TS2749: 'LazySet' refers to a value, but is being used as a type here. Did you mean 'typeof LazySet'? + + +==== index.js (2 errors) ==== + const LazySet = require("./LazySet"); -+ ~~~~~~~ -+!!! error TS2451: Cannot redeclare block-scoped variable 'LazySet'. -+!!! related TS6203 LazySet.js:5:7: 'LazySet' was also declared here. + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + /** @type {LazySet} */ ++ ~~~~~~~ ++!!! error TS2749: 'LazySet' refers to a value, but is being used as a type here. Did you mean 'typeof LazySet'? + const stringSet = undefined; + stringSet.addAll(stringSet); + + -+==== LazySet.js (2 errors) ==== ++==== LazySet.js (1 errors) ==== + // Comment out this JSDoc, and note that the errors index.js go away. + /** + * @typedef {Object} SomeObject + */ + class LazySet { -+ ~~~~~~~ -+!!! error TS2451: Cannot redeclare block-scoped variable 'LazySet'. -+!!! related TS6203 index.js:1:7: 'LazySet' was also declared here. + /** + * @param {LazySet} iterable + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.types.diff index bd3792d4d4..fcb2ee58f9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.types.diff @@ -11,49 +11,38 @@ >require : any >"./LazySet" : "./LazySet" - /** @type {LazySet} */ - const stringSet = undefined; -->stringSet : LazySet -+>stringSet : any +@@= skipped -11, +11 lines =@@ >undefined : undefined stringSet.addAll(stringSet); ->stringSet.addAll(stringSet) : void ->stringSet.addAll : (iterable: LazySet) => void -->stringSet : LazySet -->addAll : (iterable: LazySet) => void -->stringSet : LazySet +>stringSet.addAll(stringSet) : any +>stringSet.addAll : any -+>stringSet : any + >stringSet : LazySet +->addAll : (iterable: LazySet) => void +>addAll : any -+>stringSet : any + >stringSet : LazySet - === LazySet.js === -@@= skipped -30, +30 lines =@@ - * @param {LazySet} iterable +@@= skipped -20, +20 lines =@@ */ addAll(iterable) {} -->addAll : (iterable: LazySet) => void + >addAll : (iterable: LazySet) => void ->iterable : import("LazySet") -+>addAll : (iterable: any) => void -+>iterable : any ++>iterable : LazySet [Symbol.iterator]() {} >[Symbol.iterator] : () => void @@= skipped -11, +11 lines =@@ - } module.exports = LazySet; -->module.exports = LazySet : typeof LazySet + >module.exports = LazySet : typeof LazySet ->module.exports : typeof LazySet ->module : { exports: typeof LazySet; } ->exports : typeof LazySet -->LazySet : typeof LazySet -+>module.exports = LazySet : any +>module.exports : any +>module : any +>exports : any -+>LazySet : any + >LazySet : typeof LazySet diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.types.diff index 953d55a41c..bbe48c29d3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.types.diff @@ -7,31 +7,18 @@ ->send : (handlers: ResolveRejectMap) => Promise ->handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : (handlers: ResolveRejectMap) => Promise ->handlers : ResolveRejectMap -->new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : Promise -+>send : (handlers: any) => Promise -+>handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : (handlers: any) => Promise -+>handlers : any -+>new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : Promise ++>send : (handlers: { [id: string]: [Function, Function]; }) => Promise ++>handlers => new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : (handlers: { [id: string]: [Function, Function]; }) => Promise ++>handlers : { [id: string]: [Function, Function]; } + >new Promise((resolve, reject) => { handlers[++id] = [resolve, reject]}) : Promise >Promise : PromiseConstructor -->(resolve, reject) => { handlers[++id] = [resolve, reject]} : (resolve: (value: any) => void, reject: (reason?: any) => void) => void -->resolve : (value: any) => void -+>(resolve, reject) => { handlers[++id] = [resolve, reject]} : (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void -+>resolve : (value: unknown) => void - >reject : (reason?: any) => void - + >(resolve, reject) => { handlers[++id] = [resolve, reject]} : (resolve: (value: any) => void, reject: (reason?: any) => void) => void +@@= skipped -12, +12 lines =@@ handlers[++id] = [resolve, reject] -->handlers[++id] = [resolve, reject] : [(value: any) => void, (reason?: any) => void] -->handlers[++id] : [Function, Function] + >handlers[++id] = [resolve, reject] : [(value: any) => void, (reason?: any) => void] + >handlers[++id] : [Function, Function] ->handlers : ResolveRejectMap -+>handlers[++id] = [resolve, reject] : ((value: unknown) => void)[] -+>handlers[++id] : any -+>handlers : any ++>handlers : { [id: string]: [Function, Function]; } >++id : number >id : number -->[resolve, reject] : [(value: any) => void, (reason?: any) => void] -->resolve : (value: any) => void -+>[resolve, reject] : ((value: unknown) => void)[] -+>resolve : (value: unknown) => void - >reject : (reason?: any) => void - - }) + >[resolve, reject] : [(value: any) => void, (reason?: any) => void] diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff index 5b098b29d9..67bf093500 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff @@ -4,15 +4,18 @@ - @@= skipped --1, +1 lines =@@ +index.js(1,39): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++index.js(3,22): error TS2307: Cannot find module './module.js' or its corresponding type declarations. +index.js(21,1): 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 (3 errors) ==== + const {taskGroups, taskNameToGroup} = require('./module.js'); + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + /** @typedef {import('./module.js').TaskGroup} TaskGroup */ ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module './module.js' or its corresponding type declarations. + + /** + * @typedef TaskNode diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff index 0969f84dfa..73ec43650c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff @@ -18,9 +18,8 @@ */ constructor(x, y){} ->x : import("module").TaskGroup -->y : TaskNode +>x : any -+>y : any + >y : TaskNode } module.exports = MainThreadTasks; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt.diff new file mode 100644 index 0000000000..dd3cb451d4 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt.diff @@ -0,0 +1,28 @@ +--- old.jsDeclarationsUniqueSymbolUsage.errors.txt ++++ new.jsDeclarationsUniqueSymbolUsage.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++b.js(2,28): error TS2694: Namespace '"a"' has no exported member 'WithSymbol'. ++b.js(3,26): error TS2694: Namespace '"a"' has no exported member 'WithSymbol'. ++ ++ ++==== a.js (0 errors) ==== ++ export const kSymbol = Symbol("my-symbol"); ++ ++ /** ++ * @typedef {{[kSymbol]: true}} WithSymbol ++ */ ++==== b.js (2 errors) ==== ++ /** ++ * @returns {import('./a').WithSymbol} ++ ~~~~~~~~~~ ++!!! error TS2694: Namespace '"a"' has no exported member 'WithSymbol'. ++ * @param {import('./a').WithSymbol} value ++ ~~~~~~~~~~ ++!!! error TS2694: Namespace '"a"' has no exported member 'WithSymbol'. ++ */ ++ export function b(value) { ++ return value; ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.types.diff deleted file mode 100644 index f2d1b617e9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.types.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsdocBindingInUnreachableCode.types -+++ new.jsdocBindingInUnreachableCode.types -@@= skipped -7, +7 lines =@@ - * @param {string} s - */ - const x = function (s) { -->x : (s: string) => void -->function (s) { } : (s: string) => void -->s : string -+>x : (s: any) => void -+>function (s) { } : (s: any) => void -+>s : any - - }; - } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt.diff deleted file mode 100644 index e4de43455a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt.diff +++ /dev/null @@ -1,54 +0,0 @@ ---- old.jsdocCatchClauseWithTypeAnnotation.errors.txt -+++ new.jsdocCatchClauseWithTypeAnnotation.errors.txt -@@= skipped -0, +0 lines =@@ --foo.js(20,54): error TS2339: Property 'foo' does not exist on type 'unknown'. --foo.js(21,54): error TS2339: Property 'foo' does not exist on type 'unknown'. --foo.js(22,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. --foo.js(23,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. - foo.js(35,7): error TS2492: Cannot redeclare identifier 'err' in catch clause. --foo.js(46,45): error TS2339: Property 'x' does not exist on type '{}'. --foo.js(47,45): error TS2339: Property 'x' does not exist on type '{}'. --foo.js(48,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. --foo.js(49,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. - - --==== foo.js (9 errors) ==== -+==== foo.js (1 errors) ==== - /** - * @typedef {any} Any - */ -@@= skipped -29, +21 lines =@@ - try { } catch (/** @type {unknown} */ err) { console.log(err); } // should be OK - try { } catch (/** @type {Unknown} */ err) { console.log(err); } // should be OK - try { } catch (/** @type {unknown} */ err) { err.foo; } // error in the body -- ~~~ --!!! error TS2339: Property 'foo' does not exist on type 'unknown'. - try { } catch (/** @type {Unknown} */ err) { err.foo; } // error in the body -- ~~~ --!!! error TS2339: Property 'foo' does not exist on type 'unknown'. - try { } catch (/** @type {Error} */ err) { } // error in the type -- ~~~~~ --!!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. - try { } catch (/** @type {object} */ err) { } // error in the type -- ~~~~~~ --!!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. - - try { console.log(); } - // @ts-ignore -@@= skipped -36, +28 lines =@@ - try { } catch (/** @type {any} */ { x }) { x.foo; } // should be OK - try { } catch (/** @type {Any} */ { x }) { x.foo;} // should be OK - try { } catch (/** @type {unknown} */ { x }) { console.log(x); } // error in the destructure -- ~ --!!! error TS2339: Property 'x' does not exist on type '{}'. - try { } catch (/** @type {Unknown} */ { x }) { console.log(x); } // error in the destructure -- ~ --!!! error TS2339: Property 'x' does not exist on type '{}'. - try { } catch (/** @type {Error} */ { x }) { } // error in the type -- ~~~~~ --!!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. - try { } catch (/** @type {object} */ { x }) { } // error in the type -- ~~~~~~ --!!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.types.diff deleted file mode 100644 index 2f23df8525..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.types.diff +++ /dev/null @@ -1,73 +0,0 @@ ---- old.jsdocCatchClauseWithTypeAnnotation.types -+++ new.jsdocCatchClauseWithTypeAnnotation.types -@@= skipped -21, +21 lines =@@ - >err : any - - try { } catch (/** @type {unknown} */ err) { } // should be OK -->err : unknown -+>err : any - - try { } catch (/** @type {Unknown} */ err) { } // should be OK -->err : unknown -+>err : any - - try { } catch (err) { err.foo; } // should be OK - >err : any -@@= skipped -24, +24 lines =@@ - >foo : any - - try { } catch (/** @type {unknown} */ err) { console.log(err); } // should be OK -->err : unknown -+>err : any - >console.log(err) : void - >console.log : (...data: any[]) => void - >console : Console - >log : (...data: any[]) => void -->err : unknown -+>err : any - - try { } catch (/** @type {Unknown} */ err) { console.log(err); } // should be OK -->err : unknown -+>err : any - >console.log(err) : void - >console.log : (...data: any[]) => void - >console : Console - >log : (...data: any[]) => void -->err : unknown -+>err : any - - try { } catch (/** @type {unknown} */ err) { err.foo; } // error in the body -->err : unknown -+>err : any - >err.foo : any -->err : unknown -+>err : any - >foo : any - - try { } catch (/** @type {Unknown} */ err) { err.foo; } // error in the body -->err : unknown -+>err : any - >err.foo : any -->err : unknown -+>err : any - >foo : any - - try { } catch (/** @type {Error} */ err) { } // error in the type -@@= skipped -61, +61 lines =@@ - - /** @type {string} */ - let err; -->err : string -+>err : any - } - try { } - catch (err) { -@@= skipped -8, +8 lines =@@ - - /** @type {boolean} */ - var err; -->err : boolean -+>err : any - } - - try { } catch ({ x }) { } // should be OK diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff index cb035fb3cc..c21b318347 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff @@ -3,7 +3,7 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+jsdocConstructorFunctionTypeReference.js(10,36): error TS7006: Parameter 'state' implicitly has an 'any' type. ++jsdocConstructorFunctionTypeReference.js(8,12): error TS2749: 'Validator' refers to a value, but is being used as a type here. Did you mean 'typeof Validator'? + + +==== jsdocConstructorFunctionTypeReference.js (1 errors) ==== @@ -15,10 +15,10 @@ + + /** + * @param {Validator} state ++ ~~~~~~~~~ ++!!! error TS2749: 'Validator' refers to a value, but is being used as a type here. Did you mean 'typeof Validator'? + */ + var validateRegExpFlags = function(state) { -+ ~~~~~ -+!!! error TS7006: Parameter 'state' implicitly has an 'any' type. + return state.flags + }; + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.types.diff index 07e6ec3e39..c72b259db6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.types.diff @@ -35,16 +35,16 @@ ->validateRegExpFlags : (state: Validator) => string ->function(state) { return state.flags} : (state: Validator) => string ->state : VFunc -+>validateRegExpFlags : (state: any) => any -+>function(state) { return state.flags} : (state: any) => any -+>state : any ++>validateRegExpFlags : (state: Validator) => any ++>function(state) { return state.flags} : (state: Validator) => any ++>state : Validator return state.flags ->state.flags : string ->state : VFunc ->flags : string +>state.flags : any -+>state : any ++>state : Validator +>flags : any }; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff index 5f89e2ed65..4dfb3b025c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff @@ -3,24 +3,28 @@ @@= skipped -0, +0 lines =@@ -functions.js(65,14): error TS2345: Argument of type 'typeof E' is not assignable to parameter of type 'new (arg1: number) => { length: number; }'. - Property 'length' is missing in type 'E' but required in type '{ length: number; }'. ++functions.js(3,13): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +functions.js(5,14): error TS7006: Parameter 'c' implicitly has an 'any' type. +functions.js(9,23): error TS7006: Parameter 'n' implicitly has an 'any' type. ++functions.js(13,13): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +functions.js(15,14): error TS7006: Parameter 'c' implicitly has an 'any' type. -+functions.js(21,17): error TS7006: Parameter 'n' implicitly has an 'any' type. +functions.js(22,14): error TS2339: Property 'length' does not exist on type 'C'. ++functions.js(30,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +functions.js(31,19): error TS7006: Parameter 'ab' implicitly has an 'any' type. +functions.js(31,23): error TS7006: Parameter 'onetwo' implicitly has an 'any' type. -+functions.js(38,12): error TS7006: Parameter 'n' implicitly has an 'any' type. ++functions.js(49,13): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? +functions.js(51,26): error TS7006: Parameter 'dref' implicitly has an 'any' type. -+functions.js(60,18): error TS7006: Parameter 'n' implicitly has an 'any' type. +functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. -==== functions.js (1 errors) ==== -+==== functions.js (11 errors) ==== ++==== functions.js (12 errors) ==== /** * @param {function(this: string, number): number} c is just passing on through * @return {function(this: string, number): number} ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. */ function id1(c) { + ~ @@ -35,6 +39,9 @@ /** * @param {function(new: { length: number }, number): number} c is just passing on through * @return {function(new: { length: number }, number): number} ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. */ function id2(c) { + ~ @@ -42,20 +49,22 @@ return c } - class C { +@@= skipped -24, +46 lines =@@ /** @param {number} n */ constructor(n) { -+ ~ -+!!! error TS7006: Parameter 'n' implicitly has an 'any' type. this.length = n; + ~~~~~~ +!!! error TS2339: Property 'length' does not exist on type 'C'. } } -@@= skipped -33, +52 lines =@@ +@@= skipped -8, +10 lines =@@ + z.length; /** @type {function ("a" | "b", 1 | 2): 3 | 4} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. var f = function (ab, onetwo) { return ab === "a" ? 3 : 4; } + ~~ +!!! error TS7006: Parameter 'ab' implicitly has an 'any' type. @@ -64,17 +73,12 @@ /** -@@= skipped -7, +11 lines =@@ - * @param {number} n - */ - function D(n) { -+ ~ -+!!! error TS7006: Parameter 'n' implicitly has an 'any' type. - this.length = n; - } - -@@= skipped -13, +15 lines =@@ +@@= skipped -19, +26 lines =@@ + /** + * @param {function(new: D, number)} dref * @return {D} ++ ~ ++!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? */ var construct = function(dref) { return new dref(33); } + ~~~~ @@ -82,14 +86,7 @@ var z3 = construct(D); z3.length; -@@= skipped -9, +11 lines =@@ - * @param {number} n - */ - var E = function(n) { -+ ~ -+!!! error TS7006: Parameter 'n' implicitly has an 'any' type. - this.not_length_on_purpose = n; - }; +@@= skipped -16, +20 lines =@@ var y3 = id2(E); @@ -100,7 +97,7 @@ // Repro from #39229 -@@= skipped -16, +14 lines =@@ +@@= skipped -11, +7 lines =@@ * @type {(...args: [string, string] | [number, string, string]) => void} */ function foo(...args) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.types.diff index ed9309fc49..99cde71581 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.types.diff @@ -6,7 +6,7 @@ function id1(c) { ->id1 : (c: (this: string, arg1: number) => number) => (this: string, arg1: number) => number ->c : (this: string, arg1: number) => number -+>id1 : (c: any) => any ++>id1 : (c: any) => function +>c : any return c @@ -25,9 +25,9 @@ ->this : string ->length : number ->n : number -+>x : any -+>id1(function (n) { return this.length + n }) : any -+>id1 : (c: any) => any ++>x : function ++>id1(function (n) { return this.length + n }) : function ++>id1 : (c: any) => function +>function (n) { return this.length + n } : (n: any) => any +>n : any +>this.length + n : any @@ -43,7 +43,7 @@ function id2(c) { ->id2 : (c: new (arg1: number) => { length: number; }) => new (arg1: number) => { length: number; } ->c : new (arg1: number) => { length: number; } -+>id2 : (c: any) => any ++>id2 : (c: any) => function +>c : any return c @@ -52,31 +52,16 @@ } class C { -@@= skipped -36, +36 lines =@@ - - /** @param {number} n */ - constructor(n) { -->n : number -+>n : any - - this.length = n; -->this.length = n : number -+>this.length = n : any - >this.length : any - >this : this - >length : any -->n : number -+>n : any - } +@@= skipped -48, +48 lines =@@ } var y = id2(C); ->y : new (arg1: number) => { length: number; } ->id2(C) : new (arg1: number) => { length: number; } ->id2 : (c: new (arg1: number) => { length: number; }) => new (arg1: number) => { length: number; } -+>y : any -+>id2(C) : any -+>id2 : (c: any) => any ++>y : function ++>id2(C) : function ++>id2 : (c: any) => function >C : typeof C var z = new y(12); @@ -85,7 +70,7 @@ ->y : new (arg1: number) => { length: number; } +>z : any +>new y(12) : any -+>y : any ++>y : function >12 : 12 z.length; @@ -102,7 +87,7 @@ ->function (ab, onetwo) { return ab === "a" ? 3 : 4; } : (ab: "a" | "b", onetwo: 1 | 2) => 3 | 4 ->ab : "a" | "b" ->onetwo : 1 | 2 -+>f : (ab: any, onetwo: any) => 3 | 4 ++>f : function +>function (ab, onetwo) { return ab === "a" ? 3 : 4; } : (ab: any, onetwo: any) => 3 | 4 +>ab : any +>onetwo : any @@ -113,24 +98,21 @@ >"a" : "a" >3 : 3 >4 : 4 -@@= skipped -47, +47 lines =@@ +@@= skipped -35, +35 lines =@@ * @param {number} n */ function D(n) { ->D : typeof D -->n : number -+>D : (n: any) => void -+>n : any ++>D : (n: number) => void + >n : number this.length = n; -->this.length = n : number -+>this.length = n : any + >this.length = n : number >this.length : any ->this : this +>this : any >length : any -->n : number -+>n : any + >n : number } var y2 = id2(D); @@ -138,10 +120,10 @@ ->id2(D) : new (arg1: number) => { length: number; } ->id2 : (c: new (arg1: number) => { length: number; }) => new (arg1: number) => { length: number; } ->D : typeof D -+>y2 : any -+>id2(D) : any -+>id2 : (c: any) => any -+>D : (n: any) => void ++>y2 : function ++>id2(D) : function ++>id2 : (c: any) => function ++>D : (n: number) => void var z2 = new y2(33); ->z2 : { length: number; } @@ -149,7 +131,7 @@ ->y2 : new (arg1: number) => { length: number; } +>z2 : any +>new y2(33) : any -+>y2 : any ++>y2 : function >33 : 33 z2.length; @@ -171,29 +153,26 @@ ->dref : new (arg1: number) => D ->new dref(33) : D ->dref : new (arg1: number) => D -+>construct : (dref: any) => any -+>function(dref) { return new dref(33); } : (dref: any) => any ++>construct : (dref: any) => D ++>function(dref) { return new dref(33); } : (dref: any) => D +>dref : any +>new dref(33) : any +>dref : any >33 : 33 var z3 = construct(D); -->z3 : D -->construct(D) : D + >z3 : D + >construct(D) : D ->construct : (dref: new (arg1: number) => D) => D ->D : typeof D -+>z3 : any -+>construct(D) : any -+>construct : (dref: any) => any -+>D : (n: any) => void ++>construct : (dref: any) => D ++>D : (n: number) => void z3.length; ->z3.length : number -->z3 : D -->length : number +>z3.length : any -+>z3 : any + >z3 : D +->length : number +>length : any @@ -204,22 +183,19 @@ var E = function(n) { ->E : typeof E ->function(n) { this.not_length_on_purpose = n;} : typeof E -->n : number -+>E : (n: any) => void -+>function(n) { this.not_length_on_purpose = n;} : (n: any) => void -+>n : any ++>E : (n: number) => void ++>function(n) { this.not_length_on_purpose = n;} : (n: number) => void + >n : number this.not_length_on_purpose = n; -->this.not_length_on_purpose = n : number -+>this.not_length_on_purpose = n : any + >this.not_length_on_purpose = n : number >this.not_length_on_purpose : any ->this : this +>this : any >not_length_on_purpose : any -->n : number -+>n : any + >n : number - }; +@@= skipped -15, +15 lines =@@ var y3 = id2(E); @@ -227,14 +203,14 @@ ->id2(E) : new (arg1: number) => { length: number; } ->id2 : (c: new (arg1: number) => { length: number; }) => new (arg1: number) => { length: number; } ->E : typeof E -+>y3 : any -+>id2(E) : any -+>id2 : (c: any) => any -+>E : (n: any) => void ++>y3 : function ++>id2(E) : function ++>id2 : (c: any) => function ++>E : (n: number) => void // Repro from #39229 -@@= skipped -26, +26 lines =@@ +@@= skipped -11, +11 lines =@@ * @type {(...args: [string, string] | [number, string, string]) => void} */ function foo(...args) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.types.diff index 0d4ecfe3ef..7d3db579f1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.types.diff @@ -1,15 +1,6 @@ --- old.jsdocImplements_class.types +++ new.jsdocImplements_class.types -@@= skipped -5, +5 lines =@@ - - /** @return {number} */ - method() { throw new Error(); } -->method : () => number -+>method : () => void - >new Error() : Error - >Error : ErrorConstructor - } -@@= skipped -30, +30 lines =@@ +@@= skipped -35, +35 lines =@@ var Ns = {}; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.errors.txt.diff new file mode 100644 index 0000000000..5b9e9bb1c1 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.jsdocImportType.errors.txt ++++ new.jsdocImportType.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++use.js(2,22): error TS2307: Cannot find module './mod1' or its corresponding type declarations. ++use.js(8,12): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? ++ ++ ++==== use.js (2 errors) ==== ++ /// ++ /** @typedef {import("./mod1")} C ++ ~~~~~~~~ ++!!! error TS2307: Cannot find module './mod1' or its corresponding type declarations. ++ * @type {C} */ ++ var c; ++ c.chunk; ++ ++ const D = require("./mod1"); ++ /** @type {D} */ ++ ~ ++!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? ++ var d; ++ d.chunk; ++ ++==== types.d.ts (0 errors) ==== ++ declare function require(name: string): any; ++ declare var exports: any; ++ declare var module: { exports: any }; ++==== mod1.js (0 errors) ==== ++ /// ++ class Chunk { ++ constructor() { ++ this.chunk = 1; ++ } ++ } ++ module.exports = Chunk; ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.types.diff index d06710a806..0080237768 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.types.diff @@ -23,22 +23,19 @@ >require : (name: string) => any >"./mod1" : "./mod1" - /** @type {D} */ - var d; -->d : D -+>d : any +@@= skipped -18, +18 lines =@@ + >d : D d.chunk; ->d.chunk : number -->d : D -->chunk : number +>d.chunk : any -+>d : any + >d : D +->chunk : number +>chunk : any === types.d.ts === declare function require(name: string): any; -@@= skipped -34, +34 lines =@@ +@@= skipped -16, +16 lines =@@ >module : { exports: any; } >exports : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff new file mode 100644 index 0000000000..09508f12a1 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.jsdocImportType2.errors.txt ++++ new.jsdocImportType2.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++use.js(2,22): error TS2307: Cannot find module './mod1' or its corresponding type declarations. ++use.js(8,12): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? ++ ++ ++==== use.js (2 errors) ==== ++ /// ++ /** @typedef {import("./mod1")} C ++ ~~~~~~~~ ++!!! error TS2307: Cannot find module './mod1' or its corresponding type declarations. ++ * @type {C} */ ++ var c; ++ c.chunk; ++ ++ const D = require("./mod1"); ++ /** @type {D} */ ++ ~ ++!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? ++ var d; ++ d.chunk; ++ ++==== types.d.ts (0 errors) ==== ++ declare function require(name: string): any; ++ declare var exports: any; ++ declare var module: { exports: any }; ++==== mod1.js (0 errors) ==== ++ /// ++ module.exports = class Chunk { ++ constructor() { ++ this.chunk = 1; ++ } ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.types.diff index 5a0498183b..a307c6c1c9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.types.diff @@ -23,22 +23,19 @@ >require : (name: string) => any >"./mod1" : "./mod1" - /** @type {D} */ - var d; -->d : D -+>d : any +@@= skipped -18, +18 lines =@@ + >d : D d.chunk; ->d.chunk : number -->d : D -->chunk : number +>d.chunk : any -+>d : any + >d : D +->chunk : number +>chunk : any === types.d.ts === declare function require(name: string): any; -@@= skipped -34, +34 lines =@@ +@@= skipped -16, +16 lines =@@ >module : { exports: any; } >exports : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff index e55e44a227..5bb0ac21ec 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff @@ -4,6 +4,7 @@ - @@= skipped --1, +1 lines =@@ +mod1.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++test.js(1,22): error TS2306: File 'mod1.js' is not a module. + + +==== mod1.js (1 errors) ==== @@ -14,8 +15,10 @@ + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + -+==== test.js (0 errors) ==== ++==== test.js (1 errors) ==== + /** @typedef {import('./mod1').C} X */ ++ ~~~~~~~~ ++!!! error TS2306: File 'mod1.js' is not a module. + /** @param {X} c */ + function demo(c) { + c.s diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt.diff new file mode 100644 index 0000000000..3f2fae2ebd --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.jsdocImportTypeReferenceToCommonjsModule.errors.txt ++++ new.jsdocImportTypeReferenceToCommonjsModule.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++test.js(1,13): error TS1340: Module './ex' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./ex')'? ++ ++ ++==== ex.d.ts (0 errors) ==== ++ declare var config: { ++ fix: boolean ++ } ++ export = config; ++ ++==== test.js (1 errors) ==== ++ /** @param {import('./ex')} a */ ++ ~~~~~~~~~~~~~~ ++!!! error TS1340: Module './ex' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./ex')'? ++ function demo(a) { ++ a.fix ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToESModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToESModule.errors.txt.diff new file mode 100644 index 0000000000..def5d93263 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToESModule.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.jsdocImportTypeReferenceToESModule.errors.txt ++++ new.jsdocImportTypeReferenceToESModule.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++test.js(1,13): error TS1340: Module './ex' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./ex')'? ++ ++ ++==== ex.d.ts (0 errors) ==== ++ export var config: {} ++ ++==== test.js (1 errors) ==== ++ /** @param {import('./ex')} a */ ++ ~~~~~~~~~~~~~~ ++!!! error TS1340: Module './ex' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./ex')'? ++ function demo(a) { ++ a.config ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt.diff new file mode 100644 index 0000000000..7ec491bcaa --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.jsdocImportTypeReferenceToStringLiteral.errors.txt ++++ new.jsdocImportTypeReferenceToStringLiteral.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++a.js(1,26): error TS2694: Namespace '"b"' has no exported member 'FOO'. ++ ++ ++==== b.js (0 errors) ==== ++ export const FOO = "foo"; ++ ++==== a.js (1 errors) ==== ++ /** @type {import('./b').FOO} */ ++ ~~~ ++!!! error TS2694: Namespace '"b"' has no exported member 'FOO'. ++ let x; ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocIndexSignature.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocIndexSignature.errors.txt.diff index 67f90c1063..b8d8c51d2a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocIndexSignature.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocIndexSignature.errors.txt.diff @@ -1,23 +1,46 @@ --- old.jsdocIndexSignature.errors.txt +++ new.jsdocIndexSignature.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -indices.js(9,5): error TS2322: Type 'number' is not assignable to type 'boolean'. -- -- ++indices.js(1,12): error TS2315: Type 'Object' is not generic. ++indices.js(1,18): error TS8020: JSDoc types can only be used inside documentation comments. ++indices.js(3,12): error TS2315: Type 'Object' is not generic. ++indices.js(3,18): error TS8020: JSDoc types can only be used inside documentation comments. ++indices.js(5,12): error TS2315: Type 'Object' is not generic. ++indices.js(5,18): error TS8020: JSDoc types can only be used inside documentation comments. ++indices.js(7,13): error TS2315: Type 'Object' is not generic. ++indices.js(7,19): error TS8020: JSDoc types can only be used inside documentation comments. + + -==== indices.js (1 errors) ==== -- /** @type {Object.} */ -- var o1; -- /** @type {Object.} */ -- var o2; -- /** @type {Object.} */ -- var o3; -- /** @param {Object.} o */ -- function f(o) { -- o.foo = 1; // error ++==== indices.js (8 errors) ==== + /** @type {Object.} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. + var o1; + /** @type {Object.} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. + var o2; + /** @type {Object.} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. + var o3; + /** @param {Object.} o */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. + function f(o) { + o.foo = 1; // error - ~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'boolean'. -- o.bar = false; // ok -- } -- -@@= skipped --1, +1 lines =@@ -+ + o.bar = false; // ok + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.types.diff index b3b98332b0..a921d61f84 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.types.diff @@ -5,38 +5,7 @@ */ function f(p1, p2, p3, p4, p5) { ->f : (p1: "literal", p2: "literal", p3: "literal" | "other", p4: "literal" | number, p5: 12 | true | "str") => string -->p1 : "literal" -->p2 : "literal" -->p3 : "literal" | "other" -->p4 : number | "literal" -->p5 : "str" | 12 | true -+>f : (p1: any, p2: any, p3: any, p4: any, p5: any) => string -+>p1 : any -+>p2 : any -+>p3 : any -+>p4 : any -+>p5 : any - - return p1 + p2 + p3 + p4 + p5 + '.'; - >p1 + p2 + p3 + p4 + p5 + '.' : string -->p1 + p2 + p3 + p4 + p5 : string -->p1 + p2 + p3 + p4 : string -->p1 + p2 + p3 : string -->p1 + p2 : string -->p1 : "literal" -->p2 : "literal" -->p3 : "literal" | "other" -->p4 : number | "literal" -->p5 : "str" | 12 | true -+>p1 + p2 + p3 + p4 + p5 : any -+>p1 + p2 + p3 + p4 : any -+>p1 + p2 + p3 : any -+>p1 + p2 : any -+>p1 : any -+>p2 : any -+>p3 : any -+>p4 : any -+>p5 : any - >'.' : "." - } - ++>f : (p1: "literal", p2: "literal", p3: "literal" | "other", p4: number | "literal", p5: "str" | 12 | true) => string + >p1 : "literal" + >p2 : "literal" + >p3 : "literal" | "other" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.types.diff deleted file mode 100644 index fe73817cd1..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.types.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsdocNeverUndefinedNull.types -+++ new.jsdocNeverUndefinedNull.types -@@= skipped -7, +7 lines =@@ - * @returns {void} nothing - */ - function f(p1, p2, p3) { -->f : (p1: never, p2: undefined, p3: null) => void -->p1 : never -->p2 : undefined -->p3 : null -+>f : (p1: any, p2: any, p3: any) => void -+>p1 : any -+>p2 : any -+>p3 : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff index 2c33e4dd18..a7781ae987 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff @@ -3,7 +3,7 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'jsdocOuterTypeParameters1.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. --jsdocOuterTypeParameters1.js(1,14): error TS2304: Cannot find name 'T'. + jsdocOuterTypeParameters1.js(1,14): error TS2304: Cannot find name 'T'. -jsdocOuterTypeParameters1.js(4,17): error TS2304: Cannot find name 'T'. -jsdocOuterTypeParameters1.js(4,19): error TS1069: Unexpected token. A type parameter name was expected without curly braces. jsdocOuterTypeParameters1.js(7,35): error TS2339: Property 'foo' does not exist on type 'Bar'. @@ -12,10 +12,10 @@ -!!! error TS5055: Cannot write file 'jsdocOuterTypeParameters1.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -==== jsdocOuterTypeParameters1.js (4 errors) ==== -+==== jsdocOuterTypeParameters1.js (1 errors) ==== ++==== jsdocOuterTypeParameters1.js (2 errors) ==== /** @return {T} */ -- ~ --!!! error TS2304: Cannot find name 'T'. + ~ + !!! error TS2304: Cannot find name 'T'. const dedupingMixin = function(mixin) {}; /** @template {T} */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.types.diff deleted file mode 100644 index bda5b3ab4a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.types.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsdocOuterTypeParameters1.types -+++ new.jsdocOuterTypeParameters1.types -@@= skipped -2, +2 lines =@@ - === jsdocOuterTypeParameters1.js === - /** @return {T} */ - const dedupingMixin = function(mixin) {}; -->dedupingMixin : (mixin: any) => T -->function(mixin) {} : (mixin: any) => T -+>dedupingMixin : (mixin: any) => void -+>function(mixin) {} : (mixin: any) => void - >mixin : any - - /** @template {T} */ - const PropertyAccessors = dedupingMixin(() => { -->PropertyAccessors : T -->dedupingMixin(() => { class Bar { static bar() { this.prototype.foo(); } }}) : T -->dedupingMixin : (mixin: any) => T -+>PropertyAccessors : void -+>dedupingMixin(() => { class Bar { static bar() { this.prototype.foo(); } }}) : void -+>dedupingMixin : (mixin: any) => void - >() => { class Bar { static bar() { this.prototype.foo(); } }} : () => void - - class Bar { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff index d1baa63090..837f743c5a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff @@ -4,16 +4,17 @@ -error TS5055: Cannot write file 'jsdocOuterTypeParameters1.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -jsdocOuterTypeParameters1.js(1,14): error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. ++jsdocOuterTypeParameters1.js(1,14): error TS2304: Cannot find name 'T'. jsdocOuterTypeParameters1.js(7,35): error TS2339: Property 'foo' does not exist on type 'Bar'. -!!! error TS5055: Cannot write file 'jsdocOuterTypeParameters1.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. --==== jsdocOuterTypeParameters1.js (2 errors) ==== -+==== jsdocOuterTypeParameters1.js (1 errors) ==== + ==== jsdocOuterTypeParameters1.js (2 errors) ==== /** @return {T} */ -- ~ + ~ -!!! error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. ++!!! error TS2304: Cannot find name 'T'. const dedupingMixin = function(mixin) {}; /** @template T */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.types.diff deleted file mode 100644 index e39f24636a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.types.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsdocOuterTypeParameters2.types -+++ new.jsdocOuterTypeParameters2.types -@@= skipped -2, +2 lines =@@ - === jsdocOuterTypeParameters1.js === - /** @return {T} */ - const dedupingMixin = function(mixin) {}; -->dedupingMixin : (mixin: any) => T -->function(mixin) {} : (mixin: any) => T -+>dedupingMixin : (mixin: any) => void -+>function(mixin) {} : (mixin: any) => void - >mixin : any - - /** @template T */ - const PropertyAccessors = dedupingMixin(() => { -->PropertyAccessors : T -->dedupingMixin(() => { class Bar { static bar() { this.prototype.foo(); } }}) : T -->dedupingMixin : (mixin: any) => T -+>PropertyAccessors : void -+>dedupingMixin(() => { class Bar { static bar() { this.prototype.foo(); } }}) : void -+>dedupingMixin : (mixin: any) => void - >() => { class Bar { static bar() { this.prototype.foo(); } }} : () => void - - class Bar { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.types.diff deleted file mode 100644 index 1158dba9dd..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.types.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.jsdocOverrideTag1.types -+++ new.jsdocOverrideTag1.types -@@= skipped -9, +9 lines =@@ - * @returns {boolean} - */ - foo (a) { -->foo : (a: string | number) => boolean -->a : string | number -+>foo : (a: any) => a is string -+>a : any - - return typeof a === 'string' - >typeof a === 'string' : boolean - >typeof a : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" -->a : string | number -+>a : any - >'string' : "string" - } - bar () { -@@= skipped -26, +26 lines =@@ - * @returns {boolean} - */ - foo (a) { -->foo : (a: string | number) => boolean -->a : string | number -+>foo : (a: any) => a is string -+>a : any - - return super.foo(a) - >super.foo(a) : boolean -->super.foo : (a: string | number) => boolean -+>super.foo : (a: any) => a is string - >super : A -->foo : (a: string | number) => boolean -->a : string | number -+>foo : (a: any) => a is string -+>a : any - } - - bar () { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.types.diff index 7ca76fe88c..384678651d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.types.diff @@ -7,14 +7,13 @@ ->good1 : ({ a, b }: { a: string; b: string; }, x: string) => void ->a : string ->b : string -->x : string -+>good1 : (__0: { a: any; b: any; }, x: any) => void ++>good1 : (__0: { a: any; b: any; }, x: string) => void +>a : any +>b : any -+>x : any + >x : string /** - * @param {{a: string, b: string}} obj +@@= skipped -10, +10 lines =@@ * @param {{c: number, d: number}} OBJECTION */ function good2({a, b}, {c, d}) {} @@ -31,20 +30,18 @@ /** * @param {number} x -@@= skipped -22, +22 lines =@@ +@@= skipped -12, +12 lines =@@ * @param {string} y */ function good3(x, {a, b}, y) {} ->good3 : (x: number, { a, b }: { a: string; b: string; }, y: string) => void -->x : number ++>good3 : (x: number, __1: { a: any; b: any; }, y: string) => void + >x : number ->a : string ->b : string -->y : string -+>good3 : (x: any, __1: { a: any; b: any; }, y: any) => void -+>x : any +>a : any +>b : any -+>y : any + >y : string /** * @param {{a: string, b: string}} obj @@ -66,14 +63,12 @@ ->good5 : ({ a, b }: { a: string; b: string;}, x: string) => void ->a : string ->b : string -->x : string -+>good5 : (__0: { a: any; b: any; }, x: any) => void ++>good5 : (__0: { a: any; b: any; }, x: string) => void +>a : any +>b : any -+>x : any + >x : string /** - * @param {Object} obj @@= skipped -14, +14 lines =@@ * @param {string} OBJECTION.d - meh */ @@ -96,18 +91,15 @@ */ function good7(x, {a, b}, y) {} ->good7 : (x: number, { a, b }: { a: string; b: string;}, y: string) => void -->x : number ++>good7 : (x: number, __1: { a: any; b: any; }, y: string) => void + >x : number ->a : string ->b : string -->y : string -+>good7 : (x: any, __1: { a: any; b: any; }, y: any) => void -+>x : any +>a : any +>b : any -+>y : any + >y : string /** - * @param {Object} obj @@= skipped -12, +12 lines =@@ * @param {string} obj.b */ @@ -144,12 +136,10 @@ */ function bad1(x, {a, b}) {} ->bad1 : (x: string, { a, b }: string) => void -->x : string -+>bad1 : (x: any, __1: { a: any; b: any; }) => void -+>x : any ++>bad1 : (x: string, __1: { a: any; b: any; }) => void + >x : string >a : any >b : any - @@= skipped -10, +10 lines =@@ * @param {{a: string, b: string}} obj */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff index 7b5acb674f..c9460f74db 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff @@ -1,71 +1,83 @@ --- old.jsdocParamTagTypeLiteral.errors.txt +++ new.jsdocParamTagTypeLiteral.errors.txt -@@= skipped -0, +0 lines =@@ +@@= skipped -0, +-1 lines =@@ -0.js(3,20): error TS8024: JSDoc '@param' tag has name 'unrelated', but there is no parameter with that name. -+0.js(5,17): error TS7006: Parameter 'notSpecial' implicitly has an 'any' type. -+0.js(17,15): error TS7006: Parameter 'opts1' implicitly has an 'any' type. -+0.js(28,52): error TS7006: Parameter 'opts2' implicitly has an 'any' type. -+0.js(38,15): error TS7006: Parameter 'opts3' implicitly has an 'any' type. -+0.js(50,15): error TS7006: Parameter 'opts4' implicitly has an 'any' type. -+0.js(66,15): error TS7006: Parameter 'opts5' implicitly has an 'any' type. - - +- +- -==== 0.js (1 errors) ==== -+==== 0.js (6 errors) ==== - /** - * @param {Object} notSpecial - * @param {string} unrelated - not actually related because it's not notSpecial.unrelated +- /** +- * @param {Object} notSpecial +- * @param {string} unrelated - not actually related because it's not notSpecial.unrelated - ~~~~~~~~~ -!!! error TS8024: JSDoc '@param' tag has name 'unrelated', but there is no parameter with that name. - */ - function normal(notSpecial) { -+ ~~~~~~~~~~ -+!!! error TS7006: Parameter 'notSpecial' implicitly has an 'any' type. - notSpecial; // should just be 'Object' - } - normal(12); -@@= skipped -20, +25 lines =@@ - * @param {string} [opts1.w="hi"] doc5 - */ - function foo1(opts1) { -+ ~~~~~ -+!!! error TS7006: Parameter 'opts1' implicitly has an 'any' type. - opts1.x; - } - -@@= skipped -11, +13 lines =@@ - * @param {string=} opts2[].anotherY - */ - function foo2(/** @param opts2 bad idea theatre! */opts2) { -+ ~~~~~ -+!!! error TS7006: Parameter 'opts2' implicitly has an 'any' type. - opts2[0].anotherX; - } - -@@= skipped -10, +12 lines =@@ - * @param {string} opts3.x - */ - function foo3(opts3) { -+ ~~~~~ -+!!! error TS7006: Parameter 'opts3' implicitly has an 'any' type. - opts3.x; - } - foo3({x: 'abc'}); -@@= skipped -12, +14 lines =@@ - * @param {string} [opts4[].w="hi"] - */ - function foo4(opts4) { -+ ~~~~~ -+!!! error TS7006: Parameter 'opts4' implicitly has an 'any' type. - opts4[0].x; - } - -@@= skipped -16, +18 lines =@@ - * @param {number} opts5[].unnest - Here we are almost all the way back at the beginning. - */ - function foo5(opts5) { -+ ~~~~~ -+!!! error TS7006: Parameter 'opts5' implicitly has an 'any' type. - opts5[0].what.bad[0].idea; - opts5[0].unnest; - } +- */ +- function normal(notSpecial) { +- notSpecial; // should just be 'Object' +- } +- normal(12); +- +- /** +- * @param {Object} opts1 doc1 +- * @param {string} opts1.x doc2 +- * @param {string=} opts1.y doc3 +- * @param {string} [opts1.z] doc4 +- * @param {string} [opts1.w="hi"] doc5 +- */ +- function foo1(opts1) { +- opts1.x; +- } +- +- foo1({x: 'abc'}); +- +- /** +- * @param {Object[]} opts2 +- * @param {string} opts2[].anotherX +- * @param {string=} opts2[].anotherY +- */ +- function foo2(/** @param opts2 bad idea theatre! */opts2) { +- opts2[0].anotherX; +- } +- +- foo2([{anotherX: "world"}]); +- +- /** +- * @param {object} opts3 +- * @param {string} opts3.x +- */ +- function foo3(opts3) { +- opts3.x; +- } +- foo3({x: 'abc'}); +- +- /** +- * @param {object[]} opts4 +- * @param {string} opts4[].x +- * @param {string=} opts4[].y +- * @param {string} [opts4[].z] +- * @param {string} [opts4[].w="hi"] +- */ +- function foo4(opts4) { +- opts4[0].x; +- } +- +- foo4([{ x: 'hi' }]); +- +- /** +- * @param {object[]} opts5 - Let's test out some multiple nesting levels +- * @param {string} opts5[].help - (This one is just normal) +- * @param {object} opts5[].what - Look at us go! Here's the first nest! +- * @param {string} opts5[].what.a - (Another normal one) +- * @param {Object[]} opts5[].what.bad - Now we're nesting inside a nested type +- * @param {string} opts5[].what.bad[].idea - I don't think you can get back out of this level... +- * @param {boolean} opts5[].what.bad[].oh - Oh ... that's how you do it. +- * @param {number} opts5[].unnest - Here we are almost all the way back at the beginning. +- */ +- function foo5(opts5) { +- opts5[0].what.bad[0].idea; +- opts5[0].unnest; +- } +- +- foo5([{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }]); +- +@@= skipped --1, +1 lines =@@ ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.types.diff index f210968315..49affed553 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.types.diff @@ -1,26 +1,6 @@ --- old.jsdocParamTagTypeLiteral.types +++ new.jsdocParamTagTypeLiteral.types -@@= skipped -5, +5 lines =@@ - * @param {string} unrelated - not actually related because it's not notSpecial.unrelated - */ - function normal(notSpecial) { -->normal : (notSpecial: Object) => void -->notSpecial : Object -+>normal : (notSpecial: any) => void -+>notSpecial : any - - notSpecial; // should just be 'Object' -->notSpecial : Object -+>notSpecial : any - } - normal(12); - >normal(12) : void -->normal : (notSpecial: Object) => void -+>normal : (notSpecial: any) => void - >12 : 12 - - /** -@@= skipped -19, +19 lines =@@ +@@= skipped -24, +24 lines =@@ * @param {string} [opts1.w="hi"] doc5 */ function foo1(opts1) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.errors.txt.diff deleted file mode 100644 index e6e876adcc..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsdocParseBackquotedParamName.errors.txt -+++ new.jsdocParseBackquotedParamName.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(5,18): error TS1016: A required parameter cannot follow an optional parameter. -+a.js(5,12): error TS7006: Parameter 'args' implicitly has an 'any' type. -+a.js(5,18): error TS7006: Parameter 'bwarg' implicitly has an 'any' type. - - --==== a.js (1 errors) ==== -+==== a.js (2 errors) ==== - /** - * @param {string=} `args` - * @param `bwarg` {?number?} - */ - function f(args, bwarg) { -+ ~~~~ -+!!! error TS7006: Parameter 'args' implicitly has an 'any' type. - ~~~~~ --!!! error TS1016: A required parameter cannot follow an optional parameter. -+!!! error TS7006: Parameter 'bwarg' implicitly has an 'any' type. - } - - ==== ts.ts (0 errors) ==== diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.types.diff index 94bc384066..754efe4f80 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.types.diff @@ -5,11 +5,7 @@ */ function f(args, bwarg) { ->f : (args?: string | undefined, bwarg: (number | null) | null) => void -->args : string | undefined -->bwarg : number | null -+>f : (args: any, bwarg: any) => void -+>args : any -+>bwarg : any ++>f : (args: string | undefined, bwarg: number | null) => void + >args : string | undefined + >bwarg : number | null } - - === ts.ts === diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff index 18fafa051f..00fe0a54aa 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff @@ -3,9 +3,11 @@ @@= skipped -0, +0 lines =@@ -a.js(2,13): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. +a.js(3,12): error TS7006: Parameter 'callback' implicitly has an 'any' type. ++a.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? - ==== a.js (1 errors) ==== +-==== a.js (1 errors) ==== ++==== a.js (2 errors) ==== // from bcryptjs /** @param {function(...[*])} callback */ - ~~~~~~~~~~~~~~~~ @@ -16,3 +18,11 @@ callback([1], [2], [3]) } + /** + * @type {!function(...number):string} ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + * @inner + */ + var stringFromCharCode = String.fromCharCode; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.types.diff index 2e3ae76421..6f3674deb3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.types.diff @@ -29,7 +29,7 @@ */ var stringFromCharCode = String.fromCharCode; ->stringFromCharCode : (...arg0: number[]) => string -+>stringFromCharCode : (...codes: number[]) => string ++>stringFromCharCode : function >String.fromCharCode : (...codes: number[]) => string >String : StringConstructor >fromCharCode : (...codes: number[]) => string diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff index 4b661c13ec..8649a77e4f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff @@ -3,12 +3,16 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +paren.js(2,10): error TS7006: Parameter 's' implicitly has an 'any' type. +paren.js(2,13): error TS7006: Parameter 'id' implicitly has an 'any' type. + + -+==== paren.js (2 errors) ==== ++==== paren.js (3 errors) ==== + /** @type {function((string), function((string)): string): string} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + var x = (s, id) => id(s) + ~ +!!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.types.diff index f379b2de9e..7ecfce7970 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.types.diff @@ -11,7 +11,7 @@ ->id(s) : string ->id : (arg0: (string)) => string ->s : string -+>x : (s: any, id: any) => any ++>x : function +>(s, id) => id(s) : (s: any, id: any) => any +>s : any +>id : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.errors.txt.diff deleted file mode 100644 index 3b910ca7a9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.errors.txt.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.jsdocParseMatchingBackticks.errors.txt -+++ new.jsdocParseMatchingBackticks.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+jsdocParseMatchingBackticks.js(12,19): error TS7006: Parameter 'x' implicitly has an 'any' type. -+jsdocParseMatchingBackticks.js(12,22): error TS7006: Parameter 'y' implicitly has an 'any' type. -+jsdocParseMatchingBackticks.js(12,25): error TS7006: Parameter 'z' implicitly has an 'any' type. -+jsdocParseMatchingBackticks.js(12,28): error TS7006: Parameter 'alpha' implicitly has an 'any' type. -+jsdocParseMatchingBackticks.js(12,35): error TS7006: Parameter 'beta' implicitly has an 'any' type. -+jsdocParseMatchingBackticks.js(12,41): error TS7006: Parameter 'gamma' implicitly has an 'any' type. -+ -+ -+==== jsdocParseMatchingBackticks.js (6 errors) ==== -+ /** -+ * `@param` initial at-param is OK in title comment -+ * @param {string} x hi there `@param` -+ * @param {string} y hi there `@ * param -+ * this is the margin -+ * so we'll drop everything before it -+ `@param` @param {string} z hello??? -+ * `@param` @param {string} alpha hello??? -+ * `@ * param` @param {string} beta hello??? -+ * @param {string} gamma -+ */ -+ export function f(x, y, z, alpha, beta, gamma) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'y' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'z' implicitly has an 'any' type. -+ ~~~~~ -+!!! error TS7006: Parameter 'alpha' implicitly has an 'any' type. -+ ~~~~ -+!!! error TS7006: Parameter 'beta' implicitly has an 'any' type. -+ ~~~~~ -+!!! error TS7006: Parameter 'gamma' implicitly has an 'any' type. -+ return x + y + z + alpha + beta + gamma -+ } -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.types.diff deleted file mode 100644 index 430d6467ee..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.types.diff +++ /dev/null @@ -1,46 +0,0 @@ ---- old.jsdocParseMatchingBackticks.types -+++ new.jsdocParseMatchingBackticks.types -@@= skipped -12, +12 lines =@@ - * @param {string} gamma - */ - export function f(x, y, z, alpha, beta, gamma) { -->f : (x: string, y: string, z: string, alpha: string, beta: string, gamma: string) => string -->x : string -->y : string -->z : string -->alpha : string -->beta : string -->gamma : string -+>f : (x: any, y: any, z: any, alpha: any, beta: any, gamma: any) => any -+>x : any -+>y : any -+>z : any -+>alpha : any -+>beta : any -+>gamma : any - - return x + y + z + alpha + beta + gamma -->x + y + z + alpha + beta + gamma : string -->x + y + z + alpha + beta : string -->x + y + z + alpha : string -->x + y + z : string -->x + y : string -->x : string -->y : string -->z : string -->alpha : string -->beta : string -->gamma : string -+>x + y + z + alpha + beta + gamma : any -+>x + y + z + alpha + beta : any -+>x + y + z + alpha : any -+>x + y + z : any -+>x + y : any -+>x : any -+>y : any -+>z : any -+>alpha : any -+>beta : any -+>gamma : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff index 493485caab..ee5d9700e8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff @@ -3,11 +3,15 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +paren.js(2,9): error TS7006: Parameter 's' implicitly has an 'any' type. + + -+==== paren.js (1 errors) ==== ++==== paren.js (2 errors) ==== + /** @type {function((string)): string} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + var x = s => s.toString() + ~ +!!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.types.diff index ef12063284..c66b206bda 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.types.diff @@ -11,7 +11,7 @@ ->s.toString : () => string ->s : string ->toString : () => string -+>x : (s: any) => any ++>x : function +>s => s.toString() : (s: any) => any +>s : any +>s.toString() : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff index 57d4c13aa4..31ed89d7a9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff @@ -3,16 +3,19 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+a.js(3,12): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. ++a.js(3,12): error TS2370: A rest parameter must be of an array type. ++a.js(3,19): error TS1047: A rest parameter cannot be optional. +a.js(12,14): error TS7006: Parameter 'f' implicitly has an 'any' type. + + -+==== a.js (2 errors) ==== ++==== a.js (3 errors) ==== + /** @param {...*=} args + @return {*=} */ + function f(...args) { + ~~~~~~~ -+!!! error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. ++!!! error TS2370: A rest parameter must be of an array type. ++ ++!!! error TS1047: A rest parameter cannot be optional. + return null + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.types.diff index 1ecafd1037..aa400dc80a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.types.diff @@ -6,8 +6,8 @@ function f(...args) { ->f : (...args?: any[] | undefined) => any | undefined ->args : any -+>f : (...args: any[]) => null -+>args : any[] ++>f : (...args: any[] | undefined) => any ++>args : any[] | undefined return null } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff index 0121bc4eb3..77d5754b7c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff @@ -1,10 +1,8 @@ --- old.jsdocPostfixEqualsAddsOptionality.errors.txt +++ new.jsdocPostfixEqualsAddsOptionality.errors.txt @@= skipped -0, +0 lines =@@ --a.js(4,5): error TS2322: Type 'null' is not assignable to type 'number | undefined'. --a.js(8,3): error TS2345: Argument of type 'null' is not assignable to parameter of type 'number | undefined'. -+a.js(2,12): error TS7006: Parameter 'a' implicitly has an 'any' type. -+a.js(7,1): error TS2554: Expected 1 arguments, but got 0. + a.js(4,5): error TS2322: Type 'null' is not assignable to type 'number | undefined'. + a.js(8,3): error TS2345: Argument of type 'null' is not assignable to parameter of type 'number | undefined'. +a.js(13,12): error TS7006: Parameter 'a' implicitly has an 'any' type. +a.js(18,1): error TS2554: Expected 1 arguments, but got 0. @@ -13,23 +11,8 @@ +==== a.js (4 errors) ==== /** @param {number=} a */ function f(a) { -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. a = 1 - a = null // should not be allowed -- ~ --!!! error TS2322: Type 'null' is not assignable to type 'number | undefined'. - a = undefined - } - f() -+ ~ -+!!! error TS2554: Expected 1 arguments, but got 0. -+!!! related TS6210 a.js:2:12: An argument for 'a' was not provided. - f(null) // should not be allowed -- ~~~~ --!!! error TS2345: Argument of type 'null' is not assignable to parameter of type 'number | undefined'. - f(undefined) - f(1) +@@= skipped -19, +21 lines =@@ /** @param {???!?number?=} a */ function g(a) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.types.diff index e10afb03b2..1f8c2f2f7d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.types.diff @@ -1,52 +1,6 @@ --- old.jsdocPostfixEqualsAddsOptionality.types +++ new.jsdocPostfixEqualsAddsOptionality.types -@@= skipped -2, +2 lines =@@ - === a.js === - /** @param {number=} a */ - function f(a) { -->f : (a?: number | undefined) => void -->a : number | undefined -+>f : (a: any) => void -+>a : any - - a = 1 - >a = 1 : 1 -->a : number | undefined -+>a : any - >1 : 1 - - a = null // should not be allowed - >a = null : null -->a : number | undefined -+>a : any - - a = undefined - >a = undefined : undefined -->a : number | undefined -+>a : any - >undefined : undefined - } - f() - >f() : void -->f : (a?: number | undefined) => void -+>f : (a: any) => void - - f(null) // should not be allowed - >f(null) : void -->f : (a?: number | undefined) => void -+>f : (a: any) => void - - f(undefined) - >f(undefined) : void -->f : (a?: number | undefined) => void -+>f : (a: any) => void - >undefined : undefined - - f(1) - >f(1) : void -->f : (a?: number | undefined) => void -+>f : (a: any) => void - >1 : 1 +@@= skipped -39, +39 lines =@@ /** @param {???!?number?=} a */ function g(a) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff index 6369772a84..9c29384ad3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff @@ -13,24 +13,18 @@ -prefixPostfix.js(14,21): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. -prefixPostfix.js(14,21): error TS1005: '}' expected. +prefixPostfix.js(18,12): error TS7006: Parameter 'x' implicitly has an 'any' type. -+prefixPostfix.js(18,15): error TS7006: Parameter 'y' implicitly has an 'any' type. +prefixPostfix.js(18,18): error TS7006: Parameter 'z' implicitly has an 'any' type. prefixPostfix.js(18,21): error TS7006: Parameter 'a' implicitly has an 'any' type. -+prefixPostfix.js(18,24): error TS7006: Parameter 'b' implicitly has an 'any' type. +prefixPostfix.js(18,27): error TS7006: Parameter 'c' implicitly has an 'any' type. -+prefixPostfix.js(18,30): error TS7006: Parameter 'e' implicitly has an 'any' type. +prefixPostfix.js(18,33): error TS7006: Parameter 'f' implicitly has an 'any' type. +prefixPostfix.js(18,36): error TS7006: Parameter 'g' implicitly has an 'any' type. prefixPostfix.js(18,39): error TS7006: Parameter 'h' implicitly has an 'any' type. -+prefixPostfix.js(18,42): error TS7006: Parameter 'i' implicitly has an 'any' type. +prefixPostfix.js(18,45): error TS7006: Parameter 'j' implicitly has an 'any' type. prefixPostfix.js(18,48): error TS7006: Parameter 'k' implicitly has an 'any' type. -+prefixPostfix.js(18,51): error TS7006: Parameter 'l' implicitly has an 'any' type. -+prefixPostfix.js(18,54): error TS7006: Parameter 'm' implicitly has an 'any' type. -==== prefixPostfix.js (14 errors) ==== -+==== prefixPostfix.js (15 errors) ==== ++==== prefixPostfix.js (9 errors) ==== /** * @param {number![]} x - number[] * @param {!number[]} y - number[] @@ -73,33 +67,20 @@ function f(x, y, z, a, b, c, e, f, g, h, i, j, k, l, m) { + ~ +!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'y' implicitly has an 'any' type. + ~ +!!! error TS7006: Parameter 'z' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. + ~ +!!! error TS7006: Parameter 'c' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'e' implicitly has an 'any' type. + ~ +!!! error TS7006: Parameter 'f' implicitly has an 'any' type. + ~ +!!! error TS7006: Parameter 'g' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'h' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'i' implicitly has an 'any' type. + ~ +!!! error TS7006: Parameter 'j' implicitly has an 'any' type. ~ !!! error TS7006: Parameter 'k' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'l' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'm' implicitly has an 'any' type. } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.types.diff index 0ad674c66f..d3dfe2602c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.types.diff @@ -6,32 +6,26 @@ function f(x, y, z, a, b, c, e, f, g, h, i, j, k, l, m) { ->f : (x: number[], y: number[], z: (number[]), a: any, b: number[] | null, c: (number[]) | null, e: (number | null)[], f: (number | null)[], g: (number | null)[], h: any, i: number[][], j: (number[] | null)[], k: any, l: number extends number ? true : false, m: [number, number?]) => void ->x : number[] -->y : number[] -->z : number[] -+>f : (x: any, y: any, z: any, a: any, b: any, c: any, e: any, f: any, g: any, h: any, i: any, j: any, k: any, l: any, m: any) => void ++>f : (x: any, y: number[], z: any, a: any, b: number[] | null, c: any, e: (number | null)[], f: any, g: any, h: any, i: number[][], j: any, k: any, l: true, m: [number, (number | undefined)?]) => void +>x : any -+>y : any + >y : number[] +->z : number[] +>z : any >a : any -->b : number[] | null + >b : number[] | null ->c : number[] | null ->e : number | null | undefined ->f : number | null | undefined ->g : number | null | undefined -+>b : any +>c : any -+>e : any ++>e : (number | null)[] +>f : any +>g : any >h : any ->i : number[] | undefined ->j : number[] | null | undefined -+>i : any ++>i : number[][] +>j : any >k : any -->l : true -->m : [number, (number | undefined)?] -+>l : any -+>m : any - } - + >l : true + >m : [number, (number | undefined)?] diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.errors.txt.diff deleted file mode 100644 index 2c8264ffb2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsdocPrivateName1.errors.txt -+++ new.jsdocPrivateName1.errors.txt -@@= skipped -0, +-1 lines =@@ --jsdocPrivateName1.js(3,5): error TS2322: Type 'number' is not assignable to type 'boolean'. -- -- --==== jsdocPrivateName1.js (1 errors) ==== -- class A { -- /** @type {boolean} some number value */ -- #foo = 3 // Error because not assignable to boolean -- ~~~~ --!!! error TS2322: Type 'number' is not assignable to type 'boolean'. -- } -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.types.diff deleted file mode 100644 index 78138593af..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsdocPrivateName1.types -+++ new.jsdocPrivateName1.types -@@= skipped -5, +5 lines =@@ - - /** @type {boolean} some number value */ - #foo = 3 // Error because not assignable to boolean -->#foo : boolean -+>#foo : number - >3 : 3 - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff index 3270f2608a..9977298d26 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff @@ -3,15 +3,19 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++returns.js(5,5): error TS2322: Type 'number' is not assignable to type 'string'. ++returns.js(12,5): error TS2322: Type 'number' is not assignable to type 'string'. +returns.js(19,12): error TS2872: This kind of expression is always truthy. + + -+==== returns.js (1 errors) ==== ++==== returns.js (3 errors) ==== + /** + * @returns {string} This comment is not currently exposed + */ + function f() { + return 5; ++ ~~~~~~ ++!!! error TS2322: Type 'number' is not assignable to type 'string'. + } + + /** @@ -19,6 +23,8 @@ + */ + function f1() { + return 5; ++ ~~~~~~ ++!!! error TS2322: Type 'number' is not assignable to type 'string'. + } + + /** diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.types.diff index 9e5295ea24..36874665df 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.types.diff @@ -1,29 +1,11 @@ --- old.jsdocReturnTag1.types +++ new.jsdocReturnTag1.types -@@= skipped -4, +4 lines =@@ - * @returns {string} This comment is not currently exposed - */ - function f() { -->f : () => string -+>f : () => number - - return 5; - >5 : 5 -@@= skipped -10, +10 lines =@@ +@@= skipped -14, +14 lines =@@ * @returns {string=} This comment is not currently exposed */ function f1() { ->f1 : () => string | undefined -+>f1 : () => number ++>f1 : () => string return 5; >5 : 5 -@@= skipped -10, +10 lines =@@ - * @returns {string|number} This comment is not currently exposed - */ - function f2() { -->f2 : () => string | number -+>f2 : () => "hello" | 5 - - return 5 || "hello"; - >5 || "hello" : "hello" | 5 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.errors.txt.diff deleted file mode 100644 index 2f6cc9d6fe..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.errors.txt.diff +++ /dev/null @@ -1,68 +0,0 @@ ---- old.jsdocSignatureOnReturnedFunction.errors.txt -+++ new.jsdocSignatureOnReturnedFunction.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+jsdocSignatureOnReturnedFunction.js(7,13): error TS7006: Parameter 'a' implicitly has an 'any' type. -+jsdocSignatureOnReturnedFunction.js(7,16): error TS7006: Parameter 'b' implicitly has an 'any' type. -+jsdocSignatureOnReturnedFunction.js(18,22): error TS7006: Parameter 'a' implicitly has an 'any' type. -+jsdocSignatureOnReturnedFunction.js(18,25): error TS7006: Parameter 'b' implicitly has an 'any' type. -+jsdocSignatureOnReturnedFunction.js(25,13): error TS7006: Parameter 'a' implicitly has an 'any' type. -+jsdocSignatureOnReturnedFunction.js(25,16): error TS7006: Parameter 'b' implicitly has an 'any' type. -+jsdocSignatureOnReturnedFunction.js(32,22): error TS7006: Parameter 'a' implicitly has an 'any' type. -+jsdocSignatureOnReturnedFunction.js(32,25): error TS7006: Parameter 'b' implicitly has an 'any' type. -+ -+ -+==== jsdocSignatureOnReturnedFunction.js (8 errors) ==== -+ function f1() { -+ /** -+ * @param {number} a -+ * @param {number} b -+ * @returns {number} -+ */ -+ return (a, b) => { -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. -+ return a + b; -+ } -+ } -+ -+ function f2() { -+ /** -+ * @param {number} a -+ * @param {number} b -+ * @returns {number} -+ */ -+ return function (a, b){ -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. -+ return a + b; -+ } -+ } -+ -+ function f3() { -+ /** @type {(a: number, b: number) => number} */ -+ return (a, b) => { -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. -+ return a + b; -+ } -+ } -+ -+ function f4() { -+ /** @type {(a: number, b: number) => number} */ -+ return function (a, b){ -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. -+ return a + b; -+ } -+ } -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.types.diff index 6773adc1cf..42e8dc2c10 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.types.diff @@ -1,105 +1,18 @@ --- old.jsdocSignatureOnReturnedFunction.types +++ new.jsdocSignatureOnReturnedFunction.types -@@= skipped -1, +1 lines =@@ - - === jsdocSignatureOnReturnedFunction.js === - function f1() { -->f1 : () => (a: number, b: number) => number -+>f1 : () => (a: any, b: any) => any - - /** - * @param {number} a -@@= skipped -8, +8 lines =@@ - * @returns {number} - */ - return (a, b) => { -->(a, b) => { return a + b; } : (a: number, b: number) => number -->a : number -->b : number -+>(a, b) => { return a + b; } : (a: any, b: any) => any -+>a : any -+>b : any - - return a + b; -->a + b : number -->a : number -->b : number -+>a + b : any -+>a : any -+>b : any - } - } - - function f2() { -->f2 : () => (a: number, b: number) => number -+>f2 : () => (a: any, b: any) => any - - /** - * @param {number} a -@@= skipped -20, +20 lines =@@ - * @returns {number} - */ - return function (a, b){ -->function (a, b){ return a + b; } : (a: number, b: number) => number -->a : number -->b : number -+>function (a, b){ return a + b; } : (a: any, b: any) => any -+>a : any -+>b : any - - return a + b; -->a + b : number -->a : number -->b : number -+>a + b : any -+>a : any -+>b : any - } - } - - function f3() { -->f3 : () => (a: number, b: number) => number -+>f3 : () => (a: any, b: any) => any - +@@= skipped -46, +46 lines =@@ /** @type {(a: number, b: number) => number} */ return (a, b) => { -->(a, b) => { return a + b; } : (a: number, b: number) => number -->a : number -->b : number -+>(a, b) => { return a + b; } : (a: any, b: any) => any -+>a : any -+>b : any - - return a + b; -->a + b : number -->a : number -->b : number -+>a + b : any -+>a : any -+>b : any - } - } - - function f4() { -->f4 : () => (a: number, b: number) => number -+>f4 : () => (a: any, b: any) => any + >(a, b) => { return a + b; } : (a: number, b: number) => number ++>(a, b) => { return a + b; } : (a: number, b: number) => number + >a : number + >b : number +@@= skipped -16, +17 lines =@@ /** @type {(a: number, b: number) => number} */ return function (a, b){ -->function (a, b){ return a + b; } : (a: number, b: number) => number -->a : number -->b : number -+>function (a, b){ return a + b; } : (a: any, b: any) => any -+>a : any -+>b : any - - return a + b; -->a + b : number -->a : number -->b : number -+>a + b : any -+>a : any -+>b : any - } - } + >function (a, b){ return a + b; } : (a: number, b: number) => number ++>function (a, b){ return a + b; } : (a: number, b: number) => number + >a : number + >b : number diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff index 1f3bad0a46..cd447865f2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff @@ -2,9 +2,9 @@ +++ new.jsdocTemplateClass.errors.txt @@= skipped -0, +0 lines =@@ -templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to type 'number'. -+templateTagOnClasses.js(10,14): error TS2339: Property 'a' does not exist on type 'Foo'. -+templateTagOnClasses.js(25,3): error TS2339: Property 'a' does not exist on type 'Foo'. -+templateTagOnClasses.js(25,9): error TS2339: Property 'a' does not exist on type 'Foo'. ++templateTagOnClasses.js(10,14): error TS2339: Property 'a' does not exist on type 'Foo'. ++templateTagOnClasses.js(25,3): error TS2339: Property 'a' does not exist on type 'Foo'. ++templateTagOnClasses.js(25,9): error TS2339: Property 'a' does not exist on type 'Foo'. -==== templateTagOnClasses.js (1 errors) ==== @@ -17,7 +17,7 @@ constructor (x) { this.a = x + ~ -+!!! error TS2339: Property 'a' does not exist on type 'Foo'. ++!!! error TS2339: Property 'a' does not exist on type 'Foo'. } /** * @@ -28,7 +28,7 @@ - ~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. + ~ -+!!! error TS2339: Property 'a' does not exist on type 'Foo'. ++!!! error TS2339: Property 'a' does not exist on type 'Foo'. + ~ -+!!! error TS2339: Property 'a' does not exist on type 'Foo'. ++!!! error TS2339: Property 'a' does not exist on type 'Foo'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.types.diff index efcee783b8..8037c04cb3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.types.diff @@ -1,84 +1,39 @@ --- old.jsdocTemplateClass.types +++ new.jsdocTemplateClass.types -@@= skipped -6, +6 lines =@@ - */ - /** @template T */ - class Foo { -->Foo : Foo -+>Foo : Foo - - /** @typedef {(t: T) => T} Id2 */ - /** @param {T} x */ - constructor (x) { -->x : T -+>x : any - - this.a = x -->this.a = x : T -+>this.a = x : any - >this.a : any - >this : this - >a : any -->x : T -+>x : any - } - /** - * -@@= skipped -22, +22 lines =@@ +@@= skipped -28, +28 lines =@@ * @return {T} */ foo(x, y, alpha) { ->foo : (x: T, y: Id, alpha: (t: T) => T) => T -->x : T ++>foo : (x: T, y: (t: T) => T, alpha: (t: T) => T) => T + >x : T ->y : Id -->alpha : (t: T) => T -+>foo : (x: any, y: any, alpha: any) => any -+>x : any -+>y : any -+>alpha : any ++>y : (t: T) => T + >alpha : (t: T) => T return alpha(y(x)) -->alpha(y(x)) : T -->alpha : (t: T) => T -->y(x) : T + >alpha(y(x)) : T + >alpha : (t: T) => T + >y(x) : T ->y : Id -->x : T -+>alpha(y(x)) : any -+>alpha : any -+>y(x) : any -+>y : any -+>x : any ++>y : (t: T) => T + >x : T } } - var f = new Foo(1) -->f : Foo -->new Foo(1) : Foo -+>f : Foo -+>new Foo(1) : Foo - >Foo : typeof Foo - >1 : 1 - - var g = new Foo(false) -->g : Foo -->new Foo(false) : Foo -+>g : Foo -+>new Foo(false) : Foo - >Foo : typeof Foo +@@= skipped -26, +26 lines =@@ >false : false f.a = g.a ->f.a = g.a : boolean ->f.a : number -->f : Foo -->a : number -->g.a : boolean -->g : Foo -->a : boolean +>f.a = g.a : any +>f.a : any -+>f : Foo + >f : Foo +->a : number +->g.a : boolean +>a : any +>g.a : any -+>g : Foo + >g : Foo +->a : boolean +>a : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.types.diff index 1d191652c2..f340ec5d5a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.types.diff @@ -5,9 +5,8 @@ */ function Zet(t) { ->Zet : typeof Zet -->t : T -+>Zet : (t: any) => void -+>t : any ++>Zet : (t: T) => void + >t : T /** @type {T} */ this.u @@ -19,17 +18,14 @@ +>u : any this.t = t -->this.t = t : T -+>this.t = t : any + >this.t = t : T >this.t : any ->this : this +>this : any >t : any -->t : T -+>t : any + >t : T } - /** - * @param {T} v +@@= skipped -21, +21 lines =@@ * @param {Id} id */ Zet.prototype.add = function(v, id) { @@ -38,7 +34,7 @@ >Zet.prototype.add : any >Zet.prototype : any ->Zet : typeof Zet -+>Zet : (t: any) => void ++>Zet : (t: T) => void >prototype : any >add : any ->function(v, id) { this.u = v || this.t return id(this.u)} : (v: T, id: Id) => T @@ -86,7 +82,7 @@ ->Zet : typeof Zet +>z : any +>new Zet(1) : any -+>Zet : (t: any) => void ++>Zet : (t: T) => void >1 : 1 z.t = 2 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.types.diff index 550dddeaf4..674556f764 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.types.diff @@ -5,9 +5,8 @@ */ function Zet(t) { ->Zet : typeof Zet -->t : T -+>Zet : (t: any) => void -+>t : any ++>Zet : (t: T) => void + >t : T /** @type {T} */ this.u @@ -19,17 +18,13 @@ +>u : any this.t = t -->this.t = t : T -+>this.t = t : any + >this.t = t : T >this.t : any ->this : this +>this : any >t : any -->t : T -+>t : any + >t : T } - /** - * @param {T} v @@= skipped -22, +22 lines =@@ * @param {T} o.nested */ @@ -39,7 +34,7 @@ >Zet.prototype.add : any >Zet.prototype : any ->Zet : typeof Zet -+>Zet : (t: any) => void ++>Zet : (t: T) => void >prototype : any >add : any ->function(v, o) { this.u = v || o.nested return this.u} : (v: T, o: { nested: T;}) => T @@ -83,7 +78,7 @@ ->Zet : typeof Zet +>z : any +>new Zet(1) : any -+>Zet : (t: any) => void ++>Zet : (t: T) => void >1 : 1 z.t = 2 @@ -108,12 +103,11 @@ /** @type {number} */ let answer = z.add(3, { nested: 4 }) -->answer : number + >answer : number ->z.add(3, { nested: 4 }) : number ->z.add : (v: number, o: { nested: number; }) => number ->z : Zet ->add : (v: number, o: { nested: number; }) => number -+>answer : any +>z.add(3, { nested: 4 }) : any +>z.add : any +>z : any @@ -121,12 +115,3 @@ >3 : 3 >{ nested: 4 } : { nested: number; } >nested : number -@@= skipped -65, +65 lines =@@ - */ - /** @type {A} */ - const options = { value: null }; -->options : A -+>options : { value: any; } - >{ value: null } : { value: null; } - >value : null - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff index b06fd95851..daf552c939 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff @@ -2,11 +2,27 @@ +++ new.jsdocTemplateTag.errors.txt @@= skipped -0, +0 lines =@@ -forgot.js(23,1): error TS2322: Type '(keyframes: any[]) => void' is not assignable to type '(keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions) => Animation'. ++forgot.js(13,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +forgot.js(23,1): error TS2322: Type '(keyframes: Keyframe[] | PropertyIndexedKeyframes) => void' is not assignable to type '(keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions) => Animation'. Type 'void' is not assignable to type 'Animation'. -@@= skipped -26, +26 lines =@@ +-==== forgot.js (1 errors) ==== ++==== forgot.js (2 errors) ==== + /** + * @param {T} a + * @template T +@@= skipped -15, +16 lines =@@ + * @param {T} a + * @template T + * @returns {function(): T} ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + */ + function g(a) { + return () => a +@@= skipped -11, +14 lines =@@ */ Element.prototype.animate = function(keyframes) {}; ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.types.diff index 82d56b6e5b..ef254c27e8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.types.diff @@ -1,46 +1,16 @@ --- old.jsdocTemplateTag.types +++ new.jsdocTemplateTag.types -@@= skipped -5, +5 lines =@@ - * @template T - */ - function f(a) { -->f : (a: T) => () => T -->a : T -+>f : (a: any) => () => any -+>a : any - - return () => a -->() => a : () => T -->a : T -+>() => a : () => any -+>a : any - } - let n = f(1)() -->n : number -->f(1)() : number -->f(1) : () => number -->f : (a: T) => () => T -+>n : any -+>f(1)() : any -+>f(1) : () => any -+>f : (a: any) => () => any - >1 : 1 - - /** -@@= skipped -20, +20 lines =@@ +@@= skipped -25, +25 lines =@@ * @returns {function(): T} */ function g(a) { ->g : (a: T) => () => T -->a : T -+>g : (a: any) => () => any -+>a : any ++>g : (a: T) => function + >a : T return () => a -->() => a : () => T -->a : T -+>() => a : () => any -+>a : any +@@= skipped -8, +8 lines =@@ + >a : T } let s = g('hi')() ->s : string @@ -49,8 +19,8 @@ ->g : (a: T) => () => T +>s : any +>g('hi')() : any -+>g('hi') : () => any -+>g : (a: any) => () => any ++>g('hi') : function ++>g : (a: T) => function >'hi' : "hi" /** diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.types.diff deleted file mode 100644 index 55c15deba8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.types.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.jsdocTemplateTag2.types -+++ new.jsdocTemplateTag2.types -@@= skipped -1, +1 lines =@@ - - === github17339.js === - var obj = { -->obj : { x: (a: T) => T; } -->{ /** * @template T * @param {T} a * @returns {T} */ x: function (a) { return a; },} : { x: (a: T) => T; } -+>obj : { x: (a: any) => any; } -+>{ /** * @template T * @param {T} a * @returns {T} */ x: function (a) { return a; },} : { x: (a: any) => any; } - - /** - * @template T -@@= skipped -9, +9 lines =@@ - * @returns {T} - */ - x: function (a) { -->x : (a: T) => T -->function (a) { return a; } : (a: T) => T -->a : T -+>x : (a: any) => any -+>function (a) { return a; } : (a: any) => any -+>a : any - - return a; -->a : T -+>a : any - - }, - }; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff index 050a812ed7..6460702efd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff @@ -1,56 +1,47 @@ --- old.jsdocTemplateTag3.errors.txt +++ new.jsdocTemplateTag3.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -a.js(14,29): error TS2339: Property 'a' does not exist on type 'U'. -a.js(14,35): error TS2339: Property 'b' does not exist on type 'U'. -a.js(21,3): error TS2345: Argument of type '{ a: number; }' is not assignable to parameter of type '{ a: number; b: string; }'. - Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. -a.js(24,15): error TS2304: Cannot find name 'NoLongerAllowed'. -a.js(25,2): error TS1069: Unexpected token. A type parameter name was expected without curly braces. -- -- ++a.js(21,3): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. + + -==== a.js (5 errors) ==== -- /** -- * @template {{ a: number, b: string }} T,U A Comment -- * @template {{ c: boolean }} V uh ... are comments even supported?? -- * @template W -- * @template X That last one had no comment -- * @param {T} t -- * @param {U} u -- * @param {V} v -- * @param {W} w -- * @param {X} x -- * @return {W | X} -- */ -- function f(t, u, v, w, x) { -- if(t.a + t.b.length > u.a - u.b.length && v.c) { ++==== a.js (1 errors) ==== + /** + * @template {{ a: number, b: string }} T,U A Comment + * @template {{ c: boolean }} V uh ... are comments even supported?? +@@= skipped -20, +15 lines =@@ + */ + function f(t, u, v, w, x) { + if(t.a + t.b.length > u.a - u.b.length && v.c) { - ~ -!!! error TS2339: Property 'a' does not exist on type 'U'. - ~ -!!! error TS2339: Property 'b' does not exist on type 'U'. -- return w; -- } -- return x; -- } -- -- f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); -- f({ a: 12 }, undefined, undefined, 101, 'nope'); -- ~~~~~~~~~~ + return w; + } + return x; +@@= skipped -12, +8 lines =@@ + f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); + f({ a: 12 }, undefined, undefined, 101, 'nope'); + ~~~~~~~~~~ -!!! error TS2345: Argument of type '{ a: number; }' is not assignable to parameter of type '{ a: number; b: string; }'. -!!! error TS2345: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. --!!! related TS2728 a.js:2:28: 'b' is declared here. -- -- /** -- * @template {NoLongerAllowed} ++!!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. + !!! related TS2728 a.js:2:28: 'b' is declared here. + + /** + * @template {NoLongerAllowed} - ~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'NoLongerAllowed'. -- * @template T preceding line's syntax is no longer allowed + * @template T preceding line's syntax is no longer allowed - ~ -!!! error TS1069: Unexpected token. A type parameter name was expected without curly braces. -- * @param {T} x -- */ -- function g(x) { } -- -- -@@= skipped --1, +1 lines =@@ -+ + * @param {T} x + */ + function g(x) { } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.types.diff index 532b8f966e..7a9366b90b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.types.diff @@ -5,104 +5,46 @@ */ function f(t, u, v, w, x) { ->f : (t: T, u: U, v: V, w: W, x: X) => W | X -->t : T -->u : U -->v : V -->w : W -->x : X -+>f : (t: any, u: any, v: any, w: any, x: any) => any -+>t : any -+>u : any -+>v : any -+>w : any -+>x : any - - if(t.a + t.b.length > u.a - u.b.length && v.c) { -->t.a + t.b.length > u.a - u.b.length && v.c : boolean -+>t.a + t.b.length > u.a - u.b.length && v.c : any - >t.a + t.b.length > u.a - u.b.length : boolean -->t.a + t.b.length : number -->t.a : number -->t : T -->a : number -->t.b.length : number -->t.b : string -->t : T -->b : string -->length : number -+>t.a + t.b.length : any -+>t.a : any -+>t : any -+>a : any -+>t.b.length : any -+>t.b : any -+>t : any -+>b : any -+>length : any ++>f : (t: T, u: U, v: V, w: W, x: X) => W | X + >t : T + >u : U + >v : V +@@= skipped -20, +20 lines =@@ + >b : string + >length : number >u.a - u.b.length : number - >u.a : any -->u : U -+>u : any - >a : any - >u.b.length : any - >u.b : any -->u : U -+>u : any - >b : any - >length : any -->v.c : boolean -->v : V -->c : boolean -+>v.c : any -+>v : any -+>c : any - - return w; -->w : W -+>w : any - } - return x; -->x : X -+>x : any - } +->u.a : any ++>u.a : number + >u : U +->a : any +->u.b.length : any +->u.b : any ++>a : number ++>u.b.length : number ++>u.b : string + >u : U +->b : any +->length : any ++>b : string ++>length : number + >v.c : boolean + >v : V + >c : boolean +@@= skipped -21, +21 lines =@@ f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); -->f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope') : "nope" | 101 + >f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope') : "nope" | 101 ->f : (t: T, u: U, v: V, w: W, x: X) => W | X -+>f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope') : any -+>f : (t: any, u: any, v: any, w: any, x: any) => any ++>f : (t: T, u: U, v: V, w: W, x: X) => W | X >{ a: 12, b: 'hi', c: null } : { a: number; b: string; c: null; } >a : number >12 : 12 -@@= skipped -49, +49 lines =@@ - >'hi' : "hi" - >c : null - >undefined : undefined -->{ c: false, d: 12, b: undefined } : { c: false; d: number; b: undefined; } -->c : false -+>{ c: false, d: 12, b: undefined } : { c: boolean; d: number; b: undefined; } -+>c : boolean - >false : false - >d : number - >12 : 12 -@@= skipped -11, +11 lines =@@ - >'nope' : "nope" +@@= skipped -20, +20 lines =@@ f({ a: 12 }, undefined, undefined, 101, 'nope'); -->f({ a: 12 }, undefined, undefined, 101, 'nope') : "nope" | 101 + >f({ a: 12 }, undefined, undefined, 101, 'nope') : "nope" | 101 ->f : (t: T, u: U, v: V, w: W, x: X) => W | X -+>f({ a: 12 }, undefined, undefined, 101, 'nope') : any -+>f : (t: any, u: any, v: any, w: any, x: any) => any ++>f : (t: T, u: U, v: V, w: W, x: X) => W | X >{ a: 12 } : { a: number; } >a : number >12 : 12 -@@= skipped -16, +16 lines =@@ - * @param {T} x - */ - function g(x) { } -->g : (x: T) => void -->x : T -+>g : (x: any) => void -+>x : any - - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.types.diff index 05e7d580dc..54eaeb9094 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.types.diff @@ -5,7 +5,7 @@ */ function Multimap() { ->Multimap : typeof Multimap -+>Multimap : () => void ++>Multimap : () => void /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; @@ -28,7 +28,7 @@ >Multimap.prototype.get : any >Multimap.prototype : any ->Multimap : typeof Multimap -+>Multimap : () => void ++>Multimap : () => void >prototype : any >get : any ->function (key) { return this._map[key + ''];} : (key: K) => V @@ -57,8 +57,8 @@ var Multimap2 = function() { ->Multimap2 : typeof Multimap2 ->function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : typeof Multimap2 -+>Multimap2 : () => void -+>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : () => void ++>Multimap2 : () => void ++>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : () => void /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; @@ -81,7 +81,7 @@ >Multimap2.prototype.get : any >Multimap2.prototype : any ->Multimap2 : typeof Multimap2 -+>Multimap2 : () => void ++>Multimap2 : () => void >prototype : any >get : any ->function (key) { return this._map[key + ''];} : (key: K) => V diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff index 963e5a9020..06a4860016 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff @@ -4,18 +4,20 @@ - @@= skipped --1, +1 lines =@@ +a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+a.js(17,5): error TS7023: 'get' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -+a.js(17,9): error TS7006: Parameter 'key' implicitly has an 'any' type. -+a.js(18,21): error TS2339: Property '_map' does not exist on type '{ get: (key: any) => any; }'. ++a.js(14,16): error TS2304: Cannot find name 'K'. ++a.js(15,18): error TS2304: Cannot find name 'V'. ++a.js(18,21): error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. +a.js(30,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+a.js(38,19): error TS7006: Parameter 'key' implicitly has an 'any' type. ++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(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(60,9): error TS7006: Parameter 'key' implicitly has an 'any' type. ++a.js(57,16): error TS2304: Cannot find name 'K'. ++a.js(58,18): error TS2304: Cannot find name 'V'. + + -+==== a.js (10 errors) ==== ++==== a.js (12 errors) ==== + /** + * Should work for function declarations + * @constructor @@ -32,16 +34,16 @@ + Multimap.prototype = { + /** + * @param {K} key the key ok ++ ~ ++!!! error TS2304: Cannot find name 'K'. + * @returns {V} the value ok ++ ~ ++!!! error TS2304: Cannot find name 'V'. + */ + get(key) { -+ ~~~ -+!!! error TS7023: 'get' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -+ ~~~ -+!!! error TS7006: Parameter 'key' implicitly has an 'any' type. + return this._map[key + '']; + ~~~~ -+!!! error TS2339: Property '_map' does not exist on type '{ get: (key: any) => any; }'. ++!!! error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. + } + } + @@ -61,11 +63,13 @@ + Multimap2.prototype = { + /** + * @param {K} key the key ok ++ ~ ++!!! error TS2304: Cannot find name 'K'. + * @returns {V} the value ok ++ ~ ++!!! error TS2304: Cannot find name 'V'. + */ + get: function(key) { -+ ~~~ -+!!! error TS7006: Parameter 'key' implicitly has an 'any' type. + return this._map[key + '']; + } + } @@ -91,11 +95,13 @@ +!!! error TS2339: Property 'Multimap3' does not exist on type '{}'. + /** + * @param {K} key the key ok ++ ~ ++!!! error TS2304: Cannot find name 'K'. + * @returns {V} the value ok ++ ~ ++!!! error TS2304: Cannot find name 'V'. + */ + get(key) { -+ ~~~ -+!!! error TS7006: Parameter 'key' implicitly has an 'any' type. + return this._map[key + '']; + } + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.types.diff index d1de9f6cf0..711f71b54a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.types.diff @@ -5,7 +5,7 @@ */ function Multimap() { ->Multimap : typeof Multimap -+>Multimap : { (): void; prototype: { get: (key: any) => any; }; } ++>Multimap : { (): void; prototype: { get: (key: K) => V; }; } /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; @@ -26,21 +26,16 @@ ->Multimap : typeof Multimap ->prototype : { get(key: K): V; } ->{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: K): V; } -+>Multimap.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } -+>Multimap.prototype : { get: (key: any) => any; } -+>Multimap : { (): void; prototype: { get: (key: any) => any; }; } -+>prototype : { get: (key: any) => any; } -+>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } ++>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; } ++>Multimap : { (): void; prototype: { get: (key: K) => V; }; } ++>prototype : { get: (key: K) => V; } ++>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: K) => V; } /** * @param {K} key the key ok - * @returns {V} the value ok - */ - get(key) { -->get : (key: K) => V -->key : K -+>get : (key: any) => any -+>key : any +@@= skipped -28, +28 lines =@@ + >key : K return this._map[key + '']; ->this._map[key + ''] : V @@ -49,22 +44,19 @@ ->_map : { [x: string]: V; } +>this._map[key + ''] : any +>this._map : any -+>this : { get: (key: any) => any; } ++>this : { get: (key: K) => V; } +>_map : any >key + '' : string -->key : K -+>key : any + >key : K >'' : "" - } - } -@@= skipped -45, +45 lines =@@ +@@= skipped -17, +17 lines =@@ * @template V */ var Multimap2 = function() { ->Multimap2 : typeof Multimap2 ->function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : typeof Multimap2 -+>Multimap2 : () => void -+>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : () => void ++>Multimap2 : () => void ++>function() { /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {};} : () => void /** @type {Object} TODO: Remove the prototype from the fresh object */ this._map = {}; @@ -80,28 +72,18 @@ }; Multimap2.prototype = { -->Multimap2.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: K) => V; } + >Multimap2.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: K) => V; } ->Multimap2.prototype : { get: (key: K) => V; } ->Multimap2 : typeof Multimap2 ->prototype : { get: (key: K) => V; } -->{ /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: K) => V; } -+>Multimap2.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: any) => any; } +>Multimap2.prototype : any -+>Multimap2 : () => void ++>Multimap2 : () => void +>prototype : any -+>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: any) => any; } + >{ /** * @param {K} key the key ok * @returns {V} the value ok */ get: function(key) { return this._map[key + '']; }} : { get: (key: K) => V; } /** - * @param {K} key the key ok - * @returns {V} the value ok - */ - get: function(key) { -->get : (key: K) => V -->function(key) { return this._map[key + '']; } : (key: K) => V -->key : K -+>get : (key: any) => any -+>function(key) { return this._map[key + '']; } : (key: any) => any -+>key : any +@@= skipped -30, +30 lines =@@ + >key : K return this._map[key + '']; ->this._map[key + ''] : V @@ -113,10 +95,9 @@ +>this : any +>_map : any >key + '' : string -->key : K -+>key : any + >key : K >'' : "" - } +@@= skipped -11, +11 lines =@@ } var Ns = {}; @@ -125,7 +106,7 @@ >{} : {} /** -@@= skipped -51, +51 lines =@@ +@@= skipped -10, +10 lines =@@ * @template V */ Ns.Multimap3 = function() { @@ -161,23 +142,18 @@ ->Multimap3 : typeof Multimap3 ->prototype : { get(key: K): V; } ->{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: K): V; } -+>Ns.Multimap3.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } ++>Ns.Multimap3.prototype = { /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: K) => V; } +>Ns.Multimap3.prototype : any +>Ns.Multimap3 : any +>Ns : {} +>Multimap3 : any +>prototype : any -+>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } ++>{ /** * @param {K} key the key ok * @returns {V} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: K) => V; } /** * @param {K} key the key ok - * @returns {V} the value ok - */ - get(key) { -->get : (key: K) => V -->key : K -+>get : (key: any) => any -+>key : any +@@= skipped -34, +34 lines =@@ + >key : K return this._map[key + '']; ->this._map[key + ''] : V @@ -189,8 +165,5 @@ +>this : any +>_map : any >key + '' : string -->key : K -+>key : any + >key : K >'' : "" - } - } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff deleted file mode 100644 index fb8ce84e04..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff +++ /dev/null @@ -1,120 +0,0 @@ ---- old.jsdocTemplateTag6.errors.txt -+++ new.jsdocTemplateTag6.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+a.js(6,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -+a.js(18,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -+a.js(30,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -+a.js(41,13): error TS7006: Parameter 'x' implicitly has an 'any' type. -+a.js(52,13): error TS7006: Parameter 'obj' implicitly has an 'any' type. -+a.js(65,17): error TS7006: Parameter 'x' implicitly has an 'any' type. -+a.js(71,9): error TS7006: Parameter 'x' implicitly has an 'any' type. -+a.js(84,13): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. -+ -+ -+==== a.js (8 errors) ==== -+ /** -+ * @template const T -+ * @param {T} x -+ * @returns {T} -+ */ -+ function f1(x) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ return x; -+ } -+ const t1 = f1("a"); -+ const t2 = f1(["a", ["b", "c"]]); -+ const t3 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -+ -+ /** -+ * @template const T, U -+ * @param {T} x -+ * @returns {T} -+ */ -+ function f2(x) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ return x; -+ }; -+ const t4 = f2('a'); -+ const t5 = f2(['a', ['b', 'c']]); -+ const t6 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -+ -+ /** -+ * @template const T -+ * @param {T} x -+ * @returns {T[]} -+ */ -+ function f3(x) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ return [x]; -+ } -+ const t7 = f3("hello"); -+ const t8 = f3("hello"); -+ -+ /** -+ * @template const T -+ * @param {[T, T]} x -+ * @returns {T} -+ */ -+ function f4(x) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ return x[0]; -+ } -+ const t9 = f4([[1, "x"], [2, "y"]]); -+ const t10 = f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]); -+ -+ /** -+ * @template const T -+ * @param {{ x: T, y: T}} obj -+ * @returns {T} -+ */ -+ function f5(obj) { -+ ~~~ -+!!! error TS7006: Parameter 'obj' implicitly has an 'any' type. -+ return obj.x; -+ } -+ const t11 = f5({ x: [1, "x"], y: [2, "y"] }); -+ const t12 = f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }); -+ -+ /** -+ * @template const T -+ */ -+ class C { -+ /** -+ * @param {T} x -+ */ -+ constructor(x) {} -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ -+ /** -+ * @template const U -+ * @param {U} x -+ */ -+ foo(x) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ return x; -+ } -+ } -+ -+ const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -+ const t14 = t13.foo(["a", ["b", "c"]]); -+ -+ /** -+ * @template {readonly unknown[]} const T -+ * @param {T} args -+ * @returns {T} -+ */ -+ function f6(...args) { -+ ~~~~~~~ -+!!! error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. -+ return args; -+ } -+ const t15 = f6(1, 'b', { a: 1, b: 'x' }); -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.types.diff index b8e9a90698..bd2aa87e0d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.types.diff @@ -5,402 +5,184 @@ */ function f1(x) { ->f1 : (x: T) => T -->x : T -+>f1 : (x: any) => any -+>x : any ++>f1 : (x: T) => T + >x : T return x; -->x : T -+>x : any - } +@@= skipped -9, +9 lines =@@ const t1 = f1("a"); -->t1 : "a" -->f1("a") : "a" + >t1 : "a" + >f1("a") : "a" ->f1 : (x: T) => T -+>t1 : any -+>f1("a") : any -+>f1 : (x: any) => any ++>f1 : (x: T) => T >"a" : "a" const t2 = f1(["a", ["b", "c"]]); -->t2 : readonly ["a", readonly ["b", "c"]] -->f1(["a", ["b", "c"]]) : readonly ["a", readonly ["b", "c"]] + >t2 : readonly ["a", readonly ["b", "c"]] + >f1(["a", ["b", "c"]]) : readonly ["a", readonly ["b", "c"]] ->f1 : (x: T) => T -->["a", ["b", "c"]] : ["a", ["b", "c"]] -+>t2 : any -+>f1(["a", ["b", "c"]]) : any -+>f1 : (x: any) => any -+>["a", ["b", "c"]] : (string | string[])[] ++>f1 : (x: T) => T + >["a", ["b", "c"]] : ["a", ["b", "c"]] >"a" : "a" -->["b", "c"] : ["b", "c"] -+>["b", "c"] : string[] - >"b" : "b" - >"c" : "c" - + >["b", "c"] : ["b", "c"] +@@= skipped -16, +16 lines =@@ const t3 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -->t3 : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } -->f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } + >t3 : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } + >f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } ->f1 : (x: T) => T -->{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: 1; b: "c"; d: ["e", 2, true, { f: "g"; }]; } -->a : 1 -+>t3 : any -+>f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : any -+>f1 : (x: any) => any -+>{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: number; b: string; d: (string | number | boolean | { f: string; })[]; } -+>a : number ++>f1 : (x: T) => T + >{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: 1; b: "c"; d: ["e", 2, true, { f: "g"; }]; } + >a : 1 >1 : 1 -->b : "c" -+>b : string - >"c" : "c" -->d : ["e", 2, true, { f: "g"; }] -->["e", 2, true, { f: "g" }] : ["e", 2, true, { f: "g"; }] -+>d : (string | number | boolean | { f: string; })[] -+>["e", 2, true, { f: "g" }] : (string | number | boolean | { f: string; })[] - >"e" : "e" - >2 : 2 - >true : true -->{ f: "g" } : { f: "g"; } -->f : "g" -+>{ f: "g" } : { f: string; } -+>f : string - >"g" : "g" - - /** -@@= skipped -46, +46 lines =@@ +@@= skipped -21, +21 lines =@@ * @returns {T} */ function f2(x) { ->f2 : (x: T) => T -->x : T -+>f2 : (x: any) => any -+>x : any ++>f2 : (x: T) => T + >x : T return x; -->x : T -+>x : any - - }; +@@= skipped -10, +10 lines =@@ const t4 = f2('a'); -->t4 : "a" -->f2('a') : "a" + >t4 : "a" + >f2('a') : "a" ->f2 : (x: T) => T -+>t4 : any -+>f2('a') : any -+>f2 : (x: any) => any ++>f2 : (x: T) => T >'a' : "a" const t5 = f2(['a', ['b', 'c']]); -->t5 : readonly ["a", readonly ["b", "c"]] -->f2(['a', ['b', 'c']]) : readonly ["a", readonly ["b", "c"]] + >t5 : readonly ["a", readonly ["b", "c"]] + >f2(['a', ['b', 'c']]) : readonly ["a", readonly ["b", "c"]] ->f2 : (x: T) => T -->['a', ['b', 'c']] : ["a", ["b", "c"]] -+>t5 : any -+>f2(['a', ['b', 'c']]) : any -+>f2 : (x: any) => any -+>['a', ['b', 'c']] : (string | string[])[] ++>f2 : (x: T) => T + >['a', ['b', 'c']] : ["a", ["b", "c"]] >'a' : "a" -->['b', 'c'] : ["b", "c"] -+>['b', 'c'] : string[] - >'b' : "b" - >'c' : "c" - + >['b', 'c'] : ["b", "c"] +@@= skipped -16, +16 lines =@@ const t6 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -->t6 : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } -->f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } + >t6 : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } + >f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : { readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; } ->f2 : (x: T) => T -->{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: 1; b: "c"; d: ["e", 2, true, { f: "g"; }]; } -->a : 1 -+>t6 : any -+>f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : any -+>f2 : (x: any) => any -+>{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: number; b: string; d: (string | number | boolean | { f: string; })[]; } -+>a : number ++>f2 : (x: T) => T + >{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: 1; b: "c"; d: ["e", 2, true, { f: "g"; }]; } + >a : 1 >1 : 1 -->b : "c" -+>b : string - >"c" : "c" -->d : ["e", 2, true, { f: "g"; }] -->["e", 2, true, { f: "g" }] : ["e", 2, true, { f: "g"; }] -+>d : (string | number | boolean | { f: string; })[] -+>["e", 2, true, { f: "g" }] : (string | number | boolean | { f: string; })[] - >"e" : "e" - >2 : 2 - >true : true -->{ f: "g" } : { f: "g"; } -->f : "g" -+>{ f: "g" } : { f: string; } -+>f : string - >"g" : "g" - - /** -@@= skipped -47, +47 lines =@@ +@@= skipped -21, +21 lines =@@ * @returns {T[]} */ function f3(x) { ->f3 : (x: T) => T[] -->x : T -+>f3 : (x: any) => any[] -+>x : any ++>f3 : (x: T) => T[] + >x : T return [x]; -->[x] : T[] -->x : T -+>[x] : any[] -+>x : any - } +@@= skipped -10, +10 lines =@@ const t7 = f3("hello"); -->t7 : "hello"[] -->f3("hello") : "hello"[] + >t7 : "hello"[] + >f3("hello") : "hello"[] ->f3 : (x: T) => T[] -+>t7 : any[] -+>f3("hello") : any[] -+>f3 : (x: any) => any[] ++>f3 : (x: T) => T[] >"hello" : "hello" const t8 = f3("hello"); -->t8 : "hello"[] -->f3("hello") : "hello"[] + >t8 : "hello"[] + >f3("hello") : "hello"[] ->f3 : (x: T) => T[] -+>t8 : any[] -+>f3("hello") : any[] -+>f3 : (x: any) => any[] ++>f3 : (x: T) => T[] >"hello" : "hello" /** -@@= skipped -25, +25 lines =@@ +@@= skipped -15, +15 lines =@@ * @returns {T} */ function f4(x) { ->f4 : (x: [T, T]) => T -->x : [T, T] -+>f4 : (x: any) => any -+>x : any ++>f4 : (x: [T, T]) => T + >x : [T, T] return x[0]; -->x[0] : T -->x : [T, T] -+>x[0] : any -+>x : any - >0 : 0 - } +@@= skipped -11, +11 lines =@@ const t9 = f4([[1, "x"], [2, "y"]]); -->t9 : readonly [1, "x"] | readonly [2, "y"] -->f4([[1, "x"], [2, "y"]]) : readonly [1, "x"] | readonly [2, "y"] + >t9 : readonly [1, "x"] | readonly [2, "y"] + >f4([[1, "x"], [2, "y"]]) : readonly [1, "x"] | readonly [2, "y"] ->f4 : (x: [T, T]) => T -->[[1, "x"], [2, "y"]] : [[1, "x"], [2, "y"]] -->[1, "x"] : [1, "x"] -+>t9 : any -+>f4([[1, "x"], [2, "y"]]) : any -+>f4 : (x: any) => any -+>[[1, "x"], [2, "y"]] : (string | number)[][] -+>[1, "x"] : (string | number)[] ++>f4 : (x: [T, T]) => T + >[[1, "x"], [2, "y"]] : [[1, "x"], [2, "y"]] + >[1, "x"] : [1, "x"] >1 : 1 - >"x" : "x" -->[2, "y"] : [2, "y"] -+>[2, "y"] : (string | number)[] - >2 : 2 - >"y" : "y" - +@@= skipped -12, +12 lines =@@ const t10 = f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]); -->t10 : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } -->f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]) : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } + >t10 : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } + >f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]) : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } ->f4 : (x: [T, T]) => T -->[{ a: 1, b: "x" }, { a: 2, b: "y" }] : [{ a: 1; b: "x"; }, { a: 2; b: "y"; }] -->{ a: 1, b: "x" } : { a: 1; b: "x"; } -->a : 1 -+>t10 : any -+>f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]) : any -+>f4 : (x: any) => any -+>[{ a: 1, b: "x" }, { a: 2, b: "y" }] : { a: number; b: string; }[] -+>{ a: 1, b: "x" } : { a: number; b: string; } -+>a : number - >1 : 1 -->b : "x" -+>b : string - >"x" : "x" -->{ a: 2, b: "y" } : { a: 2; b: "y"; } -->a : 2 -+>{ a: 2, b: "y" } : { a: number; b: string; } -+>a : number - >2 : 2 -->b : "y" -+>b : string - >"y" : "y" - - /** -@@= skipped -42, +42 lines =@@ ++>f4 : (x: [T, T]) => T + >[{ a: 1, b: "x" }, { a: 2, b: "y" }] : [{ a: 1; b: "x"; }, { a: 2; b: "y"; }] + >{ a: 1, b: "x" } : { a: 1; b: "x"; } + >a : 1 +@@= skipped -19, +19 lines =@@ * @returns {T} */ function f5(obj) { ->f5 : (obj: { x: T; y: T; }) => T -->obj : { x: T; y: T; } -+>f5 : (obj: any) => any -+>obj : any ++>f5 : (obj: { x: T; y: T; }) => T + >obj : { x: T; y: T; } return obj.x; -->obj.x : T -->obj : { x: T; y: T; } -->x : T -+>obj.x : any -+>obj : any -+>x : any - } +@@= skipped -11, +11 lines =@@ const t11 = f5({ x: [1, "x"], y: [2, "y"] }); -->t11 : readonly [1, "x"] | readonly [2, "y"] -->f5({ x: [1, "x"], y: [2, "y"] }) : readonly [1, "x"] | readonly [2, "y"] + >t11 : readonly [1, "x"] | readonly [2, "y"] + >f5({ x: [1, "x"], y: [2, "y"] }) : readonly [1, "x"] | readonly [2, "y"] ->f5 : (obj: { x: T; y: T; }) => T -->{ x: [1, "x"], y: [2, "y"] } : { x: [1, "x"]; y: [2, "y"]; } -->x : [1, "x"] -->[1, "x"] : [1, "x"] -+>t11 : any -+>f5({ x: [1, "x"], y: [2, "y"] }) : any -+>f5 : (obj: any) => any -+>{ x: [1, "x"], y: [2, "y"] } : { x: (string | number)[]; y: (string | number)[]; } -+>x : (string | number)[] -+>[1, "x"] : (string | number)[] - >1 : 1 - >"x" : "x" -->y : [2, "y"] -->[2, "y"] : [2, "y"] -+>y : (string | number)[] -+>[2, "y"] : (string | number)[] - >2 : 2 - >"y" : "y" - ++>f5 : (obj: { x: T; y: T; }) => T + >{ x: [1, "x"], y: [2, "y"] } : { x: [1, "x"]; y: [2, "y"]; } + >x : [1, "x"] + >[1, "x"] : [1, "x"] +@@= skipped -14, +14 lines =@@ const t12 = f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }); -->t12 : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } -->f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }) : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } + >t12 : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } + >f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }) : { readonly a: 1; readonly b: "x"; } | { readonly a: 2; readonly b: "y"; } ->f5 : (obj: { x: T; y: T; }) => T -->{ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } } : { x: { a: 1; b: "x"; }; y: { a: 2; b: "y"; }; } -->x : { a: 1; b: "x"; } -->{ a: 1, b: "x" } : { a: 1; b: "x"; } -->a : 1 -+>t12 : any -+>f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }) : any -+>f5 : (obj: any) => any -+>{ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } } : { x: { a: number; b: string; }; y: { a: number; b: string; }; } -+>x : { a: number; b: string; } -+>{ a: 1, b: "x" } : { a: number; b: string; } -+>a : number - >1 : 1 -->b : "x" -+>b : string - >"x" : "x" -->y : { a: 2; b: "y"; } -->{ a: 2, b: "y" } : { a: 2; b: "y"; } -->a : 2 -+>y : { a: number; b: string; } -+>{ a: 2, b: "y" } : { a: number; b: string; } -+>a : number - >2 : 2 -->b : "y" -+>b : string - >"y" : "y" - - /** - * @template const T - */ - class C { -->C : C -+>C : C - - /** - * @param {T} x - */ - constructor(x) {} -->x : T -+>x : any - - /** - * @template const U ++>f5 : (obj: { x: T; y: T; }) => T + >{ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } } : { x: { a: 1; b: "x"; }; y: { a: 2; b: "y"; }; } + >x : { a: 1; b: "x"; } + >{ a: 1, b: "x" } : { a: 1; b: "x"; } +@@= skipped -32, +32 lines =@@ * @param {U} x */ foo(x) { ->foo : (x: U) => U -->x : U -+>foo : (x: any) => any -+>x : any ++>foo : (x: U) => U + >x : U return x; -->x : U -+>x : any - } - } - - const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -->t13 : C<{ readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; }> -->new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : C<{ readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; }> -+>t13 : C -+>new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }) : C - >C : typeof C -->{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: 1; b: "c"; d: ["e", 2, true, { f: "g"; }]; } -->a : 1 -+>{ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] } : { a: number; b: string; d: (string | number | boolean | { f: string; })[]; } -+>a : number - >1 : 1 -->b : "c" -+>b : string - >"c" : "c" -->d : ["e", 2, true, { f: "g"; }] -->["e", 2, true, { f: "g" }] : ["e", 2, true, { f: "g"; }] -+>d : (string | number | boolean | { f: string; })[] -+>["e", 2, true, { f: "g" }] : (string | number | boolean | { f: string; })[] - >"e" : "e" - >2 : 2 - >true : true -->{ f: "g" } : { f: "g"; } -->f : "g" -+>{ f: "g" } : { f: string; } -+>f : string - >"g" : "g" - +@@= skipped -29, +29 lines =@@ const t14 = t13.foo(["a", ["b", "c"]]); -->t14 : readonly ["a", readonly ["b", "c"]] -->t13.foo(["a", ["b", "c"]]) : readonly ["a", readonly ["b", "c"]] + >t14 : readonly ["a", readonly ["b", "c"]] + >t13.foo(["a", ["b", "c"]]) : readonly ["a", readonly ["b", "c"]] ->t13.foo : (x: U) => U -->t13 : C<{ readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; }> ++>t13.foo : (x: U) => U + >t13 : C<{ readonly a: 1; readonly b: "c"; readonly d: readonly ["e", 2, true, { readonly f: "g"; }]; }> ->foo : (x: U) => U -->["a", ["b", "c"]] : ["a", ["b", "c"]] -+>t14 : any -+>t13.foo(["a", ["b", "c"]]) : any -+>t13.foo : (x: any) => any -+>t13 : C -+>foo : (x: any) => any -+>["a", ["b", "c"]] : (string | string[])[] ++>foo : (x: U) => U + >["a", ["b", "c"]] : ["a", ["b", "c"]] >"a" : "a" -->["b", "c"] : ["b", "c"] -+>["b", "c"] : string[] - >"b" : "b" - >"c" : "c" - -@@= skipped -101, +101 lines =@@ + >["b", "c"] : ["b", "c"] +@@= skipped -15, +15 lines =@@ * @returns {T} */ function f6(...args) { ->f6 : (...args: T) => T -->args : T -+>f6 : (...args: any[]) => any[] -+>args : any[] ++>f6 : (...args: T) => T + >args : T return args; -->args : T -+>args : any[] - } +@@= skipped -9, +9 lines =@@ const t15 = f6(1, 'b', { a: 1, b: 'x' }); -->t15 : readonly [1, "b", { readonly a: 1; readonly b: "x"; }] -->f6(1, 'b', { a: 1, b: 'x' }) : readonly [1, "b", { readonly a: 1; readonly b: "x"; }] + >t15 : readonly [1, "b", { readonly a: 1; readonly b: "x"; }] + >f6(1, 'b', { a: 1, b: 'x' }) : readonly [1, "b", { readonly a: 1; readonly b: "x"; }] ->f6 : (...args: T) => T -+>t15 : any[] -+>f6(1, 'b', { a: 1, b: 'x' }) : any[] -+>f6 : (...args: any[]) => any[] ++>f6 : (...args: T) => T >1 : 1 >'b' : "b" -->{ a: 1, b: 'x' } : { a: 1; b: "x"; } -->a : 1 -+>{ a: 1, b: 'x' } : { a: number; b: string; } -+>a : number - >1 : 1 -->b : "x" -+>b : string - >'x' : "x" - + >{ a: 1, b: 'x' } : { a: 1; b: "x"; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff deleted file mode 100644 index e5d55a4558..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.jsdocTemplateTag7.errors.txt -+++ new.jsdocTemplateTag7.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class --a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter -+a.js(16,12): error TS7006: Parameter 'x' implicitly has an 'any' type. - - --==== a.js (2 errors) ==== -+==== a.js (1 errors) ==== - /** - * @template const T -- ~~~~~ --!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - * @typedef {[T]} X - */ - -@@= skipped -16, +13 lines =@@ - - /** - * @template private T -- ~~~~~~~ --!!! error TS1273: 'private' modifier cannot appear on a type parameter - * @param {T} x - * @returns {T} - */ - function f(x) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - return x; - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.types.diff deleted file mode 100644 index f6a0ac8fde..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.types.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.jsdocTemplateTag7.types -+++ new.jsdocTemplateTag7.types -@@= skipped -9, +9 lines =@@ - * @template const T - */ - class C { } -->C : C -+>C : C - - /** - * @template private T -@@= skipped -8, +8 lines =@@ - * @returns {T} - */ - function f(x) { -->f : (x: T) => T -->x : T -+>f : (x: any) => any -+>x : any - - return x; -->x : T -+>x : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff index 10de493639..9b0fb0c535 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff @@ -1,58 +1,49 @@ --- old.jsdocTemplateTag8.errors.txt +++ new.jsdocTemplateTag8.errors.txt @@= skipped -0, +0 lines =@@ --a.js(18,1): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. -- Type 'unknown' is not assignable to type 'string'. --a.js(36,1): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. -- Type 'unknown' is not assignable to type 'string'. --a.js(55,1): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. -- Types of property 'f' are incompatible. -- Type '(x: string) => string' is not assignable to type '(x: unknown) => unknown'. -- Types of parameters 'x' and 'x' are incompatible. -- Type 'unknown' is not assignable to type 'string'. --a.js(56,1): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. -+a.js(17,1): error TS2322: Type '{ x: string; }' is not assignable to type '{ x: number; }'. -+ Types of property 'x' are incompatible. -+ Type 'string' is not assignable to type 'number'. -+a.js(18,1): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. -+ Types of property 'x' are incompatible. -+ Type 'number' is not assignable to type 'string'. ++a.js(2,14): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias + a.js(18,1): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. + Type 'unknown' is not assignable to type 'string'. ++a.js(21,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias +a.js(29,33): error TS7006: Parameter 'x' implicitly has an 'any' type. +a.js(34,31): error TS7006: Parameter 'x' implicitly has an 'any' type. + a.js(36,1): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. + Type 'unknown' is not assignable to type 'string'. ++a.js(40,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias +a.js(48,29): error TS7006: Parameter 'x' implicitly has an 'any' type. +a.js(53,27): error TS7006: Parameter 'x' implicitly has an 'any' type. -+a.js(56,1): error TS2322: Type '{ f: (x: any) => void; }' is not assignable to type '{ f: (x: any) => string; }'. - The types returned by 'f(...)' are incompatible between these types. + a.js(55,1): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +- Types of property 'f' are incompatible. +- Type '(x: string) => string' is not assignable to type '(x: unknown) => unknown'. +- Types of parameters 'x' and 'x' are incompatible. +- Type 'unknown' is not assignable to type 'string'. ++ Type 'unknown' is not assignable to type 'string'. + a.js(56,1): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +- The types returned by 'f(...)' are incompatible between these types. - Type 'unknown' is not assignable to type 'string'. --a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias -+ Type 'void' is not assignable to type 'string'. -+a.js(62,12): error TS7006: Parameter 'x' implicitly has an 'any' type. ++ Type 'unknown' is not assignable to type 'string'. + a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias -==== a.js (5 errors) ==== -+==== a.js (8 errors) ==== ++==== a.js (12 errors) ==== /** * @template out T ++ ~~~ ++!!! error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Covariant -@@= skipped -30, +31 lines =@@ - let sub_covariant = { x: '' }; - - super_covariant = sub_covariant; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2322: Type '{ x: string; }' is not assignable to type '{ x: number; }'. -+!!! error TS2322: Types of property 'x' are incompatible. -+!!! error TS2322: Type 'string' is not assignable to type 'number'. - sub_covariant = super_covariant; // Error - ~~~~~~~~~~~~~ --!!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. --!!! error TS2322: Type 'unknown' is not assignable to type 'string'. -+!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. -+!!! error TS2322: Types of property 'x' are incompatible. -+!!! error TS2322: Type 'number' is not assignable to type 'string'. + * @property {T} x + */ +@@= skipped -37, +42 lines =@@ /** * @template in T -@@= skipped -15, +20 lines =@@ ++ ~~ ++!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias + * @typedef {Object} Contravariant + * @property {(x: T) => void} f + */ +@@= skipped -8, +10 lines =@@ * @type {Contravariant} */ let super_contravariant = { f: (x) => {} }; @@ -67,13 +58,17 @@ +!!! error TS7006: Parameter 'x' implicitly has an 'any' type. super_contravariant = sub_contravariant; // Error -- ~~~~~~~~~~~~~~~~~~~ --!!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. --!!! error TS2322: Type 'unknown' is not assignable to type 'string'. - sub_contravariant = super_contravariant; + ~~~~~~~~~~~~~~~~~~~ +@@= skipped -14, +18 lines =@@ /** -@@= skipped -22, +23 lines =@@ + * @template in out T ++ ~~ ++!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias + * @typedef {Object} Invariant + * @property {(x: T) => T} f + */ +@@= skipped -8, +10 lines =@@ * @type {Invariant} */ let super_invariant = { f: (x) => {} }; @@ -88,27 +83,19 @@ +!!! error TS7006: Parameter 'x' implicitly has an 'any' type. super_invariant = sub_invariant; // Error -- ~~~~~~~~~~~~~~~ --!!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. + ~~~~~~~~~~~~~~~ + !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. -!!! error TS2322: Types of property 'f' are incompatible. -!!! error TS2322: Type '(x: string) => string' is not assignable to type '(x: unknown) => unknown'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'unknown' is not assignable to type 'string'. ++!!! error TS2322: Type 'unknown' is not assignable to type 'string'. sub_invariant = super_invariant; // Error ~~~~~~~~~~~~~ --!!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. -+!!! error TS2322: Type '{ f: (x: any) => void; }' is not assignable to type '{ f: (x: any) => string; }'. - !!! error TS2322: The types returned by 'f(...)' are incompatible between these types. + !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +-!!! error TS2322: The types returned by 'f(...)' are incompatible between these types. -!!! error TS2322: Type 'unknown' is not assignable to type 'string'. -+!!! error TS2322: Type 'void' is not assignable to type 'string'. ++!!! error TS2322: Type 'unknown' is not assignable to type 'string'. /** * @template in T -- ~~ --!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias - * @param {T} x - */ - function f(x) {} -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.types.diff index 31c7c84ea0..a1fa576958 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.types.diff @@ -1,52 +1,13 @@ --- old.jsdocTemplateTag8.types +++ new.jsdocTemplateTag8.types -@@= skipped -10, +10 lines =@@ - * @type {Covariant} - */ - let super_covariant = { x: 1 }; -->super_covariant : Covariant -+>super_covariant : { x: number; } - >{ x: 1 } : { x: number; } - >x : number - >1 : 1 -@@= skipped -9, +9 lines =@@ - * @type {Covariant} - */ - let sub_covariant = { x: '' }; -->sub_covariant : Covariant -+>sub_covariant : { x: string; } - >{ x: '' } : { x: string; } - >x : string - >'' : "" - - super_covariant = sub_covariant; -->super_covariant = sub_covariant : Covariant -->super_covariant : Covariant -->sub_covariant : Covariant -+>super_covariant = sub_covariant : { x: string; } -+>super_covariant : { x: number; } -+>sub_covariant : { x: string; } - - sub_covariant = super_covariant; // Error -->sub_covariant = super_covariant : Covariant -->sub_covariant : Covariant -->super_covariant : Covariant -+>sub_covariant = super_covariant : { x: number; } -+>sub_covariant : { x: string; } -+>super_covariant : { x: number; } - - /** - * @template in T -@@= skipped -25, +25 lines =@@ - * @type {Contravariant} +@@= skipped -45, +45 lines =@@ */ let super_contravariant = { f: (x) => {} }; -->super_contravariant : Contravariant + >super_contravariant : Contravariant ->{ f: (x) => {} } : { f: (x: unknown) => void; } ->f : (x: unknown) => void ->(x) => {} : (x: unknown) => void ->x : unknown -+>super_contravariant : { f: (x: any) => void; } +>{ f: (x) => {} } : { f: (x: any) => void; } +>f : (x: any) => void +>(x) => {} : (x: any) => void @@ -56,45 +17,26 @@ * @type {Contravariant} */ let sub_contravariant = { f: (x) => {} }; -->sub_contravariant : Contravariant + >sub_contravariant : Contravariant ->{ f: (x) => {} } : { f: (x: string) => void; } ->f : (x: string) => void ->(x) => {} : (x: string) => void ->x : string -+>sub_contravariant : { f: (x: any) => void; } +>{ f: (x) => {} } : { f: (x: any) => void; } +>f : (x: any) => void +>(x) => {} : (x: any) => void +>x : any super_contravariant = sub_contravariant; // Error -->super_contravariant = sub_contravariant : Contravariant -->super_contravariant : Contravariant -->sub_contravariant : Contravariant -+>super_contravariant = sub_contravariant : { f: (x: any) => void; } -+>super_contravariant : { f: (x: any) => void; } -+>sub_contravariant : { f: (x: any) => void; } - - sub_contravariant = super_contravariant; -->sub_contravariant = super_contravariant : Contravariant -->sub_contravariant : Contravariant -->super_contravariant : Contravariant -+>sub_contravariant = super_contravariant : { f: (x: any) => void; } -+>sub_contravariant : { f: (x: any) => void; } -+>super_contravariant : { f: (x: any) => void; } - - /** - * @template in out T + >super_contravariant = sub_contravariant : Contravariant @@= skipped -36, +36 lines =@@ - * @type {Invariant} */ let super_invariant = { f: (x) => {} }; -->super_invariant : Invariant + >super_invariant : Invariant ->{ f: (x) => {} } : { f: (x: unknown) => void; } ->f : (x: unknown) => void ->(x) => {} : (x: unknown) => void ->x : unknown -+>super_invariant : { f: (x: any) => void; } +>{ f: (x) => {} } : { f: (x: any) => void; } +>f : (x: any) => void +>(x) => {} : (x: any) => void @@ -104,12 +46,11 @@ * @type {Invariant} */ let sub_invariant = { f: (x) => { return "" } }; -->sub_invariant : Invariant + >sub_invariant : Invariant ->{ f: (x) => { return "" } } : { f: (x: string) => string; } ->f : (x: string) => string ->(x) => { return "" } : (x: string) => string ->x : string -+>sub_invariant : { f: (x: any) => string; } +>{ f: (x) => { return "" } } : { f: (x: any) => string; } +>f : (x: any) => string +>(x) => { return "" } : (x: any) => string @@ -117,28 +58,11 @@ >"" : "" super_invariant = sub_invariant; // Error -->super_invariant = sub_invariant : Invariant -->super_invariant : Invariant -->sub_invariant : Invariant -+>super_invariant = sub_invariant : { f: (x: any) => string; } -+>super_invariant : { f: (x: any) => void; } -+>sub_invariant : { f: (x: any) => string; } - - sub_invariant = super_invariant; // Error -->sub_invariant = super_invariant : Invariant -->sub_invariant : Invariant -->super_invariant : Invariant -+>sub_invariant = super_invariant : { f: (x: any) => void; } -+>sub_invariant : { f: (x: any) => string; } -+>super_invariant : { f: (x: any) => void; } - - /** - * @template in T +@@= skipped -31, +31 lines =@@ * @param {T} x */ function f(x) {} ->f : (x: T) => void -->x : T -+>f : (x: any) => void -+>x : any ++>f : (x: T) => void + >x : T diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff index eec04653f1..e636f4616c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff @@ -1,95 +1,70 @@ --- old.jsdocTemplateTagDefault.errors.txt +++ new.jsdocTemplateTagDefault.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -file.js(9,20): error TS2322: Type 'number' is not assignable to type 'string'. -file.js(22,34): error TS1005: '=' expected. -file.js(27,35): error TS1110: Type expected. --file.js(33,14): error TS2706: Required type parameters may not follow optional type parameters. --file.js(38,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. --file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. ++file.js(3,15): error TS2304: Cannot find name 'T'. + file.js(33,14): error TS2706: Required type parameters may not follow optional type parameters. + file.js(38,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. ++file.js(45,17): error TS2304: Cannot find name 'T'. + file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. -file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. -- -- --==== file.js (7 errors) ==== -- /** -- * @template {string | number} [T=string] - ok: defaults are permitted -- * @typedef {[T]} A -- */ -- -- /** @type {A} */ // ok, default for `T` in `A` is `string` -- const aDefault1 = [""]; -- /** @type {A} */ // error: `number` is not assignable to string` -- const aDefault2 = [0]; ++file.js(60,17): error TS2304: Cannot find name 'U'. ++file.js(61,17): error TS2304: Cannot find name 'T'. + + + ==== file.js (7 errors) ==== + /** + * @template {string | number} [T=string] - ok: defaults are permitted + * @typedef {[T]} A ++ ~ ++!!! error TS2304: Cannot find name 'T'. + */ + + /** @type {A} */ // ok, default for `T` in `A` is `string` + const aDefault1 = [""]; + /** @type {A} */ // error: `number` is not assignable to string` + const aDefault2 = [0]; - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -- /** @type {A} */ // ok, `T` is provided for `A` -- const aString = [""]; -- /** @type {A} */ // ok, `T` is provided for `A` -- const aNumber = [0]; -- -- /** -- * @template T -- * @template [U=T] - ok: default can reference earlier type parameter -- * @typedef {[T, U]} B -- */ -- -- /** -- * @template {string | number} [T] - error: default requires an `=type` + /** @type {A} */ // ok, `T` is provided for `A` + const aString = [""]; + /** @type {A} */ // ok, `T` is provided for `A` +@@= skipped -31, +31 lines =@@ + + /** + * @template {string | number} [T] - error: default requires an `=type` - ~ -!!! error TS1005: '=' expected. -- * @typedef {[T]} C -- */ -- -- /** -- * @template {string | number} [T=] - error: default requires a `type` + * @typedef {[T]} C + */ + + /** + * @template {string | number} [T=] - error: default requires a `type` - ~ -!!! error TS1110: Type expected. -- * @typedef {[T]} D -- */ -- -- /** -- * @template {string | number} [T=string] -- * @template U - error: Required type parameters cannot follow optional type parameters -- ~ --!!! error TS2706: Required type parameters may not follow optional type parameters. -- * @typedef {[T, U]} E -- */ -- -- /** -- * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. -- ~ + * @typedef {[T]} D + */ + +@@= skipped -31, +27 lines =@@ + /** + * @template T + * @template [U=T] - ok: default can reference earlier type parameter ++ ~ ++!!! error TS2304: Cannot find name 'T'. + * @param {T} a + * @param {U} b + */ +@@= skipped -18, +20 lines =@@ + /** + * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. + ~ -!!! error TS2744: Type parameter defaults can only reference previously declared type parameters. -- * @template [U=T] -- * @typedef {[T, U]} G -- */ -- -- /** -- * @template T -- * @template [U=T] - ok: default can reference earlier type parameter -- * @param {T} a -- * @param {U} b -- */ -- function f1(a, b) {} -- -- /** -- * @template {string | number} [T=string] -- * @template U - error: Required type parameters cannot follow optional type parameters -- ~ --!!! error TS2706: Required type parameters may not follow optional type parameters. -- * @param {T} a -- * @param {U} b -- */ -- function f2(a, b) {} -- -- /** -- * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. -- ~ --!!! error TS2744: Type parameter defaults can only reference previously declared type parameters. -- * @template [U=T] -- * @param {T} a -- * @param {U} b -- */ -- function f3(a, b) {} -- -@@= skipped --1, +1 lines =@@ -+ ++!!! error TS2304: Cannot find name 'U'. + * @template [U=T] ++ ~ ++!!! error TS2304: Cannot find name 'T'. + * @param {T} a + * @param {U} b + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff index 18cbb392d4..bac0af2dbc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff @@ -5,70 +5,55 @@ /** @type {A} */ // ok, default for `T` in `A` is `string` const aDefault1 = [""]; ->aDefault1 : A -->[""] : [string] -+>aDefault1 : string[] -+>[""] : string[] ++>aDefault1 : [T] + >[""] : [string] >"" : "" /** @type {A} */ // error: `number` is not assignable to string` const aDefault2 = [0]; ->aDefault2 : A -->[0] : [number] -+>aDefault2 : number[] -+>[0] : number[] ++>aDefault2 : [T] + >[0] : [number] >0 : 0 /** @type {A} */ // ok, `T` is provided for `A` const aString = [""]; ->aString : A -->[""] : [string] -+>aString : string[] -+>[""] : string[] ++>aString : [T] + >[""] : [string] >"" : "" /** @type {A} */ // ok, `T` is provided for `A` const aNumber = [0]; ->aNumber : A -->[0] : [number] -+>aNumber : number[] -+>[0] : number[] ++>aNumber : [T] + >[0] : [number] >0 : 0 - /** @@= skipped -57, +57 lines =@@ * @param {U} b */ function f1(a, b) {} ->f1 : (a: T, b: U) => void -->a : T -->b : U -+>f1 : (a: any, b: any) => void -+>a : any -+>b : any ++>f1 : (a: T, b: U) => void + >a : T + >b : U - /** - * @template {string | number} [T=string] @@= skipped -11, +11 lines =@@ * @param {U} b */ function f2(a, b) {} ->f2 : (a: T, b: U) => void -->a : T -->b : U -+>f2 : (a: any, b: any) => void -+>a : any -+>b : any ++>f2 : (a: T, b: U) => void + >a : T + >b : U - /** - * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. @@= skipped -11, +11 lines =@@ * @param {U} b */ function f3(a, b) {} ->f3 : (a: T, b: U) => void -->a : T -->b : U -+>f3 : (a: any, b: any) => void -+>a : any -+>b : any ++>f3 : (a: T, b: U) => void + >a : T + >b : U diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff index 5d4aec8581..1f58ae47d9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff @@ -1,21 +1,29 @@ --- old.jsdocTemplateTagNameResolution.errors.txt +++ new.jsdocTemplateTagNameResolution.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -file.js(10,7): error TS2322: Type 'string' is not assignable to type 'number'. -- -- ++file.js(3,21): error TS2304: Cannot find name 'T'. ++file.js(4,14): error TS2304: Cannot find name 'T'. ++file.js(4,16): error TS2304: Cannot find name 'K'. + + -==== file.js (1 errors) ==== -- /** -- * @template T -- * @template {keyof T} K -- * @typedef {T[K]} Foo -- */ -- -- const x = { a: 1 }; -- -- /** @type {Foo} */ -- const y = "a"; ++==== file.js (3 errors) ==== + /** + * @template T + * @template {keyof T} K ++ ~ ++!!! error TS2304: Cannot find name 'T'. + * @typedef {T[K]} Foo ++ ~ ++!!! error TS2304: Cannot find name 'T'. ++ ~ ++!!! error TS2304: Cannot find name 'K'. + */ + + const x = { a: 1 }; + + /** @type {Foo} */ + const y = "a"; - ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.types.diff index 146d98e60d..10ad107341 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.types.diff @@ -5,6 +5,6 @@ /** @type {Foo} */ const y = "a"; ->y : number -+>y : "a" ++>y : T >"a" : "a" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff index 953254940d..2531a30be7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff @@ -1,63 +1,56 @@ --- old.jsdocThisType.errors.txt +++ new.jsdocThisType.errors.txt -@@= skipped -0, +-1 lines =@@ --/a.js(3,10): error TS2339: Property 'test' does not exist on type 'Foo'. +@@= skipped -0, +0 lines =@@ + /a.js(3,10): error TS2339: Property 'test' does not exist on type 'Foo'. -/a.js(8,10): error TS2339: Property 'test' does not exist on type 'Foo'. --/a.js(13,10): error TS2339: Property 'test' does not exist on type 'Foo'. + /a.js(13,10): error TS2339: Property 'test' does not exist on type 'Foo'. -/a.js(18,10): error TS2339: Property 'test' does not exist on type 'Foo'. -/a.js(23,10): error TS2339: Property 'test' does not exist on type 'Foo'. -/a.js(28,10): error TS2339: Property 'test' does not exist on type 'Foo'. -- -- --==== /types.d.ts (0 errors) ==== -- export interface Foo { -- foo: () => void; -- } -- -- export type M = (this: Foo) => void; -- ++/a.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + + ==== /types.d.ts (0 errors) ==== +@@= skipped -12, +9 lines =@@ + + export type M = (this: Foo) => void; + -==== /a.js (6 errors) ==== -- /** @type {import('./types').M} */ -- export const f1 = function() { -- this.test(); ++==== /a.js (3 errors) ==== + /** @type {import('./types').M} */ + export const f1 = function() { + this.test(); +@@= skipped -11, +11 lines =@@ + /** @type {import('./types').M} */ + export function f2() { + this.test(); - ~~~~ -!!! error TS2339: Property 'test' does not exist on type 'Foo'. -- } -- -- /** @type {import('./types').M} */ -- export function f2() { -- this.test(); + } + + /** @type {(this: import('./types').Foo) => void} */ +@@= skipped -14, +12 lines =@@ + /** @type {(this: import('./types').Foo) => void} */ + export function f4() { + this.test(); - ~~~~ -!!! error TS2339: Property 'test' does not exist on type 'Foo'. -- } -- -- /** @type {(this: import('./types').Foo) => void} */ -- export const f3 = function() { -- this.test(); + } + + /** @type {function(this: import('./types').Foo): void} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + export const f5 = function() { + this.test(); - ~~~~ -!!! error TS2339: Property 'test' does not exist on type 'Foo'. -- } -- -- /** @type {(this: import('./types').Foo) => void} */ -- export function f4() { -- this.test(); + } + + /** @type {function(this: import('./types').Foo): void} */ + export function f6() { + this.test(); - ~~~~ -!!! error TS2339: Property 'test' does not exist on type 'Foo'. -- } -- -- /** @type {function(this: import('./types').Foo): void} */ -- export const f5 = function() { -- this.test(); -- ~~~~ --!!! error TS2339: Property 'test' does not exist on type 'Foo'. -- } -- -- /** @type {function(this: import('./types').Foo): void} */ -- export function f6() { -- this.test(); -- ~~~~ --!!! error TS2339: Property 'test' does not exist on type 'Foo'. -- } -- -@@= skipped --1, +1 lines =@@ -+ + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.types.diff index eaec68714a..c167eb69fc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.types.diff @@ -6,14 +6,14 @@ export const f1 = function() { ->f1 : import("/types").M ->function() { this.test();} : (this: import("/types").Foo) => void -+>f1 : () => void -+>function() { this.test();} : () => void ++>f1 : M ++>function() { this.test();} : (this: Foo) => void this.test(); >this.test() : any >this.test : any ->this : import("/types").Foo -+>this : any ++>this : Foo >test : any } @@ -34,14 +34,14 @@ export const f3 = function() { ->f3 : (this: import("./types").Foo) => void ->function() { this.test();} : (this: import("./types").Foo) => void -+>f3 : () => void -+>function() { this.test();} : () => void ++>f3 : (this: Foo) => void ++>function() { this.test();} : (this: Foo) => void this.test(); >this.test() : any >this.test : any ->this : import("/types").Foo -+>this : any ++>this : Foo >test : any } @@ -62,7 +62,7 @@ export const f5 = function() { ->f5 : (this: import("./types").Foo) => void ->function() { this.test();} : (this: import("./types").Foo) => void -+>f5 : () => void ++>f5 : function +>function() { this.test();} : () => void this.test(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff new file mode 100644 index 0000000000..e03e9d76e5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.jsdocTypeDefAtStartOfFile.errors.txt ++++ new.jsdocTypeDefAtStartOfFile.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++index.js(1,12): error TS2304: Cannot find name 'AnyEffect'. ++index.js(3,12): error TS2304: Cannot find name 'Third'. ++ ++ ++==== dtsEquivalent.js (0 errors) ==== ++ /** @typedef {{[k: string]: any}} AnyEffect */ ++ /** @typedef {number} Third */ ++==== index.js (2 errors) ==== ++ /** @type {AnyEffect} */ ++ ~~~~~~~~~ ++!!! error TS2304: Cannot find name 'AnyEffect'. ++ let b; ++ /** @type {Third} */ ++ ~~~~~ ++!!! error TS2304: Cannot find name 'Third'. ++ let c; ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.types.diff index 02b68d0480..8b037dfbeb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.types.diff @@ -1,14 +1,9 @@ --- old.jsdocTypeDefAtStartOfFile.types +++ new.jsdocTypeDefAtStartOfFile.types -@@= skipped -6, +6 lines =@@ - === index.js === - /** @type {AnyEffect} */ - let b; -->b : AnyEffect -+>b : any +@@= skipped -10, +10 lines =@@ /** @type {Third} */ let c; ->c : number -+>c : any ++>c : Third diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff index b63d4bf21d..262c292351 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff @@ -4,14 +4,17 @@ - @@= skipped --1, +1 lines =@@ +bug27342.js(1,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++bug27342.js(3,11): error TS2304: Cannot find name 'exports'. + + -+==== bug27342.js (1 errors) ==== ++==== bug27342.js (2 errors) ==== + module.exports = {} + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + /** + * @type {exports} ++ ~~~~~~~ ++!!! error TS2304: Cannot find name 'exports'. + */ + var x + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.types.diff index af427dd532..350242544a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.types.diff @@ -19,6 +19,6 @@ */ var x ->x : typeof import("bug27342") -+>x : any ++>x : exports diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff index 63e4a4f2bd..6e5a04bd5a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff @@ -5,9 +5,11 @@ @@= skipped --1, +1 lines =@@ +jsdocTypeReferenceToImport.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`. +jsdocTypeReferenceToImport.js(2,11): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++jsdocTypeReferenceToImport.js(3,12): error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? ++jsdocTypeReferenceToImport.js(8,12): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? + + -+==== jsdocTypeReferenceToImport.js (2 errors) ==== ++==== jsdocTypeReferenceToImport.js (4 errors) ==== + const C = require('./ex').C; + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -15,11 +17,15 @@ + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + /** @type {C} c */ ++ ~ ++!!! error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? + var c = new C() + c.start + c.end + + /** @type {D} c */ ++ ~ ++!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? + var d = new D() + d.start + d.end diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.types.diff index 9af52988dc..48a451cab5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.types.diff @@ -29,27 +29,24 @@ /** @type {C} c */ var c = new C() -->c : C + >c : C ->new C() : C ->C : typeof C -+>c : any +>new C() : any +>C : any c.start ->c.start : number -->c : C -->start : number +>c.start : any -+>c : any + >c : C +->start : number +>start : any c.end ->c.end : number -->c : C -->end : number +>c.end : any -+>c : any + >c : C +->end : number +>end : any /** @type {D} c */ @@ -57,7 +54,7 @@ ->d : C ->new D() : C ->D : typeof C -+>d : any ++>d : D +>new D() : any +>D : any @@ -66,7 +63,7 @@ ->d : C ->start : number +>d.start : any -+>d : any ++>d : D +>start : any d.end @@ -74,7 +71,7 @@ ->d : C ->end : number +>d.end : any -+>d : any ++>d : D +>end : any === ex.d.ts === diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.types.diff index ccb01c3175..e72ddd96ef 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.types.diff @@ -30,17 +30,15 @@ /** @type {any} */ var x = {} -->x : any -+>x : {} +@@= skipped -13, +13 lines =@@ >{} : {} return new MW(x); ->new MW(x) : MW ->MW : typeof MW -->x : any +>new MW(x) : any +>MW : any -+>x : {} + >x : any }; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff index 1f84bbb30a..4f06122ae6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff @@ -3,13 +3,16 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++jsdocTypeReferenceToMergedClass.js(2,12): error TS2503: Cannot find namespace 'Workspace'. +jsdocTypeReferenceToMergedClass.js(6,11): error TS2339: Property 'Project' does not exist on type '{}'. +jsdocTypeReferenceToMergedClass.js(7,11): error TS2339: Property 'Project' does not exist on type '{}'. + + -+==== jsdocTypeReferenceToMergedClass.js (2 errors) ==== ++==== jsdocTypeReferenceToMergedClass.js (3 errors) ==== + var Workspace = {} + /** @type {Workspace.Project} */ ++ ~~~~~~~~~ ++!!! error TS2503: Cannot find namespace 'Workspace'. + var p; + p.isServiceProject() + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.types.diff index 6ea824b364..e2ad380e81 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.types.diff @@ -11,7 +11,7 @@ /** @type {Workspace.Project} */ var p; ->p : wp -+>p : any ++>p : Project p.isServiceProject() ->p.isServiceProject() : void @@ -20,7 +20,7 @@ ->isServiceProject : () => void +>p.isServiceProject() : any +>p.isServiceProject : any -+>p : any ++>p : Project +>isServiceProject : any Workspace.Project = function wp() { } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff new file mode 100644 index 0000000000..9ea73f0fd7 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.jsdocTypeReferenceToValue.errors.txt ++++ new.jsdocTypeReferenceToValue.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++foo.js(1,13): error TS2749: 'Image' refers to a value, but is being used as a type here. Did you mean 'typeof Image'? ++ ++ ++==== foo.js (1 errors) ==== ++ /** @param {Image} image */ ++ ~~~~~ ++!!! error TS2749: 'Image' refers to a value, but is being used as a type here. Did you mean 'typeof Image'? ++ function process(image) { ++ return new image(1, 1) ++ } ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.types.diff index 6b6cb40c9e..bf3b90b2d7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.types.diff @@ -6,14 +6,14 @@ function process(image) { ->process : (image: new (width?: number, height?: number) => HTMLImageElement) => HTMLImageElement ->image : new (width?: number, height?: number) => HTMLImageElement -+>process : (image: any) => any -+>image : any ++>process : (image: Image) => any ++>image : Image return new image(1, 1) ->new image(1, 1) : HTMLImageElement ->image : new (width?: number, height?: number) => HTMLImageElement +>new image(1, 1) : any -+>image : any ++>image : Image >1 : 1 >1 : 1 } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.types.diff deleted file mode 100644 index 2dabe2cf53..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsdocTypeReferenceUseBeforeDef.types -+++ new.jsdocTypeReferenceUseBeforeDef.types -@@= skipped -2, +2 lines =@@ - === bug25097.js === - /** @type {C | null} */ - const c = null -->c : C -+>c : any - - class C { - >C : C diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff index 3b52250c34..b0be4b125c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff @@ -3,29 +3,21 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+b.ts(1,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'S' must be of type 'any', but here has type 'string'. -+b.ts(2,5): error TS2403: Subsequent variable declarations must have the same type. Variable 's' must be of type 'any', but here has type 'string'. -+b.ts(3,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'N' must be of type 'any', but here has type 'number'. -+b.ts(4,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'n' must be of type 'any', but here has type 'number'. -+b.ts(5,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'B' must be of type 'any', but here has type 'boolean'. -+b.ts(6,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'any', but here has type 'boolean'. -+b.ts(7,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'V' must be of type 'any', but here has type 'void'. -+b.ts(8,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'v' must be of type 'any', but here has type 'void'. -+b.ts(9,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'U' must be of type 'any', but here has type 'undefined'. -+b.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'u' must be of type 'any', but here has type 'undefined'. -+b.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'Nl' must be of type 'any', but here has type 'null'. -+b.ts(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'nl' must be of type 'any', but here has type 'null'. -+b.ts(13,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'A' must be of type 'any', but here has type 'any[]'. -+b.ts(14,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'any[]'. -+b.ts(15,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'P' must be of type 'any', but here has type 'Promise'. -+b.ts(16,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'any', but here has type 'Promise'. -+b.ts(17,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'nullable' must be of type 'any', but here has type 'number | null'. -+b.ts(20,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'Func' must be of type 'any', but here has type 'Function'. -+b.ts(21,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type 'any', but here has type '(s: string) => number'. -+b.ts(22,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'ctor' must be of type 'any', but here has type 'new (s: string) => { s: string; }'. ++a.js(19,12): error TS2304: Cannot find name 'Void'. ++a.js(25,12): error TS2304: Cannot find name 'Undefined'. ++a.js(31,12): error TS2304: Cannot find name 'Null'. ++a.js(37,12): error TS2314: Generic type 'T[]' requires 1 type argument(s). ++a.js(40,12): error TS2552: Cannot find name 'array'. Did you mean 'Array'? ++a.js(43,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++a.js(46,12): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? ++b.ts(1,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'S' must be of type 'String', but here has type 'string'. ++b.ts(3,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'N' must be of type 'Number', but here has type 'number'. ++b.ts(5,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'B' must be of type 'Boolean', but here has type 'boolean'. ++b.ts(18,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'Obj' must be of type 'Object', but here has type 'any'. ++b.ts(19,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'obj' must be of type 'object', but here has type 'any'. + + -+==== a.js (0 errors) ==== ++==== a.js (7 errors) ==== + /** @type {String} */ + var S; + @@ -45,33 +37,48 @@ + var b; + + /** @type {Void} */ ++ ~~~~ ++!!! error TS2304: Cannot find name 'Void'. + var V; + + /** @type {void} */ + var v; + + /** @type {Undefined} */ ++ ~~~~~~~~~ ++!!! error TS2304: Cannot find name 'Undefined'. + var U; + + /** @type {undefined} */ + var u; + + /** @type {Null} */ ++ ~~~~ ++!!! error TS2304: Cannot find name 'Null'. + var Nl; + + /** @type {null} */ + var nl; + + /** @type {Array} */ ++ ~~~~~ ++!!! error TS2314: Generic type 'T[]' requires 1 type argument(s). + var A; + + /** @type {array} */ ++ ~~~~~ ++!!! error TS2552: Cannot find name 'array'. Did you mean 'Array'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Array' is declared here. + var a; + + /** @type {Promise} */ ++ ~~~~~~~ ++!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + var P; + + /** @type {promise} */ ++ ~~~~~~~ ++!!! error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? + var p; + + /** @type {?number} */ @@ -92,87 +99,42 @@ + /** @type {new (s: string) => { s: string }} */ + var ctor; + -+==== b.ts (20 errors) ==== ++==== b.ts (5 errors) ==== + var S: string; + ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'S' must be of type 'any', but here has type 'string'. ++!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'S' must be of type 'String', but here has type 'string'. +!!! related TS6203 a.js:2:5: 'S' was also declared here. + var s: string; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 's' must be of type 'any', but here has type 'string'. -+!!! related TS6203 a.js:5:5: 's' was also declared here. + var N: number; + ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'N' must be of type 'any', but here has type 'number'. ++!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'N' must be of type 'Number', but here has type 'number'. +!!! related TS6203 a.js:8:5: 'N' was also declared here. + var n: number -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'n' must be of type 'any', but here has type 'number'. -+!!! related TS6203 a.js:11:5: 'n' was also declared here. + var B: boolean; + ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'B' must be of type 'any', but here has type 'boolean'. ++!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'B' must be of type 'Boolean', but here has type 'boolean'. +!!! related TS6203 a.js:14:5: 'B' was also declared here. + var b: boolean; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'any', but here has type 'boolean'. -+!!! related TS6203 a.js:17:5: 'b' was also declared here. + var V :void; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'V' must be of type 'any', but here has type 'void'. -+!!! related TS6203 a.js:20:5: 'V' was also declared here. + var v: void; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'v' must be of type 'any', but here has type 'void'. -+!!! related TS6203 a.js:23:5: 'v' was also declared here. + var U: undefined; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'U' must be of type 'any', but here has type 'undefined'. -+!!! related TS6203 a.js:26:5: 'U' was also declared here. + var u: undefined; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'u' must be of type 'any', but here has type 'undefined'. -+!!! related TS6203 a.js:29:5: 'u' was also declared here. + var Nl: null; -+ ~~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Nl' must be of type 'any', but here has type 'null'. -+!!! related TS6203 a.js:32:5: 'Nl' was also declared here. + var nl: null; -+ ~~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'nl' must be of type 'any', but here has type 'null'. -+!!! related TS6203 a.js:35:5: 'nl' was also declared here. + var A: any[]; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'A' must be of type 'any', but here has type 'any[]'. -+!!! related TS6203 a.js:38:5: 'A' was also declared here. + var a: any[]; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'any[]'. -+!!! related TS6203 a.js:41:5: 'a' was also declared here. + var P: Promise; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'P' must be of type 'any', but here has type 'Promise'. -+!!! related TS6203 a.js:44:5: 'P' was also declared here. + var p: Promise; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'any', but here has type 'Promise'. -+!!! related TS6203 a.js:47:5: 'p' was also declared here. + var nullable: number | null; -+ ~~~~~~~~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'nullable' must be of type 'any', but here has type 'number | null'. -+!!! related TS6203 a.js:50:5: 'nullable' was also declared here. + var Obj: any; ++ ~~~ ++!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Obj' must be of type 'Object', but here has type 'any'. ++!!! related TS6203 a.js:53:5: 'Obj' was also declared here. + var obj: any; ++ ~~~ ++!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'obj' must be of type 'object', but here has type 'any'. ++!!! related TS6203 a.js:56:5: 'obj' was also declared here. + var Func: Function; -+ ~~~~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Func' must be of type 'any', but here has type 'Function'. -+!!! related TS6203 a.js:59:5: 'Func' was also declared here. + var f: (s: string) => number; -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type 'any', but here has type '(s: string) => number'. -+!!! related TS6203 a.js:62:5: 'f' was also declared here. + var ctor: new (s: string) => { s: string }; -+ ~~~~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'ctor' must be of type 'any', but here has type 'new (s: string) => { s: string; }'. -+!!! related TS6203 a.js:65:5: 'ctor' was also declared here. + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.types.diff index d1863ee13d..4c97134fce 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.types.diff @@ -5,62 +5,56 @@ /** @type {String} */ var S; ->S : string -+>S : any ++>S : String /** @type {string} */ var s; -->s : string -+>s : any +@@= skipped -8, +8 lines =@@ /** @type {Number} */ var N; ->N : number -+>N : any ++>N : Number /** @type {number} */ var n; -->n : number -+>n : any +@@= skipped -8, +8 lines =@@ /** @type {Boolean} */ var B; ->B : boolean -+>B : any ++>B : Boolean /** @type {boolean} */ var b; -->b : boolean -+>b : any +@@= skipped -8, +8 lines =@@ /** @type {Void} */ var V; ->V : void -+>V : any ++>V : Void /** @type {void} */ var v; -->v : void -+>v : any +@@= skipped -8, +8 lines =@@ /** @type {Undefined} */ var U; ->U : undefined -+>U : any ++>U : Undefined /** @type {undefined} */ var u; -->u : undefined -+>u : any +@@= skipped -8, +8 lines =@@ /** @type {Null} */ var Nl; ->Nl : null -+>Nl : any ++>Nl : Null /** @type {null} */ var nl; -->nl : null -+>nl : any +@@= skipped -8, +8 lines =@@ /** @type {Array} */ var A; @@ -70,7 +64,7 @@ /** @type {array} */ var a; ->a : any[] -+>a : any ++>a : array /** @type {Promise} */ var P; @@ -80,80 +74,68 @@ /** @type {promise} */ var p; ->p : Promise -+>p : any ++>p : promise /** @type {?number} */ var nullable; -->nullable : number | null -+>nullable : any +@@= skipped -20, +20 lines =@@ /** @type {Object} */ var Obj; -@@= skipped -76, +76 lines =@@ +->Obj : any ++>Obj : Object + + /** @type {object} */ + var obj; +->obj : any ++>obj : object /** @type {Function} */ var Func; -->Func : Function -+>Func : any - - /** @type {(s: string) => number} */ - var f; -->f : (s: string) => number -+>f : any - - /** @type {new (s: string) => { s: string }} */ - var ctor; -->ctor : new (s: string) => { s: string; } -+>ctor : any +@@= skipped -20, +20 lines =@@ === b.ts === var S: string; ->S : string -+>S : any ++>S : String var s: string; -->s : string -+>s : any + >s : string var N: number; ->N : number -+>N : any ++>N : Number var n: number -->n : number -+>n : any + >n : number var B: boolean; ->B : boolean -+>B : any ++>B : Boolean var b: boolean; -->b : boolean -+>b : any + >b : boolean var V :void; ->V : void -+>V : any ++>V : Void var v: void; -->v : void -+>v : any + >v : void var U: undefined; ->U : undefined -+>U : any ++>U : Undefined var u: undefined; -->u : undefined -+>u : any + >u : undefined var Nl: null; ->Nl : null -+>Nl : any ++>Nl : Null var nl: null; -->nl : null -+>nl : any + >nl : null var A: any[]; ->A : any[] @@ -161,7 +143,7 @@ var a: any[]; ->a : any[] -+>a : any ++>a : array var P: Promise; ->P : Promise @@ -169,29 +151,18 @@ var p: Promise; ->p : Promise -+>p : any ++>p : promise var nullable: number | null; -->nullable : number | null -+>nullable : any + >nullable : number | null var Obj: any; - >Obj : any -@@= skipped -69, +69 lines =@@ - >obj : any +->Obj : any ++>Obj : Object - var Func: Function; -->Func : Function -+>Func : any - - var f: (s: string) => number; -->f : (s: string) => number -+>f : any - >s : string - - var ctor: new (s: string) => { s: string }; -->ctor : new (s: string) => { s: string; } -+>ctor : any - >s : string - >s : string + var obj: any; +->obj : any ++>obj : object + var Func: Function; + >Func : Function diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff index 58986dfabf..b17750921e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff @@ -14,52 +14,29 @@ - Types of property 'p' are incompatible. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. --b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. --b.js(66,38): error TS2454: Variable 'numOrStr' is used before being assigned. --b.js(67,2): error TS2322: Type 'string | number' is not assignable to type 'string'. -- Type 'number' is not assignable to type 'string'. --b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. -+b.js(2,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'W' must be of type 'string', but here has type 'number'. -+b.js(4,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'W' must be of type 'string', but here has type 'number'. -+b.js(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'string'. -+b.js(13,5): error TS2403: Subsequent variable declarations must have the same type. Variable 's' must be of type 'any', but here has type 'string'. ++b.js(4,31): 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. +b.js(17,14): error TS2339: Property 'p' does not exist on type 'SomeBase'. +b.js(23,14): error TS2339: Property 'x' does not exist on type 'SomeDerived'. +b.js(28,14): error TS2339: Property 'q' does not exist on type 'SomeOther'. - - + b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. + b.js(66,38): error TS2454: Variable 'numOrStr' is used before being assigned. + b.js(67,2): error TS2322: Type 'string | number' is not assignable to type 'string'. +@@= skipped -20, +11 lines =@@ ==== a.ts (0 errors) ==== var W: string; -==== b.js (10 errors) ==== -+==== b.js (7 errors) ==== ++==== b.js (8 errors) ==== // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'W' must be of type 'string', but here has type 'number'. -+!!! related TS6203 a.ts:1:5: 'W' was also declared here. var W = /** @type {string} */(4); // Error - ~~~~~~ --!!! 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 TS2403: Subsequent variable declarations must have the same type. Variable 'W' must be of type 'string', but here has type 'number'. -+!!! related TS6203 a.ts:1:5: 'W' was also declared here. ++ ~ + !!! 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. /** @type {*} */ - var a; -@@= skipped -35, +28 lines =@@ - var s; - - var a = /** @type {*} */("" + 4); -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'any', but here has type 'string'. -+!!! related TS6203 b.js:7:5: 'a' was also declared here. - var s = "" + /** @type {*} */(4); -+ ~ -+!!! error TS2403: Subsequent variable declarations must have the same type. Variable 's' must be of type 'any', but here has type 'string'. -+!!! related TS6203 b.js:10:5: 's' was also declared here. - +@@= skipped -20, +20 lines =@@ class SomeBase { constructor() { this.p = 42; @@ -83,7 +60,7 @@ } } -@@= skipped -33, +45 lines =@@ +@@= skipped -28, +34 lines =@@ someBase = /** @type {SomeBase} */(someDerived); someBase = /** @type {SomeBase} */(someBase); someBase = /** @type {SomeBase} */(someOther); // Error @@ -123,20 +100,3 @@ someBase = /** @type {SomeBase} */(someFakeClass); // Type assertion cannot be a type-predicate type -@@= skipped -41, +21 lines =@@ - /** @type {string} */ - var str; - if(/** @type {numOrStr is string} */(numOrStr === undefined)) { // Error -- ~~~~~~~~~~~~~~~~~~ --!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. -- ~~~~~~~~ --!!! error TS2454: Variable 'numOrStr' is used before being assigned. - str = numOrStr; // Error, no narrowing occurred -- ~~~ --!!! error TS2322: Type 'string | number' is not assignable to type 'string'. --!!! error TS2322: Type 'number' is not assignable to type 'string'. -- ~~~~~~~~ --!!! error TS2454: Variable 'numOrStr' is used before being assigned. - } - - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff index 7d19fc5da4..7f91b86ec1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff @@ -1,48 +1,38 @@ --- old.jsdocTypeTagCast.types +++ new.jsdocTypeTagCast.types -@@= skipped -7, +7 lines =@@ - // @ts-check +@@= skipped -8, +8 lines =@@ var W = /** @type {string} */(/** @type {*} */ (4)); >W : string -->(/** @type {*} */ (4)) : string -->(4) : any -+>(/** @type {*} */ (4)) : 4 -+>(4) : 4 + >(/** @type {*} */ (4)) : string ++>(4) : string + >(4) : any ++>4 : any >4 : 4 var W = /** @type {string} */(4); // Error >W : string -->(4) : string -+>(4) : 4 + >(4) : string ++>4 : string >4 : 4 /** @type {*} */ -@@= skipped -15, +15 lines =@@ - - /** @type {string} */ - var s; -->s : string -+>s : any - +@@= skipped -19, +22 lines =@@ var a = /** @type {*} */("" + 4); >a : any -->("" + 4) : any -+>("" + 4) : string + >("" + 4) : any ++>"" + 4 : any >"" + 4 : string >"" : "" >4 : 4 - - var s = "" + /** @type {*} */(4); -->s : string -+>s : any +@@= skipped -9, +10 lines =@@ >"" + /** @type {*} */(4) : string >"" : "" -->(4) : any -+>(4) : 4 + >(4) : any ++>4 : any >4 : 4 class SomeBase { -@@= skipped -59, +59 lines =@@ +@@= skipped -45, +46 lines =@@ } function SomeFakeClass() { @@ -73,63 +63,67 @@ +>SomeFakeClass : () => void someBase = /** @type {SomeBase} */(someDerived); -->someBase = /** @type {SomeBase} */(someDerived) : SomeBase -+>someBase = /** @type {SomeBase} */(someDerived) : SomeDerived + >someBase = /** @type {SomeBase} */(someDerived) : SomeBase >someBase : SomeBase -->(someDerived) : SomeBase -+>(someDerived) : SomeDerived + >(someDerived) : SomeBase ++>someDerived : SomeBase >someDerived : SomeDerived someBase = /** @type {SomeBase} */(someBase); -@@= skipped -17, +17 lines =@@ +@@= skipped -15, +16 lines =@@ + >someBase : SomeBase + >(someBase) : SomeBase >someBase : SomeBase ++>someBase : SomeBase someBase = /** @type {SomeBase} */(someOther); // Error -->someBase = /** @type {SomeBase} */(someOther) : SomeBase -+>someBase = /** @type {SomeBase} */(someOther) : SomeOther + >someBase = /** @type {SomeBase} */(someOther) : SomeBase >someBase : SomeBase -->(someOther) : SomeBase -+>(someOther) : SomeOther + >(someOther) : SomeBase ++>someOther : SomeBase >someOther : SomeOther someDerived = /** @type {SomeDerived} */(someDerived); -@@= skipped -12, +12 lines =@@ +@@= skipped -12, +14 lines =@@ >someDerived : SomeDerived + >(someDerived) : SomeDerived + >someDerived : SomeDerived ++>someDerived : SomeDerived someDerived = /** @type {SomeDerived} */(someBase); -->someDerived = /** @type {SomeDerived} */(someBase) : SomeDerived -+>someDerived = /** @type {SomeDerived} */(someBase) : SomeBase + >someDerived = /** @type {SomeDerived} */(someBase) : SomeDerived >someDerived : SomeDerived -->(someBase) : SomeDerived -+>(someBase) : SomeBase + >(someBase) : SomeDerived ++>someBase : SomeDerived >someBase : SomeBase someDerived = /** @type {SomeDerived} */(someOther); // Error -->someDerived = /** @type {SomeDerived} */(someOther) : SomeDerived -+>someDerived = /** @type {SomeDerived} */(someOther) : SomeOther + >someDerived = /** @type {SomeDerived} */(someOther) : SomeDerived >someDerived : SomeDerived -->(someOther) : SomeDerived -+>(someOther) : SomeOther + >(someOther) : SomeDerived ++>someOther : SomeDerived >someOther : SomeOther someOther = /** @type {SomeOther} */(someDerived); // Error -->someOther = /** @type {SomeOther} */(someDerived) : SomeOther -+>someOther = /** @type {SomeOther} */(someDerived) : SomeDerived + >someOther = /** @type {SomeOther} */(someDerived) : SomeOther >someOther : SomeOther -->(someDerived) : SomeOther -+>(someDerived) : SomeDerived + >(someDerived) : SomeOther ++>someDerived : SomeOther >someDerived : SomeDerived someOther = /** @type {SomeOther} */(someBase); // Error -->someOther = /** @type {SomeOther} */(someBase) : SomeOther -+>someOther = /** @type {SomeOther} */(someBase) : SomeBase + >someOther = /** @type {SomeOther} */(someBase) : SomeOther >someOther : SomeOther -->(someBase) : SomeOther -+>(someBase) : SomeBase + >(someBase) : SomeOther ++>someBase : SomeOther >someBase : SomeBase someOther = /** @type {SomeOther} */(someOther); -@@= skipped -31, +31 lines =@@ +@@= skipped -30, +35 lines =@@ + >someOther : SomeOther + >(someOther) : SomeOther + >someOther : SomeOther ++>someOther : SomeOther someFakeClass = someBase; >someFakeClass = someBase : SomeBase @@ -151,59 +145,34 @@ +>someFakeClass : any someBase = /** @type {SomeBase} */(someFakeClass); -->someBase = /** @type {SomeBase} */(someFakeClass) : SomeBase -+>someBase = /** @type {SomeBase} */(someFakeClass) : any + >someBase = /** @type {SomeBase} */(someFakeClass) : SomeBase >someBase : SomeBase -->(someFakeClass) : SomeBase + >(someFakeClass) : SomeBase ->someFakeClass : SomeFakeClass -+>(someFakeClass) : any ++>someFakeClass : SomeBase +>someFakeClass : any // Type assertion cannot be a type-predicate type /** @type {number | string} */ - var numOrStr; -->numOrStr : string | number -+>numOrStr : any - - /** @type {string} */ - var str; -->str : string -+>str : any - +@@= skipped -34, +36 lines =@@ if(/** @type {numOrStr is string} */(numOrStr === undefined)) { // Error >(numOrStr === undefined) : boolean >numOrStr === undefined : boolean -->numOrStr : string | number -+>numOrStr : any ++>numOrStr === undefined : boolean + >numOrStr : string | number >undefined : undefined - str = numOrStr; // Error, no narrowing occurred -->str = numOrStr : string | number -->str : string -->numOrStr : string | number -+>str = numOrStr : any -+>str : any -+>numOrStr : any - } - - - var asConst1 = /** @type {const} */(1); -->asConst1 : 1 -+>asConst1 : number +@@= skipped -14, +15 lines =@@ + >asConst1 : 1 >(1) : 1 >1 : 1 ++>1 : 1 var asConst2 = /** @type {const} */({ -->asConst2 : { readonly x: 1; } -->({ x: 1}) : { readonly x: 1; } -->{ x: 1} : { readonly x: 1; } -+>asConst2 : { x: number; } -+>({ x: 1}) : { x: number; } -+>{ x: 1} : { x: number; } + >asConst2 : { readonly x: 1; } + >({ x: 1}) : { readonly x: 1; } + >{ x: 1} : { readonly x: 1; } ++>{ x: 1} : { readonly x: 1; } x: 1 -->x : 1 -+>x : number - >1 : 1 - - }); + >x : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff index efbaae8b0e..186716f23c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff @@ -3,12 +3,17 @@ @@= skipped -0, +0 lines =@@ -a.js(3,5): error TS2322: Type 'number' is not assignable to type 'string'. -a.js(7,5): error TS2322: Type 'number' is not assignable to type 'string'. ++a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +a.js(2,12): error TS7006: Parameter 'value' implicitly has an 'any' type. +a.js(6,12): error TS7006: Parameter 's' implicitly has an 'any' type. - ==== a.js (2 errors) ==== +-==== a.js (2 errors) ==== ++==== a.js (3 errors) ==== /** @type {function(string): void} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. const f = (value) => { + ~~~~~ +!!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.types.diff index a682d47f42..53101cd728 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.types.diff @@ -7,7 +7,7 @@ ->f : (arg0: string) => void ->(value) => { value = 1 // should error} : (value: string) => void ->value : string -+>f : (value: any) => void ++>f : function +>(value) => { value = 1 // should error} : (value: any) => void +>value : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff index 00ecef629a..f075ff78a8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff @@ -1,10 +1,11 @@ --- old.jsdocTypeTagRequiredParameters.errors.txt +++ new.jsdocTypeTagRequiredParameters.errors.txt @@= skipped -0, +0 lines =@@ +-a.js(11,1): error TS2554: Expected 1 arguments, but got 0. ++a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +a.js(2,12): error TS7006: Parameter 'value' implicitly has an 'any' type. +a.js(5,12): error TS7006: Parameter 's' implicitly has an 'any' type. +a.js(8,12): error TS7006: Parameter 's' implicitly has an 'any' type. - a.js(11,1): error TS2554: Expected 1 arguments, but got 0. a.js(12,1): error TS2554: Expected 1 arguments, but got 0. a.js(13,1): error TS2554: Expected 1 arguments, but got 0. @@ -12,6 +13,9 @@ -==== a.js (3 errors) ==== +==== a.js (6 errors) ==== /** @type {function(string): void} */ ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. const f = (value) => { + ~~~~~ +!!! error TS7006: Parameter 'value' implicitly has an 'any' type. @@ -28,10 +32,9 @@ } f() // should error - ~ - !!! error TS2554: Expected 1 arguments, but got 0. +- ~ +-!!! error TS2554: Expected 1 arguments, but got 0. -!!! related TS6210 a.js:1:21: An argument for '0' was not provided. -+!!! related TS6210 a.js:2:12: An argument for 'value' was not provided. g() // should error ~ !!! error TS2554: Expected 1 arguments, but got 0. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.types.diff index d2585e8d6c..a3180ab39c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.types.diff @@ -7,7 +7,7 @@ ->f : (arg0: string) => void ->(value) => {} : (value: string) => void ->value : string -+>f : (value: any) => void ++>f : function +>(value) => {} : (value: any) => void +>value : any @@ -28,9 +28,10 @@ } f() // should error - >f() : void +->f() : void ->f : (arg0: string) => void -+>f : (value: any) => void ++>f() : any ++>f : function g() // should error >g() : void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.types.diff deleted file mode 100644 index 9792e36423..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsdocVariableDeclarationWithTypeAnnotation.types -+++ new.jsdocVariableDeclarationWithTypeAnnotation.types -@@= skipped -2, +2 lines =@@ - === foo.js === - /** @type {boolean} */ - var /** @type {string} */ x, -->x : string -+>x : any - - /** @type {number} */ y; -->y : number -+>y : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff new file mode 100644 index 0000000000..a1c6c35172 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.jsdocVariadicType.errors.txt ++++ new.jsdocVariadicType.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++a.js(2,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++ ++ ++==== a.js (1 errors) ==== ++ /** ++ * @type {function(boolean, string, ...*):void} ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ */ ++ const foo = function (a, b, ...r) { }; ++ ++==== b.ts (0 errors) ==== ++ foo(false, ''); ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.types.diff index ec15ff1e12..395d30eb13 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.types.diff @@ -8,7 +8,7 @@ ->function (a, b, ...r) { } : (a: boolean, b: string, ...r: any[]) => void ->a : boolean ->b : string -+>foo : (a: any, b: any, ...r: any[]) => void ++>foo : function +>function (a, b, ...r) { } : (a: any, b: any, ...r: any[]) => void +>a : any +>b : any @@ -16,9 +16,10 @@ === b.ts === foo(false, ''); - >foo(false, '') : void +->foo(false, '') : void ->foo : (arg0: boolean, arg1: string, ...arg2: any[]) => void -+>foo : (a: any, b: any, ...r: any[]) => void ++>foo(false, '') : any ++>foo : function >false : false >'' : "" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.types.diff deleted file mode 100644 index b857e75e28..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.types.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.linkTagEmit1.types -+++ new.linkTagEmit1.types -@@= skipped -18, +18 lines =@@ - * @param {number} integer {@link Z} - */ - function computeCommonSourceDirectoryOfFilenames(integer) { -->computeCommonSourceDirectoryOfFilenames : (integer: number) => number -->integer : number -+>computeCommonSourceDirectoryOfFilenames : (integer: any) => any -+>integer : any - - return integer + 1 // pls pls pls -->integer + 1 : number -->integer : number -+>integer + 1 : any -+>integer : any - >1 : 1 - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.types.diff deleted file mode 100644 index b6c25f2d7b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.malformedTags.types -+++ new.malformedTags.types -@@= skipped -6, +6 lines =@@ - * @type Function - */ - var isArray = Array.isArray; -->isArray : Function -+>isArray : (arg: any) => arg is any[] - >Array.isArray : (arg: any) => arg is any[] - >Array : ArrayConstructor - >isArray : (arg: any) => arg is any[] diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.types.diff index a7a1fc376f..66151eef5a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.types.diff @@ -1,38 +1,12 @@ --- old.moduleExportAssignment6.types +++ new.moduleExportAssignment6.types -@@= skipped -5, +5 lines =@@ - - /** @param {number} x */ - constructor(x) { -->x : number -+>x : any - - this.x = x -->this.x = x : number -+>this.x = x : any - >this.x : any - >this : this - >x : any -->x : number -+>x : any - - this.exports = [x] -->this.exports = [x] : number[] -+>this.exports = [x] : any[] - >this.exports : any - >this : this - >exports : any -->[x] : number[] -->x : number -+>[x] : any[] -+>x : any +@@= skipped -24, +24 lines =@@ } /** @param {number} y */ m(y) { ->m : (y: number) => number -->y : number -+>m : (y: any) => any -+>y : any ++>m : (y: number) => any + >y : number return this.x + y ->this.x + y : number @@ -41,9 +15,8 @@ +>this.x : any >this : this ->x : number -->y : number +>x : any -+>y : any + >y : number } } function exec() { @@ -52,7 +25,7 @@ const module = new C(12); >module : C -@@= skipped -40, +40 lines =@@ +@@= skipped -21, +21 lines =@@ >12 : 12 return module.exports; // should be fine because `module` is defined locally diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff index 82e12872ff..05bc56ce6a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff @@ -9,20 +9,32 @@ -index.ts(8,24): error TS2694: Namespace '"mod".export=' has no exported member 'literal'. -index.ts(19,31): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. -main.js(20,35): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. -+index.ts(2,15): error TS2306: File 'mod.js' is not a module. -+index.ts(3,15): error TS2306: File 'mod.js' is not a module. -+index.ts(4,15): error TS2306: File 'mod.js' is not a module. -+index.ts(5,15): error TS2306: File 'mod.js' is not a module. -+index.ts(6,15): error TS2306: File 'mod.js' is not a module. -+index.ts(7,15): error TS2306: File 'mod.js' is not a module. -+index.ts(8,15): error TS2306: File 'mod.js' is not a module. -+index.ts(14,22): error TS2306: File 'mod.js' is not a module. -+index.ts(15,22): error TS2306: File 'mod.js' is not a module. -+index.ts(16,22): error TS2306: File 'mod.js' is not a module. -+index.ts(17,22): error TS2306: File 'mod.js' is not a module. -+index.ts(18,22): error TS2306: File 'mod.js' is not a module. -+index.ts(19,22): error TS2306: File 'mod.js' is not a module. -+index.ts(20,22): error TS2306: File 'mod.js' is not a module. ++index.ts(2,24): error TS2694: Namespace '"mod"' has no exported member 'Thing'. ++index.ts(3,24): error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. ++index.ts(4,24): error TS2694: Namespace '"mod"' has no exported member 'foo'. ++index.ts(5,24): error TS2694: Namespace '"mod"' has no exported member 'qux'. ++index.ts(6,24): error TS2694: Namespace '"mod"' has no exported member 'baz'. ++index.ts(8,24): error TS2694: Namespace '"mod"' has no exported member 'literal'. ++index.ts(14,31): error TS2694: Namespace '"mod"' has no exported member 'Thing'. ++index.ts(15,31): error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. ++index.ts(16,31): error TS2694: Namespace '"mod"' has no exported member 'foo'. ++index.ts(17,31): error TS2694: Namespace '"mod"' has no exported member 'qux'. ++index.ts(18,31): error TS2694: Namespace '"mod"' has no exported member 'baz'. ++index.ts(19,31): error TS2694: Namespace '"mod"' has no exported member 'buz'. ++index.ts(20,31): error TS2694: Namespace '"mod"' has no exported member 'literal'. ++main.js(2,28): error TS2694: Namespace '"mod"' has no exported member 'Thing'. ++main.js(3,28): error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. ++main.js(4,28): error TS2694: Namespace '"mod"' has no exported member 'foo'. ++main.js(5,28): error TS2694: Namespace '"mod"' has no exported member 'qux'. ++main.js(6,28): error TS2694: Namespace '"mod"' has no exported member 'baz'. ++main.js(8,28): error TS2694: Namespace '"mod"' has no exported member 'literal'. ++main.js(15,35): error TS2694: Namespace '"mod"' has no exported member 'Thing'. ++main.js(16,35): error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. ++main.js(17,35): error TS2694: Namespace '"mod"' has no exported member 'foo'. ++main.js(18,35): error TS2694: Namespace '"mod"' has no exported member 'qux'. ++main.js(19,35): error TS2694: Namespace '"mod"' has no exported member 'baz'. ++main.js(20,35): error TS2694: Namespace '"mod"' has no exported member 'buz'. ++main.js(21,35): error TS2694: Namespace '"mod"' has no exported member 'literal'. +mod.js(6,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -39,91 +51,120 @@ Thing, AnotherThing, foo, -@@= skipped -21, +30 lines =@@ +@@= skipped -21, +42 lines =@@ baz() { return 5 }, literal: "", } -==== main.js (1 errors) ==== -+==== main.js (0 errors) ==== ++==== main.js (13 errors) ==== /** * @param {import("./mod").Thing} a ++ ~~~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'Thing'. * @param {import("./mod").AnotherThing} b -@@= skipped -21, +21 lines =@@ ++ ~~~~~~~~~~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. + * @param {import("./mod").foo} c ++ ~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'foo'. + * @param {import("./mod").qux} d ++ ~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'qux'. + * @param {import("./mod").baz} e ++ ~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'baz'. + * @param {import("./mod").buz} f + * @param {import("./mod").literal} g ++ ~~~~~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'literal'. + */ + function jstypes(a, b, c, d, e, f, g) { + return a.x + b.y + c() + d() + e() + f() + g.length +@@= skipped -16, +28 lines =@@ + + /** + * @param {typeof import("./mod").Thing} a ++ ~~~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'Thing'. + * @param {typeof import("./mod").AnotherThing} b ++ ~~~~~~~~~~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. + * @param {typeof import("./mod").foo} c ++ ~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'foo'. * @param {typeof import("./mod").qux} d ++ ~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'qux'. * @param {typeof import("./mod").baz} e ++ ~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'baz'. * @param {typeof import("./mod").buz} f -- ~~~ + ~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. ++!!! error TS2694: Namespace '"mod"' has no exported member 'buz'. * @param {typeof import("./mod").literal} g ++ ~~~~~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'literal'. */ function jsvalues(a, b, c, d, e, f, g) { return a.length + b.length + c() + d() + e() + f() + g.length } -==== index.ts (7 errors) ==== -+==== index.ts (14 errors) ==== ++==== index.ts (13 errors) ==== function types( a: import('./mod').Thing, -- ~~~~~ + ~~~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++!!! error TS2694: Namespace '"mod"' has no exported member 'Thing'. b: import('./mod').AnotherThing, -- ~~~~~~~~~~~~ + ~~~~~~~~~~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'AnotherThing'. -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++!!! error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. c: import('./mod').foo, -- ~~~ + ~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'foo'. -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++!!! error TS2694: Namespace '"mod"' has no exported member 'foo'. d: import('./mod').qux, -- ~~~ + ~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'qux'. -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++!!! error TS2694: Namespace '"mod"' has no exported member 'qux'. e: import('./mod').baz, -- ~~~ + ~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++!!! error TS2694: Namespace '"mod"' has no exported member 'baz'. f: import('./mod').buz, -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. g: import('./mod').literal, -- ~~~~~~~ + ~~~~~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'literal'. -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++!!! error TS2694: Namespace '"mod"' has no exported member 'literal'. ) { return a.x + b.y + c() + d() + e() + f() + g.length } function values( a: typeof import('./mod').Thing, -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++ ~~~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'Thing'. b: typeof import('./mod').AnotherThing, -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++ ~~~~~~~~~~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'AnotherThing'. c: typeof import('./mod').foo, -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++ ~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'foo'. d: typeof import('./mod').qux, -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++ ~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'qux'. e: typeof import('./mod').baz, -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++ ~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'baz'. f: typeof import('./mod').buz, -- ~~~ + ~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++!!! error TS2694: Namespace '"mod"' has no exported member 'buz'. g: typeof import('./mod').literal, -+ ~~~~~~~ -+!!! error TS2306: File 'mod.js' is not a module. ++ ~~~~~~~ ++!!! error TS2694: Namespace '"mod"' has no exported member 'literal'. ) { return a.length + b.length + c() + d() + e() + f() + g.length } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff index d6f8be2170..29518b6bea 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff @@ -29,13 +29,13 @@ ->e : () => number ->f : import("mod").buz ->g : string -+>jstypes : (a: any, b: any, c: any, d: any, e: any, f: any, g: any) => any ++>jstypes : (a: any, b: any, c: any, d: any, e: any, f: () => number, g: any) => any +>a : any +>b : any +>c : any +>d : any +>e : any -+>f : any ++>f : () => number +>g : any return a.x + b.y + c() + d() + e() + f() + g.length @@ -57,11 +57,6 @@ ->d : () => number ->e() : number ->e : () => number -->f() : number -->f : import("mod").buz -->g.length : number -->g : string -->length : number +>a.x + b.y + c() + d() + e() + f() + g.length : any +>a.x + b.y + c() + d() + e() + f() : any +>a.x + b.y + c() + d() + e() : any @@ -80,8 +75,12 @@ +>d : any +>e() : any +>e : any -+>f() : any -+>f : any + >f() : number +->f : import("mod").buz +->g.length : number +->g : string +->length : number ++>f : () => number +>g.length : any +>g : any +>length : any @@ -156,7 +155,7 @@ === index.ts === function types( ->types : (a: import("./mod").Thing, b: import("./mod").AnotherThing, c: import("./mod").foo, d: import("./mod").qux, e: import("./mod").baz, f: import("./mod").buz, g: import("./mod").literal) => any -+>types : (a: any, b: any, c: any, d: any, e: any, f: any, g: any) => any ++>types : (a: any, b: any, c: any, d: any, e: any, f: () => number, g: any) => any a: import('./mod').Thing, >a : any @@ -165,18 +164,16 @@ f: import('./mod').buz, ->f : import("mod").buz -+>f : any ++>f : () => number g: import('./mod').literal, >g : any -@@= skipped -25, +25 lines =@@ - >d : any +@@= skipped -26, +26 lines =@@ >e() : any >e : any -->f() : number + >f() : number ->f : import("mod").buz -+>f() : any -+>f : any ++>f : () => number >g.length : any >g : any >length : any @@ -212,7 +209,7 @@ >baz : any f: typeof import('./mod').buz, -@@= skipped -35, +35 lines =@@ +@@= skipped -34, +34 lines =@@ >buz : any g: typeof import('./mod').literal, diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.types.diff index 30171e2aa0..60b579adb4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.types.diff @@ -113,16 +113,16 @@ ->f : (c: C, classic: s.Classic) => void ->c : C ->classic : s.Classic -+>f : (c: any, classic: any) => void -+>c : any -+>classic : any ++>f : (c: K, classic: Classic) => void ++>c : K ++>classic : Classic c.x ->c.x : number ->c : C ->x : number +>c.x : any -+>c : any ++>c : K +>x : any classic.p @@ -130,7 +130,7 @@ ->classic : s.Classic ->p : number +>classic.p : any -+>classic : any ++>classic : Classic +>p : any } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment2.errors.txt.diff deleted file mode 100644 index c114c2ddd7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment2.errors.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.moduleExportsElementAccessAssignment2.errors.txt -+++ new.moduleExportsElementAccessAssignment2.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+file1.js(9,12): error TS7006: Parameter 'type' implicitly has an 'any' type. -+file1.js(9,18): error TS7006: Parameter 'ctor' implicitly has an 'any' type. -+file1.js(9,24): error TS7006: Parameter 'exports' implicitly has an 'any' type. -+ -+ -+==== file1.js (3 errors) ==== -+ // this file _should_ be a global file -+ var GlobalThing = { x: 12 }; -+ -+ /** -+ * @param {*} type -+ * @param {*} ctor -+ * @param {*} exports -+ */ -+ function f(type, ctor, exports) { -+ ~~~~ -+!!! error TS7006: Parameter 'type' implicitly has an 'any' type. -+ ~~~~ -+!!! error TS7006: Parameter 'ctor' implicitly has an 'any' type. -+ ~~~~~~~ -+!!! error TS7006: Parameter 'exports' implicitly has an 'any' type. -+ if (typeof exports !== "undefined") { -+ exports["AST_" + type] = ctor; -+ } -+ } -+ -+==== ref.js (0 errors) ==== -+ GlobalThing.x -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/noAssertForUnparseableTypedefs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/noAssertForUnparseableTypedefs.errors.txt.diff new file mode 100644 index 0000000000..3dc274ce71 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/noAssertForUnparseableTypedefs.errors.txt.diff @@ -0,0 +1,15 @@ +--- old.noAssertForUnparseableTypedefs.errors.txt ++++ new.noAssertForUnparseableTypedefs.errors.txt +@@= skipped -0, +0 lines =@@ ++bug26693.js(1,15): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + bug26693.js(2,22): error TS2307: Cannot find module 'nope' or its corresponding type declarations. + + +-==== bug26693.js (1 errors) ==== ++==== bug26693.js (2 errors) ==== + /** @typedef {module:locale} hi */ ++ ~~~~~~ ++!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + import { nope } from 'nope'; + ~~~~~~ + !!! error TS2307: Cannot find module 'nope' or its corresponding type declarations. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff index ada3f5d3c0..1b93fe96e9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff @@ -1,6 +1,6 @@ --- old.overloadTag1.errors.txt +++ new.overloadTag1.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -overloadTag1.js(7,5): error TS2394: This overload signature is not compatible with its implementation signature. -overloadTag1.js(25,10): error TS2769: No overload matches this call. - Overload 1 of 2, '(a: number, b: number): number', gave the following error. @@ -12,67 +12,48 @@ - Argument of type 'string' is not assignable to parameter of type 'number'. - Overload 2 of 2, '(a: string, b: boolean): string', gave the following error. - Argument of type 'string' is not assignable to parameter of type 'boolean'. -- -- ++overloadTag1.js(26,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. + + -==== overloadTag1.js (3 errors) ==== -- /** -- * @overload -- * @param {number} a -- * @param {number} b -- * @returns {number} -- * -- * @overload ++==== overloadTag1.js (1 errors) ==== + /** + * @overload + * @param {number} a +@@= skipped -18, +8 lines =@@ + * @returns {number} + * + * @overload - ~~~~~~~~ -!!! error TS2394: This overload signature is not compatible with its implementation signature. -!!! related TS2750 overloadTag1.js:16:17: The implementation signature is declared here. -- * @param {string} a -- * @param {boolean} b -- * @returns {string} -- * -- * @param {string | number} a -- * @param {string | number} b -- * @returns {string | number} -- */ -- export function overloaded(a,b) { -- if (typeof a === "string" && typeof b === "string") { -- return a + b; -- } else if (typeof a === "number" && typeof b === "number") { -- return a + b; -- } -- throw new Error("Invalid arguments"); -- } -- var o1 = overloaded(1,2) -- var o2 = overloaded("zero", "one") + * @param {string} a + * @param {boolean} b + * @returns {string} +@@= skipped -21, +18 lines =@@ + } + var o1 = overloaded(1,2) + var o2 = overloaded("zero", "one") - ~~~~~~~~~~ -!!! error TS2769: No overload matches this call. -!!! error TS2769: Overload 1 of 2, '(a: number, b: number): number', gave the following error. -!!! error TS2769: Argument of type 'string' is not assignable to parameter of type 'number'. -!!! error TS2769: Overload 2 of 2, '(a: string, b: boolean): string', gave the following error. -!!! error TS2769: Argument of type 'string' is not assignable to parameter of type 'boolean'. -- var o3 = overloaded("a",false) -- -- /** -- * @overload -- * @param {number} a -- * @param {number} b -- * @returns {number} -- * -- * @overload -- * @param {string} a -- * @param {boolean} b -- * @returns {string} -- */ -- export function uncheckedInternally(a, b) { -- return a + b; -- } -- uncheckedInternally(1,2) -- uncheckedInternally("zero", "one") + var o3 = overloaded("a",false) ++ ~~~~~ ++!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. + + /** + * @overload +@@= skipped -24, +20 lines =@@ + } + uncheckedInternally(1,2) + uncheckedInternally("zero", "one") - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2769: No overload matches this call. -!!! error TS2769: Overload 1 of 2, '(a: number, b: number): number', gave the following error. -!!! error TS2769: Argument of type 'string' is not assignable to parameter of type 'number'. -!!! error TS2769: Overload 2 of 2, '(a: string, b: boolean): string', gave the following error. -!!! error TS2769: Argument of type 'string' is not assignable to parameter of type 'boolean'. -- -@@= skipped --1, +1 lines =@@ -+ + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.types.diff index 9b03c1377b..0037387909 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.types.diff @@ -5,41 +5,11 @@ */ export function overloaded(a,b) { ->overloaded : { (a: number, b: number): number; (a: string, b: boolean): string; } -->a : string | number -->b : string | number -+>overloaded : (a: any, b: any) => string | number -+>a : any -+>b : any ++>overloaded : (a: string | number, b: string | number) => string | number + >a : string | number + >b : string | number - if (typeof a === "string" && typeof b === "string") { - >typeof a === "string" && typeof b === "string" : boolean - >typeof a === "string" : boolean - >typeof a : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" -->a : string | number -+>a : any - >"string" : "string" - >typeof b === "string" : boolean - >typeof b : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" -->b : string | number -+>b : any - >"string" : "string" - - return a + b; -@@= skipped -24, +24 lines =@@ - >typeof a === "number" && typeof b === "number" : boolean - >typeof a === "number" : boolean - >typeof a : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" -->a : string | number -+>a : any - >"number" : "number" - >typeof b === "number" : boolean - >typeof b : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" -->b : string | number -+>b : any - >"number" : "number" - - return a + b; -@@= skipped -18, +18 lines =@@ +@@= skipped -42, +42 lines =@@ >"Invalid arguments" : "Invalid arguments" } var o1 = overloaded(1,2) @@ -48,7 +18,7 @@ ->overloaded : { (a: number, b: number): number; (a: string, b: boolean): string; } +>o1 : string | number +>overloaded(1,2) : string | number -+>overloaded : (a: any, b: any) => string | number ++>overloaded : (a: string | number, b: string | number) => string | number >1 : 1 >2 : 2 @@ -58,7 +28,7 @@ ->overloaded : { (a: number, b: number): number; (a: string, b: boolean): string; } +>o2 : string | number +>overloaded("zero", "one") : string | number -+>overloaded : (a: any, b: any) => string | number ++>overloaded : (a: string | number, b: string | number) => string | number >"zero" : "zero" >"one" : "one" @@ -68,7 +38,7 @@ ->overloaded : { (a: number, b: number): number; (a: string, b: boolean): string; } +>o3 : string | number +>overloaded("a",false) : string | number -+>overloaded : (a: any, b: any) => string | number ++>overloaded : (a: string | number, b: string | number) => string | number >"a" : "a" >false : false diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff index 0941eb1298..0699fa71da 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff @@ -2,7 +2,6 @@ +++ new.overloadTag2.errors.txt @@= skipped -0, +0 lines =@@ -overloadTag2.js(14,9): error TS2394: This overload signature is not compatible with its implementation signature. -+overloadTag2.js(25,17): error TS7006: Parameter 'a' implicitly has an 'any' type. overloadTag2.js(25,20): error TS7006: Parameter 'b' implicitly has an 'any' type. -overloadTag2.js(30,9): error TS2554: Expected 1-2 arguments, but got 0. +overloadTag2.js(30,9): error TS2554: Expected 2 arguments, but got 0. @@ -11,11 +10,11 @@ -==== overloadTag2.js (3 errors) ==== -+==== overloadTag2.js (5 errors) ==== ++==== overloadTag2.js (4 errors) ==== export class Foo { #a = true ? 1 : "1" #b -@@= skipped -17, +19 lines =@@ +@@= skipped -17, +18 lines =@@ /** * @constructor * @overload @@ -25,16 +24,7 @@ * @param {number} a */ /** -@@= skipped -14, +11 lines =@@ - * @param {number | string} a - */ - constructor(a, b) { -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ - !!! error TS7006: Parameter 'b' implicitly has an 'any' type. - this.#a = a -@@= skipped -8, +10 lines =@@ +@@= skipped -22, +19 lines =@@ } var a = new Foo() ~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.types.diff deleted file mode 100644 index af5d6dd3c2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.types.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.overloadTag2.types -+++ new.overloadTag2.types -@@= skipped -34, +34 lines =@@ - * @param {number | string} a - */ - constructor(a, b) { -->a : string | number -+>a : any - >b : any - - this.#a = a -->this.#a = a : string | number -+>this.#a = a : any - >this.#a : string | number - >this : this -->a : string | number -+>a : any - - this.#b = b - >this.#b = b : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff deleted file mode 100644 index d6d68c5bc2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.overloadTag3.errors.txt -+++ new.overloadTag3.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+/a.js(14,9): error TS7006: Parameter 'value' implicitly has an 'any' type. -+ -+ -+==== /a.js (1 errors) ==== -+ /** -+ * @template T -+ */ -+ export class Foo { -+ /** -+ * @constructor -+ * @overload -+ */ -+ constructor() { } -+ -+ /** -+ * @param {T} value -+ */ -+ bar(value) { } -+ ~~~~~ -+!!! error TS7006: Parameter 'value' implicitly has an 'any' type. -+ } -+ -+ /** @type {Foo} */ -+ let foo; -+ foo = new Foo(); -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.types.diff deleted file mode 100644 index 82af181382..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.types.diff +++ /dev/null @@ -1,35 +0,0 @@ ---- old.overloadTag3.types -+++ new.overloadTag3.types -@@= skipped -4, +4 lines =@@ - * @template T - */ - export class Foo { -->Foo : Foo -+>Foo : Foo - - /** - * @constructor -@@= skipped -12, +12 lines =@@ - * @param {T} value - */ - bar(value) { } -->bar : (value: T) => void -->value : T -+>bar : (value: any) => void -+>value : any - } - - /** @type {Foo} */ - let foo; -->foo : Foo -+>foo : any - - foo = new Foo(); -->foo = new Foo() : Foo -->foo : Foo -->new Foo() : Foo -+>foo = new Foo() : Foo -+>foo : any -+>new Foo() : Foo - >Foo : typeof Foo - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.errors.txt.diff deleted file mode 100644 index 63eb03d883..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.paramTagBracketsAddOptionalUndefined.errors.txt -+++ new.paramTagBracketsAddOptionalUndefined.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+a.js(6,12): error TS7006: Parameter 'p' implicitly has an 'any' type. -+a.js(6,15): error TS7006: Parameter 'q' implicitly has an 'any' type. -+a.js(6,18): error TS7006: Parameter 'r' implicitly has an 'any' type. -+a.js(13,1): error TS2554: Expected 3 arguments, but got 0. -+ -+ -+==== a.js (4 errors) ==== -+ /** -+ * @param {number} [p] -+ * @param {number=} q -+ * @param {number} [r=101] -+ */ -+ function f(p, q, r) { -+ ~ -+!!! error TS7006: Parameter 'p' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'q' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'r' implicitly has an 'any' type. -+ p = undefined -+ q = undefined -+ // note that, unlike TS, JSDOC [r=101] retains | undefined because -+ // there's no code emitted to get rid of it. -+ r = undefined -+ } -+ f() -+ ~ -+!!! error TS2554: Expected 3 arguments, but got 0. -+!!! related TS6210 a.js:6:12: An argument for 'p' was not provided. -+ f(undefined, undefined, undefined) -+ f(1, 2, 3) -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.types.diff index 68f4e41698..f0c2d340d8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.types.diff @@ -5,43 +5,21 @@ */ function f(p, q, r) { ->f : (p?: number, q?: number | undefined, r?: number) => void -->p : number | undefined -->q : number | undefined -->r : number | undefined -+>f : (p: any, q: any, r: any) => void -+>p : any -+>q : any -+>r : any - - p = undefined - >p = undefined : undefined -->p : number | undefined -+>p : any - >undefined : undefined - - q = undefined - >q = undefined : undefined -->q : number | undefined -+>q : any - >undefined : undefined - - // note that, unlike TS, JSDOC [r=101] retains | undefined because - // there's no code emitted to get rid of it. - r = undefined - >r = undefined : undefined -->r : number | undefined -+>r : any - >undefined : undefined ++>f : (p?: number | undefined, q?: number | undefined, r?: number | undefined) => void + >p : number | undefined + >q : number | undefined + >r : number | undefined +@@= skipped -24, +24 lines =@@ } f() >f() : void ->f : (p?: number, q?: number | undefined, r?: number) => void -+>f : (p: any, q: any, r: any) => void ++>f : (p?: number | undefined, q?: number | undefined, r?: number | undefined) => void f(undefined, undefined, undefined) >f(undefined, undefined, undefined) : void ->f : (p?: number, q?: number | undefined, r?: number) => void -+>f : (p: any, q: any, r: any) => void ++>f : (p?: number | undefined, q?: number | undefined, r?: number | undefined) => void >undefined : undefined >undefined : undefined >undefined : undefined @@ -49,7 +27,7 @@ f(1, 2, 3) >f(1, 2, 3) : void ->f : (p?: number, q?: number | undefined, r?: number) => void -+>f : (p: any, q: any, r: any) => void ++>f : (p?: number | undefined, q?: number | undefined, r?: number | undefined) => void >1 : 1 >2 : 2 >3 : 3 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff index e4df1be6db..50618fcb05 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff @@ -1,18 +1,19 @@ --- old.paramTagNestedWithoutTopLevelObject3.errors.txt +++ new.paramTagNestedWithoutTopLevelObject3.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -paramTagNestedWithoutTopLevelObject3.js(3,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. -- -- --==== paramTagNestedWithoutTopLevelObject3.js (1 errors) ==== -- /** -- * @param {object} xyz -- * @param {number} xyz.bar.p ++paramTagNestedWithoutTopLevelObject3.js(6,16): error TS2339: Property 'bar' does not exist on type 'object'. + + + ==== paramTagNestedWithoutTopLevelObject3.js (1 errors) ==== + /** + * @param {object} xyz + * @param {number} xyz.bar.p - ~~~~~~~~~ -!!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. -- */ -- function g(xyz) { -- return xyz.bar.p; -- } -@@= skipped --1, +1 lines =@@ -+ + */ + function g(xyz) { + return xyz.bar.p; ++ ~~~ ++!!! error TS2339: Property 'bar' does not exist on type 'object'. + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.types.diff index bddb3a5c20..11c74c421f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.types.diff @@ -1,11 +1,17 @@ --- old.paramTagNestedWithoutTopLevelObject3.types +++ new.paramTagNestedWithoutTopLevelObject3.types -@@= skipped -5, +5 lines =@@ - * @param {number} xyz.bar.p +@@= skipped -6, +6 lines =@@ */ function g(xyz) { -->g : (xyz: object) => any -+>g : (xyz: any) => any - >xyz : any + >g : (xyz: object) => any +->xyz : any ++>xyz : object return xyz.bar.p; + >xyz.bar.p : any + >xyz.bar : any +->xyz : any ++>xyz : object + >bar : any + >p : any + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff new file mode 100644 index 0000000000..f95cacd22b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.paramTagTypeResolution2.errors.txt ++++ new.paramTagTypeResolution2.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 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() } }); ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.types.diff index 2cff69ce23..f13acbbc63 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.types.diff @@ -1,21 +1,6 @@ --- old.paramTagTypeResolution2.types +++ new.paramTagTypeResolution2.types -@@= skipped -6, +6 lines =@@ - * @param {{[K in keyof T]: (value: T[K]) => void }} b - */ - function f(a, b) { -->f : (a: T, b: { [K in keyof T]: (value: T[K]) => void; }) => void -->a : T -->b : { [K in keyof T]: (value: T[K]) => void; } -+>f : (a: any, b: any) => void -+>a : any -+>b : any - } - - f({ x: 42 }, { x(param) { param.toFixed() } }); - >f({ x: 42 }, { x(param) { param.toFixed() } }) : void -->f : (a: T, b: { [K in keyof T]: (value: T[K]) => void; }) => void -+>f : (a: any, b: any) => void +@@= skipped -17, +17 lines =@@ >{ x: 42 } : { x: number; } >x : number >42 : 42 @@ -26,11 +11,11 @@ ->param.toFixed : (fractionDigits?: number) => string ->param : number ->toFixed : (fractionDigits?: number) => string -+>{ x(param) { param.toFixed() } } : { x: (param: any) => void; } -+>x : (param: any) => void -+>param : any ++>{ x(param) { param.toFixed() } } : { x: (param: K) => void; } ++>x : (param: K) => void ++>param : K +>param.toFixed() : any +>param.toFixed : any -+>param : any ++>param : K +>toFixed : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff index a631931505..394556c036 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff @@ -9,28 +9,7 @@ bad.js(9,14): error TS7006: Parameter 'x' implicitly has an 'any' type. bad.js(9,17): error TS7006: Parameter 'y' implicitly has an 'any' type. bad.js(9,20): error TS7006: Parameter 'z' implicitly has an 'any' type. -+good.js(9,15): error TS7006: Parameter 'x' implicitly has an 'any' type. -+good.js(9,18): error TS7006: Parameter 'y' implicitly has an 'any' type. -+good.js(9,21): error TS7006: Parameter 'z' implicitly has an 'any' type. - - --==== good.js (0 errors) ==== -+==== good.js (3 errors) ==== - /** - * @param - * {number} x Arg x. -@@= skipped -17, +15 lines =@@ - * Arg z. - */ - function good(x, y, z) { -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'y' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'z' implicitly has an 'any' type. - } - +@@= skipped -22, +17 lines =@@ good(1, 2, 3) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.types.diff deleted file mode 100644 index 42ae0e6a8b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.types.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.paramTagWrapping.types -+++ new.paramTagWrapping.types -@@= skipped -9, +9 lines =@@ - * Arg z. - */ - function good(x, y, z) { -->good : (x: number, y: number, z: number) => void -->x : number -->y : number -->z : number -+>good : (x: any, y: any, z: any) => void -+>x : any -+>y : any -+>z : any - } - - good(1, 2, 3) - >good(1, 2, 3) : void -->good : (x: number, y: number, z: number) => void -+>good : (x: any, y: any, z: any) => void - >1 : 1 - >2 : 2 - >3 : 3 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff new file mode 100644 index 0000000000..e410109eb6 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff @@ -0,0 +1,63 @@ +--- old.propertiesOfGenericConstructorFunctions.errors.txt ++++ new.propertiesOfGenericConstructorFunctions.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++propertiesOfGenericConstructorFunctions.js(14,12): error TS2749: 'Multimap' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap'? ++ ++ ++==== propertiesOfGenericConstructorFunctions.js (1 errors) ==== ++ /** ++ * @template {string} K ++ * @template V ++ * @param {string} ik ++ * @param {V} iv ++ */ ++ function Multimap(ik, iv) { ++ /** @type {{ [s: string]: V }} */ ++ this._map = {}; ++ // without type annotation ++ this._map2 = { [ik]: iv }; ++ }; ++ ++ /** @type {Multimap<"a" | "b", number>} with type annotation */ ++ ~~~~~~~~ ++!!! error TS2749: 'Multimap' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap'? ++ const map = new Multimap("a", 1); ++ // without type annotation ++ const map2 = new Multimap("m", 2); ++ ++ /** @type {number} */ ++ var n = map._map['hi'] ++ /** @type {number} */ ++ var n = map._map2['hi'] ++ /** @type {number} */ ++ var n = map2._map['hi'] ++ /** @type {number} */ ++ var n = map._map2['hi'] ++ ++ /** ++ * @class ++ * @template T ++ * @param {T} t ++ */ ++ function Cp(t) { ++ this.x = 1 ++ this.y = t ++ } ++ Cp.prototype = { ++ m1() { return this.x }, ++ m2() { this.z = this.x + 1; return this.y } ++ } ++ var cp = new Cp(1) ++ ++ /** @type {number} */ ++ var n = cp.x ++ /** @type {number} */ ++ var n = cp.y ++ /** @type {number} */ ++ var n = cp.m1() ++ /** @type {number} */ ++ var n = cp.m2() ++ ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.types.diff index 27bf5eb03d..bca3fe886a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.types.diff @@ -5,11 +5,9 @@ */ function Multimap(ik, iv) { ->Multimap : typeof Multimap -->ik : string -->iv : V -+>Multimap : (ik: any, iv: any) => void -+>ik : any -+>iv : any ++>Multimap : (ik: string, iv: V) => void + >ik : string + >iv : V /** @type {{ [s: string]: V }} */ this._map = {}; @@ -24,31 +22,21 @@ // without type annotation this._map2 = { [ik]: iv }; -->this._map2 = { [ik]: iv } : { [x: string]: V; } -+>this._map2 = { [ik]: iv } : { [x: number]: any; } + >this._map2 = { [ik]: iv } : { [x: string]: V; } >this._map2 : any ->this : this +>this : any >_map2 : any -->{ [ik]: iv } : { [x: string]: V; } -->[ik] : V -->ik : string -->iv : V -+>{ [ik]: iv } : { [x: number]: any; } -+>[ik] : any -+>ik : any -+>iv : any - - }; - + >{ [ik]: iv } : { [x: string]: V; } + >[ik] : V +@@= skipped -28, +28 lines =@@ /** @type {Multimap<"a" | "b", number>} with type annotation */ const map = new Multimap("a", 1); -->map : Multimap<"a" | "b", number> + >map : Multimap<"a" | "b", number> ->new Multimap("a", 1) : Multimap<"a" | "b", number> ->Multimap : typeof Multimap -+>map : any +>new Multimap("a", 1) : any -+>Multimap : (ik: any, iv: any) => void ++>Multimap : (ik: string, iv: V) => void >"a" : "a" >1 : 1 @@ -59,46 +47,41 @@ ->Multimap : typeof Multimap +>map2 : any +>new Multimap("m", 2) : any -+>Multimap : (ik: any, iv: any) => void ++>Multimap : (ik: string, iv: V) => void >"m" : "m" >2 : 2 /** @type {number} */ var n = map._map['hi'] -->n : number + >n : number ->map._map['hi'] : number ->map._map : { [s: string]: number; } -->map : Multimap<"a" | "b", number> -->_map : { [s: string]: number; } -+>n : any +>map._map['hi'] : any +>map._map : any -+>map : any + >map : Multimap<"a" | "b", number> +->_map : { [s: string]: number; } +>_map : any >'hi' : "hi" /** @type {number} */ var n = map._map2['hi'] -->n : number + >n : number ->map._map2['hi'] : number ->map._map2 : { [x: string]: number; } -->map : Multimap<"a" | "b", number> -->_map2 : { [x: string]: number; } -+>n : any +>map._map2['hi'] : any +>map._map2 : any -+>map : any + >map : Multimap<"a" | "b", number> +->_map2 : { [x: string]: number; } +>_map2 : any >'hi' : "hi" /** @type {number} */ var n = map2._map['hi'] -->n : number + >n : number ->map2._map['hi'] : number ->map2._map : { [s: string]: number; } ->map2 : Multimap ->_map : { [s: string]: number; } -+>n : any +>map2._map['hi'] : any +>map2._map : any +>map2 : any @@ -107,27 +90,24 @@ /** @type {number} */ var n = map._map2['hi'] -->n : number + >n : number ->map._map2['hi'] : number ->map._map2 : { [x: string]: number; } -->map : Multimap<"a" | "b", number> -->_map2 : { [x: string]: number; } -+>n : any +>map._map2['hi'] : any +>map._map2 : any -+>map : any + >map : Multimap<"a" | "b", number> +->_map2 : { [x: string]: number; } +>_map2 : any >'hi' : "hi" /** -@@= skipped -83, +83 lines =@@ +@@= skipped -55, +55 lines =@@ * @param {T} t */ function Cp(t) { ->Cp : typeof Cp -->t : T -+>Cp : { (t: any): void; prototype: { m1: () => any; m2: () => any; }; } -+>t : any ++>Cp : { (t: T): void; prototype: { m1: () => any; m2: () => any; }; } + >t : T this.x = 1 >this.x = 1 : 1 @@ -138,14 +118,12 @@ >1 : 1 this.y = t -->this.y = t : T -+>this.y = t : any + >this.y = t : T >this.y : any ->this : this +>this : any >y : any -->t : T -+>t : any + >t : T } Cp.prototype = { ->Cp.prototype = { m1() { return this.x }, m2() { this.z = this.x + 1; return this.y }} : { m1(): number; m2(): T; } @@ -155,7 +133,7 @@ ->{ m1() { return this.x }, m2() { this.z = this.x + 1; return this.y }} : { m1(): number; m2(): T; } +>Cp.prototype = { m1() { return this.x }, m2() { this.z = this.x + 1; return this.y }} : { m1: () => any; m2: () => any; } +>Cp.prototype : { m1: () => any; m2: () => any; } -+>Cp : { (t: any): void; prototype: { m1: () => any; m2: () => any; }; } ++>Cp : { (t: T): void; prototype: { m1: () => any; m2: () => any; }; } +>prototype : { m1: () => any; m2: () => any; } +>{ m1() { return this.x }, m2() { this.z = this.x + 1; return this.y }} : { m1: () => any; m2: () => any; } @@ -202,39 +180,36 @@ ->Cp : typeof Cp +>cp : any +>new Cp(1) : any -+>Cp : { (t: any): void; prototype: { m1: () => any; m2: () => any; }; } ++>Cp : { (t: T): void; prototype: { m1: () => any; m2: () => any; }; } >1 : 1 /** @type {number} */ var n = cp.x -->n : number + >n : number ->cp.x : number ->cp : Cp ->x : number -+>n : any +>cp.x : any +>cp : any +>x : any /** @type {number} */ var n = cp.y -->n : number + >n : number ->cp.y : number ->cp : Cp ->y : number -+>n : any +>cp.y : any +>cp : any +>y : any /** @type {number} */ var n = cp.m1() -->n : number + >n : number ->cp.m1() : number ->cp.m1 : () => number ->cp : Cp ->m1 : () => number -+>n : any +>cp.m1() : any +>cp.m1 : any +>cp : any @@ -242,12 +217,11 @@ /** @type {number} */ var n = cp.m2() -->n : number + >n : number ->cp.m2() : number ->cp.m2 : () => number ->cp : Cp ->m2 : () => number -+>n : any +>cp.m2() : any +>cp.m2 : any +>cp : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.types.diff index 6765d1b21c..e97de3368c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.types.diff @@ -1,60 +1,29 @@ --- old.propertyAssignmentUseParentType2.types +++ new.propertyAssignmentUseParentType2.types -@@= skipped -2, +2 lines =@@ - === propertyAssignmentUseParentType2.js === +@@= skipped -3, +3 lines =@@ /** @type {{ (): boolean; nuo: 789 }} */ export const inlined = () => true -->inlined : { (): boolean; nuo: 789; } + >inlined : { (): boolean; nuo: 789; } ->() => true : { (): boolean; nuo: 789; } -+>inlined : { (): boolean; nuo: number; } -+>() => true : { (): boolean; nuo: number; } ++>() => true : { (): true; nuo: 789; } >true : true inlined.nuo = 789 - >inlined.nuo = 789 : 789 -->inlined.nuo : 789 -->inlined : { (): boolean; nuo: 789; } -->nuo : 789 -+>inlined.nuo : number -+>inlined : { (): boolean; nuo: number; } -+>nuo : number - >789 : 789 - +@@= skipped -13, +13 lines =@@ /** @type {{ (): boolean; nuo: 789 }} */ export const duplicated = () => true -->duplicated : { (): boolean; nuo: 789; } + >duplicated : { (): boolean; nuo: 789; } ->() => true : { (): boolean; nuo: 789; } -+>duplicated : { (): boolean; nuo: number; } -+>() => true : { (): boolean; nuo: number; } ++>() => true : { (): true; nuo: 789; } >true : true /** @type {789} */ - duplicated.nuo = 789 - >duplicated.nuo = 789 : 789 -->duplicated.nuo : 789 -->duplicated : { (): boolean; nuo: 789; } -->nuo : 789 -+>duplicated.nuo : number -+>duplicated : { (): boolean; nuo: number; } -+>nuo : number - >789 : 789 - +@@= skipped -14, +14 lines =@@ /** @type {{ (): boolean; nuo: 789 }} */ export const conflictingDuplicated = () => true -->conflictingDuplicated : { (): boolean; nuo: 789; } + >conflictingDuplicated : { (): boolean; nuo: 789; } ->() => true : { (): boolean; nuo: 1000; } -+>conflictingDuplicated : { (): boolean; nuo: number; } -+>() => true : { (): boolean; nuo: number; } ++>() => true : { (): true; nuo: 789; } >true : true /** @type {1000} */ - conflictingDuplicated.nuo = 789 - >conflictingDuplicated.nuo = 789 : 789 -->conflictingDuplicated.nuo : 789 -->conflictingDuplicated : { (): boolean; nuo: 789; } -->nuo : 789 -+>conflictingDuplicated.nuo : number -+>conflictingDuplicated : { (): boolean; nuo: number; } -+>nuo : number - >789 : 789 - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff index bf58b928b2..3249e91f43 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff @@ -3,6 +3,8 @@ @@= skipped -0, +0 lines =@@ -other.js(5,5): error TS2339: Property 'wat' does not exist on type 'One'. -other.js(10,5): error TS2339: Property 'wat' does not exist on type 'Two'. ++other.js(2,11): error TS2503: Cannot find namespace 'Ns'. ++other.js(7,11): error TS2503: Cannot find namespace 'Ns'. +prototypePropertyAssignmentMergeAcrossFiles2.js(2,4): error TS2339: Property 'One' does not exist on type '{}'. +prototypePropertyAssignmentMergeAcrossFiles2.js(3,4): error TS2339: Property 'Two' does not exist on type '{}'. +prototypePropertyAssignmentMergeAcrossFiles2.js(5,4): error TS2339: Property 'One' does not exist on type '{}'. @@ -29,10 +31,11 @@ +!!! error TS2339: Property 'Two' does not exist on type '{}'. } --==== other.js (2 errors) ==== -+==== other.js (0 errors) ==== + ==== other.js (2 errors) ==== /** * @type {Ns.One} ++ ~~ ++!!! error TS2503: Cannot find namespace 'Ns'. */ var one; one.wat; @@ -40,6 +43,8 @@ -!!! error TS2339: Property 'wat' does not exist on type 'One'. /** * @type {Ns.Two} ++ ~~ ++!!! error TS2503: Cannot find namespace 'Ns'. */ var two; two.wat; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.types.diff index e3ad5f2302..d751eaec59 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.types.diff @@ -67,29 +67,3 @@ >{} : {} } -@@= skipped -13, +13 lines =@@ - * @type {Ns.One} - */ - var one; -->one : One -+>one : any - - one.wat; - >one.wat : any -->one : One -+>one : any - >wat : any - - /** - * @type {Ns.Two} - */ - var two; -->two : Two -+>two : any - - two.wat; - >two.wat : any -->two : Two -+>two : any - >wat : any - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff new file mode 100644 index 0000000000..ff3362d846 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff @@ -0,0 +1,26 @@ +--- old.prototypePropertyAssignmentMergedTypeReference.errors.txt ++++ new.prototypePropertyAssignmentMergedTypeReference.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++prototypePropertyAssignmentMergedTypeReference.js(7,22): error TS2749: 'f' refers to a value, but is being used as a type here. Did you mean 'typeof f'? ++prototypePropertyAssignmentMergedTypeReference.js(8,5): error TS2322: Type '() => number' is not assignable to type 'new () => f'. ++ Type '() => number' provides no match for the signature 'new (): f'. ++ ++ ++==== prototypePropertyAssignmentMergedTypeReference.js (2 errors) ==== ++ var f = function() { ++ return 12; ++ }; ++ ++ f.prototype.a = "a"; ++ ++ /** @type {new () => f} */ ++ ~ ++!!! error TS2749: 'f' refers to a value, but is being used as a type here. Did you mean 'typeof f'? ++ var x = f; ++ ~ ++!!! error TS2322: Type '() => number' is not assignable to type 'new () => f'. ++!!! error TS2322: Type '() => number' provides no match for the signature 'new (): f'. ++ ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.types.diff index 599c98f5bc..f05f0940dc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.types.diff @@ -20,12 +20,11 @@ >prototype : any >a : any >"a" : "a" - +@@= skipped -8, +8 lines =@@ /** @type {new () => f} */ var x = f; -->x : new () => f + >x : new () => f ->f : typeof f -+>x : () => number +>f : () => number diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff index 84778a0c58..293599179b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff @@ -1,39 +1,72 @@ --- old.recursiveTypeReferences2.errors.txt +++ new.recursiveTypeReferences2.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. - Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -- -- ++bug39372.js(1,36): error TS2456: Type alias 'JsonArray' circularly references itself. ++bug39372.js(3,88): error TS2456: Type alias 'Json' circularly references itself. ++bug39372.js(9,17): error TS2304: Cannot find name 'T'. ++bug39372.js(9,32): error TS2304: Cannot find name 'T'. ++bug39372.js(12,17): error TS2304: Cannot find name 'T'. ++bug39372.js(14,10): error TS2304: Cannot find name 'T'. ++bug39372.js(14,55): error TS2304: Cannot find name 'T'. ++bug39372.js(18,15): error TS2304: Cannot find name 'T'. ++bug39372.js(19,5): error TS2304: Cannot find name 'T'. ++bug39372.js(20,19): error TS2304: Cannot find name 'T'. ++bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (??? & ???)[]; }; $O: { [x: string]: { $$?: Record; } & (??? | ??? & ???); }; $$?: Record; } & ???; }'. ++ Type '{}' is missing the following properties from type '{ $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; }': $A, $O + + -==== bug39372.js (1 errors) ==== -- /** @typedef {ReadonlyArray} JsonArray */ -- /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ -- /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ -- -- /** -- * @template T -- * @typedef {{ -- $A: { -- [K in keyof T]?: XMLObject[] -- }, -- $O: { -- [K in keyof T]?: { -- $$?: Record -- } & (T[K] extends string ? {$:string} : XMLObject) -- }, -- $$?: Record, -- } & { -- [K in keyof T]?: ( -- T[K] extends string ? string -- : XMLObject -- ) -- }} XMLObject */ -- -- /** @type {XMLObject<{foo:string}>} */ -- const p = {}; -- ~ ++==== bug39372.js (11 errors) ==== + /** @typedef {ReadonlyArray} JsonArray */ ++ ~~~~~~~~~ ++!!! error TS2456: Type alias 'JsonArray' circularly references itself. + /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ + /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ ++ ~~~~ ++!!! error TS2456: Type alias 'Json' circularly references itself. + + /** + * @template T + * @typedef {{ + $A: { + [K in keyof T]?: XMLObject[] ++ ~ ++!!! error TS2304: Cannot find name 'T'. ++ ~ ++!!! error TS2304: Cannot find name 'T'. + }, + $O: { + [K in keyof T]?: { ++ ~ ++!!! error TS2304: Cannot find name 'T'. + $$?: Record + } & (T[K] extends string ? {$:string} : XMLObject) ++ ~ ++!!! error TS2304: Cannot find name 'T'. ++ ~ ++!!! error TS2304: Cannot find name 'T'. + }, + $$?: Record, + } & { + [K in keyof T]?: ( ++ ~ ++!!! error TS2304: Cannot find name 'T'. + T[K] extends string ? string ++ ~ ++!!! error TS2304: Cannot find name 'T'. + : XMLObject ++ ~ ++!!! error TS2304: Cannot find name 'T'. + ) + }} XMLObject */ + + /** @type {XMLObject<{foo:string}>} */ + const p = {}; + ~ -!!! error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. -!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -- -@@= skipped --1, +1 lines =@@ -+ ++!!! error TS2322: Type '{}' is not assignable to type '{ $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (??? & ???)[]; }; $O: { [x: string]: { $$?: Record; } & (??? | ??? & ???); }; $$?: Record; } & ???; }'. ++!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; }': $A, $O + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff index d2e2a5d4fd..20266d58f1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff @@ -5,6 +5,6 @@ /** @type {XMLObject<{foo:string}>} */ const p = {}; ->p : XMLObject<{ foo: string; }> -+>p : {} ++>p : { $A: { [x: string]: (??? & { [x: string]: string | ??? & ???; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | ??? & { [x: string]: string | ??? & ???; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (??? & ???)[]; }; $O: { [x: string]: { $$?: Record; } & (??? | ??? & ???); }; $$?: Record; } & ???; } >{} : {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff index 99e9a0c170..ccb15f3f75 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff @@ -5,9 +5,11 @@ @@= skipped --1, +1 lines =@@ +bug25127.js(3,14): error TS2339: Property 'c' does not exist on type 'Entry'. +bug25127.js(15,14): error TS2339: Property 'd' does not exist on type 'Group'. ++bug25127.js(27,41): error TS2339: Property 'c' does not exist on type 'Entry'. ++bug25127.js(27,51): error TS2339: Property 'd' does not exist on type 'Group'. + + -+==== bug25127.js (2 errors) ==== ++==== bug25127.js (4 errors) ==== + class Entry { + constructor() { + this.c = 1 @@ -39,6 +41,10 @@ + /** @param {Entry | Group} chunk */ + function f(chunk) { + let x = chunk.isInit(chunk) ? chunk.c : chunk.d ++ ~ ++!!! error TS2339: Property 'c' does not exist on type 'Entry'. ++ ~ ++!!! error TS2339: Property 'd' does not exist on type 'Group'. + return x + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.types.diff index d5da6bcc15..dc262e0a10 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.types.diff @@ -1,58 +1,32 @@ --- old.returnTagTypeGuard.types +++ new.returnTagTypeGuard.types -@@= skipped -16, +16 lines =@@ - * @return {this is Entry} - */ - isInit(x) { -->isInit : (x: any) => this is Entry -+>isInit : (x: any) => boolean - >x : any - - return true -@@= skipped -23, +23 lines =@@ - * @return {false} - */ - isInit(x) { -->isInit : (x: any) => false -+>isInit : (x: any) => boolean - >x : any - - return false -@@= skipped -9, +9 lines =@@ +@@= skipped -48, +48 lines =@@ } /** @param {Entry | Group} chunk */ function f(chunk) { ->f : (chunk: Entry | Group) => string | number -->chunk : Entry | Group -+>f : (chunk: any) => any -+>chunk : any ++>f : (chunk: Entry | Group) => any + >chunk : Entry | Group let x = chunk.isInit(chunk) ? chunk.c : chunk.d ->x : string | number ->chunk.isInit(chunk) ? chunk.c : chunk.d : string | number -->chunk.isInit(chunk) : boolean -->chunk.isInit : ((x: any) => this is Entry) | ((x: any) => false) -->chunk : Entry | Group -->isInit : ((x: any) => this is Entry) | ((x: any) => false) -->chunk : Entry | Group -->chunk.c : number -->chunk : Entry -->c : number -->chunk.d : string -->chunk : Group -->d : string +>x : any +>chunk.isInit(chunk) ? chunk.c : chunk.d : any -+>chunk.isInit(chunk) : any -+>chunk.isInit : any -+>chunk : any -+>isInit : any -+>chunk : any + >chunk.isInit(chunk) : boolean + >chunk.isInit : ((x: any) => this is Entry) | ((x: any) => false) + >chunk : Entry | Group + >isInit : ((x: any) => this is Entry) | ((x: any) => false) + >chunk : Entry | Group +->chunk.c : number +>chunk.c : any -+>chunk : any + >chunk : Entry +->c : number +->chunk.d : string +>c : any +>chunk.d : any -+>chunk : any + >chunk : Group +->d : string +>d : any return x @@ -66,18 +40,10 @@ /** @param {boolean | number} val */ function foo(val) { ->foo : (val: boolean | number) => void -->val : number | boolean -+>foo : (val: any) => void -+>val : any ++>foo : (val: number | boolean) => void + >val : number | boolean if (isBoolean(val)) { - >isBoolean(val) : boolean - >isBoolean : (value: any) => value is boolean -->val : number | boolean -+>val : any - - val; - >val : boolean @@= skipped -21, +21 lines =@@ /** @type {Cb} */ @@ -93,18 +59,12 @@ >"number" : "number" /** @param {unknown} x */ - function g(x) { -->g : (x: unknown) => void -->x : unknown -+>g : (x: any) => void -+>x : any +@@= skipped -14, +14 lines =@@ if (isNumber(x)) { >isNumber(x) : boolean ->isNumber : (x: unknown) => x is number -->x : unknown +>isNumber : (x: any) => x is number -+>x : any + >x : unknown x * 2; - >x * 2 : number diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.types.diff deleted file mode 100644 index f4e09c027d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.types.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.syntaxErrors.types -+++ new.syntaxErrors.types -@@= skipped -10, +10 lines =@@ - // @ts-ignore - /** @param {C.} skipped */ - function f(x, y, skipped) { -->f : (x: any, y: any, skipped: C) => any -+>f : (x: any, y: any, skipped: any) => any - >x : any - >y : any -->skipped : C -+>skipped : any - - return x.t + y.t; - >x.t + y.t : any -@@= skipped -17, +17 lines =@@ - var x = f({ t: 1000 }, { t: 3000 }, { t: 5000 }); - >x : any - >f({ t: 1000 }, { t: 3000 }, { t: 5000 }) : any -->f : (x: any, y: any, skipped: C) => any -+>f : (x: any, y: any, skipped: any) => any - >{ t: 1000 } : { t: number; } - >t : number - >1000 : 1000 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff index 657c13c744..458377b651 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff @@ -6,6 +6,8 @@ -templateInsideCallback.js(9,5): error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag -templateInsideCallback.js(10,12): error TS2304: Cannot find name 'T'. -templateInsideCallback.js(15,11): error TS2315: Type 'Call' is not generic. ++templateInsideCallback.js(15,11): error TS2304: Cannot find name 'Call'. ++templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. templateInsideCallback.js(17,18): error TS7006: Parameter 'x' implicitly has an 'any' type. -templateInsideCallback.js(23,5): error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag -templateInsideCallback.js(30,5): error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag @@ -13,7 +15,6 @@ -templateInsideCallback.js(33,16): error TS2304: Cannot find name 'T'. -templateInsideCallback.js(38,5): error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag -templateInsideCallback.js(39,12): error TS2304: Cannot find name 'T'. -+templateInsideCallback.js(47,18): error TS7006: Parameter 'array' implicitly has an 'any' type. -!!! error TS-1: Pre-emit (11) and post-emit (13) diagnostic counts do not match! This can indicate that a semantic _error_ was added by the emit resolver - such an error may not be reflected on the command line or in the editor, but may be captured in a baseline here! @@ -21,7 +22,7 @@ -!!! related TS7012 templateInsideCallback.js:29:5: This overload implicitly returns the type 'any' because it lacks a return type annotation. -!!! related TS7012 templateInsideCallback.js:37:5: This overload implicitly returns the type 'any' because it lacks a return type annotation. -==== templateInsideCallback.js (11 errors) ==== -+==== templateInsideCallback.js (2 errors) ==== ++==== templateInsideCallback.js (3 errors) ==== /** * @typedef Oops - ~~~~ @@ -29,7 +30,7 @@ * @template T * @property {T} a * @property {T} b -@@= skipped -27, +11 lines =@@ +@@= skipped -27, +12 lines =@@ /** * @callback Call * @template T @@ -45,10 +46,14 @@ * @type {Call} - ~~~~~~~ -!!! error TS2315: Type 'Call' is not generic. ++ ~~~~ ++!!! error TS2304: Cannot find name 'Call'. ++ ~ ++!!! error TS2304: Cannot find name 'T'. */ const identity = x => x; ~ -@@= skipped -22, +16 lines =@@ +@@= skipped -22, +20 lines =@@ * @property {Object} oh * @property {number} oh.no * @template T @@ -83,12 +88,3 @@ * @returns {T[]} */ /** -@@= skipped -27, +17 lines =@@ - * @returns {unknown[]} - */ - function flatMap(array, iterable = identity) { -+ ~~~~~ -+!!! error TS7006: Parameter 'array' implicitly has an 'any' type. - /** @type {unknown[]} */ - const result = []; - for (let i = 0; i < array.length; i += 1) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff index c6c1f66648..e09c17d843 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff @@ -5,70 +5,28 @@ */ const identity = x => x; ->identity : any -->x => x : (x: any) => any -+>identity : (x: any) => any -+>x => x : (x: any) => any ++>identity : Call + >x => x : (x: any) => any >x : any >x : any - @@= skipped -34, +34 lines =@@ * @returns {unknown[]} */ function flatMap(array, iterable = identity) { ->flatMap : { (): any; (): any; } -->array : unknown[] -->iterable : (x: unknown) => unknown ++>flatMap : (array: unknown[], iterable?: (x: unknown) => unknown) => unknown[] + >array : unknown[] + >iterable : (x: unknown) => unknown ->identity : any -+>flatMap : (array: any, iterable?: (x: any) => any) => any[] -+>array : any -+>iterable : (x: any) => any -+>identity : (x: any) => any ++>identity : Call /** @type {unknown[]} */ const result = []; -->result : unknown[] -+>result : any[] - >[] : never[] - - for (let i = 0; i < array.length; i += 1) { -@@= skipped -15, +15 lines =@@ - >0 : 0 - >i < array.length : boolean - >i : number -->array.length : number -->array : unknown[] -->length : number -+>array.length : any -+>array : any -+>length : any - >i += 1 : number - >i : number - >1 : 1 - - result.push(.../** @type {unknown[]} */(iterable(array[i]))); - >result.push(.../** @type {unknown[]} */(iterable(array[i]))) : number -->result.push : (...items: unknown[]) => number -->result : unknown[] -->push : (...items: unknown[]) => number -->.../** @type {unknown[]} */(iterable(array[i])) : unknown -->(iterable(array[i])) : unknown[] -->iterable(array[i]) : unknown -->iterable : (x: unknown) => unknown -->array[i] : unknown -->array : unknown[] -+>result.push : (...items: any[]) => number -+>result : any[] -+>push : (...items: any[]) => number -+>.../** @type {unknown[]} */(iterable(array[i])) : any -+>(iterable(array[i])) : any -+>iterable(array[i]) : any -+>iterable : (x: any) => any -+>array[i] : any -+>array : any - >i : number - } - return result; -->result : unknown[] -+>result : any[] - } - +@@= skipped -29, +29 lines =@@ + >push : (...items: unknown[]) => number + >.../** @type {unknown[]} */(iterable(array[i])) : unknown + >(iterable(array[i])) : unknown[] ++>iterable(array[i]) : unknown[] + >iterable(array[i]) : unknown + >iterable : (x: unknown) => unknown + >array[i] : unknown diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.types.diff new file mode 100644 index 0000000000..8684595695 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.types.diff @@ -0,0 +1,49 @@ +--- old.thisPropertyAssignmentInherited.types ++++ new.thisPropertyAssignmentInherited.types +@@= skipped -7, +7 lines =@@ + * @returns {String} + */ + get textContent() { +->textContent : string ++>textContent : String + + return '' + >'' : "" + } + set textContent(x) {} +->textContent : string +->x : string ++>textContent : String ++>x : String + + cloneNode() { return this} + >cloneNode : () => this +@@= skipped -22, +22 lines =@@ + >HTMLElement : HTMLElement + + get innerHTML() { return this.textContent; } +->innerHTML : string +->this.textContent : string ++>innerHTML : String ++>this.textContent : String + >this : this +->textContent : string ++>textContent : String + + set innerHTML(html) { this.textContent = html; } +->innerHTML : string +->html : string +->this.textContent = html : string +->this.textContent : string ++>innerHTML : String ++>html : String ++>this.textContent = html : String ++>this.textContent : String + >this : this +->textContent : string +->html : string ++>textContent : String ++>html : String + + toString() { + >toString : () => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff index fee1ebf83c..4138103bfc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff @@ -3,18 +3,15 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+a.js(5,12): error TS7006: Parameter 's' implicitly has an 'any' type. +a.js(6,12): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + + -+==== a.js (2 errors) ==== ++==== a.js (1 errors) ==== + /** @this {{ n: number }} Mount Holyoke Preparatory School + * @param {string} s + * @return {number} + */ + function f(s) { -+ ~ -+!!! error TS7006: Parameter 's' implicitly has an 'any' type. + return this.n + s.length + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.types.diff index b516e2cef8..50643a4e40 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.types.diff @@ -5,49 +5,44 @@ */ function f(s) { ->f : (this: { n: number; }, s: string) => number -->s : string -+>f : (s: any) => any -+>s : any ++>f : (s: string) => number + >s : string return this.n + s.length ->this.n + s.length : number ->this.n : number ->this : { n: number; } ->n : number -->s.length : number -->s : string -->length : number +>this.n + s.length : any +>this.n : any +>this : any +>n : any -+>s.length : any -+>s : any -+>length : any + >s.length : number + >s : string + >length : number } const o = { ->o : { f: (this: { n: number; }, s: string) => number; n: number; } ->{ f, n: 1} : { f: (this: { n: number; }, s: string) => number; n: number; } -+>o : { f: (s: any) => any; n: number; } -+>{ f, n: 1} : { f: (s: any) => any; n: number; } ++>o : { f: (s: string) => number; n: number; } ++>{ f, n: 1} : { f: (s: string) => number; n: number; } f, ->f : (this: { n: number; }, s: string) => number -+>f : (s: any) => any ++>f : (s: string) => number n: 1 >n : number - >1 : 1 +@@= skipped -26, +26 lines =@@ } o.f('hi') -->o.f('hi') : number + >o.f('hi') : number ->o.f : (this: { n: number; }, s: string) => number ->o : { f: (this: { n: number; }, s: string) => number; n: number; } ->f : (this: { n: number; }, s: string) => number -+>o.f('hi') : any -+>o.f : (s: any) => any -+>o : { f: (s: any) => any; n: number; } -+>f : (s: any) => any ++>o.f : (s: string) => number ++>o : { f: (s: string) => number; n: number; } ++>f : (s: string) => number >'hi' : "hi" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff index 13c4636b9c..6dab6a5a93 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff @@ -6,17 +6,8 @@ p = (a) => this.fn("" + a); ->p : (this: T, a: string) => any ->(a) => this.fn("" + a) : (this: T, a: string) => any -->a : string -+>p : (a: any) => any -+>(a) => this.fn("" + a) : (a: any) => any -+>a : any ++>p : (a: string) => any ++>(a) => this.fn("" + a) : (a: string) => any + >a : string >this.fn("" + a) : any >this.fn : any - >this : this - >fn : any - >"" + a : string - >"" : "" -->a : string -+>a : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff new file mode 100644 index 0000000000..ad89e66e54 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff @@ -0,0 +1,66 @@ +--- old.thisTypeOfConstructorFunctions.errors.txt ++++ new.thisTypeOfConstructorFunctions.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++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 (4 errors) ==== ++ /** ++ * @class ++ * @template T ++ * @param {T} t ++ */ ++ function Cp(t) { ++ /** @type {this} */ ++ this.dit = this ++ this.y = t ++ /** @return {this} */ ++ this.m3 = () => this ++ } ++ ++ Cp.prototype = { ++ /** @return {this} */ ++ ~~~~ ++!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. ++ m4() { ++ this.z = this.y; return this ++ } ++ } ++ ++ /** ++ * @class ++ * @template T ++ * @param {T} t ++ */ ++ function Cpp(t) { ++ this.y = t ++ } ++ /** @return {this} */ ++ Cpp.prototype.m2 = function () { ++ this.z = this.y; return this ++ } ++ ++ var cp = new Cp(1) ++ var cpp = new Cpp(2) ++ cp.dit ++ ++ /** @type {Cpp} */ ++ ~~~ ++!!! error TS2749: 'Cpp' refers to a value, but is being used as a type here. Did you mean 'typeof Cpp'? ++ var cppn = cpp.m2() ++ ++ /** @type {Cp} */ ++ ~~ ++!!! error TS2749: 'Cp' refers to a value, but is being used as a type here. Did you mean 'typeof Cp'? ++ var cpn = cp.m3() ++ /** @type {Cp} */ ++ ~~ ++!!! error TS2749: 'Cp' refers to a value, but is being used as a type here. Did you mean 'typeof Cp'? ++ var cpn = cp.m4() ++ ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.types.diff index f80f1e19f7..a6eb6b1c7c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.types.diff @@ -5,9 +5,8 @@ */ function Cp(t) { ->Cp : typeof Cp -->t : T -+>Cp : { (t: any): void; prototype: { m4: () => any; }; } -+>t : any ++>Cp : { (t: T): void; prototype: { m4: () => any; }; } + >t : T /** @type {this} */ this.dit = this @@ -23,14 +22,12 @@ +>this : any this.y = t -->this.y = t : T -+>this.y = t : any + >this.y = t : T >this.y : any ->this : this +>this : any >y : any -->t : T -+>t : any + >t : T /** @return {this} */ this.m3 = () => this @@ -54,7 +51,7 @@ ->{ /** @return {this} */ m4() { this.z = this.y; return this }} : { m4(): this; } +>Cp.prototype = { /** @return {this} */ m4() { this.z = this.y; return this }} : { m4: () => any; } +>Cp.prototype : { m4: () => any; } -+>Cp : { (t: any): void; prototype: { m4: () => any; }; } ++>Cp : { (t: T): void; prototype: { m4: () => any; }; } +>prototype : { m4: () => any; } +>{ /** @return {this} */ m4() { this.z = this.y; return this }} : { m4: () => any; } @@ -88,19 +85,16 @@ */ function Cpp(t) { ->Cpp : typeof Cpp -->t : T -+>Cpp : (t: any) => void -+>t : any ++>Cpp : (t: T) => void + >t : T this.y = t -->this.y = t : T -+>this.y = t : any + >this.y = t : T >this.y : any ->this : this +>this : any >y : any -->t : T -+>t : any + >t : T } /** @return {this} */ Cpp.prototype.m2 = function () { @@ -109,7 +103,7 @@ >Cpp.prototype.m2 : any >Cpp.prototype : any ->Cpp : typeof Cpp -+>Cpp : (t: any) => void ++>Cpp : (t: T) => void >prototype : any >m2 : any ->function () { this.z = this.y; return this} : () => this @@ -140,7 +134,7 @@ ->Cp : typeof Cp +>cp : any +>new Cp(1) : any -+>Cp : { (t: any): void; prototype: { m4: () => any; }; } ++>Cp : { (t: T): void; prototype: { m4: () => any; }; } >1 : 1 var cpp = new Cpp(2) @@ -149,7 +143,7 @@ ->Cpp : typeof Cpp +>cpp : any +>new Cpp(2) : any -+>Cpp : (t: any) => void ++>Cpp : (t: T) => void >2 : 2 cp.dit @@ -162,12 +156,11 @@ /** @type {Cpp} */ var cppn = cpp.m2() -->cppn : Cpp + >cppn : Cpp ->cpp.m2() : Cpp ->cpp.m2 : () => Cpp ->cpp : Cpp ->m2 : () => Cpp -+>cppn : any +>cpp.m2() : any +>cpp.m2 : any +>cpp : any @@ -175,12 +168,11 @@ /** @type {Cp} */ var cpn = cp.m3() -->cpn : Cp + >cpn : Cp ->cp.m3() : Cp ->cp.m3 : () => Cp ->cp : Cp ->m3 : () => Cp -+>cpn : any +>cp.m3() : any +>cp.m3 : any +>cp : any @@ -188,12 +180,11 @@ /** @type {Cp} */ var cpn = cp.m4() -->cpn : Cp + >cpn : Cp ->cp.m4() : Cp ->cp.m4 : () => Cp ->cp : Cp ->m4 : () => Cp -+>cpn : any +>cp.m4() : any +>cp.m4 : any +>cp : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff deleted file mode 100644 index 14976ac8da..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.typeFromContextualThisType.errors.txt -+++ new.typeFromContextualThisType.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 lines =@@ -+bug25926.js(4,14): error TS2339: Property 'b' does not exist on type '{ a: () => void; }'. -+bug25926.js(4,18): error TS7006: Parameter 'n' implicitly has an 'any' type. -+bug25926.js(11,14): error TS2339: Property 'e' does not exist on type '{ d: () => void; }'. -+bug25926.js(11,23): error TS2339: Property 'f' does not exist on type '{ d: () => void; }'. -+bug25926.js(11,27): error TS7006: Parameter 'm' implicitly has an 'any' type. -+bug25926.js(11,37): error TS2339: Property 'g' does not exist on type '{ d: () => void; }'. -+ -+ -+==== bug25926.js (6 errors) ==== -+ /** @type {{ a(): void; b?(n: number): number; }} */ -+ const o1 = { -+ a() { -+ this.b = n => n; -+ ~ -+!!! error TS2339: Property 'b' does not exist on type '{ a: () => void; }'. -+ ~ -+!!! error TS7006: Parameter 'n' implicitly has an 'any' type. -+ } -+ }; -+ -+ /** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ -+ const o2 = { -+ d() { -+ this.e = this.f = m => this.g || m; -+ ~ -+!!! error TS2339: Property 'e' does not exist on type '{ d: () => void; }'. -+ ~ -+!!! error TS2339: Property 'f' does not exist on type '{ d: () => void; }'. -+ ~ -+!!! error TS7006: Parameter 'm' implicitly has an 'any' type. -+ ~ -+!!! error TS2339: Property 'g' does not exist on type '{ d: () => void; }'. -+ } -+ }; -+ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.types.diff index 6a31f32550..896712e42f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.types.diff @@ -6,71 +6,49 @@ const o1 = { ->o1 : { a(): void; b?(n: number): number; } ->{ a() { this.b = n => n; }} : { a(): void; } -+>o1 : { a: () => void; } ++>o1 : { a: () => void; b?: ((n: number) => number) | undefined; } +>{ a() { this.b = n => n; }} : { a: () => void; } a() { >a : () => void - +@@= skipped -9, +9 lines =@@ this.b = n => n; -->this.b = n => n : (n: number) => number -->this.b : ((n: number) => number) | undefined + >this.b = n => n : (n: number) => number + >this.b : ((n: number) => number) | undefined ->this : { a(): void; b?(n: number): number; } -->b : ((n: number) => number) | undefined -->n => n : (n: number) => number -->n : number -->n : number -+>this.b = n => n : (n: any) => any -+>this.b : any -+>this : { a: () => void; } -+>b : any -+>n => n : (n: any) => any -+>n : any -+>n : any - } - }; ++>this : { a: () => void; b?: ((n: number) => number) | undefined; } + >b : ((n: number) => number) | undefined + >n => n : (n: number) => number + >n : number +@@= skipped -10, +10 lines =@@ /** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ const o2 = { ->o2 : { d(): void; e?(n: number): number; f?(n: number): number; g?: number; } ->{ d() { this.e = this.f = m => this.g || m; }} : { d(): void; } -+>o2 : { d: () => void; } ++>o2 : { d: () => void; e?: ((n: number) => number) | undefined; f?: ((n: number) => number) | undefined; g?: number | undefined; } +>{ d() { this.e = this.f = m => this.g || m; }} : { d: () => void; } d() { >d : () => void - +@@= skipped -9, +9 lines =@@ this.e = this.f = m => this.g || m; -->this.e = this.f = m => this.g || m : (m: number) => number -->this.e : ((n: number) => number) | undefined + >this.e = this.f = m => this.g || m : (m: number) => number + >this.e : ((n: number) => number) | undefined ->this : { d(): void; e?(n: number): number; f?(n: number): number; g?: number; } -->e : ((n: number) => number) | undefined -->this.f = m => this.g || m : (m: number) => number -->this.f : ((n: number) => number) | undefined ++>this : { d: () => void; e?: ((n: number) => number) | undefined; f?: ((n: number) => number) | undefined; g?: number | undefined; } + >e : ((n: number) => number) | undefined + >this.f = m => this.g || m : (m: number) => number + >this.f : ((n: number) => number) | undefined ->this : { d(): void; e?(n: number): number; f?(n: number): number; g?: number; } -->f : ((n: number) => number) | undefined -->m => this.g || m : (m: number) => number -->m : number -->this.g || m : number -->this.g : number | undefined ++>this : { d: () => void; e?: ((n: number) => number) | undefined; f?: ((n: number) => number) | undefined; g?: number | undefined; } + >f : ((n: number) => number) | undefined + >m => this.g || m : (m: number) => number + >m : number + >this.g || m : number + >this.g : number | undefined ->this : { d(): void; e?(n: number): number; f?(n: number): number; g?: number; } -->g : number | undefined -->m : number -+>this.e = this.f = m => this.g || m : (m: any) => any -+>this.e : any -+>this : { d: () => void; } -+>e : any -+>this.f = m => this.g || m : (m: any) => any -+>this.f : any -+>this : { d: () => void; } -+>f : any -+>m => this.g || m : (m: any) => any -+>m : any -+>this.g || m : any -+>this.g : any -+>this : { d: () => void; } -+>g : any -+>m : any ++>this : { d: () => void; e?: ((n: number) => number) | undefined; f?: ((n: number) => number) | undefined; g?: number | undefined; } + >g : number | undefined + >m : number } - }; - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff index 14aff1f6cf..627d899f5b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff @@ -6,21 +6,18 @@ -a.js(5,5): error TS7008: Member 'empty' implicitly has an 'any[]' type. -a.js(25,29): error TS7006: Parameter 'l' implicitly has an 'any[]' type. +a.js(7,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -+a.js(22,5): error TS7034: Variable 'n' implicitly has type 'any' in some locations where its type cannot be determined. -+a.js(25,26): error TS7005: Variable 'n' implicitly has an 'any' type. a.js(27,5): error TS2322: Type 'undefined' is not assignable to type 'null'. a.js(29,5): error TS2322: Type '1' is not assignable to type 'null'. a.js(30,5): error TS2322: Type 'true' is not assignable to type 'null'. a.js(31,5): error TS2322: Type '{}' is not assignable to type 'null'. a.js(32,5): error TS2322: Type '"ok"' is not assignable to type 'null'. --a.js(37,5): error TS2322: Type 'string' is not assignable to type 'number'. + a.js(37,5): error TS2322: Type 'string' is not assignable to type 'number'. +a.js(40,12): error TS2345: Argument of type '1' is not assignable to parameter of type 'never'. +a.js(41,12): error TS2345: Argument of type '"ok"' is not assignable to parameter of type 'never'. -+a.js(56,17): error TS7006: Parameter 'v' implicitly has an 'any' type. -==== a.js (10 errors) ==== -+==== a.js (11 errors) ==== ++==== a.js (9 errors) ==== function A () { // should get any on this-assignments in constructor this.unknown = null @@ -39,28 +36,16 @@ a.unknown = 1 a.unknown = true a.unknown = {} -@@= skipped -38, +35 lines =@@ - - /** @type {number | undefined} */ - var n; -+ ~ -+!!! error TS7034: Variable 'n' implicitly has type 'any' in some locations where its type cannot be determined. +@@= skipped -41, +36 lines =@@ // should get any on parameter initialisers function f(a = null, b = n, l = []) { - ~~~~~~ -!!! error TS7006: Parameter 'l' implicitly has an 'any[]' type. -+ ~ -+!!! error TS7005: Variable 'n' implicitly has an 'any' type. // a should be null in strict mode a = undefined ~ -@@= skipped -27, +29 lines =@@ - b = 1 - b = undefined - b = 'error' -- ~ --!!! error TS2322: Type 'string' is not assignable to type 'number'. +@@= skipped -29, +27 lines =@@ // l should be any[] l.push(1) @@ -72,12 +57,3 @@ } // should get any on variable initialisers -@@= skipped -21, +23 lines =@@ - - /** @type {(v: unknown) => v is undefined} */ - const isUndef = v => v === undefined; -+ ~ -+!!! error TS7006: Parameter 'v' implicitly has an 'any' type. - const e = [1, undefined]; - - // should be undefined[] diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.types.diff index ca15caa722..eff302c05c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.types.diff @@ -164,44 +164,21 @@ >'hi' : "hi" /** @type {number | undefined} */ - var n; -->n : number | undefined -+>n : any +@@= skipped -126, +126 lines =@@ // should get any on parameter initialisers function f(a = null, b = n, l = []) { ->f : (a?: null, b?: number | undefined, l?: any[]) => void -+>f : (a?: null, b?: any, l?: never[]) => void ++>f : (a?: null, b?: number | undefined, l?: never[]) => void >a : null -->b : number | undefined -->n : number | undefined + >b : number | undefined + >n : number | undefined ->l : any[] -+>b : any -+>n : any +>l : never[] >[] : never[] // a should be null in strict mode -@@= skipped -166, +166 lines =@@ - // b should be number | undefined, not any - b = 1 - >b = 1 : 1 -->b : number | undefined -+>b : any - >1 : 1 - - b = undefined - >b = undefined : undefined -->b : number | undefined -+>b : any - >undefined : undefined - - b = 'error' - >b = 'error' : "error" -->b : number | undefined -+>b : any - >'error' : "error" - +@@= skipped -56, +56 lines =@@ // l should be any[] l.push(1) >l.push(1) : number @@ -224,33 +201,3 @@ >'ok' : "ok" } -@@= skipped -72, +72 lines =@@ - - /** @type {(v: unknown) => v is undefined} */ - const isUndef = v => v === undefined; -->isUndef : (v: unknown) => v is undefined -->v => v === undefined : (v: unknown) => v is undefined -->v : unknown -+>isUndef : (v: any) => boolean -+>v => v === undefined : (v: any) => boolean -+>v : any - >v === undefined : boolean -->v : unknown -+>v : any - >undefined : undefined - - const e = [1, undefined]; -@@= skipped -15, +15 lines =@@ - - // should be undefined[] - const g = e.filter(isUndef); -->g : undefined[] -->e.filter(isUndef) : undefined[] -+>g : (number | undefined)[] -+>e.filter(isUndef) : (number | undefined)[] - >e.filter : { (predicate: (value: number | undefined, index: number, array: (number | undefined)[]) => value is S, thisArg?: any): S[]; (predicate: (value: number | undefined, index: number, array: (number | undefined)[]) => unknown, thisArg?: any): (number | undefined)[]; } - >e : (number | undefined)[] - >filter : { (predicate: (value: number | undefined, index: number, array: (number | undefined)[]) => value is S, thisArg?: any): S[]; (predicate: (value: number | undefined, index: number, array: (number | undefined)[]) => unknown, thisArg?: any): (number | undefined)[]; } -->isUndef : (v: unknown) => v is undefined -+>isUndef : (v: any) => boolean - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.errors.txt.diff deleted file mode 100644 index 9ddc1879de..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.errors.txt.diff +++ /dev/null @@ -1,35 +0,0 @@ ---- old.typeFromJSInitializer4.errors.txt -+++ new.typeFromJSInitializer4.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(2,5): error TS7034: Variable 'n' implicitly has type 'any' in some locations where its type cannot be determined. - a.js(5,12): error TS7006: Parameter 'a' implicitly has an 'any' type. -+a.js(5,26): error TS7005: Variable 'n' implicitly has an 'any' type. - a.js(5,29): error TS7006: Parameter 'l' implicitly has an 'any[]' type. --a.js(17,5): error TS2322: Type 'string' is not assignable to type 'number'. - - --==== a.js (3 errors) ==== -+==== a.js (4 errors) ==== - /** @type {number | undefined} */ - var n; -+ ~ -+!!! error TS7034: Variable 'n' implicitly has type 'any' in some locations where its type cannot be determined. - - // should get any on parameter initialisers - function f(a = null, b = n, l = []) { - ~~~~~~~~ - !!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7005: Variable 'n' implicitly has an 'any' type. - ~~~~~~ - !!! error TS7006: Parameter 'l' implicitly has an 'any[]' type. - // a should be any -@@= skipped -24, +29 lines =@@ - b = 1 - b = undefined - b = 'error' -- ~ --!!! error TS2322: Type 'string' is not assignable to type 'number'. - - // l should be any[] - l.push(1) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.types.diff deleted file mode 100644 index a46c728105..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.types.diff +++ /dev/null @@ -1,42 +0,0 @@ ---- old.typeFromJSInitializer4.types -+++ new.typeFromJSInitializer4.types -@@= skipped -2, +2 lines =@@ - === a.js === - /** @type {number | undefined} */ - var n; -->n : number -+>n : any - - // should get any on parameter initialisers - function f(a = null, b = n, l = []) { -->f : (a?: any, b?: number, l?: any[]) => void -+>f : (a?: any, b?: any, l?: any[]) => void - >a : any -->b : number -->n : number -+>b : any -+>n : any - >l : any[] - >[] : undefined[] - -@@= skipped -44, +44 lines =@@ - // b should be number | undefined, not any - b = 1 - >b = 1 : 1 -->b : number -+>b : any - >1 : 1 - - b = undefined - >b = undefined : undefined -->b : number -+>b : any - >undefined : undefined - - b = 'error' - >b = 'error' : "error" -->b : number -+>b : any - >'error' : "error" - - // l should be any[] diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff index 9b8e49178a..1f35e42090 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff @@ -3,9 +3,17 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++a.js(3,13): error TS2749: 'A' refers to a value, but is being used as a type here. Did you mean 'typeof A'? +b-ext.js(3,14): error TS2339: Property 'x' does not exist on type 'B'. ++b.js(3,13): error TS2749: 'B' refers to a value, but is being used as a type here. Did you mean 'typeof B'? ++c.js(3,13): error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? ++d.js(3,13): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? +e-ext.js(3,14): error TS2339: Property 'x' does not exist on type 'E'. ++e.js(3,13): error TS2749: 'E' refers to a value, but is being used as a type here. Did you mean 'typeof E'? ++f.js(5,13): error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? ++g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? +h.js(3,14): error TS2339: Property 'x' does not exist on type 'H'. ++h.js(8,19): error TS2339: Property 'x' does not exist on type 'H'. + + +==== node.d.ts (0 errors) ==== @@ -17,10 +25,12 @@ + this.x = 1; + }; + -+==== a.js (0 errors) ==== ++==== a.js (1 errors) ==== + const { A } = require("./a-ext"); + + /** @param {A} p */ ++ ~ ++!!! error TS2749: 'A' refers to a value, but is being used as a type here. Did you mean 'typeof A'? + function a(p) { p.x; } + +==== b-ext.js (1 errors) ==== @@ -32,10 +42,12 @@ + } + }; + -+==== b.js (0 errors) ==== ++==== b.js (1 errors) ==== + const { B } = require("./b-ext"); + + /** @param {B} p */ ++ ~ ++!!! error TS2749: 'B' refers to a value, but is being used as a type here. Did you mean 'typeof B'? + function b(p) { p.x; } + +==== c-ext.js (0 errors) ==== @@ -43,10 +55,12 @@ + this.x = 1; + } + -+==== c.js (0 errors) ==== ++==== c.js (1 errors) ==== + const { C } = require("./c-ext"); + + /** @param {C} p */ ++ ~ ++!!! error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? + function c(p) { p.x; } + +==== d-ext.js (0 errors) ==== @@ -54,10 +68,12 @@ + this.x = 1; + }; + -+==== d.js (0 errors) ==== ++==== d.js (1 errors) ==== + const { D } = require("./d-ext"); + + /** @param {D} p */ ++ ~ ++!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? + function d(p) { p.x; } + +==== e-ext.js (1 errors) ==== @@ -69,29 +85,35 @@ + } + } + -+==== e.js (0 errors) ==== ++==== e.js (1 errors) ==== + const { E } = require("./e-ext"); + + /** @param {E} p */ ++ ~ ++!!! error TS2749: 'E' refers to a value, but is being used as a type here. Did you mean 'typeof E'? + function e(p) { p.x; } + -+==== f.js (0 errors) ==== ++==== f.js (1 errors) ==== + var F = function () { + this.x = 1; + }; + + /** @param {F} p */ ++ ~ ++!!! error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? + function f(p) { p.x; } + -+==== g.js (0 errors) ==== ++==== g.js (1 errors) ==== + function G() { + this.x = 1; + } + + /** @param {G} p */ ++ ~ ++!!! error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? + function g(p) { p.x; } + -+==== h.js (1 errors) ==== ++==== h.js (2 errors) ==== + class H { + constructor() { + this.x = 1; @@ -102,3 +124,5 @@ + + /** @param {H} p */ + function h(p) { p.x; } ++ ~ ++!!! error TS2339: Property 'x' does not exist on type 'H'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.types.diff index 114c2049c0..70f281743d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.types.diff @@ -34,17 +34,14 @@ >require : (id: string) => any >"./a-ext" : "./a-ext" - /** @param {A} p */ +@@= skipped -9, +9 lines =@@ function a(p) { p.x; } -->a : (p: A) => void -->p : A + >a : (p: A) => void + >p : A ->p.x : number -->p : A -->x : number -+>a : (p: any) => void -+>p : any +>p.x : any -+>p : any + >p : A +->x : number +>x : any === b-ext.js === @@ -59,7 +56,7 @@ >class { constructor() { this.x = 1; }} : typeof B constructor() { -@@= skipped -33, +33 lines =@@ +@@= skipped -24, +24 lines =@@ === b.js === const { B } = require("./b-ext"); @@ -70,17 +67,14 @@ >require : (id: string) => any >"./b-ext" : "./b-ext" - /** @param {B} p */ +@@= skipped -9, +9 lines =@@ function b(p) { p.x; } -->b : (p: B) => void -->p : B + >b : (p: B) => void + >p : B ->p.x : number -->p : B -->x : number -+>b : (p: any) => void -+>p : any +>p.x : any -+>p : any + >p : B +->x : number +>x : any === c-ext.js === @@ -106,17 +100,14 @@ >require : (id: string) => any >"./c-ext" : "./c-ext" - /** @param {C} p */ +@@= skipped -27, +27 lines =@@ function c(p) { p.x; } -->c : (p: C) => void -->p : C + >c : (p: C) => void + >p : C ->p.x : number -->p : C -->x : number -+>c : (p: any) => void -+>p : any +>p.x : any -+>p : any + >p : C +->x : number +>x : any === d-ext.js === @@ -134,7 +125,7 @@ >x : any >1 : 1 -@@= skipped -56, +56 lines =@@ +@@= skipped -20, +20 lines =@@ === d.js === const { D } = require("./d-ext"); @@ -145,22 +136,19 @@ >require : (id: string) => any >"./d-ext" : "./d-ext" - /** @param {D} p */ +@@= skipped -9, +9 lines =@@ function d(p) { p.x; } -->d : (p: D) => void -->p : D + >d : (p: D) => void + >p : D ->p.x : number -->p : D -->x : number -+>d : (p: any) => void -+>p : any +>p.x : any -+>p : any + >p : D +->x : number +>x : any === e-ext.js === export class E { -@@= skipped -29, +29 lines =@@ +@@= skipped -20, +20 lines =@@ === e.js === const { E } = require("./e-ext"); @@ -171,17 +159,14 @@ >require : (id: string) => any >"./e-ext" : "./e-ext" - /** @param {E} p */ +@@= skipped -9, +9 lines =@@ function e(p) { p.x; } -->e : (p: E) => void -->p : E + >e : (p: E) => void + >p : E ->p.x : number -->p : E -->x : number -+>e : (p: any) => void -+>p : any +>p.x : any -+>p : any + >p : E +->x : number +>x : any === f.js === @@ -199,19 +184,14 @@ >x : any >1 : 1 -@@= skipped -29, +29 lines =@@ - - /** @param {F} p */ +@@= skipped -22, +22 lines =@@ function f(p) { p.x; } -->f : (p: F) => void -->p : F + >f : (p: F) => void + >p : F ->p.x : number -->p : F -->x : number -+>f : (p: any) => void -+>p : any +>p.x : any -+>p : any + >p : F +->x : number +>x : any === g.js === @@ -227,34 +207,25 @@ >x : any >1 : 1 } - - /** @param {G} p */ +@@= skipped -20, +20 lines =@@ function g(p) { p.x; } -->g : (p: G) => void -->p : G + >g : (p: G) => void + >p : G ->p.x : number -->p : G -->x : number -+>g : (p: any) => void -+>p : any +>p.x : any -+>p : any + >p : G +->x : number +>x : any === h.js === class H { -@@= skipped -42, +42 lines =@@ - - /** @param {H} p */ +@@= skipped -22, +22 lines =@@ function h(p) { p.x; } -->h : (p: H) => void -->p : H + >h : (p: H) => void + >p : H ->p.x : number -->p : H -->x : number -+>h : (p: any) => void -+>p : any +>p.x : any -+>p : any + >p : H +->x : number +>x : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.types.diff deleted file mode 100644 index e7d7ff0d52..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.types.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.typeFromPrivatePropertyAssignmentJs.types -+++ new.typeFromPrivatePropertyAssignmentJs.types -@@= skipped -7, +7 lines =@@ - - /** @type {{ foo?: string } | undefined } */ - #a; -->#a : { foo?: string; } -+>#a : any - - /** @type {{ foo?: string } | undefined } */ - #b; -->#b : { foo?: string; } -+>#b : any - - m() { - >m : () => void - - const a = this.#a || {}; -->a : { foo?: string; } -->this.#a || {} : { foo?: string; } -->this.#a : { foo?: string; } -+>a : any -+>this.#a || {} : any -+>this.#a : any - >this : this - >{} : {} - - this.#b = this.#b || {}; -->this.#b = this.#b || {} : { foo?: string; } -->this.#b : { foo?: string; } -+>this.#b = this.#b || {} : any -+>this.#b : any - >this : this -->this.#b || {} : { foo?: string; } -->this.#b : { foo?: string; } -+>this.#b || {} : any -+>this.#b : any - >this : this - >{} : {} - } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff index 9ba0b36eb2..e664ba81d5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff @@ -4,9 +4,11 @@ - @@= skipped --1, +1 lines =@@ +a.js(4,7): error TS2339: Property 'Inner' does not exist on type 'typeof O'. ++a.js(8,12): error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? ++a.js(11,12): error TS2503: Cannot find namespace 'Outer'. + + -+==== a.js (1 errors) ==== ++==== a.js (3 errors) ==== + var Outer = class O { + m(x, y) { } + } @@ -17,9 +19,13 @@ + + } + /** @type {Outer} */ ++ ~~~~~ ++!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? + var si + si.m + /** @type {Outer.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var oi + oi.n + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.types.diff index 4b7e36e323..1033acc3a8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.types.diff @@ -17,27 +17,27 @@ /** @type {Outer} */ var si ->si : O -+>si : any ++>si : Outer si.m ->si.m : (x: any, y: any) => void ->si : O ->m : (x: any, y: any) => void +>si.m : any -+>si : any ++>si : Outer +>m : any /** @type {Outer.Inner} */ var oi ->oi : I -+>oi : any ++>oi : Inner oi.n ->oi.n : (a: any, b: any) => void ->oi : I ->n : (a: any, b: any) => void +>oi.n : any -+>oi : any ++>oi : Inner +>n : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff index 9f8abcdd71..97079b8545 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++main.js(4,12): error TS2503: Cannot find namespace 'Outer'. +someview.js(10,14): error TS2339: Property 'y' does not exist on type 'Inner'. + + @@ -44,11 +45,13 @@ + }; + return Application; + })(); -+==== main.js (0 errors) ==== ++==== main.js (1 errors) ==== + var app = new Outer.app.Application(); + var inner = new Outer.app.Inner(); + inner.y; + /** @type {Outer.app.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var x; + x.y; + Outer.app.statische(101); // Infinity, duh diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.types.diff index 98ed7e19e4..73beb34e90 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.types.diff @@ -229,15 +229,13 @@ /** @type {Outer.app.Inner} */ var x; -->x : Inner -+>x : any + >x : Inner x.y; ->x.y : number -->x : Inner -->y : number +>x.y : any -+>x : any + >x : Inner +->y : number +>y : any Outer.app.statische(101); // Infinity, duh diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.errors.txt.diff index 2e5bbae387..86f508d4ff 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++main.js(4,12): error TS2503: Cannot find namespace 'Outer'. +someview.js(10,14): error TS2339: Property 'y' does not exist on type 'Inner'. + + @@ -44,11 +45,13 @@ + }; + return Application; + })(); -+==== main.js (0 errors) ==== ++==== main.js (1 errors) ==== + var app = new Outer.app.Application(); + var inner = new Outer.app.Inner(); + inner.y; + /** @type {Outer.app.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var x; + x.y; + Outer.app.statische(101); // Infinity, duh diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.types.diff index 5e1fbbc7ae..b516be9775 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.types.diff @@ -229,15 +229,13 @@ /** @type {Outer.app.Inner} */ var x; -->x : Inner -+>x : any + >x : Inner x.y; ->x.y : number -->x : Inner -->y : number +>x.y : any -+>x : any + >x : Inner +->y : number +>y : any Outer.app.statische(101); // Infinity, duh diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.errors.txt.diff index 1b358dcf1a..709710d9f3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++use.js(1,12): error TS2503: Cannot find namespace 'Outer'. +use.js(5,22): error TS2339: Property 'Inner' does not exist on type '{}'. +work.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. +work.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. @@ -22,8 +23,10 @@ + m() { } + } + -+==== use.js (1 errors) ==== ++==== use.js (2 errors) ==== + /** @type {Outer.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var inner + inner.x + inner.m() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.types.diff index 39fb252707..d5de076c03 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.types.diff @@ -39,29 +39,23 @@ x: 1, >x : number -@@= skipped -31, +31 lines =@@ - === use.js === - /** @type {Outer.Inner} */ - var inner -->inner : Inner -+>inner : any +@@= skipped -34, +34 lines =@@ + >inner : Inner inner.x ->inner.x : number -->inner : Inner -->x : number +>inner.x : any -+>inner : any + >inner : Inner +->x : number +>x : any inner.m() ->inner.m() : void ->inner.m : () => void -->inner : Inner -->m : () => void +>inner.m() : any +>inner.m : any -+>inner : any + >inner : Inner +->m : () => void +>m : any var inno = new Outer.Inner() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff index c885063aab..5079f95655 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff @@ -5,10 +5,11 @@ @@= skipped --1, +1 lines =@@ +a.js(3,7): error TS2339: Property 'Inner' does not exist on type '{}'. +a.js(5,14): error TS2339: Property 'x' does not exist on type 'Inner'. ++a.js(10,12): error TS2503: Cannot find namespace 'Outer'. +a.js(14,22): error TS2339: Property 'Inner' does not exist on type '{}'. + + -+==== a.js (3 errors) ==== ++==== a.js (4 errors) ==== + var Outer = {}; + + Outer.Inner = class { @@ -23,6 +24,8 @@ + } + + /** @type {Outer.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var inner + inner.x + inner.m() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.types.diff index 85a4de6536..4f37048588 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.types.diff @@ -19,29 +19,23 @@ >class { constructor() { this.x = 1 } m() { }} : typeof Inner constructor() { -@@= skipped -24, +24 lines =@@ - - /** @type {Outer.Inner} */ - var inner -->inner : Inner -+>inner : any +@@= skipped -27, +27 lines =@@ + >inner : Inner inner.x ->inner.x : number -->inner : Inner -->x : number +>inner.x : any -+>inner : any + >inner : Inner +->x : number +>x : any inner.m() ->inner.m() : void ->inner.m : () => void -->inner : Inner -->m : () => void +>inner.m() : any +>inner.m : any -+>inner : any + >inner : Inner +->m : () => void +>m : any var inno = new Outer.Inner() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff index d6e59f438d..4e3e2fba37 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff @@ -5,10 +5,11 @@ @@= skipped --1, +1 lines =@@ +a.js(3,7): error TS2339: Property 'Inner' does not exist on type '{}'. +a.js(4,7): error TS2339: Property 'Inner' does not exist on type '{}'. ++a.js(9,12): error TS2503: Cannot find namespace 'Outer'. +a.js(13,22): error TS2339: Property 'Inner' does not exist on type '{}'. + + -+==== a.js (3 errors) ==== ++==== a.js (4 errors) ==== + var Outer = {}; + + Outer.Inner = function () {} @@ -22,6 +23,8 @@ + } + + /** @type {Outer.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var inner + inner.x + inner.m() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.types.diff index 3db28a4f32..adab055b2c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.types.diff @@ -38,29 +38,23 @@ x: 1, >x : number -@@= skipped -29, +29 lines =@@ - - /** @type {Outer.Inner} */ - var inner -->inner : Inner -+>inner : any +@@= skipped -32, +32 lines =@@ + >inner : Inner inner.x ->inner.x : number -->inner : Inner -->x : number +>inner.x : any -+>inner : any + >inner : Inner +->x : number +>x : any inner.m() ->inner.m() : void ->inner.m : () => void -->inner : Inner -->m : () => void +>inner.m() : any +>inner.m : any -+>inner : any + >inner : Inner +->m : () => void +>m : any var inno = new Outer.Inner() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff index 4fb290638b..cca49f15f0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff @@ -4,9 +4,11 @@ - @@= skipped --1, +1 lines =@@ +a.js(6,14): error TS2339: Property 'x' does not exist on type 'I'. ++a.js(9,12): error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? ++a.js(12,12): error TS2503: Cannot find namespace 'Outer'. + + -+==== a.js (1 errors) ==== ++==== a.js (3 errors) ==== + function Outer() { + this.y = 2 + } @@ -18,9 +20,13 @@ + } + } + /** @type {Outer} */ ++ ~~~~~ ++!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? + var ok + ok.y + /** @type {Outer.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var oc + oc.x + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.types.diff index 636477172b..aea9aa8662 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.types.diff @@ -23,31 +23,26 @@ >Inner : typeof I >class I { constructor() { this.x = 1 }} : typeof I >I : typeof I -@@= skipped -28, +28 lines =@@ - } - /** @type {Outer} */ - var ok -->ok : Outer -+>ok : any +@@= skipped -31, +31 lines =@@ + >ok : Outer ok.y ->ok.y : number -->ok : Outer -->y : number +>ok.y : any -+>ok : any + >ok : Outer +->y : number +>y : any /** @type {Outer.Inner} */ var oc ->oc : I -+>oc : any ++>oc : Inner oc.x ->oc.x : number ->oc : I ->x : number +>oc.x : any -+>oc : any ++>oc : Inner +>x : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff index 794b24d9de..3a0a45820f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff @@ -6,9 +6,10 @@ +def.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. +usage.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. +usage.js(5,19): error TS2339: Property 'Inner' does not exist on type '{}'. ++usage.js(7,12): error TS2503: Cannot find namespace 'Outer'. + + -+==== usage.js (2 errors) ==== ++==== usage.js (3 errors) ==== + // note that usage is first in the compilation + Outer.Inner.Message = function() { + ~~~~~ @@ -20,6 +21,8 @@ +!!! error TS2339: Property 'Inner' does not exist on type '{}'. + y.name + /** @type {Outer.Inner} should be instance type, not static type */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var x; + x.name + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.types.diff index 84e7dee675..b58936acfc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.types.diff @@ -40,15 +40,13 @@ /** @type {Outer.Inner} should be instance type, not static type */ var x; -->x : Inner -+>x : any + >x : Inner x.name ->x.name : () => string -->x : Inner -->name : () => string +>x.name : any -+>x : any + >x : Inner +->name : () => string +>name : any === def.js === diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff index f2a1bb765e..4531ff7bdf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff @@ -5,9 +5,11 @@ @@= skipped --1, +1 lines =@@ +a.js(4,7): error TS2339: Property 'Inner' does not exist on type '() => void'. +a.js(6,14): error TS2339: Property 'x' does not exist on type 'I'. ++a.js(9,12): error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? ++a.js(12,12): error TS2503: Cannot find namespace 'Outer'. + + -+==== a.js (2 errors) ==== ++==== a.js (4 errors) ==== + var Outer = function O() { + this.y = 2 + } @@ -21,9 +23,13 @@ + } + } + /** @type {Outer} */ ++ ~~~~~ ++!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? + var ja + ja.y + /** @type {Outer.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var da + da.x + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.types.diff index 3894166bdc..4ecbd6d9d7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.types.diff @@ -35,26 +35,26 @@ /** @type {Outer} */ var ja ->ja : O -+>ja : any ++>ja : Outer ja.y ->ja.y : number ->ja : O ->y : number +>ja.y : any -+>ja : any ++>ja : Outer +>y : any /** @type {Outer.Inner} */ var da ->da : I -+>da : any ++>da : Inner da.x ->da.x : number ->da : I ->x : number +>da.x : any -+>da : any ++>da : Inner +>x : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff index 128ce049a7..4a037f26e0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++bug26877.js(1,13): error TS2503: Cannot find namespace 'Emu'. +bug26877.js(4,23): error TS2339: Property 'D' does not exist on type '{}'. +bug26877.js(5,19): error TS2339: Property 'D' does not exist on type '{}'. +bug26877.js(7,5): error TS2339: Property 'D' does not exist on type '{}'. @@ -10,8 +11,10 @@ +second.js(3,5): error TS2339: Property 'D' does not exist on type '{}'. + + -+==== bug26877.js (4 errors) ==== ++==== bug26877.js (5 errors) ==== + /** @param {Emu.D} x */ ++ ~~~ ++!!! error TS2503: Cannot find namespace 'Emu'. + function ollKorrect(x) { + x._model + const y = new Emu.D() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.types.diff index 4022dd01d4..d98fcf8ad9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.types.diff @@ -1,20 +1,13 @@ --- old.typeFromPropertyAssignment35.types +++ new.typeFromPropertyAssignment35.types -@@= skipped -2, +2 lines =@@ - === bug26877.js === - /** @param {Emu.D} x */ - function ollKorrect(x) { -->ollKorrect : (x: D) => void -->x : D -+>ollKorrect : (x: any) => void -+>x : any +@@= skipped -6, +6 lines =@@ + >x : D x._model ->x._model : number -->x : D -->_model : number +>x._model : any -+>x : any + >x : D +->_model : number +>_model : any const y = new Emu.D() @@ -54,7 +47,7 @@ >class { constructor() { this._model = 1 }} : typeof D constructor() { -@@= skipped -42, +42 lines =@@ +@@= skipped -38, +38 lines =@@ === second.js === var Emu = {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff index ac91c9aa73..1160915612 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff @@ -5,14 +5,16 @@ @@= skipped --1, +1 lines =@@ +a.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. +a.js(4,14): error TS2339: Property 'y' does not exist on type 'Inner'. ++a.js(8,12): error TS2503: Cannot find namespace 'Outer'. +a.js(11,23): error TS2339: Property 'Inner' does not exist on type '{}'. ++b.js(1,12): error TS2503: Cannot find namespace 'Outer'. +b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. + + +==== def.js (0 errors) ==== + var Outer = {}; + -+==== a.js (3 errors) ==== ++==== a.js (4 errors) ==== + Outer.Inner = class { + ~~~~~ +!!! error TS2339: Property 'Inner' does not exist on type '{}'. @@ -25,6 +27,8 @@ + } + + /** @type {Outer.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var local + local.y + var inner = new Outer.Inner() @@ -32,8 +36,10 @@ +!!! error TS2339: Property 'Inner' does not exist on type '{}'. + inner.y + -+==== b.js (1 errors) ==== ++==== b.js (2 errors) ==== + /** @type {Outer.Inner} */ ++ ~~~~~ ++!!! error TS2503: Cannot find namespace 'Outer'. + var x + x.y + var z = new Outer.Inner() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.types.diff index 78803b4f81..55e3a4920e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.types.diff @@ -31,18 +31,14 @@ >12 : 12 } } - - /** @type {Outer.Inner} */ - var local -->local : Inner -+>local : any +@@= skipped -27, +27 lines =@@ + >local : Inner local.y ->local.y : number -->local : Inner -->y : number +>local.y : any -+>local : any + >local : Inner +->y : number +>y : any var inner = new Outer.Inner() @@ -67,16 +63,14 @@ === b.js === /** @type {Outer.Inner} */ - var x -->x : Inner -+>x : any +@@= skipped -22, +22 lines =@@ + >x : Inner x.y ->x.y : number -->x : Inner -->y : number +>x.y : any -+>x : any + >x : Inner +->y : number +>y : any var z = new Outer.Inner() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.errors.txt.diff new file mode 100644 index 0000000000..c0e369b6ff --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.typeFromPropertyAssignment40.errors.txt ++++ new.typeFromPropertyAssignment40.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++typeFromPropertyAssignment40.js(5,12): error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? ++ ++ ++==== typeFromPropertyAssignment40.js (1 errors) ==== ++ function Outer() { ++ var self = this ++ self.y = 2 ++ } ++ /** @type {Outer} */ ++ ~~~~~ ++!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? ++ var ok ++ ok.y ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.types.diff index 43d4292953..ec0d98d775 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.types.diff @@ -21,16 +21,13 @@ >y : any >2 : 2 } - /** @type {Outer} */ - var ok -->ok : Outer -+>ok : any +@@= skipped -18, +18 lines =@@ + >ok : Outer ok.y ->ok.y : number -->ok : Outer -->y : number +>ok.y : any -+>ok : any + >ok : Outer +->y : number +>y : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff new file mode 100644 index 0000000000..d058564af3 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.typeFromPropertyAssignment5.errors.txt ++++ new.typeFromPropertyAssignment5.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++b.js(3,12): error TS2503: Cannot find namespace 'MC'. ++ ++ ++==== a.js (0 errors) ==== ++ export default function MyClass() { ++ } ++ MyClass.bar = class C { ++ } ++ MyClass.bar ++ ++==== b.js (1 errors) ==== ++ import MC from './a' ++ MC.bar ++ /** @type {MC.bar} */ ++ ~~ ++!!! error TS2503: Cannot find namespace 'MC'. ++ var x ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.types.diff index db487ef655..66b96da179 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.types.diff @@ -36,5 +36,5 @@ /** @type {MC.bar} */ var x ->x : C -+>x : any ++>x : bar diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff index f67d4b476a..c9d605435f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff @@ -6,6 +6,7 @@ +a.js(1,7): error TS2339: Property 'Inner' does not exist on type 'typeof Outer'. +a.js(5,7): error TS2339: Property 'i' does not exist on type 'typeof Outer'. +b.js(1,18): error TS2339: Property 'i' does not exist on type 'typeof Outer'. ++b.js(3,13): error TS2702: 'Outer' only refers to a type, but is being used as a namespace here. + + +==== def.js (0 errors) ==== @@ -22,12 +23,14 @@ + ~ +!!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. + -+==== b.js (1 errors) ==== ++==== b.js (2 errors) ==== + var msgs = Outer.i.messages() + ~ +!!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. + + /** @param {Outer.Inner} inner */ ++ ~~~~~ ++!!! error TS2702: 'Outer' only refers to a type, but is being used as a namespace here. + function x(inner) { + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.types.diff index 4c769ac50d..bb8040fe5d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.types.diff @@ -42,7 +42,7 @@ function x(inner) { ->x : (inner: I) => void ->inner : I -+>x : (inner: any) => void -+>inner : any ++>x : (inner: Inner) => void ++>inner : Inner } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff index 79eee8a1cf..1369c11c34 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff @@ -8,9 +8,10 @@ +index.js(2,37): error TS2339: Property 'Item' does not exist on type '{}'. +index.js(4,11): error TS2339: Property 'Object' does not exist on type '{}'. +index.js(4,41): error TS2339: Property 'Object' does not exist on type '{}'. ++index.js(6,12): error TS2503: Cannot find namespace 'Workspace'. + + -+==== index.js (5 errors) ==== ++==== index.js (6 errors) ==== + First.Item = class I {} + ~~~~ +!!! error TS2339: Property 'Item' does not exist on type '{}'. @@ -27,6 +28,8 @@ +!!! error TS2339: Property 'Object' does not exist on type '{}'. + + /** @type {Workspace.Object} */ ++ ~~~~~~~~~ ++!!! error TS2503: Cannot find namespace 'Workspace'. + var am; + +==== roots.js (0 errors) ==== diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.types.diff index 4abdd979c8..22bda480dd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.types.diff @@ -47,8 +47,7 @@ /** @type {Workspace.Object} */ var am; -->am : Object -+>am : any +@@= skipped -32, +32 lines =@@ === roots.js === var First = {}; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff index 7082e2ece8..1244d23302 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff @@ -4,14 +4,13 @@ -bug26885.js(11,16): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. - No index signature with a parameter of type 'string' was found on type '{}'. +bug26885.js(2,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+bug26885.js(10,5): error TS7023: 'get' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -+bug26885.js(10,9): error TS7006: Parameter 'key' implicitly has an 'any' type. -+bug26885.js(11,21): error TS2339: Property '_map' does not exist on type '{ get: (key: any) => any; }'. ++bug26885.js(11,21): error TS2339: Property '_map' does not exist on type '{ get: (key: string) => number; }'. ++bug26885.js(15,12): error TS2749: 'Multimap3' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap3'? +bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -==== bug26885.js (1 errors) ==== -+==== bug26885.js (5 errors) ==== ++==== bug26885.js (4 errors) ==== function Multimap3() { this._map = {}; + ~~~~ @@ -19,24 +18,21 @@ }; Multimap3.prototype = { -@@= skipped -12, +17 lines =@@ - * @returns {number} the value ok +@@= skipped -13, +17 lines =@@ */ get(key) { -+ ~~~ -+!!! error TS7023: 'get' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -+ ~~~ -+!!! error TS7006: Parameter 'key' implicitly has an 'any' type. return this._map[key + '']; - ~~~~~~~~~~~~~~~~~~~ -!!! error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. -!!! error TS7053: No index signature with a parameter of type 'string' was found on type '{}'. + ~~~~ -+!!! error TS2339: Property '_map' does not exist on type '{ get: (key: any) => any; }'. ++!!! error TS2339: Property '_map' does not exist on type '{ get: (key: string) => number; }'. } } /** @type {Multimap3} */ ++ ~~~~~~~~~ ++!!! error TS2749: 'Multimap3' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap3'? const map = new Multimap3(); + ~~~~~~~~~~~~~~~ +!!! error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.types.diff index 99e80a05c2..aa3930f09c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.types.diff @@ -5,7 +5,7 @@ === bug26885.js === function Multimap3() { ->Multimap3 : typeof Multimap3 -+>Multimap3 : { (): void; prototype: { get: (key: any) => any; }; } ++>Multimap3 : { (): void; prototype: { get: (key: string) => number; }; } this._map = {}; >this._map = {} : {} @@ -23,21 +23,15 @@ ->Multimap3 : typeof Multimap3 ->prototype : { get(key: string): number; } ->{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: string): number; } -+>Multimap3.prototype = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } -+>Multimap3.prototype : { get: (key: any) => any; } -+>Multimap3 : { (): void; prototype: { get: (key: any) => any; }; } -+>prototype : { get: (key: any) => any; } -+>{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } ++>Multimap3.prototype = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: string) => number; } ++>Multimap3.prototype : { get: (key: string) => number; } ++>Multimap3 : { (): void; prototype: { get: (key: string) => number; }; } ++>prototype : { get: (key: string) => number; } ++>{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: string) => number; } /** * @param {string} key - * @returns {number} the value ok - */ - get(key) { -->get : (key: string) => number -->key : string -+>get : (key: any) => any -+>key : any +@@= skipped -28, +28 lines =@@ return this._map[key + '']; >this._map[key + ''] : any @@ -45,34 +39,29 @@ ->this : this ->_map : {} +>this._map : any -+>this : { get: (key: any) => any; } ++>this : { get: (key: string) => number; } +>_map : any >key + '' : string -->key : string -+>key : any + >key : string >'' : "" - } - } - +@@= skipped -12, +12 lines =@@ /** @type {Multimap3} */ const map = new Multimap3(); -->map : Multimap3 + >map : Multimap3 ->new Multimap3() : Multimap3 ->Multimap3 : typeof Multimap3 -+>map : any +>new Multimap3() : any -+>Multimap3 : { (): void; prototype: { get: (key: any) => any; }; } ++>Multimap3 : { (): void; prototype: { get: (key: string) => number; }; } const n = map.get('hi') ->n : number ->map.get('hi') : number ->map.get : (key: string) => number -->map : Multimap3 -->get : (key: string) => number +>n : any +>map.get('hi') : any +>map.get : any -+>map : any + >map : Multimap3 +->get : (key: string) => number +>get : any >'hi' : "hi" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.types.diff index 9f2419b7f1..a5dd1b1fb4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.types.diff @@ -5,7 +5,7 @@ === a.js === function Multimap4() { ->Multimap4 : typeof Multimap4 -+>Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } ++>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } this._map = {}; >this._map = {} : {} @@ -21,22 +21,16 @@ ->Multimap4["prototype"] = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: string): number; } ->Multimap4["prototype"] : { get(key: string): number; } ->Multimap4 : typeof Multimap4 -+>Multimap4["prototype"] = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } -+>Multimap4["prototype"] : { get: (key: any) => any; } -+>Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } ++>Multimap4["prototype"] = { /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: string) => number; } ++>Multimap4["prototype"] : { get: (key: string) => number; } ++>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } >"prototype" : "prototype" ->{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get(key: string): number; } -+>{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: any) => any; } ++>{ /** * @param {string} key * @returns {number} the value ok */ get(key) { return this._map[key + '']; }} : { get: (key: string) => number; } /** * @param {string} key - * @returns {number} the value ok - */ - get(key) { -->get : (key: string) => number -->key : string -+>get : (key: any) => any -+>key : any +@@= skipped -28, +28 lines =@@ return this._map[key + '']; >this._map[key + ''] : any @@ -47,19 +41,16 @@ +>this : any +>_map : any >key + '' : string -->key : string -+>key : any + >key : string >'' : "" - } - }; -@@= skipped -40, +40 lines =@@ +@@= skipped -12, +12 lines =@@ Multimap4["prototype"]["add-on"] = function() {}; >Multimap4["prototype"]["add-on"] = function() {} : () => void >Multimap4["prototype"]["add-on"] : any ->Multimap4["prototype"] : { get(key: string): number; } ->Multimap4 : typeof Multimap4 -+>Multimap4["prototype"] : { get: (key: any) => any; } -+>Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } ++>Multimap4["prototype"] : { get: (key: string) => number; } ++>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } >"prototype" : "prototype" >"add-on" : "add-on" >function() {} : () => void @@ -69,8 +60,8 @@ >Multimap4["prototype"]["addon"] : any ->Multimap4["prototype"] : { get(key: string): number; } ->Multimap4 : typeof Multimap4 -+>Multimap4["prototype"] : { get: (key: any) => any; } -+>Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } ++>Multimap4["prototype"] : { get: (key: string) => number; } ++>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } >"prototype" : "prototype" >"addon" : "addon" >function() {} : () => void @@ -80,8 +71,8 @@ >Multimap4["prototype"]["__underscores__"] : any ->Multimap4["prototype"] : { get(key: string): number; } ->Multimap4 : typeof Multimap4 -+>Multimap4["prototype"] : { get: (key: any) => any; } -+>Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } ++>Multimap4["prototype"] : { get: (key: string) => number; } ++>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } >"prototype" : "prototype" >"__underscores__" : "__underscores__" >function() {} : () => void @@ -92,7 +83,7 @@ ->Multimap4 : typeof Multimap4 +>map4 : any +>new Multimap4() : any -+>Multimap4 : { (): void; prototype: { get: (key: any) => any; }; } ++>Multimap4 : { (): void; prototype: { get: (key: string) => number; }; } map4.get(""); ->map4.get("") : number diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff index 5710e50dc9..9db1564091 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff @@ -1,16 +1,17 @@ --- old.typeLookupInIIFE.errors.txt +++ new.typeLookupInIIFE.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -a.js(3,15): error TS2694: Namespace 'ns' has no exported member 'NotFound'. -- -- --==== a.js (1 errors) ==== -- // #22973 -- var ns = (function() {})(); -- /** @type {ns.NotFound} */ ++a.js(3,12): error TS2503: Cannot find namespace 'ns'. + + + ==== a.js (1 errors) ==== + // #22973 + var ns = (function() {})(); + /** @type {ns.NotFound} */ - ~~~~~~~~ -!!! error TS2694: Namespace 'ns' has no exported member 'NotFound'. -- var crash; -- -@@= skipped --1, +1 lines =@@ -+ ++ ~~ ++!!! error TS2503: Cannot find namespace 'ns'. + var crash; + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.types.diff index 9875c4ff5b..8ea9da074c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.types.diff @@ -5,5 +5,5 @@ /** @type {ns.NotFound} */ var crash; ->crash : ns.NotFound -+>crash : any ++>crash : NotFound diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff index 67ef76739b..1a0afdd749 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff @@ -1,19 +1,20 @@ --- old.typeTagNoErasure.errors.txt +++ new.typeTagNoErasure.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -typeTagNoErasure.js(7,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -- -- --==== typeTagNoErasure.js (1 errors) ==== -- /** @template T @typedef {(data: T1) => T1} Test */ -- -- /** @type {Test} */ -- const test = dibbity => dibbity -- -- test(1) // ok, T=1 -- test('hi') // error, T=number ++typeTagNoErasure.js(1,39): error TS2304: Cannot find name 'T'. + + + ==== typeTagNoErasure.js (1 errors) ==== + /** @template T @typedef {(data: T1) => T1} Test */ ++ ~ ++!!! error TS2304: Cannot find name 'T'. + + /** @type {Test} */ + const test = dibbity => dibbity + + test(1) // ok, T=1 + test('hi') // error, T=number - ~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -- -@@= skipped --1, +1 lines =@@ -+ + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff index 2739ad0fc1..75632d9228 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff @@ -6,24 +6,21 @@ const test = dibbity => dibbity ->test : Test ->dibbity => dibbity : (dibbity: T1) => T1 -->dibbity : T1 -->dibbity : T1 -+>test : (dibbity: any) => any -+>dibbity => dibbity : (dibbity: any) => any -+>dibbity : any -+>dibbity : any ++>test : (data: T1) => T1 ++>dibbity => dibbity : (dibbity: T1) => T1 + >dibbity : T1 + >dibbity : T1 test(1) // ok, T=1 -->test(1) : 1 + >test(1) : 1 ->test : Test -+>test(1) : any -+>test : (dibbity: any) => any ++>test : (data: T1) => T1 >1 : 1 test('hi') // error, T=number ->test('hi') : number ->test : Test -+>test('hi') : any -+>test : (dibbity: any) => any ++>test('hi') : "hi" ++>test : (data: T1) => T1 >'hi' : "hi" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.types.diff index 7a799288f6..4c9ada9f36 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.types.diff @@ -21,22 +21,3 @@ >1 : 1 /**@type {IFn}*/ - const inJsArrow = (j) => { -->inJsArrow : IFn -->(j) => { return j;} : (j: T) => T -->j : T -+>inJsArrow : (j: any) => any -+>(j) => { return j;} : (j: any) => any -+>j : any - - return j; -->j : T -+>j : any - } - inJsArrow(2); // no error gets linted as expected -->inJsArrow(2) : 2 -->inJsArrow : IFn -+>inJsArrow(2) : any -+>inJsArrow : (j: any) => any - >2 : 2 - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnPropertyAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnPropertyAssignment.types.diff index 5e05570c5f..1fad76b3aa 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnPropertyAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnPropertyAssignment.types.diff @@ -1,44 +1,16 @@ --- old.typeTagOnPropertyAssignment.types +++ new.typeTagOnPropertyAssignment.types -@@= skipped -1, +1 lines =@@ - - === typeTagOnPropertyAssignment.js === - const o = { -->o : { a: "a"; n: () => "b"; } -->{ /** * @type {"a"} */ a: "a", /** @type {() => 'b'} */ n: () => 'b'} : { a: "a"; n: () => "b"; } -+>o : { a: string; n: () => string; } -+>{ /** * @type {"a"} */ a: "a", /** @type {() => 'b'} */ n: () => 'b'} : { a: string; n: () => string; } - - /** - * @type {"a"} - */ +@@= skipped -10, +10 lines =@@ a: "a", -->a : "a" -+>a : string + >a : "a" >"a" : "a" ++>"a" : "a" /** @type {() => 'b'} */ n: () => 'b' -->n : () => "b" -->() => 'b' : () => "b" -+>n : () => string -+>() => 'b' : () => string + >n : () => "b" + >() => 'b' : () => "b" ++>() => 'b' : () => "b" >'b' : "b" }; - o.a -->o.a : "a" -->o : { a: "a"; n: () => "b"; } -->a : "a" -+>o.a : string -+>o : { a: string; n: () => string; } -+>a : string - - o.n -->o.n : () => "b" -->o : { a: "a"; n: () => "b"; } -->n : () => "b" -+>o.n : () => string -+>o : { a: string; n: () => string; } -+>n : () => string - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff index 90298bbdc2..ea3fe19b73 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff @@ -70,29 +70,25 @@ /** @type {import('./mod1').Both} */ var both1 = { type: 'a', x: 1 }; ->both1 : import("mod1").Both -->{ type: 'a', x: 1 } : { type: "a"; x: 1; } -->type : "a" -+>both1 : { type: string; x: number; } -+>{ type: 'a', x: 1 } : { type: string; x: number; } -+>type : string ++>both1 : { type: "a"; x: 1; } | { type: "b"; y: 1; } + >{ type: 'a', x: 1 } : { type: "a"; x: 1; } + >type : "a" >'a' : "a" -->x : 1 -+>x : number - >1 : 1 +@@= skipped -9, +9 lines =@@ /** @type {import('./mod2').Both} */ var both2 = both1; ->both2 : import("mod2").Both ->both1 : import("mod1").A -+>both2 : { type: string; x: number; } -+>both1 : { type: string; x: number; } ++>both2 : Both ++>both1 : { type: "a"; x: 1; } /** @type {import('./mod3').Both} */ var both3 = both2; ->both3 : import("mod3").Both ->both2 : import("mod2").A -+>both3 : { type: string; x: number; } -+>both2 : { type: string; x: number; } ++>both3 : { type: "a"; x: 1; } | { type: "b"; y: 1; } ++>both2 : A diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff index ecc36a9d6a..5b880ebdd3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff @@ -6,16 +6,22 @@ -mod1.js(9,23): error TS2300: Duplicate identifier 'Baz'. -mod1.js(11,5): error TS2300: Duplicate identifier 'Baz'. +use.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`. ++use.js(2,19): error TS2307: Cannot find module './mod1.js' or its corresponding type declarations. ++use.js(4,12): error TS2503: Cannot find namespace 'mod'. -==== use.js (0 errors) ==== -+==== use.js (1 errors) ==== ++==== use.js (3 errors) ==== var mod = require('./mod1.js'); + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @type {import("./mod1.js").Baz} */ ++ ~~~~~~~~~~~ ++!!! error TS2307: Cannot find module './mod1.js' or its corresponding type declarations. var b; /** @type {mod.Baz} */ ++ ~~~ ++!!! error TS2503: Cannot find namespace 'mod'. var bb; var bbb = new mod.Baz(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff index ccb0a0cfcc..bb6453bd98 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff @@ -19,7 +19,7 @@ /** @type {mod.Baz} */ var bb; ->bb : number -+>bb : any ++>bb : Baz var bbb = new mod.Baz(); ->bbb : Baz diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule5.errors.txt.diff index 3768eb4ab3..fcf1071a27 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule5.errors.txt.diff @@ -1,6 +1,6 @@ --- old.typedefCrossModule5.errors.txt +++ new.typedefCrossModule5.errors.txt -@@= skipped -0, +0 lines =@@ +@@= skipped -0, +-1 lines =@@ -mod1.js:1:23 - error TS2300: Duplicate identifier 'Foo'. - -1 /** @typedef {number} Foo */ @@ -10,18 +10,17 @@ - 1 class Foo { } // should error -    ~~~ - 'Foo' was also declared here. - mod1.js:2:7 - error TS2451: Cannot redeclare block-scoped variable 'Bar'. - - 2 class Bar {} -    ~~~ - +-mod1.js:2:7 - error TS2451: Cannot redeclare block-scoped variable 'Bar'. +- +-2 class Bar {} +-   ~~~ +- - mod2.js:2:7 -+ mod2.js:2:7 - 'Bar' was also declared here. - 2 const Bar = 3; -    ~~~ +- 2 const Bar = 3; +-    ~~~ - 'Bar' was also declared here. -mod2.js:1:7 - error TS2300: Duplicate identifier 'Foo'. - +- -1 class Foo { } // should error -   ~~~ - @@ -29,46 +28,41 @@ - 1 /** @typedef {number} Foo */ -    ~~~ - 'Foo' was also declared here. - mod2.js:2:7 - error TS2451: Cannot redeclare block-scoped variable 'Bar'. - - 2 const Bar = 3; -    ~~~ - +-mod2.js:2:7 - error TS2451: Cannot redeclare block-scoped variable 'Bar'. +- +-2 const Bar = 3; +-   ~~~ +- - mod1.js:2:7 -+ mod1.js:2:7 - 'Bar' was also declared here. - 2 class Bar {} -    ~~~ +- 2 class Bar {} +-    ~~~ - 'Bar' was also declared here. - - +- +- -==== mod1.js (2 errors) ==== -+==== mod1.js (1 errors) ==== - /** @typedef {number} Foo */ +- /** @typedef {number} Foo */ - ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. -!!! related TS6203 mod2.js:1:7: 'Foo' was also declared here. - class Bar {} - ~~~ - !!! error TS2451: Cannot redeclare block-scoped variable 'Bar'. - !!! related TS6203 mod2.js:2:7: 'Bar' was also declared here. - +- class Bar {} +- ~~~ +-!!! error TS2451: Cannot redeclare block-scoped variable 'Bar'. +-!!! related TS6203 mod2.js:2:7: 'Bar' was also declared here. +- -==== mod2.js (2 errors) ==== -+==== mod2.js (1 errors) ==== - class Foo { } // should error +- class Foo { } // should error - ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. -!!! related TS6203 mod1.js:1:23: 'Foo' was also declared here. - const Bar = 3; - ~~~ - !!! error TS2451: Cannot redeclare block-scoped variable 'Bar'. - !!! related TS6203 mod1.js:2:7: 'Bar' was also declared here. - +- const Bar = 3; +- ~~~ +-!!! error TS2451: Cannot redeclare block-scoped variable 'Bar'. +-!!! related TS6203 mod1.js:2:7: 'Bar' was also declared here. +- -Found 4 errors in 2 files. -+Found 2 errors in 2 files. - - Errors Files +- +-Errors Files - 2 mod1.js:1 - 2 mod2.js:1 -+ 1 mod1.js:2 -+ 1 mod2.js:2 -+ +@@= skipped --1, +1 lines =@@ ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff index dff9383d64..afbdcbf1dc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff @@ -3,31 +3,50 @@ @@= skipped -0, +0 lines =@@ -a.js(12,23): error TS2344: Type '{ a: number; }' does not satisfy the constraint '{ a: number; b: string; }'. - Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. --a.js(15,12): error TS2314: Generic type 'Everything' requires 5 type argument(s). ++a.js(6,19): error TS2304: Cannot find name 'T'. ++a.js(6,25): error TS2304: Cannot find name 'U'. ++a.js(6,31): error TS2304: Cannot find name 'V'. ++a.js(6,37): error TS2304: Cannot find name 'W'. ++a.js(6,43): error TS2304: Cannot find name 'X'. ++a.js(12,23): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. + a.js(15,12): error TS2314: Generic type 'Everything' requires 5 type argument(s). -test.ts(1,34): error TS2344: Type '{ a: number; }' does not satisfy the constraint '{ a: number; b: string; }'. - Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. +test.ts(1,23): error TS2304: Cannot find name 'Everything'. -==== a.js (2 errors) ==== -+==== a.js (0 errors) ==== ++==== a.js (7 errors) ==== /** * @template {{ a: number, b: string }} T,U A Comment * @template {{ c: boolean }} V uh ... are comments even supported?? -@@= skipped -17, +13 lines =@@ - var tuvwx; + * @template W + * @template X That last one had no comment + * @typedef {{ t: T, u: U, v: V, w: W, x: X }} Everything ++ ~ ++!!! error TS2304: Cannot find name 'T'. ++ ~ ++!!! error TS2304: Cannot find name 'U'. ++ ~ ++!!! error TS2304: Cannot find name 'V'. ++ ~ ++!!! error TS2304: Cannot find name 'W'. ++ ~ ++!!! error TS2304: Cannot find name 'X'. + */ + + /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ +@@= skipped -18, +31 lines =@@ /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ -- ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ -!!! error TS2344: Type '{ a: number; }' does not satisfy the constraint '{ a: number; b: string; }'. -!!! error TS2344: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. --!!! related TS2728 a.js:2:28: 'b' is declared here. ++!!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. + !!! related TS2728 a.js:2:28: 'b' is declared here. var wrong; - /** @type {Everything<{ a: number }>} */ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS2314: Generic type 'Everything' requires 5 type argument(s). - var insufficient; +@@= skipped -12, +11 lines =@@ ==== test.ts (1 errors) ==== declare var actually: Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff index 4301003998..5daa7068b2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff @@ -5,12 +5,12 @@ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ var tuvwx; ->tuvwx : Everything<{ a: number; b: "hi"; c: never; }, undefined, { c: true; d: 1; }, number, string> -+>tuvwx : any ++>tuvwx : { t: T; u: U; v: V; w: W; x: X; } /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ var wrong; ->wrong : Everything<{ a: number; }, undefined, { c: 1; d: 1; }, number, string> -+>wrong : any ++>wrong : { t: T; u: U; v: V; w: W; x: X; } /** @type {Everything<{ a: number }>} */ var insufficient; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.errors.txt.diff deleted file mode 100644 index 3895c73bfa..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.errors.txt.diff +++ /dev/null @@ -1,71 +0,0 @@ ---- old.typedefOnStatements.errors.txt -+++ new.typedefOnStatements.errors.txt -@@= skipped -1, +1 lines =@@ - typedefOnStatements.js(31,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. - typedefOnStatements.js(33,1): error TS1101: 'with' statements are not allowed in strict mode. - typedefOnStatements.js(33,1): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'. -+typedefOnStatements.js(71,17): error TS7006: Parameter 'a' implicitly has an 'any' type. -+typedefOnStatements.js(71,19): error TS7006: Parameter 'b' implicitly has an 'any' type. -+typedefOnStatements.js(71,21): error TS7006: Parameter 'c' implicitly has an 'any' type. -+typedefOnStatements.js(71,23): error TS7006: Parameter 'd' implicitly has an 'any' type. -+typedefOnStatements.js(71,25): error TS7006: Parameter 'e' implicitly has an 'any' type. -+typedefOnStatements.js(71,27): error TS7006: Parameter 'f' implicitly has an 'any' type. -+typedefOnStatements.js(71,29): error TS7006: Parameter 'g' implicitly has an 'any' type. -+typedefOnStatements.js(71,31): error TS7006: Parameter 'h' implicitly has an 'any' type. -+typedefOnStatements.js(71,33): error TS7006: Parameter 'i' implicitly has an 'any' type. -+typedefOnStatements.js(71,35): error TS7006: Parameter 'j' implicitly has an 'any' type. -+typedefOnStatements.js(71,37): error TS7006: Parameter 'k' implicitly has an 'any' type. -+typedefOnStatements.js(71,39): error TS7006: Parameter 'l' implicitly has an 'any' type. -+typedefOnStatements.js(71,41): error TS7006: Parameter 'm' implicitly has an 'any' type. -+typedefOnStatements.js(71,43): error TS7006: Parameter 'n' implicitly has an 'any' type. -+typedefOnStatements.js(71,45): error TS7006: Parameter 'o' implicitly has an 'any' type. -+typedefOnStatements.js(71,47): error TS7006: Parameter 'p' implicitly has an 'any' type. -+typedefOnStatements.js(71,49): error TS7006: Parameter 'q' implicitly has an 'any' type. - - --==== typedefOnStatements.js (4 errors) ==== -+==== typedefOnStatements.js (21 errors) ==== - /** @typedef {{a: string}} A */ - ; - /** @typedef {{ b: string }} B */ -@@= skipped -82, +99 lines =@@ - * @param {Q} q - */ - function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) { -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'c' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'd' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'e' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'f' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'g' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'h' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'i' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'j' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'k' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'l' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'm' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'n' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'o' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'p' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'q' implicitly has an 'any' type. - console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) - /** @type {Alpha} */ - var alpha = { alpha: "aleph" } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.types.diff index 5d3701bc42..da23151f7e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.types.diff @@ -22,132 +22,97 @@ ->o : O ->p : P ->q : Q -+>proof : (a: any, b: any, c: any, d: any, e: any, f: any, g: any, h: any, i: any, j: any, k: any, l: any, m: any, n: any, o: any, p: any, q: any) => void -+>a : any -+>b : any -+>c : any -+>d : any -+>e : any -+>f : any -+>g : any -+>h : any -+>i : any -+>j : any -+>k : any -+>l : any -+>m : any -+>n : any -+>o : any -+>p : any -+>q : any ++>proof : (a: { a: string; }, b: { b: string; }, c: { c: string; }, d: { d: string; }, e: { e: string; }, f: { f: string; }, g: { g: string; }, h: { h: string; }, i: { i: string; }, j: { j: string; }, k: { k: string; }, l: { l: string; }, m: { m: string; }, n: { n: string; }, o: { o: string; }, p: { p: string; }, q: { q: string; }) => void ++>a : { a: string; } ++>b : { b: string; } ++>c : { c: string; } ++>d : { d: string; } ++>e : { e: string; } ++>f : { f: string; } ++>g : { g: string; } ++>h : { h: string; } ++>i : { i: string; } ++>j : { j: string; } ++>k : { k: string; } ++>l : { l: string; } ++>m : { m: string; } ++>n : { n: string; } ++>o : { o: string; } ++>p : { p: string; } ++>q : { q: string; } console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) >console.log(a.a, b.b, c.c, d.d, e.e, f.f, g.g, h.h, i.i, j.j, k.k, l.l, m.m, n.n, o.o, p.p, q.q) : void - >console.log : (...data: any[]) => void +@@= skipped -25, +25 lines =@@ >console : Console >log : (...data: any[]) => void -->a.a : string + >a.a : string ->a : A -->a : string -->b.b : string ++>a : { a: string; } + >a : string + >b.b : string ->b : B -->b : string -->c.c : string ++>b : { b: string; } + >b : string + >c.c : string ->c : C -->c : string -->d.d : string ++>c : { c: string; } + >c : string + >d.d : string ->d : D -->d : string -->e.e : string ++>d : { d: string; } + >d : string + >e.e : string ->e : E -->e : string -->f.f : string ++>e : { e: string; } + >e : string + >f.f : string ->f : F -->f : string -->g.g : string ++>f : { f: string; } + >f : string + >g.g : string ->g : G -->g : string -->h.h : string ++>g : { g: string; } + >g : string + >h.h : string ->h : H -->h : string -->i.i : string ++>h : { h: string; } + >h : string + >i.i : string ->i : I -->i : string -->j.j : string ++>i : { i: string; } + >i : string + >j.j : string ->j : J -->j : string -->k.k : string ++>j : { j: string; } + >j : string + >k.k : string ->k : K -->k : string -->l.l : string ++>k : { k: string; } + >k : string + >l.l : string ->l : L -->l : string -->m.m : string ++>l : { l: string; } + >l : string + >m.m : string ->m : M -->m : string -->n.n : string ++>m : { m: string; } + >m : string + >n.n : string ->n : N -->n : string -->o.o : string ++>n : { n: string; } + >n : string + >o.o : string ->o : O -->o : string -->p.p : string ++>o : { o: string; } + >o : string + >p.p : string ->p : P -->p : string -->q.q : string ++>p : { p: string; } + >p : string + >q.q : string ->q : Q -->q : string -+>a.a : any -+>a : any -+>a : any -+>b.b : any -+>b : any -+>b : any -+>c.c : any -+>c : any -+>c : any -+>d.d : any -+>d : any -+>d : any -+>e.e : any -+>e : any -+>e : any -+>f.f : any -+>f : any -+>f : any -+>g.g : any -+>g : any -+>g : any -+>h.h : any -+>h : any -+>h : any -+>i.i : any -+>i : any -+>i : any -+>j.j : any -+>j : any -+>j : any -+>k.k : any -+>k : any -+>k : any -+>l.l : any -+>l : any -+>l : any -+>m.m : any -+>m : any -+>m : any -+>n.n : any -+>n : any -+>n : any -+>o.o : any -+>o : any -+>o : any -+>p.p : any -+>p : any -+>p : any -+>q.q : any -+>q : any -+>q : any ++>q : { q: string; } + >q : string /** @type {Alpha} */ - var alpha = { alpha: "aleph" } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.errors.txt.diff deleted file mode 100644 index e138e63ed9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.typedefScope1.errors.txt -+++ new.typedefScope1.errors.txt -@@= skipped -0, +-1 lines =@@ --typedefScope1.js(13,12): error TS2304: Cannot find name 'B'. -- -- --==== typedefScope1.js (1 errors) ==== -- function B1() { -- /** @typedef {number} B */ -- /** @type {B} */ -- var ok1 = 0; -- } -- -- function B2() { -- /** @typedef {string} B */ -- /** @type {B} */ -- var ok2 = 'hi'; -- } -- -- /** @type {B} */ -- ~ --!!! error TS2304: Cannot find name 'B'. -- var notOK = 0; -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.types.diff deleted file mode 100644 index 90a72ae370..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.typedefScope1.types -+++ new.typedefScope1.types -@@= skipped -22, +22 lines =@@ - - /** @type {B} */ - var notOK = 0; -->notOK : B -+>notOK : number - >0 : 0 - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff index 676cf65d09..3e7d658ddd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff @@ -3,11 +3,16 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+typedefTagExtraneousProperty.js(8,3): error TS2339: Property 'ignoreMe' does not exist on type '{ bye: string; }'. ++typedefTagExtraneousProperty.js(1,15): error TS2315: Type 'Object' is not generic. ++typedefTagExtraneousProperty.js(1,21): error TS8020: JSDoc types can only be used inside documentation comments. + + -+==== typedefTagExtraneousProperty.js (1 errors) ==== ++==== typedefTagExtraneousProperty.js (2 errors) ==== + /** @typedef {Object.} Mmap ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS2315: Type 'Object' is not generic. ++ ~ ++!!! error TS8020: JSDoc types can only be used inside documentation comments. + * @property {string} ignoreMe - should be ignored + */ + @@ -15,7 +20,5 @@ + var y = { bye: "no" }; + y + y.ignoreMe = "ok but just because of the index signature" -+ ~~~~~~~~ -+!!! error TS2339: Property 'ignoreMe' does not exist on type '{ bye: string; }'. + y['hi'] = "yes" + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.types.diff index fbe92872ff..21465fddfd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.types.diff @@ -5,14 +5,14 @@ /** @type {Mmap} */ var y = { bye: "no" }; ->y : { [x: string]: string; } -+>y : { bye: string; } ++>y : any >{ bye: "no" } : { bye: string; } >bye : string >"no" : "no" y ->y : { [x: string]: string; } -+>y : { bye: string; } ++>y : any y.ignoreMe = "ok but just because of the index signature" >y.ignoreMe = "ok but just because of the index signature" : "ok but just because of the index signature" @@ -20,7 +20,7 @@ ->y : { [x: string]: string; } ->ignoreMe : string +>y.ignoreMe : any -+>y : { bye: string; } ++>y : any +>ignoreMe : any >"ok but just because of the index signature" : "ok but just because of the index signature" @@ -29,7 +29,7 @@ ->y['hi'] : string ->y : { [x: string]: string; } +>y['hi'] : any -+>y : { bye: string; } ++>y : any >'hi' : "hi" >"yes" : "yes" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.types.diff index dea71370e6..81d5a21222 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.types.diff @@ -1,51 +1,26 @@ --- old.typedefTagNested.types +++ new.typedefTagNested.types -@@= skipped -11, +11 lines =@@ - - /** @type {App} */ - const app = { -->app : App -+>app : { name: string; icons: { image32: string; image64: string; }; } - >{ name: 'name', icons: { image32: 'x.png', image64: 'y.png', }} : { name: string; icons: { image32: string; image64: string; }; } - - name: 'name', -@@= skipped -33, +33 lines =@@ - - /** @type {Opp} */ - var mistake; -->mistake : string -+>mistake : any - - /** @typedef {Object} Upp - * @property {string} name -@@= skipped -10, +10 lines =@@ - - /** @type {Upp} */ - var sala = { name: 'uppsala', not: 0, nested: "ok" }; -->sala : Upp -+>sala : { name: string; not: number; nested: string; } - >{ name: 'uppsala', not: 0, nested: "ok" } : { name: string; not: number; nested: string; } - >name : string - >'uppsala' : "uppsala" -@@= skipped -11, +11 lines =@@ +@@= skipped -64, +64 lines =@@ + >"ok" : "ok" sala.name - >sala.name : string -->sala : Upp -+>sala : { name: string; not: number; nested: string; } - >name : string +->sala.name : string ++>sala.name : any + >sala : Upp +->name : string ++>name : any sala.not ->sala.not : Object -->sala : Upp ++>sala.not : any + >sala : Upp ->not : Object -+>sala.not : number -+>sala : { name: string; not: number; nested: string; } -+>not : number ++>not : any sala.nested - >sala.nested : string -->sala : Upp -+>sala : { name: string; not: number; nested: string; } - >nested : string +->sala.nested : string ++>sala.nested : any + >sala : Upp +->nested : string ++>nested : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff index 0f73f88c40..b94f2d4579 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff @@ -1,42 +1,26 @@ --- old.typedefTagTypeResolution.errors.txt +++ new.typedefTagTypeResolution.errors.txt -@@= skipped -0, +-1 lines =@@ --github20832.js(2,15): error TS2304: Cannot find name 'U'. +@@= skipped -0, +0 lines =@@ + github20832.js(2,15): error TS2304: Cannot find name 'U'. -github20832.js(17,12): error TS2304: Cannot find name 'V'. -- -- --==== github20832.js (2 errors) ==== -- // #20832 -- /** @typedef {U} T - should be "error, can't find type named 'U' */ -- ~ --!!! error TS2304: Cannot find name 'U'. -- /** -- * @template U -- * @param {U} x -- * @return {T} -- */ -- function f(x) { -- return x; -- } -- -- /** @type T - should be fine, since T will be any */ -- const x = 3; -- -- /** -- * @callback Cb -- * @param {V} firstParam ++github20832.js(26,12): error TS2304: Cannot find name 'Cb'. + + + ==== github20832.js (2 errors) ==== +@@= skipped -21, +21 lines =@@ + /** + * @callback Cb + * @param {V} firstParam - ~ -!!! error TS2304: Cannot find name 'V'. -- */ -- /** -- * @template V -- * @param {V} vvvvv -- */ -- function g(vvvvv) { -- } -- -- /** @type {Cb} */ -- const cb = x => {} -- -@@= skipped --1, +1 lines =@@ -+ + */ + /** + * @template V +@@= skipped -11, +9 lines =@@ + } + + /** @type {Cb} */ ++ ~~ ++!!! error TS2304: Cannot find name 'Cb'. + const cb = x => {} + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.types.diff index c54c2f7fbe..f50bd4ca3f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.types.diff @@ -5,38 +5,16 @@ */ function f(x) { ->f : (x: U) => T -->x : U -+>f : (x: any) => any -+>x : any ++>f : (x: U) => U + >x : U return x; -->x : U -+>x : any - } - - /** @type T - should be fine, since T will be any */ - const x = 3; -->x : U -+>x : 3 - >3 : 3 - - /** -@@= skipped -21, +21 lines =@@ - * @param {V} vvvvv - */ - function g(vvvvv) { -->g : (vvvvv: V) => void -->vvvvv : V -+>g : (vvvvv: any) => void -+>vvvvv : any - } - +@@= skipped -28, +28 lines =@@ /** @type {Cb} */ const cb = x => {} -->cb : Cb + >cb : Cb ->x => {} : (x: V) => any ->x : V -+>cb : (x: any) => void +>x => {} : (x: any) => void +>x : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff index 128f3065bf..7d07fa40d3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff @@ -1,141 +1,101 @@ --- old.typedefTagWrapping.errors.txt +++ new.typedefTagWrapping.errors.txt -@@= skipped -0, +-1 lines =@@ +@@= skipped -0, +0 lines =@@ -mod7.js(5,7): error TS1110: Type expected. -mod7.js(8,4): error TS1110: Type expected. -- -- ++mod1.js(2,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++mod1.js(9,12): error TS2304: Cannot find name 'Type1'. ++mod3.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++mod3.js(10,12): error TS2304: Cannot find name 'StringOrNumber1'. ++mod4.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. + + -==== mod1.js (0 errors) ==== -- /** -- * @typedef {function(string): boolean} -- * Type1 -- */ -- -- /** -- * Tries to use a type whose name is on a different -- * line than the typedef tag. -- * @param {Type1} func The function to call. -- * @param {string} arg The argument to call it with. -- * @returns {boolean} The return. -- */ -- function callIt(func, arg) { -- return func(arg); -- } -- --==== mod2.js (0 errors) ==== -- /** -- * @typedef {{ -- * num: number, -- * str: string, -- * boo: boolean -- * }} Type2 -- */ -- -- /** -- * Makes use of a type with a multiline type expression. -- * @param {Type2} obj The object. -- * @returns {string|number} The return. -- */ -- function check(obj) { -- return obj.boo ? obj.num : obj.str; -- } -- ++==== mod1.js (2 errors) ==== + /** + * @typedef {function(string): boolean} ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + * Type1 + */ + +@@= skipped -11, +18 lines =@@ + * Tries to use a type whose name is on a different + * line than the typedef tag. + * @param {Type1} func The function to call. ++ ~~~~~ ++!!! error TS2304: Cannot find name 'Type1'. + * @param {string} arg The argument to call it with. + * @returns {boolean} The return. + */ +@@= skipped -25, +27 lines =@@ + return obj.boo ? obj.num : obj.str; + } + -==== mod3.js (0 errors) ==== -- /** -- * A function whose signature is very long. -- * -- * @typedef {function(boolean, string, number): -- * (string|number)} StringOrNumber1 -- */ -- -- /** -- * Makes use of a function type with a long signature. -- * @param {StringOrNumber1} func The function. -- * @param {boolean} bool The condition. -- * @param {string} str The string. -- * @param {number} num The number. -- * @returns {string|number} The return. -- */ -- function use1(func, bool, str, num) { -- return func(bool, str, num) -- } -- ++==== mod3.js (2 errors) ==== + /** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, number): ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + * (string|number)} StringOrNumber1 + */ + + /** + * Makes use of a function type with a long signature. + * @param {StringOrNumber1} func The function. ++ ~~~~~~~~~~~~~~~ ++!!! error TS2304: Cannot find name 'StringOrNumber1'. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. +@@= skipped -20, +25 lines =@@ + return func(bool, str, num) + } + -==== mod4.js (0 errors) ==== -- /** -- * A function whose signature is very long. -- * -- * @typedef {function(boolean, string, -- * number): -- * (string|number)} StringOrNumber2 -- */ -- -- /** -- * Makes use of a function type with a long signature. -- * @param {StringOrNumber2} func The function. -- * @param {boolean} bool The condition. -- * @param {string} str The string. -- * @param {number} num The number. -- * @returns {string|number} The return. -- */ -- function use2(func, bool, str, num) { -- return func(bool, str, num) -- } -- --==== mod5.js (0 errors) ==== -- /** -- * @typedef {{ -- * num: -- * number, -- * str: -- * string, -- * boo: -- * boolean -- * }} Type5 -- */ -- -- /** -- * Makes use of a type with a multiline type expression. -- * @param {Type5} obj The object. -- * @returns {string|number} The return. -- */ -- function check5(obj) { -- return obj.boo ? obj.num : obj.str; -- } -- --==== mod6.js (0 errors) ==== -- /** -- * @typedef {{ -- * foo: -- * *, -- * bar: -- * * -- * }} Type6 -- */ -- -- /** -- * Makes use of a type with a multiline type expression. -- * @param {Type6} obj The object. -- * @returns {*} The return. -- */ -- function check6(obj) { -- return obj.foo; -- } -- -- ++==== mod4.js (2 errors) ==== + /** + * A function whose signature is very long. + * + * @typedef {function(boolean, string, ++ ~~~~~~~~ ++!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + * number): + * (string|number)} StringOrNumber2 + */ +@@= skipped -12, +15 lines =@@ + /** + * Makes use of a function type with a long signature. + * @param {StringOrNumber2} func The function. ++ ~~~~~~~~~~~~~~~ ++!!! error TS2304: Cannot find name 'StringOrNumber2'. + * @param {boolean} bool The condition. + * @param {string} str The string. + * @param {number} num The number. +@@= skipped -50, +52 lines =@@ + } + + -==== mod7.js (2 errors) ==== -- /** -- Multiline type expressions in comments without leading * are not supported. -- @typedef {{ -- foo: -- *, ++==== mod7.js (0 errors) ==== + /** + Multiline type expressions in comments without leading * are not supported. + @typedef {{ + foo: + *, - ~ -!!! error TS1110: Type expected. -- bar: -- * -- }} Type7 + bar: + * + }} Type7 - ~ -!!! error TS1110: Type expected. -- */ -- -@@= skipped --1, +1 lines =@@ -+ + */ + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.types.diff index fe1baa88ac..931b092ec9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.types.diff @@ -1,163 +1,29 @@ --- old.typedefTagWrapping.types +++ new.typedefTagWrapping.types -@@= skipped -13, +13 lines =@@ - * @returns {boolean} The return. - */ - function callIt(func, arg) { -->callIt : (func: Type1, arg: string) => boolean -->func : Type1 -->arg : string -+>callIt : (func: any, arg: any) => any -+>func : any -+>arg : any +@@= skipped -18, +18 lines =@@ + >arg : string return func(arg); ->func(arg) : boolean -->func : Type1 -->arg : string +>func(arg) : any -+>func : any -+>arg : any + >func : Type1 + >arg : string } - - === mod2.js === -@@= skipped -25, +25 lines =@@ - * @returns {string|number} The return. - */ - function check(obj) { -->check : (obj: Type2) => string | number -->obj : Type2 -+>check : (obj: any) => any -+>obj : any - - return obj.boo ? obj.num : obj.str; -->obj.boo ? obj.num : obj.str : string | number -->obj.boo : boolean -->obj : Type2 -->boo : boolean -->obj.num : number -->obj : Type2 -->num : number -->obj.str : string -->obj : Type2 -->str : string -+>obj.boo ? obj.num : obj.str : any -+>obj.boo : any -+>obj : any -+>boo : any -+>obj.num : any -+>obj : any -+>num : any -+>obj.str : any -+>obj : any -+>str : any - } - - === mod3.js === -@@= skipped -33, +33 lines =@@ - * @returns {string|number} The return. - */ - function use1(func, bool, str, num) { -->use1 : (func: StringOrNumber1, bool: boolean, str: string, num: number) => string | number -->func : StringOrNumber1 -->bool : boolean -->str : string -->num : number -+>use1 : (func: any, bool: any, str: any, num: any) => any -+>func : any -+>bool : any -+>str : any -+>num : any +@@= skipped -60, +60 lines =@@ + >num : number return func(bool, str, num) ->func(bool, str, num) : string | number -->func : StringOrNumber1 -->bool : boolean -->str : string -->num : number +>func(bool, str, num) : any -+>func : any -+>bool : any -+>str : any -+>num : any - } - - === mod4.js === + >func : StringOrNumber1 + >bool : boolean + >str : string @@= skipped -32, +32 lines =@@ - * @returns {string|number} The return. - */ - function use2(func, bool, str, num) { -->use2 : (func: StringOrNumber2, bool: boolean, str: string, num: number) => string | number -->func : StringOrNumber2 -->bool : boolean -->str : string -->num : number -+>use2 : (func: any, bool: any, str: any, num: any) => any -+>func : any -+>bool : any -+>str : any -+>num : any + >num : number return func(bool, str, num) ->func(bool, str, num) : string | number -->func : StringOrNumber2 -->bool : boolean -->str : string -->num : number +>func(bool, str, num) : any -+>func : any -+>bool : any -+>str : any -+>num : any - } - - === mod5.js === -@@= skipped -32, +32 lines =@@ - * @returns {string|number} The return. - */ - function check5(obj) { -->check5 : (obj: Type5) => string | number -->obj : Type5 -+>check5 : (obj: any) => any -+>obj : any - - return obj.boo ? obj.num : obj.str; -->obj.boo ? obj.num : obj.str : string | number -->obj.boo : boolean -->obj : Type5 -->boo : boolean -->obj.num : number -->obj : Type5 -->num : number -->obj.str : string -->obj : Type5 -->str : string -+>obj.boo ? obj.num : obj.str : any -+>obj.boo : any -+>obj : any -+>boo : any -+>obj.num : any -+>obj : any -+>num : any -+>obj.str : any -+>obj : any -+>str : any - } - - === mod6.js === -@@= skipped -32, +32 lines =@@ - * @returns {*} The return. - */ - function check6(obj) { -->check6 : (obj: Type6) => any -->obj : Type6 -+>check6 : (obj: any) => any -+>obj : any - - return obj.foo; - >obj.foo : any -->obj : Type6 -+>obj : any - >foo : any - } - + >func : StringOrNumber2 + >bool : boolean + >str : string diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff new file mode 100644 index 0000000000..d9ecf89023 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff @@ -0,0 +1,42 @@ +--- old.uniqueSymbolsDeclarationsInJs.errors.txt ++++ new.uniqueSymbolsDeclarationsInJs.errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++uniqueSymbolsDeclarationsInJs.js(11,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. ++uniqueSymbolsDeclarationsInJs.js(16,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. ++ ++ ++==== uniqueSymbolsDeclarationsInJs.js (2 errors) ==== ++ // classes ++ class C { ++ /** ++ * @readonly ++ */ ++ static readonlyStaticCall = Symbol(); ++ /** ++ * @type {unique symbol} ++ * @readonly ++ */ ++ static readonlyStaticType; ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. ++ /** ++ * @type {unique symbol} ++ * @readonly ++ */ ++ static readonlyStaticTypeAndCall = Symbol(); ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. ++ static readwriteStaticCall = Symbol(); ++ ++ /** ++ * @readonly ++ */ ++ readonlyCall = Symbol(); ++ readwriteCall = Symbol(); ++ } ++ ++ /** @type {unique symbol} */ ++ const a = Symbol(); ++ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.types.diff index 7737d224db..8443abafa1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.types.diff @@ -16,7 +16,7 @@ */ static readonlyStaticType; ->readonlyStaticType : unique symbol -+>readonlyStaticType : any ++>readonlyStaticType : symbol /** * @type {unique symbol} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff index d3069a0b6d..83db4d5e84 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff @@ -1,30 +1,22 @@ --- old.uniqueSymbolsDeclarationsInJsErrors.errors.txt +++ new.uniqueSymbolsDeclarationsInJsErrors.errors.txt -@@= skipped -0, +-1 lines =@@ --uniqueSymbolsDeclarationsInJsErrors.js(5,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. --uniqueSymbolsDeclarationsInJsErrors.js(14,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -- -- +@@= skipped -0, +0 lines =@@ + uniqueSymbolsDeclarationsInJsErrors.js(5,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. ++uniqueSymbolsDeclarationsInJsErrors.js(10,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + uniqueSymbolsDeclarationsInJsErrors.js(14,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + + -==== uniqueSymbolsDeclarationsInJsErrors.js (2 errors) ==== -- class C { -- /** -- * @type {unique symbol} -- */ -- static readwriteStaticType; -- ~~~~~~~~~~~~~~~~~~~ --!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -- /** -- * @type {unique symbol} -- * @readonly -- */ -- static readonlyType; -- /** -- * @type {unique symbol} -- */ -- static readwriteType; -- ~~~~~~~~~~~~~ --!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -- } -- -@@= skipped --1, +1 lines =@@ -+ ++==== uniqueSymbolsDeclarationsInJsErrors.js (3 errors) ==== + class C { + /** + * @type {unique symbol} +@@= skipped -14, +15 lines =@@ + * @readonly + */ + static readonlyType; ++ ~~~~~~~~~~~~ ++!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + /** + * @type {unique symbol} + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.types.diff index 0a94059f83..e4b437654f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.types.diff @@ -1,25 +1,11 @@ --- old.uniqueSymbolsDeclarationsInJsErrors.types +++ new.uniqueSymbolsDeclarationsInJsErrors.types -@@= skipped -7, +7 lines =@@ - * @type {unique symbol} - */ - static readwriteStaticType; -->readwriteStaticType : symbol -+>readwriteStaticType : any - - /** - * @type {unique symbol} +@@= skipped -14, +14 lines =@@ * @readonly */ static readonlyType; ->readonlyType : unique symbol -+>readonlyType : any ++>readonlyType : symbol /** * @type {unique symbol} - */ - static readwriteType; -->readwriteType : symbol -+>readwriteType : any - } - diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff index d51bf398ed..69e845ec0f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff @@ -4,7 +4,7 @@ - @@= skipped --1, +1 lines =@@ +use.js(1,10): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+use.js(12,12): error TS7006: Parameter 'wrap' implicitly has an 'any' type. ++use.js(10,12): error TS2503: Cannot find namespace 'ex'. + + +==== use.js (2 errors) ==== @@ -20,10 +20,10 @@ + // types work + /** + * @param {ex.Crunch} wrap ++ ~~ ++!!! error TS2503: Cannot find namespace 'ex'. + */ + function f(wrap) { -+ ~~~~ -+!!! error TS7006: Parameter 'wrap' implicitly has an 'any' type. + wrap.n + } + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.types.diff index a64feb6d8f..b723fd3e3d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.types.diff @@ -41,8 +41,8 @@ function f(wrap) { ->f : (wrap: ex.Crunch) => void ->wrap : ex.Crunch -+>f : (wrap: any) => void -+>wrap : any ++>f : (wrap: Crunch) => void ++>wrap : Crunch wrap.n ->wrap.n : number @@ -63,7 +63,7 @@ ->this.n : any ->this : this +>wrap.n : any -+>wrap : any ++>wrap : Crunch >n : any ->n : number - } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff index 45e3dbced7..26a8cc3d72 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff @@ -4,8 +4,8 @@ - @@= skipped --1, +1 lines =@@ +use.js(1,10): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+use.js(13,12): error TS7006: Parameter 'greatest' implicitly has an 'any' type. -+use.js(13,22): error TS7006: Parameter 'wrap' implicitly has an 'any' type. ++use.js(10,12): error TS2503: Cannot find namespace 'ex'. ++use.js(11,12): error TS2503: Cannot find namespace 'ex'. + + +==== use.js (3 errors) ==== @@ -21,13 +21,13 @@ + // types work + /** + * @param {ex.Greatest} greatest ++ ~~ ++!!! error TS2503: Cannot find namespace 'ex'. + * @param {ex.Crunch} wrap ++ ~~ ++!!! error TS2503: Cannot find namespace 'ex'. + */ + function f(greatest, wrap) { -+ ~~~~~~~~ -+!!! error TS7006: Parameter 'greatest' implicitly has an 'any' type. -+ ~~~~ -+!!! error TS7006: Parameter 'wrap' implicitly has an 'any' type. + greatest.day + wrap.n + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.types.diff index e35dbdf8b4..93df86ffc7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.types.diff @@ -42,16 +42,16 @@ ->f : (greatest: ex.Greatest, wrap: ex.Crunch) => void ->greatest : ex.Greatest ->wrap : ex.Crunch -+>f : (greatest: any, wrap: any) => void -+>greatest : any -+>wrap : any ++>f : (greatest: Greatest, wrap: Crunch) => void ++>greatest : Greatest ++>wrap : Crunch greatest.day ->greatest.day : 1 ->greatest : ex.Greatest ->day : 1 +>greatest.day : any -+>greatest : any ++>greatest : Greatest +>day : any wrap.n @@ -59,7 +59,7 @@ ->wrap : ex.Crunch ->n : number +>wrap.n : any -+>wrap : any ++>wrap : Crunch +>n : any }