From 68c530218a5ef1530f61da1f73d1b2de73474896 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 00:10:20 +0000 Subject: [PATCH 01/31] Initial plan From e4b5e3cc42430d82eb65b92d955af06535f7a8b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 00:40:28 +0000 Subject: [PATCH 02/31] Add getJSSyntacticDiagnosticsForFile implementation and additionalSyntacticDiagnostics field Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ast/ast.go | 9 + internal/compiler/program.go | 367 +++++++++++++++++++++++++++++++++++ 2 files changed, 376 insertions(+) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 726796500a..b163ca4575 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -10048,6 +10048,7 @@ type SourceFile struct { // Fields set by parser diagnostics []*Diagnostic jsdocDiagnostics []*Diagnostic + additionalSyntacticDiagnostics []*Diagnostic LanguageVariant core.LanguageVariant ScriptKind core.ScriptKind IsDeclarationFile bool @@ -10146,6 +10147,14 @@ func (node *SourceFile) SetJSDocDiagnostics(diags []*Diagnostic) { node.jsdocDiagnostics = diags } +func (node *SourceFile) AdditionalSyntacticDiagnostics() []*Diagnostic { + return node.additionalSyntacticDiagnostics +} + +func (node *SourceFile) SetAdditionalSyntacticDiagnostics(diags []*Diagnostic) { + node.additionalSyntacticDiagnostics = diags +} + func (node *SourceFile) JSDocCache() map[*Node][]*Node { return node.jsdocCache } diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 41cc605594..86fa4479bc 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -367,9 +367,376 @@ func (p *Program) getOptionsDiagnosticsOfConfigFile() []*ast.Diagnostic { } func (p *Program) getSyntacticDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { + // For JavaScript files, we report semantic errors for using TypeScript-only + // constructs from within a JavaScript file as syntactic errors. + if ast.IsSourceFileJS(sourceFile) { + if sourceFile.AdditionalSyntacticDiagnostics() == nil { + sourceFile.SetAdditionalSyntacticDiagnostics(p.getJSSyntacticDiagnosticsForFile(ctx, sourceFile)) + } + return append(sourceFile.AdditionalSyntacticDiagnostics(), sourceFile.Diagnostics()...) + } return sourceFile.Diagnostics() } +func (p *Program) getJSSyntacticDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { + var diagnostics []*ast.Diagnostic + + // Walk the entire AST to find TypeScript-only constructs + p.walkNodeForJSDiagnostics(sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) + + return diagnostics +} + +func (p *Program) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node, diags *[]*ast.Diagnostic) { + if node == nil { + return + } + + // Handle specific parent-child relationships first + switch parent.Kind { + case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: + // Check for question token (optional markers) - only parameters have question tokens + if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } + fallthrough + case ast.KindMethodSignature, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, + ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindVariableDeclaration: + // Check for type annotations + if p.isTypeAnnotation(parent, node) { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check node-specific constructs + switch node.Kind { + case ast.KindImportClause: + if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { + *diags = append(*diags, p.createDiagnosticForNode(parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) + return + } + + case ast.KindExportDeclaration: + if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) + return + } + + case ast.KindImportSpecifier: + if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) + return + } + + case ast.KindExportSpecifier: + if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) + return + } + + case ast.KindImportEqualsDeclaration: + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) + return + + case ast.KindExportAssignment: + if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindHeritageClause: + if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == ast.KindImplementsKeyword { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindInterfaceDeclaration: + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) + return + + case ast.KindModuleDeclaration: + moduleKeyword := "module" + // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) + return + + case ast.KindTypeAliasDeclaration: + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) + return + + case ast.KindEnumDeclaration: + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) + return + + case ast.KindNonNullExpression: + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) + return + + case ast.KindAsExpression: + if node.AsAsExpression() != nil { + *diags = append(*diags, p.createDiagnosticForNode(node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindSatisfiesExpression: + if node.AsSatisfiesExpression() != nil { + *diags = append(*diags, p.createDiagnosticForNode(node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindConstructor, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: + // Check for signature declarations (functions without bodies) + if p.isSignatureDeclaration(node) { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check for type parameters, type arguments, and modifiers + p.checkTypeParametersAndModifiers(node, diags) + + // Recursively walk children + node.ForEachChild(func(child *ast.Node) bool { + p.walkNodeForJSDiagnostics(child, node, diags) + return false + }) +} + +func (p *Program) isTypeAnnotation(parent *ast.Node, node *ast.Node) bool { + switch parent.Kind { + case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction: + if parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node { + return true + } + if parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node { + return true + } + if parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node { + return true + } + case ast.KindMethodDeclaration, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindConstructor: + if parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node { + return true + } + if parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node { + return true + } + if parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node { + return true + } + if parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node { + return true + } + case ast.KindVariableDeclaration: + if parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node { + return true + } + case ast.KindParameter: + if parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node { + return true + } + case ast.KindPropertyDeclaration: + if parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node { + return true + } + } + return false +} + +func (p *Program) isSignatureDeclaration(node *ast.Node) bool { + switch node.Kind { + case ast.KindFunctionDeclaration: + return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil + case ast.KindMethodDeclaration: + return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil + case ast.KindConstructor: + return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil + } + return false +} + +func (p *Program) checkTypeParametersAndModifiers(node *ast.Node, diags *[]*ast.Diagnostic) { + // Check type parameters + if p.hasTypeParameters(node) { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) + } + + // Check type arguments + if p.hasTypeArguments(node) { + *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) + } + + // Check modifiers + p.checkModifiers(node, diags) +} + +func (p *Program) hasTypeParameters(node *ast.Node) bool { + switch node.Kind { + case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindMethodDeclaration, ast.KindConstructor, + ast.KindGetAccessor, ast.KindSetAccessor, ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction: + // Check if node has type parameters + if node.AsClassDeclaration() != nil && node.AsClassDeclaration().TypeParameters != nil { + return true + } + if node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().TypeParameters != nil { + return true + } + if node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().TypeParameters != nil { + return true + } + // Add other cases as needed + } + return false +} + +func (p *Program) hasTypeArguments(node *ast.Node) bool { + switch node.Kind { + case ast.KindCallExpression, ast.KindNewExpression, ast.KindExpressionWithTypeArguments, + ast.KindJsxSelfClosingElement, ast.KindJsxOpeningElement, ast.KindTaggedTemplateExpression: + // Check if node has type arguments + if node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil { + return true + } + if node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil { + return true + } + // Add other cases as needed + } + return false +} + +func (p *Program) checkModifiers(node *ast.Node, diags *[]*ast.Diagnostic) { + // Check for TypeScript-only modifiers on various declaration types + switch node.Kind { + case ast.KindVariableStatement: + if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { + p.checkModifierList(node.AsVariableStatement().Modifiers(), true, diags) + } + case ast.KindPropertyDeclaration: + if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { + p.checkPropertyModifiers(node.AsPropertyDeclaration().Modifiers(), diags) + } + case ast.KindParameter: + if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { + p.checkParameterModifiers(node.AsParameterDeclaration().Modifiers(), diags) + } + } +} + +func (p *Program) checkModifierList(modifiers *ast.ModifierList, isConstValid bool, diags *[]*ast.Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + p.checkModifier(modifier, isConstValid, diags) + } +} + +func (p *Program) checkPropertyModifiers(modifiers *ast.ModifierList, diags *[]*ast.Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Property modifiers allow static and accessor, but not other TypeScript modifiers + switch modifier.Kind { + case ast.KindStaticKeyword, ast.KindAccessorKeyword: + // These are valid in JavaScript + continue + default: + if p.isTypeScriptOnlyModifier(modifier) { + *diags = append(*diags, p.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, p.getTokenText(modifier))) + } + } + } +} + +func (p *Program) checkParameterModifiers(modifiers *ast.ModifierList, diags *[]*ast.Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + if p.isTypeScriptOnlyModifier(modifier) { + *diags = append(*diags, p.createDiagnosticForNode(modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) + } + } +} + +func (p *Program) checkModifier(modifier *ast.Node, isConstValid bool, diags *[]*ast.Diagnostic) { + switch modifier.Kind { + case ast.KindConstKeyword: + if !isConstValid { + *diags = append(*diags, p.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "const")) + } + case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, + ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: + *diags = append(*diags, p.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, p.getTokenText(modifier))) + case ast.KindStaticKeyword, ast.KindExportKeyword, ast.KindDefaultKeyword, ast.KindAccessorKeyword: + // These are valid in JavaScript + } +} + +func (p *Program) isTypeScriptOnlyModifier(modifier *ast.Node) bool { + switch modifier.Kind { + case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, + ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: + return true + } + return false +} + +func (p *Program) getTokenText(node *ast.Node) string { + switch node.Kind { + case ast.KindPublicKeyword: + return "public" + case ast.KindPrivateKeyword: + return "private" + case ast.KindProtectedKeyword: + return "protected" + case ast.KindReadonlyKeyword: + return "readonly" + case ast.KindDeclareKeyword: + return "declare" + case ast.KindAbstractKeyword: + return "abstract" + case ast.KindOverrideKeyword: + return "override" + case ast.KindInKeyword: + return "in" + case ast.KindOutKeyword: + return "out" + case ast.KindConstKeyword: + return "const" + case ast.KindStaticKeyword: + return "static" + case ast.KindAccessorKeyword: + return "accessor" + default: + return "" + } +} + +func (p *Program) createDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { + // Find the source file for this node + sourceFile := ast.GetSourceFileOfNode(node) + if sourceFile == nil { + // Fallback to empty range if we can't find the source file + return ast.NewDiagnostic(nil, core.TextRange{}, message, args...) + } + return ast.NewDiagnostic(sourceFile, p.getErrorRangeForNode(node), message, args...) +} + +func (p *Program) getErrorRangeForNode(node *ast.Node) core.TextRange { + if node == nil { + return core.TextRange{} + } + return core.NewTextRange(node.Pos(), node.End()) +} + func (p *Program) getBindDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { // TODO: restore this; tsgo's main depends on this function binding all files for timing. // if checker.SkipTypeChecking(sourceFile, p.compilerOptions) { From 194f1619012e6e9c25da416d2a10a9caad47dfca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 00:48:12 +0000 Subject: [PATCH 03/31] Fix AST node conversion issues and add comprehensive test case Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ast/ast.go | 44 +- internal/compiler/program.go | 152 +++--- .../jsSyntacticDiagnostics.errors.txt | 277 +++++++++++ .../compiler/jsSyntacticDiagnostics.symbols | 189 ++++++++ .../compiler/jsSyntacticDiagnostics.types | 207 ++++++++ ...ypeArgumentCount1(strict=false).errors.txt | 31 ++ ...ongBaseTypeArgumentCount1(strict=false).js | 29 -- ...TypeArgumentCount1(strict=true).errors.txt | 8 +- ...ypeArgumentCount2(strict=false).errors.txt | 34 ++ ...ongBaseTypeArgumentCount2(strict=false).js | 32 -- ...TypeArgumentCount2(strict=true).errors.txt | 8 +- ...structuringParameterDeclaration.errors.txt | 11 + .../conformance/jsdocParseAwait.errors.txt | 11 +- ...ForMultipleVariableDeclarations.errors.txt | 12 + .../ambientPropertyDeclarationInJs.errors.txt | 10 +- .../amdLikeInputDeclarationEmit.errors.txt | 5 +- ...argumentsObjectCreatesRestForJs.errors.txt | 5 +- ...mentsReferenceInConstructor1_Js.errors.txt | 20 + ...mentsReferenceInConstructor2_Js.errors.txt | 20 + ...mentsReferenceInConstructor3_Js.errors.txt | 33 ++ ...mentsReferenceInConstructor4_Js.errors.txt | 8 +- ...mentsReferenceInConstructor5_Js.errors.txt | 29 ++ .../argumentsReferenceInMethod1_Js.errors.txt | 18 + .../argumentsReferenceInMethod2_Js.errors.txt | 18 + .../argumentsReferenceInMethod3_Js.errors.txt | 29 ++ .../argumentsReferenceInMethod4_Js.errors.txt | 8 +- .../argumentsReferenceInMethod5_Js.errors.txt | 27 ++ .../arrowExpressionBodyJSDoc.errors.txt | 26 +- .../compiler/arrowExpressionJs.errors.txt | 21 + .../arrowFunctionJSDocAnnotation.errors.txt | 27 ++ ...kJsObjectLiteralHasCheckedKeyof.errors.txt | 5 +- ...eckJsTypeDefNoUnusedLocalMarked.errors.txt | 10 +- .../compiler/constructorPropertyJs.errors.txt | 15 + ...yTypedParametersOptionalInJSDoc.errors.txt | 26 +- ...nferenceFromAnnotatedFunctionJs.errors.txt | 37 +- ...ithAnnotatedOptionalParameterJs.errors.txt | 65 +++ .../compiler/controlFlowInstanceof.errors.txt | 5 +- ...peNode4(strictnullchecks=false).errors.txt | 97 ++++ ...ypeNode4(strictnullchecks=true).errors.txt | 97 ++++ ...eclarationEmitClassAccessorsJs1.errors.txt | 26 + ...itClassSetAccessorParamNameInJs.errors.txt | 17 + ...tClassSetAccessorParamNameInJs2.errors.txt | 15 + ...tClassSetAccessorParamNameInJs3.errors.txt | 15 + ...ationEmitLateBoundJSAssignments.errors.txt | 35 ++ ...onEmitObjectLiteralAccessorsJs1.errors.txt | 71 +++ .../compiler/decoratorInJsFile.errors.txt | 12 + .../compiler/decoratorInJsFile1.errors.txt | 12 + ...xpandoFunctionContextualTypesJs.errors.txt | 11 +- ...expandoFunctionSymbolPropertyJs.errors.txt | 24 + .../exportDefaultWithJSDoc2.errors.txt | 16 + ...dedUnicodePlaneIdentifiersJSDoc.errors.txt | 17 + ...ssingTypeArgsOnJSConstructCalls.errors.txt | 22 +- .../importTypeResolutionJSDocEOF.errors.txt | 15 + ...larationEmitDoesNotRenameImport.errors.txt | 35 ++ .../jsDeclarationsInheritedTypes.errors.txt | 43 ++ ...tUseNodeModulesPathWithoutError.errors.txt | 51 ++ .../compiler/jsEnumCrossFileExport.errors.txt | 11 +- .../jsEnumTagOnObjectFrozen.errors.txt | 13 +- ...berMergedWithModuleAugmentation.errors.txt | 5 +- .../compiler/jsExtendsImplicitAny.errors.txt | 5 +- ...FileAlternativeUseOfOverloadTag.errors.txt | 67 +++ .../jsFileAlternativeUseOfOverloadTag.js | 13 - .../jsFileAlternativeUseOfOverloadTag.js.diff | 15 +- ...FileCompilationAbstractModifier.errors.txt | 10 + ...tionAmbientVarDeclarationSyntax.errors.txt | 7 + ...lationConstructorOverloadSyntax.errors.txt | 11 + .../jsFileCompilationEnumSyntax.errors.txt | 7 + ...mpilationExportAssignmentSyntax.errors.txt | 7 + ...mpilationFunctionOverloadSyntax.errors.txt | 8 + ...tionHeritageClauseSyntaxOfClass.errors.txt | 7 + ...leCompilationImportEqualsSyntax.errors.txt | 7 + ...sFileCompilationInterfaceSyntax.errors.txt | 7 + ...CompilationMethodOverloadSyntax.errors.txt | 11 + .../jsFileCompilationModuleSyntax.errors.txt | 7 + ...FileCompilationNonNullAssertion.errors.txt | 8 + ...ileCompilationOptionalParameter.errors.txt | 7 + ...pilationPublicParameterModifier.errors.txt | 7 + ...ationReturnTypeSyntaxOfFunction.errors.txt | 7 + .../jsFileCompilationSyntaxError.errors.txt | 12 + ...sFileCompilationTypeAliasSyntax.errors.txt | 7 + .../jsFileCompilationTypeAliasSyntax.types | 2 +- ...jsFileCompilationTypeAssertions.errors.txt | 5 +- ...sFileCompilationTypeOfParameter.errors.txt | 7 + ...ationTypeParameterSyntaxOfClass.errors.txt | 7 + ...arameterSyntaxOfClassExpression.errors.txt | 8 + ...onTypeParameterSyntaxOfFunction.errors.txt | 7 + ...sFileCompilationTypeSyntaxOfVar.errors.txt | 7 + .../jsFileFunctionOverloads.errors.txt | 106 +++++ .../jsFileFunctionOverloads2.errors.txt | 101 ++++ .../compiler/jsFileFunctionOverloads2.js | 26 - .../compiler/jsFileFunctionOverloads2.js.diff | 28 +- .../jsFileImportPreservedWhenUsed.errors.txt | 35 ++ .../compiler/jsFileMethodOverloads.errors.txt | 126 +++++ .../jsFileMethodOverloads2.errors.txt | 120 +++++ .../jsFileMethodOverloads3.errors.txt | 14 +- .../jsFileMethodOverloads5.errors.txt | 37 ++ .../compiler/jsdocAccessEnumType.errors.txt | 13 + ...ocArrayObjectPromiseImplicitAny.errors.txt | 38 +- ...ArrayObjectPromiseNoImplicitAny.errors.txt | 38 +- .../jsdocBracelessTypeTag1.errors.txt | 8 +- .../compiler/jsdocCallbackAndType.errors.txt | 5 +- .../jsdocClassMissingTypeArguments.errors.txt | 9 +- ...ctionClassPropertiesDeclaration.errors.txt | 8 +- .../jsdocFunctionTypeFalsePositive.errors.txt | 5 +- .../compiler/jsdocIllegalTags.errors.txt | 10 +- .../jsdocImportTypeNodeNamespace.errors.txt | 5 +- .../jsdocImportTypeResolution.errors.txt | 16 + ...ocParamTagOnPropertyInitializer.errors.txt | 11 + ...docParameterParsingInfiniteLoop.errors.txt | 5 +- .../jsdocPropertyTagInvalid.errors.txt | 5 +- ...ocReferenceGlobalTypeInCommonJs.errors.txt | 5 +- ...sdocResolveNameFailureInTypedef.errors.txt | 5 +- .../compiler/jsdocRestParameter.errors.txt | 5 +- .../jsdocRestParameter_es6.errors.txt | 11 + .../compiler/jsdocTypeCast.errors.txt | 17 +- ...TypeGenericInstantiationAttempt.errors.txt | 13 + ...eNongenericInstantiationAttempt.errors.txt | 40 +- ...efBeforeParenthesizedExpression.errors.txt | 26 + .../jsdocTypedefMissingType.errors.txt | 20 + .../compiler/jsdocTypedefNoCrash2.errors.txt | 12 + ...jsdocTypedef_propertyWithNoType.errors.txt | 14 + .../compiler/modulePreserve4.errors.txt | 6 +- ...sizedJSDocCastAtReturnStatement.errors.txt | 28 ++ ...nthesizedJSDocCastDoesNotNarrow.errors.txt | 5 +- .../requireOfJsonFileInJsFile.errors.txt | 8 +- ...nConditionalExpressionJSDocCast.errors.txt | 30 ++ .../strictOptionalProperties3.errors.txt | 8 +- .../strictOptionalProperties4.errors.txt | 20 + .../subclassThisTypeAssignable01.errors.txt | 5 +- .../subclassThisTypeAssignable02.errors.txt | 38 ++ ...signmentInNamespaceDeclaration1.errors.txt | 14 +- .../compiler/thisInFunctionCallJs.errors.txt | 8 +- .../compiler/topLevelBlockExpando.errors.txt | 47 ++ .../compiler/unicodeEscapesInJSDoc.errors.txt | 31 ++ .../compiler/uniqueSymbolJs.errors.txt | 8 +- ...nusedTypeParameters_templateTag.errors.txt | 6 +- ...usedTypeParameters_templateTag2.errors.txt | 39 +- ...PropertyInitializerDoesntNarrow.errors.txt | 23 + .../assertionTypePredicates2.errors.txt | 14 +- ...ertionsAndNonReturningFunctions.errors.txt | 23 +- .../asyncArrowFunction_allowJs.errors.txt | 17 +- .../asyncFunctionDeclaration16_es5.errors.txt | 32 +- .../callbackCrossModule.errors.txt | 10 +- .../callbackOnConstructor.errors.txt | 8 +- .../conformance/callbackTag1.errors.txt | 33 ++ .../conformance/callbackTag2.errors.txt | 26 +- .../conformance/callbackTag3.errors.txt | 13 + .../conformance/callbackTag4.errors.txt | 29 ++ .../callbackTagNamespace.errors.txt | 21 + .../callbackTagNestedParameter.errors.txt | 31 ++ .../callbackTagVariadicType.errors.txt | 8 +- .../chainedPrototypeAssignment.errors.txt | 5 +- ...heckExportsObjectAssignProperty.errors.txt | 18 +- ...tsObjectAssignPrototypeProperty.errors.txt | 8 +- .../checkJsdocOptionalParamOrder.errors.txt | 15 +- ...iableDeclaredFunctionExpression.errors.txt | 36 ++ .../checkJsdocParamTag1.errors.txt | 26 + .../checkJsdocReturnTag1.errors.txt | 11 +- .../checkJsdocReturnTag2.errors.txt | 8 +- .../checkJsdocSatisfiesTag1.errors.txt | 35 +- .../checkJsdocSatisfiesTag10.errors.txt | 5 +- .../checkJsdocSatisfiesTag11.errors.txt | 27 ++ .../checkJsdocSatisfiesTag14.errors.txt | 17 + .../checkJsdocSatisfiesTag2.errors.txt | 8 +- .../checkJsdocSatisfiesTag3.errors.txt | 11 +- .../checkJsdocSatisfiesTag4.errors.txt | 12 +- .../checkJsdocSatisfiesTag5.errors.txt | 19 + .../checkJsdocSatisfiesTag6.errors.txt | 5 +- .../checkJsdocSatisfiesTag7.errors.txt | 5 +- .../checkJsdocSatisfiesTag8.errors.txt | 5 +- .../checkJsdocSatisfiesTag9.errors.txt | 5 +- .../conformance/checkJsdocTypeTag1.errors.txt | 32 +- .../conformance/checkJsdocTypeTag2.errors.txt | 23 +- .../conformance/checkJsdocTypeTag3.errors.txt | 9 + .../conformance/checkJsdocTypeTag4.errors.txt | 8 +- .../conformance/checkJsdocTypeTag5.errors.txt | 29 +- .../conformance/checkJsdocTypeTag6.errors.txt | 11 +- .../conformance/checkJsdocTypeTag7.errors.txt | 21 + .../conformance/checkJsdocTypeTag8.errors.txt | 5 +- ...ckJsdocTypeTagOnObjectProperty2.errors.txt | 8 +- .../checkJsdocTypedefInParamTag1.errors.txt | 55 +++ ...checkJsdocTypedefOnlySourceFile.errors.txt | 5 +- .../checkObjectDefineProperty.errors.txt | 23 +- .../checkOtherObjectAssignProperty.errors.txt | 8 +- ...checkSpecialPropertyAssignments.errors.txt | 8 +- ...assCanExtendConstructorFunction.errors.txt | 28 +- .../commonJSAliasedExport.errors.txt | 5 +- ...ommonJSImportClassTypeReference.errors.txt | 5 +- ...JSImportExportedClassExpression.errors.txt | 5 +- ...SImportNestedClassTypeReference.errors.txt | 5 +- ...torFunctionMethodTypeParameters.errors.txt | 35 +- .../constructorFunctions.errors.txt | 5 +- .../constructorFunctionsStrict.errors.txt | 8 +- .../constructorTagWithThisTag.errors.txt | 15 + .../contextualTypeFromJSDoc.errors.txt | 36 ++ ...ontextualTypedSpecialAssignment.errors.txt | 10 +- ...meterDeclaration9(strict=false).errors.txt | 60 +++ ...ameterDeclaration9(strict=true).errors.txt | 16 +- .../submodule/conformance/enumTag.errors.txt | 26 +- .../conformance/enumTagImported.errors.txt | 13 +- .../enumTagUseBeforeDefCrash.errors.txt | 5 +- .../errorOnFunctionReturnType.errors.txt | 8 +- ...classDeclaration-exportModifier.errors.txt | 37 ++ .../conformance/exportNamespace_js.errors.txt | 5 +- .../exportNestedNamespaces.errors.txt | 8 +- .../exportSpecifiers_js.errors.txt | 9 + .../exportedEnumTypeAndValue.errors.txt | 5 +- .../conformance/extendsTag1.errors.txt | 19 + .../conformance/extendsTag5.errors.txt | 37 +- .../genericSetterInClassTypeJsDoc.errors.txt | 51 ++ .../conformance/grammarErrors.errors.txt | 9 +- .../importSpecifiers_js.errors.txt | 11 + .../conformance/importTag1.errors.txt | 23 + .../conformance/importTag11.errors.txt | 10 + .../conformance/importTag12.errors.txt | 10 + .../conformance/importTag13.errors.txt | 5 +- .../conformance/importTag14.errors.txt | 5 +- .../importTag15(module=es2015).errors.txt | 11 +- .../importTag15(module=esnext).errors.txt | 11 +- .../conformance/importTag16.errors.txt | 24 + .../submodule/conformance/importTag16.js | 25 - .../submodule/conformance/importTag16.js.diff | 27 +- .../conformance/importTag17.errors.txt | 14 +- .../conformance/importTag18.errors.txt | 25 + .../conformance/importTag19.errors.txt | 23 + .../conformance/importTag2.errors.txt | 23 + .../conformance/importTag20.errors.txt | 25 + .../conformance/importTag21.errors.txt | 37 ++ .../conformance/importTag23.errors.txt | 8 +- .../conformance/importTag3.errors.txt | 23 + .../conformance/importTag4.errors.txt | 11 +- .../conformance/importTag5.errors.txt | 23 + .../conformance/importTag6.errors.txt | 36 ++ .../conformance/importTag7.errors.txt | 34 ++ .../conformance/importTag8.errors.txt | 34 ++ .../conformance/importTag9.errors.txt | 34 ++ .../conformance/importTypeInJSDoc.errors.txt | 36 ++ .../conformance/inferThis.errors.txt | 65 +++ ...ypeParameterOnVariableStatement.errors.txt | 28 ++ .../jsDeclarationsClassAccessor.errors.txt | 44 ++ ...ImplementsGenericsSerialization.errors.txt | 45 ++ .../jsDeclarationsClassMethod.errors.txt | 11 +- .../jsDeclarationsClasses.errors.txt | 438 +++++++++++++++++ .../jsDeclarationsClassesErr.errors.txt | 145 ++++++ .../jsDeclarationsComputedNames.errors.txt | 32 ++ .../jsDeclarationsDefault.errors.txt | 46 ++ .../conformance/jsDeclarationsDefault.js | 76 --- .../conformance/jsDeclarationsDefault.js.diff | 78 +-- .../jsDeclarationsEnumTag.errors.txt | 26 +- .../jsDeclarationsEnums.errors.txt | 154 ++++++ ...nsExportAssignedClassExpression.errors.txt | 14 + ...clarationsExportAssignedClassExpression.js | 16 - ...tionsExportAssignedClassExpression.js.diff | 18 +- ...ssignedClassExpressionAnonymous.errors.txt | 14 + ...sExportAssignedClassExpressionAnonymous.js | 16 - ...rtAssignedClassExpressionAnonymous.js.diff | 18 +- ...ClassExpressionAnonymousWithSub.errors.txt | 5 +- ...rationsExportDefinePropertyEmit.errors.txt | 64 ++- .../jsDeclarationsExportFormsErr.errors.txt | 9 +- ...ctionClassesCjsExportAssignment.errors.txt | 27 +- .../jsDeclarationsFunctionJSDoc.errors.txt | 53 +++ ...DeclarationsFunctionLikeClasses.errors.txt | 13 +- ...eclarationsFunctionLikeClasses2.errors.txt | 20 +- ...arationsFunctionPrototypeStatic.errors.txt | 5 +- .../jsDeclarationsFunctions.errors.txt | 63 ++- .../jsDeclarationsFunctionsCjs.errors.txt | 20 +- .../jsDeclarationsGetterSetter.errors.txt | 157 ++++++ ...portAliasExposedWithinNamespace.errors.txt | 16 +- ...tAliasExposedWithinNamespaceCjs.errors.txt | 16 +- ...eclarationsImportNamespacedType.errors.txt | 5 +- .../jsDeclarationsInterfaces.errors.txt | 310 ++++++++++++ ...larationsJSDocRedirectedLookups.errors.txt | 55 ++- .../jsDeclarationsMissingGenerics.errors.txt | 17 + .../jsDeclarationsMissingGenerics.js | 23 - .../jsDeclarationsMissingGenerics.js.diff | 25 +- ...clarationsMissingTypeParameters.errors.txt | 15 +- ...larationsModuleReferenceHasEmit.errors.txt | 5 +- .../jsDeclarationsNestedParams.errors.txt | 20 +- ...ationsOptionalTypeLiteralProps1.errors.txt | 20 + ...ationsOptionalTypeLiteralProps2.errors.txt | 5 +- ...ameterTagReusesInputNodeInEmit1.errors.txt | 11 +- ...ameterTagReusesInputNodeInEmit2.errors.txt | 8 +- .../jsDeclarationsPrivateFields01.errors.txt | 27 ++ .../jsDeclarationsReactComponents.errors.txt | 102 ++++ .../jsDeclarationsReactComponents.js | 74 --- .../jsDeclarationsReactComponents.js.diff | 76 +-- ...sDeclarationsReexportedCjsAlias.errors.txt | 30 ++ ...ferenceToClassInstanceCrossFile.errors.txt | 5 +- ...sExistingNodesMappingJSDocTypes.errors.txt | 26 +- ...nsReusesExistingTypeAnnotations.errors.txt | 44 +- ...thExplicitNoArgumentConstructor.errors.txt | 22 + .../jsDeclarationsThisTypes.errors.txt | 16 + .../jsDeclarationsTypeAliases.errors.txt | 16 +- ...TypeReassignmentFromDeclaration.errors.txt | 15 + ...arationsTypeReassignmentFromDeclaration.js | 19 - ...onsTypeReassignmentFromDeclaration.js.diff | 21 +- .../jsDeclarationsTypeReferences4.errors.txt | 33 ++ ...clarationsTypedefAndImportTypes.errors.txt | 5 +- ...DeclarationsTypedefAndLatebound.errors.txt | 10 +- .../jsDeclarationsTypedefFunction.errors.txt | 27 ++ ...edefPropertyAndExportAssignment.errors.txt | 16 +- ...jsDeclarationsUniqueSymbolUsage.errors.txt | 23 + .../jsdocAccessibilityTags.errors.txt | 14 +- ...jsdocAugments_withTypeParameter.errors.txt | 16 + .../jsdocBindingInUnreachableCode.errors.txt | 14 + ...ocCatchClauseWithTypeAnnotation.errors.txt | 65 ++- ...onstructorFunctionTypeReference.errors.txt | 5 +- .../conformance/jsdocFunctionType.errors.txt | 23 +- .../conformance/jsdocImplementsTag.errors.txt | 17 + .../jsdocImplements_class.errors.txt | 17 +- .../jsdocImplements_interface.errors.txt | 11 +- ...ocImplements_interface_multiple.errors.txt | 8 +- .../jsdocImplements_missingType.errors.txt | 11 + .../jsdocImplements_missingType.js | 18 - .../jsdocImplements_missingType.js.diff | 20 +- ...cImplements_namespacedInterface.errors.txt | 31 ++ .../jsdocImplements_properties.errors.txt | 11 +- .../jsdocImplements_signatures.errors.txt | 5 +- .../conformance/jsdocImportType.errors.txt | 33 ++ .../conformance/jsdocImportType2.errors.txt | 32 ++ ...ImportTypeReferenceToClassAlias.errors.txt | 5 +- ...rtTypeReferenceToCommonjsModule.errors.txt | 5 +- ...ocImportTypeReferenceToESModule.errors.txt | 5 +- ...ortTypeReferenceToStringLiteral.errors.txt | 5 +- .../jsdocIndexSignature.errors.txt | 14 +- .../conformance/jsdocLiteral.errors.txt | 29 ++ .../jsdocNeverUndefinedNull.errors.txt | 24 + .../jsdocOuterTypeParameters1.errors.txt | 5 +- .../jsdocOuterTypeParameters2.errors.txt | 5 +- .../conformance/jsdocOverrideTag1.errors.txt | 14 +- .../conformance/jsdocParamTag2.errors.txt | 69 ++- .../jsdocParamTagTypeLiteral.errors.txt | 37 +- .../jsdocParseBackquotedParamName.errors.txt | 12 +- ...ocParseDotDotDotInJSDocFunction.errors.txt | 5 +- .../jsdocParseHigherOrderFunction.errors.txt | 5 +- .../jsdocParseMatchingBackticks.errors.txt | 36 ++ ...arseParenthesizedJSDocParameter.errors.txt | 5 +- .../jsdocParseStarEquals.errors.txt | 15 +- ...docPostfixEqualsAddsOptionality.errors.txt | 14 +- .../jsdocPrefixPostfixParsing.errors.txt | 38 +- .../conformance/jsdocPrivateName1.errors.txt | 5 +- .../conformance/jsdocReadonly.errors.txt | 19 +- .../jsdocReadonlyDeclarations.errors.txt | 5 +- .../conformance/jsdocReturnTag1.errors.txt | 33 ++ ...sdocSignatureOnReturnedFunction.errors.txt | 63 +++ .../conformance/jsdocTemplateClass.errors.txt | 47 +- ...sdocTemplateConstructorFunction.errors.txt | 49 ++ ...docTemplateConstructorFunction2.errors.txt | 22 +- .../conformance/jsdocTemplateTag.errors.txt | 32 +- .../conformance/jsdocTemplateTag2.errors.txt | 25 + .../conformance/jsdocTemplateTag3.errors.txt | 53 ++- .../conformance/jsdocTemplateTag4.errors.txt | 20 +- .../conformance/jsdocTemplateTag5.errors.txt | 38 +- .../conformance/jsdocTemplateTag6.errors.txt | 235 +++++++++ .../conformance/jsdocTemplateTag7.errors.txt | 31 +- .../conformance/jsdocTemplateTag8.errors.txt | 38 +- .../jsdocTemplateTagDefault.errors.txt | 93 +++- .../jsdocTemplateTagNameResolution.errors.txt | 5 +- .../conformance/jsdocThisType.errors.txt | 11 +- .../jsdocTypeDefAtStartOfFile.errors.txt | 13 +- .../jsdocTypeReferenceExports.errors.txt | 5 +- .../jsdocTypeReferenceToImport.errors.txt | 8 +- ...erenceToImportOfClassExpression.errors.txt | 5 +- ...nceToImportOfFunctionExpression.errors.txt | 10 +- ...jsdocTypeReferenceToMergedClass.errors.txt | 5 +- .../jsdocTypeReferenceToValue.errors.txt | 5 +- .../jsdocTypeReferenceUseBeforeDef.errors.txt | 11 + .../conformance/jsdocTypeTag.errors.txt | 74 ++- .../conformance/jsdocTypeTagCast.errors.txt | 65 ++- .../jsdocTypeTagParameterType.errors.txt | 5 +- .../jsdocTypeTagRequiredParameters.errors.txt | 5 +- ...leDeclarationWithTypeAnnotation.errors.txt | 13 + .../conformance/jsdocVariadicType.errors.txt | 5 +- .../conformance/linkTagEmit1.errors.txt | 31 ++ .../conformance/malformedTags.errors.txt | 13 + .../moduleExportAssignment.errors.txt | 5 +- .../moduleExportAssignment6.errors.txt | 33 ++ .../moduleExportAssignment7.errors.txt | 44 +- .../moduleExportNestedNamespaces.errors.txt | 8 +- ...ExportsElementAccessAssignment2.errors.txt | 29 ++ ...eModulesAllowJs1(module=node16).errors.txt | 144 +++++- ...eModulesAllowJs1(module=node18).errors.txt | 144 +++++- ...odulesAllowJs1(module=nodenext).errors.txt | 144 +++++- ...ExportAssignment(module=node16).errors.txt | 12 +- ...ExportAssignment(module=node18).errors.txt | 12 +- ...portAssignment(module=nodenext).errors.txt | 12 +- ...ImportAssignment(module=node16).errors.txt | 55 +++ ...ImportAssignment(module=node18).errors.txt | 55 +++ ...portAssignment(module=nodenext).errors.txt | 55 +++ ...ronousCallErrors(module=node16).errors.txt | 20 +- ...ronousCallErrors(module=node18).errors.txt | 20 +- ...nousCallErrors(module=nodenext).errors.txt | 50 ++ .../optionalBindingParameters3.errors.txt | 8 +- .../optionalBindingParameters4.errors.txt | 13 + .../conformance/overloadTag1.errors.txt | 23 +- .../conformance/overloadTag2.errors.txt | 14 +- .../conformance/overloadTag3.errors.txt | 49 ++ ...TagBracketsAddOptionalUndefined.errors.txt | 39 ++ ...TagNestedWithoutTopLevelObject3.errors.txt | 5 +- .../paramTagTypeResolution2.errors.txt | 28 ++ .../conformance/paramTagWrapping.errors.txt | 11 +- ...parserArrowFunctionExpression10.errors.txt | 5 +- ...parserArrowFunctionExpression13.errors.txt | 5 +- ...parserArrowFunctionExpression14.errors.txt | 14 +- ...parserArrowFunctionExpression15.errors.txt | 11 + ...parserArrowFunctionExpression16.errors.txt | 11 + ...parserArrowFunctionExpression17.errors.txt | 5 +- ...ateNamesIncompatibleModifiersJs.errors.txt | 14 +- ...esOfGenericConstructorFunctions.errors.txt | 68 ++- ...ropertyAssignmentUseParentType2.errors.txt | 11 +- ...ertyAssignmentMergeAcrossFiles2.errors.txt | 8 +- ...tyAssignmentMergedTypeReference.errors.txt | 5 +- .../recursiveTypeReferences2.errors.txt | 8 +- .../conformance/returnTagTypeGuard.errors.txt | 94 ++++ .../conformance/syntaxErrors.errors.txt | 18 + .../templateInsideCallback.errors.txt | 29 +- ...thisPropertyAssignmentInherited.errors.txt | 25 + .../submodule/conformance/thisTag1.errors.txt | 26 + .../submodule/conformance/thisTag2.errors.txt | 15 + .../submodule/conformance/thisTag2.js | 16 - .../submodule/conformance/thisTag2.js.diff | 18 +- .../submodule/conformance/thisTag3.errors.txt | 11 +- .../thisTypeOfConstructorFunctions.errors.txt | 46 +- .../typeFromContextualThisType.errors.txt | 8 +- .../typeFromJSInitializer.errors.txt | 8 +- .../typeFromJSInitializer4.errors.txt | 5 +- .../typeFromParamTagForFunction.errors.txt | 40 +- ...FromPrivatePropertyAssignmentJs.errors.txt | 22 + .../typeFromPropertyAssignment.errors.txt | 8 +- .../typeFromPropertyAssignment10.errors.txt | 5 +- .../typeFromPropertyAssignment10_1.errors.txt | 5 +- .../typeFromPropertyAssignment14.errors.txt | 5 +- .../typeFromPropertyAssignment15.errors.txt | 5 +- .../typeFromPropertyAssignment16.errors.txt | 5 +- .../typeFromPropertyAssignment2.errors.txt | 8 +- .../typeFromPropertyAssignment24.errors.txt | 5 +- .../typeFromPropertyAssignment3.errors.txt | 8 +- .../typeFromPropertyAssignment35.errors.txt | 5 +- .../typeFromPropertyAssignment4.errors.txt | 10 +- .../typeFromPropertyAssignment40.errors.txt | 5 +- .../typeFromPropertyAssignment5.errors.txt | 5 +- .../typeFromPropertyAssignment6.errors.txt | 5 +- ...romPropertyAssignmentOutOfOrder.errors.txt | 5 +- .../typeFromPrototypeAssignment3.errors.txt | 11 +- .../typeFromPrototypeAssignment4.errors.txt | 33 ++ .../conformance/typeLookupInIIFE.errors.txt | 5 +- .../typeSatisfaction_js.errors.txt | 8 + .../conformance/typeTagNoErasure.errors.txt | 8 +- ...eTagOnFunctionReferencesGeneric.errors.txt | 25 + .../conformance/typedefCrossModule.errors.txt | 11 +- .../typedefCrossModule2.errors.txt | 8 +- .../typedefMultipleTypeParameters.errors.txt | 11 +- .../typedefOnSemicolonClassElement.errors.txt | 13 + .../typedefOnSemicolonClassElement.js | 23 - .../typedefOnSemicolonClassElement.js.diff | 25 +- .../typedefOnStatements.errors.txt | 56 ++- .../conformance/typedefScope1.errors.txt | 11 +- .../typedefTagExtraneousProperty.errors.txt | 5 +- .../conformance/typedefTagNested.errors.txt | 52 ++ .../typedefTagTypeResolution.errors.txt | 46 +- .../conformance/typedefTagWrapping.errors.txt | 69 ++- .../uniqueSymbolsDeclarationsInJs.errors.txt | 56 +++ ...ueSymbolsDeclarationsInJsErrors.errors.txt | 15 +- .../varRequireFromJavascript.errors.txt | 35 ++ .../varRequireFromTypescript.errors.txt | 34 ++ ...entPropertyDeclarationInJs.errors.txt.diff | 22 +- ...mdLikeInputDeclarationEmit.errors.txt.diff | 5 +- ...entsObjectCreatesRestForJs.errors.txt.diff | 5 +- ...ReferenceInConstructor1_Js.errors.txt.diff | 24 + ...ReferenceInConstructor2_Js.errors.txt.diff | 24 + ...ReferenceInConstructor3_Js.errors.txt.diff | 37 ++ ...ReferenceInConstructor4_Js.errors.txt.diff | 29 ++ ...ReferenceInConstructor5_Js.errors.txt.diff | 33 ++ ...mentsReferenceInMethod1_Js.errors.txt.diff | 22 + ...mentsReferenceInMethod2_Js.errors.txt.diff | 22 + ...mentsReferenceInMethod3_Js.errors.txt.diff | 33 ++ ...mentsReferenceInMethod4_Js.errors.txt.diff | 27 ++ ...mentsReferenceInMethod5_Js.errors.txt.diff | 31 ++ .../arrowExpressionBodyJSDoc.errors.txt.diff | 48 +- .../arrowExpressionJs.errors.txt.diff | 25 + ...rowFunctionJSDocAnnotation.errors.txt.diff | 31 ++ ...jectLiteralHasCheckedKeyof.errors.txt.diff | 21 + ...TypeDefNoUnusedLocalMarked.errors.txt.diff | 10 +- .../constructorPropertyJs.errors.txt.diff | 19 + ...dParametersOptionalInJSDoc.errors.txt.diff | 62 +++ ...nceFromAnnotatedFunctionJs.errors.txt.diff | 37 +- ...notatedOptionalParameterJs.errors.txt.diff | 69 +++ .../controlFlowInstanceof.errors.txt.diff | 5 +- ...e4(strictnullchecks=false).errors.txt.diff | 101 ++++ ...de4(strictnullchecks=true).errors.txt.diff | 101 ++++ ...ationEmitClassAccessorsJs1.errors.txt.diff | 30 ++ ...ssSetAccessorParamNameInJs.errors.txt.diff | 21 + ...sSetAccessorParamNameInJs2.errors.txt.diff | 19 + ...sSetAccessorParamNameInJs3.errors.txt.diff | 19 + ...EmitLateBoundJSAssignments.errors.txt.diff | 39 ++ ...tObjectLiteralAccessorsJs1.errors.txt.diff | 75 +++ .../decoratorInJsFile.errors.txt.diff | 22 +- .../decoratorInJsFile1.errors.txt.diff | 22 +- ...oFunctionContextualTypesJs.errors.txt.diff | 11 +- ...doFunctionSymbolPropertyJs.errors.txt.diff | 28 ++ .../exportDefaultWithJSDoc2.errors.txt.diff | 20 + ...icodePlaneIdentifiersJSDoc.errors.txt.diff | 21 + ...TypeArgsOnJSConstructCalls.errors.txt.diff | 32 +- ...portTypeResolutionJSDocEOF.errors.txt.diff | 19 + ...ionEmitDoesNotRenameImport.errors.txt.diff | 39 ++ ...DeclarationsInheritedTypes.errors.txt.diff | 47 ++ ...odeModulesPathWithoutError.errors.txt.diff | 55 +++ .../jsEnumCrossFileExport.errors.txt.diff | 11 +- .../jsEnumTagOnObjectFrozen.errors.txt.diff | 13 +- ...rgedWithModuleAugmentation.errors.txt.diff | 19 +- .../jsExtendsImplicitAny.errors.txt.diff | 11 +- ...lternativeUseOfOverloadTag.errors.txt.diff | 71 +++ ...ompilationAbstractModifier.errors.txt.diff | 15 +- ...mbientVarDeclarationSyntax.errors.txt.diff | 14 +- ...nConstructorOverloadSyntax.errors.txt.diff | 20 +- ...sFileCompilationEnumSyntax.errors.txt.diff | 11 +- ...tionExportAssignmentSyntax.errors.txt.diff | 14 +- ...tionFunctionOverloadSyntax.errors.txt.diff | 15 +- ...eritageClauseSyntaxOfClass.errors.txt.diff | 11 +- ...pilationImportEqualsSyntax.errors.txt.diff | 14 +- ...CompilationInterfaceSyntax.errors.txt.diff | 11 +- ...lationMethodOverloadSyntax.errors.txt.diff | 20 +- ...ileCompilationModuleSyntax.errors.txt.diff | 11 +- ...ompilationNonNullAssertion.errors.txt.diff | 12 - ...mpilationOptionalParameter.errors.txt.diff | 14 +- ...ionPublicParameterModifier.errors.txt.diff | 14 +- ...ReturnTypeSyntaxOfFunction.errors.txt.diff | 11 +- ...FileCompilationSyntaxError.errors.txt.diff | 18 +- ...CompilationTypeAliasSyntax.errors.txt.diff | 11 +- ...sFileCompilationTypeAliasSyntax.types.diff | 8 - ...eCompilationTypeAssertions.errors.txt.diff | 10 +- ...CompilationTypeOfParameter.errors.txt.diff | 11 +- ...TypeParameterSyntaxOfClass.errors.txt.diff | 11 +- ...terSyntaxOfClassExpression.errors.txt.diff | 15 +- ...eParameterSyntaxOfFunction.errors.txt.diff | 11 +- ...CompilationTypeSyntaxOfVar.errors.txt.diff | 11 +- .../jsFileFunctionOverloads.errors.txt.diff | 110 +++++ .../jsFileFunctionOverloads2.errors.txt.diff | 105 ++++ ...ileImportPreservedWhenUsed.errors.txt.diff | 39 ++ .../jsFileMethodOverloads.errors.txt.diff | 130 +++++ .../jsFileMethodOverloads2.errors.txt.diff | 124 +++++ .../jsFileMethodOverloads3.errors.txt.diff | 43 ++ .../jsFileMethodOverloads5.errors.txt.diff | 41 ++ .../jsdocAccessEnumType.errors.txt.diff | 17 + ...ayObjectPromiseImplicitAny.errors.txt.diff | 38 +- ...ObjectPromiseNoImplicitAny.errors.txt.diff | 91 +++- .../jsdocBracelessTypeTag1.errors.txt.diff | 20 +- .../jsdocCallbackAndType.errors.txt.diff | 19 + ...cClassMissingTypeArguments.errors.txt.diff | 25 + ...ClassPropertiesDeclaration.errors.txt.diff | 8 +- ...cFunctionTypeFalsePositive.errors.txt.diff | 12 +- .../compiler/jsdocIllegalTags.errors.txt.diff | 26 +- ...docImportTypeNodeNamespace.errors.txt.diff | 12 +- .../jsdocImportTypeResolution.errors.txt.diff | 20 + ...amTagOnPropertyInitializer.errors.txt.diff | 15 + ...rameterParsingInfiniteLoop.errors.txt.diff | 5 +- .../jsdocPropertyTagInvalid.errors.txt.diff | 23 + ...erenceGlobalTypeInCommonJs.errors.txt.diff | 16 + ...esolveNameFailureInTypedef.errors.txt.diff | 16 + .../jsdocRestParameter.errors.txt.diff | 17 +- .../jsdocRestParameter_es6.errors.txt.diff | 15 + .../compiler/jsdocTypeCast.errors.txt.diff | 47 ++ ...enericInstantiationAttempt.errors.txt.diff | 17 + ...enericInstantiationAttempt.errors.txt.diff | 93 +++- ...oreParenthesizedExpression.errors.txt.diff | 30 ++ .../jsdocTypedefMissingType.errors.txt.diff | 35 +- .../jsdocTypedefNoCrash2.errors.txt.diff | 22 +- ...Typedef_propertyWithNoType.errors.txt.diff | 18 + .../compiler/modulePreserve4.errors.txt.diff | 19 +- ...JSDocCastAtReturnStatement.errors.txt.diff | 32 ++ ...izedJSDocCastDoesNotNarrow.errors.txt.diff | 17 + .../requireOfJsonFileInJsFile.errors.txt.diff | 33 ++ ...itionalExpressionJSDocCast.errors.txt.diff | 34 ++ .../strictOptionalProperties3.errors.txt.diff | 35 ++ .../strictOptionalProperties4.errors.txt.diff | 24 + ...bclassThisTypeAssignable01.errors.txt.diff | 19 + ...bclassThisTypeAssignable02.errors.txt.diff | 42 ++ ...entInNamespaceDeclaration1.errors.txt.diff | 20 +- .../thisInFunctionCallJs.errors.txt.diff | 34 ++ .../topLevelBlockExpando.errors.txt.diff | 51 ++ .../unicodeEscapesInJSDoc.errors.txt.diff | 35 ++ .../compiler/uniqueSymbolJs.errors.txt.diff | 19 +- ...TypeParameters_templateTag.errors.txt.diff | 13 +- ...ypeParameters_templateTag2.errors.txt.diff | 41 +- ...rtyInitializerDoesntNarrow.errors.txt.diff | 27 ++ .../assertionTypePredicates2.errors.txt.diff | 14 +- ...nsAndNonReturningFunctions.errors.txt.diff | 65 +++ ...asyncArrowFunction_allowJs.errors.txt.diff | 17 +- ...cFunctionDeclaration16_es5.errors.txt.diff | 65 ++- .../callbackCrossModule.errors.txt.diff | 10 +- .../callbackOnConstructor.errors.txt.diff | 8 +- .../conformance/callbackTag1.errors.txt.diff | 37 ++ .../conformance/callbackTag2.errors.txt.diff | 65 ++- .../conformance/callbackTag3.errors.txt.diff | 17 + .../conformance/callbackTag4.errors.txt.diff | 33 ++ .../callbackTagNamespace.errors.txt.diff | 25 + ...callbackTagNestedParameter.errors.txt.diff | 35 ++ .../callbackTagVariadicType.errors.txt.diff | 8 +- ...chainedPrototypeAssignment.errors.txt.diff | 18 +- ...xportsObjectAssignProperty.errors.txt.diff | 20 +- ...ectAssignPrototypeProperty.errors.txt.diff | 19 +- ...eckJsdocOptionalParamOrder.errors.txt.diff | 29 ++ ...DeclaredFunctionExpression.errors.txt.diff | 51 +- .../checkJsdocParamTag1.errors.txt.diff | 30 ++ .../checkJsdocReturnTag1.errors.txt.diff | 37 ++ .../checkJsdocReturnTag2.errors.txt.diff | 30 ++ .../checkJsdocSatisfiesTag1.errors.txt.diff | 62 ++- .../checkJsdocSatisfiesTag10.errors.txt.diff | 18 + .../checkJsdocSatisfiesTag11.errors.txt.diff | 43 +- .../checkJsdocSatisfiesTag14.errors.txt.diff | 30 +- .../checkJsdocSatisfiesTag2.errors.txt.diff | 8 +- .../checkJsdocSatisfiesTag3.errors.txt.diff | 29 ++ .../checkJsdocSatisfiesTag4.errors.txt.diff | 28 +- .../checkJsdocSatisfiesTag5.errors.txt.diff | 23 + .../checkJsdocSatisfiesTag6.errors.txt.diff | 21 + .../checkJsdocSatisfiesTag7.errors.txt.diff | 18 + .../checkJsdocSatisfiesTag8.errors.txt.diff | 5 +- .../checkJsdocSatisfiesTag9.errors.txt.diff | 21 + .../checkJsdocTypeTag1.errors.txt.diff | 54 ++- .../checkJsdocTypeTag2.errors.txt.diff | 25 +- .../checkJsdocTypeTag3.errors.txt.diff | 13 + .../checkJsdocTypeTag4.errors.txt.diff | 30 ++ .../checkJsdocTypeTag5.errors.txt.diff | 41 +- .../checkJsdocTypeTag6.errors.txt.diff | 30 +- .../checkJsdocTypeTag7.errors.txt.diff | 25 + .../checkJsdocTypeTag8.errors.txt.diff | 5 +- ...ocTypeTagOnObjectProperty2.errors.txt.diff | 10 +- ...eckJsdocTypedefInParamTag1.errors.txt.diff | 59 +++ ...JsdocTypedefOnlySourceFile.errors.txt.diff | 5 +- .../checkObjectDefineProperty.errors.txt.diff | 48 +- ...kOtherObjectAssignProperty.errors.txt.diff | 10 +- ...SpecialPropertyAssignments.errors.txt.diff | 24 + ...nExtendConstructorFunction.errors.txt.diff | 39 +- .../commonJSAliasedExport.errors.txt.diff | 5 +- ...JSImportClassTypeReference.errors.txt.diff | 5 +- ...ortExportedClassExpression.errors.txt.diff | 5 +- ...rtNestedClassTypeReference.errors.txt.diff | 5 +- ...nctionMethodTypeParameters.errors.txt.diff | 35 +- .../constructorFunctions.errors.txt.diff | 14 +- ...constructorFunctionsStrict.errors.txt.diff | 11 +- .../constructorTagWithThisTag.errors.txt.diff | 19 + .../contextualTypeFromJSDoc.errors.txt.diff | 40 ++ ...tualTypedSpecialAssignment.errors.txt.diff | 10 +- ...Declaration9(strict=false).errors.txt.diff | 64 +++ ...rDeclaration9(strict=true).errors.txt.diff | 51 ++ .../conformance/enumTag.errors.txt.diff | 47 +- .../enumTagImported.errors.txt.diff | 13 +- .../enumTagUseBeforeDefCrash.errors.txt.diff | 5 +- .../errorOnFunctionReturnType.errors.txt.diff | 12 +- ...Declaration-exportModifier.errors.txt.diff | 61 +-- .../exportNamespace_js.errors.txt.diff | 18 - .../exportNestedNamespaces.errors.txt.diff | 8 +- .../exportSpecifiers_js.errors.txt.diff | 17 +- .../exportedEnumTypeAndValue.errors.txt.diff | 5 +- .../conformance/extendsTag1.errors.txt.diff | 23 + .../conformance/extendsTag5.errors.txt.diff | 95 ++++ ...ericSetterInClassTypeJsDoc.errors.txt.diff | 55 +++ .../conformance/grammarErrors.errors.txt.diff | 22 +- .../importSpecifiers_js.errors.txt.diff | 21 +- .../conformance/importTag1.errors.txt.diff | 27 ++ .../conformance/importTag11.errors.txt.diff | 15 +- .../conformance/importTag12.errors.txt.diff | 18 +- .../conformance/importTag13.errors.txt.diff | 12 +- .../conformance/importTag14.errors.txt.diff | 12 +- ...importTag15(module=es2015).errors.txt.diff | 31 ++ ...importTag15(module=esnext).errors.txt.diff | 31 ++ .../conformance/importTag16.errors.txt.diff | 28 ++ .../conformance/importTag17.errors.txt.diff | 21 +- .../conformance/importTag18.errors.txt.diff | 29 ++ .../conformance/importTag19.errors.txt.diff | 27 ++ .../conformance/importTag2.errors.txt.diff | 27 ++ .../conformance/importTag20.errors.txt.diff | 29 ++ .../conformance/importTag21.errors.txt.diff | 41 ++ .../conformance/importTag23.errors.txt.diff | 26 + .../conformance/importTag3.errors.txt.diff | 27 ++ .../conformance/importTag4.errors.txt.diff | 40 ++ .../conformance/importTag5.errors.txt.diff | 27 ++ .../conformance/importTag6.errors.txt.diff | 40 ++ .../conformance/importTag7.errors.txt.diff | 38 ++ .../conformance/importTag8.errors.txt.diff | 38 ++ .../conformance/importTag9.errors.txt.diff | 38 ++ .../importTypeInJSDoc.errors.txt.diff | 40 ++ .../conformance/inferThis.errors.txt.diff | 69 +++ ...rameterOnVariableStatement.errors.txt.diff | 32 ++ ...sDeclarationsClassAccessor.errors.txt.diff | 48 ++ ...mentsGenericsSerialization.errors.txt.diff | 49 ++ .../jsDeclarationsClassMethod.errors.txt.diff | 11 +- .../jsDeclarationsClasses.errors.txt.diff | 442 +++++++++++++++++ .../jsDeclarationsClassesErr.errors.txt.diff | 269 ++++++----- ...sDeclarationsComputedNames.errors.txt.diff | 36 ++ .../jsDeclarationsDefault.errors.txt.diff | 50 ++ .../jsDeclarationsEnumTag.errors.txt.diff | 26 +- .../jsDeclarationsEnums.errors.txt.diff | 225 ++++++--- ...ortAssignedClassExpression.errors.txt.diff | 18 + ...edClassExpressionAnonymous.errors.txt.diff | 18 + ...ExpressionAnonymousWithSub.errors.txt.diff | 5 +- ...nsExportDefinePropertyEmit.errors.txt.diff | 64 ++- ...DeclarationsExportFormsErr.errors.txt.diff | 18 +- ...ClassesCjsExportAssignment.errors.txt.diff | 27 +- ...sDeclarationsFunctionJSDoc.errors.txt.diff | 57 +++ ...rationsFunctionLikeClasses.errors.txt.diff | 13 +- ...ationsFunctionLikeClasses2.errors.txt.diff | 20 +- ...onsFunctionPrototypeStatic.errors.txt.diff | 5 +- .../jsDeclarationsFunctions.errors.txt.diff | 63 ++- ...jsDeclarationsFunctionsCjs.errors.txt.diff | 20 +- ...jsDeclarationsGetterSetter.errors.txt.diff | 161 +++++++ ...liasExposedWithinNamespace.errors.txt.diff | 19 +- ...sExposedWithinNamespaceCjs.errors.txt.diff | 16 +- ...ationsImportNamespacedType.errors.txt.diff | 5 +- .../jsDeclarationsInterfaces.errors.txt.diff | 448 ++++++++++++------ ...ionsJSDocRedirectedLookups.errors.txt.diff | 55 ++- ...eclarationsMissingGenerics.errors.txt.diff | 21 + ...tionsMissingTypeParameters.errors.txt.diff | 15 +- ...ionsModuleReferenceHasEmit.errors.txt.diff | 5 +- ...jsDeclarationsNestedParams.errors.txt.diff | 20 +- ...sOptionalTypeLiteralProps1.errors.txt.diff | 24 + ...sOptionalTypeLiteralProps2.errors.txt.diff | 5 +- ...rTagReusesInputNodeInEmit1.errors.txt.diff | 11 +- ...rTagReusesInputNodeInEmit2.errors.txt.diff | 8 +- ...eclarationsPrivateFields01.errors.txt.diff | 31 ++ ...eclarationsReactComponents.errors.txt.diff | 106 +++++ ...arationsReexportedCjsAlias.errors.txt.diff | 34 ++ ...ceToClassInstanceCrossFile.errors.txt.diff | 5 +- ...tingNodesMappingJSDocTypes.errors.txt.diff | 26 +- ...sesExistingTypeAnnotations.errors.txt.diff | 44 +- ...licitNoArgumentConstructor.errors.txt.diff | 26 + .../jsDeclarationsThisTypes.errors.txt.diff | 20 + .../jsDeclarationsTypeAliases.errors.txt.diff | 16 +- ...eassignmentFromDeclaration.errors.txt.diff | 19 + ...eclarationsTypeReferences4.errors.txt.diff | 52 +- ...tionsTypedefAndImportTypes.errors.txt.diff | 5 +- ...rationsTypedefAndLatebound.errors.txt.diff | 10 +- ...eclarationsTypedefFunction.errors.txt.diff | 31 ++ ...ropertyAndExportAssignment.errors.txt.diff | 16 +- ...larationsUniqueSymbolUsage.errors.txt.diff | 27 ++ .../jsdocAccessibilityTags.errors.txt.diff | 45 ++ ...Augments_withTypeParameter.errors.txt.diff | 20 + ...ocBindingInUnreachableCode.errors.txt.diff | 18 + ...chClauseWithTypeAnnotation.errors.txt.diff | 146 ++++++ ...uctorFunctionTypeReference.errors.txt.diff | 5 +- .../jsdocFunctionType.errors.txt.diff | 46 +- .../jsdocImplementsTag.errors.txt.diff | 21 + .../jsdocImplements_class.errors.txt.diff | 49 ++ .../jsdocImplements_interface.errors.txt.diff | 41 ++ ...lements_interface_multiple.errors.txt.diff | 30 ++ ...sdocImplements_missingType.errors.txt.diff | 21 +- ...ements_namespacedInterface.errors.txt.diff | 35 ++ ...jsdocImplements_properties.errors.txt.diff | 37 ++ ...jsdocImplements_signatures.errors.txt.diff | 19 + .../jsdocImportType.errors.txt.diff | 37 ++ .../jsdocImportType2.errors.txt.diff | 36 ++ ...tTypeReferenceToClassAlias.errors.txt.diff | 5 +- ...eReferenceToCommonjsModule.errors.txt.diff | 5 +- ...ortTypeReferenceToESModule.errors.txt.diff | 5 +- ...peReferenceToStringLiteral.errors.txt.diff | 5 +- .../jsdocIndexSignature.errors.txt.diff | 14 +- .../conformance/jsdocLiteral.errors.txt.diff | 33 ++ .../jsdocNeverUndefinedNull.errors.txt.diff | 28 ++ .../jsdocOuterTypeParameters1.errors.txt.diff | 5 +- .../jsdocOuterTypeParameters2.errors.txt.diff | 6 +- .../jsdocOverrideTag1.errors.txt.diff | 39 ++ .../jsdocParamTag2.errors.txt.diff | 142 +++++- .../jsdocParamTagTypeLiteral.errors.txt.diff | 102 ++++ ...ocParseBackquotedParamName.errors.txt.diff | 24 + ...seDotDotDotInJSDocFunction.errors.txt.diff | 5 +- ...ocParseHigherOrderFunction.errors.txt.diff | 5 +- ...sdocParseMatchingBackticks.errors.txt.diff | 40 ++ ...arenthesizedJSDocParameter.errors.txt.diff | 5 +- .../jsdocParseStarEquals.errors.txt.diff | 15 +- ...stfixEqualsAddsOptionality.errors.txt.diff | 34 ++ .../jsdocPrefixPostfixParsing.errors.txt.diff | 47 +- .../jsdocPrivateName1.errors.txt.diff | 16 + .../conformance/jsdocReadonly.errors.txt.diff | 39 ++ .../jsdocReadonlyDeclarations.errors.txt.diff | 5 +- .../jsdocReturnTag1.errors.txt.diff | 37 ++ ...ignatureOnReturnedFunction.errors.txt.diff | 67 +++ .../jsdocTemplateClass.errors.txt.diff | 78 +++ ...emplateConstructorFunction.errors.txt.diff | 71 ++- ...mplateConstructorFunction2.errors.txt.diff | 46 +- .../jsdocTemplateTag.errors.txt.diff | 46 +- .../jsdocTemplateTag2.errors.txt.diff | 29 ++ .../jsdocTemplateTag3.errors.txt.diff | 78 ++- .../jsdocTemplateTag4.errors.txt.diff | 20 +- .../jsdocTemplateTag5.errors.txt.diff | 38 +- .../jsdocTemplateTag6.errors.txt.diff | 239 ++++++++++ .../jsdocTemplateTag7.errors.txt.diff | 63 +++ .../jsdocTemplateTag8.errors.txt.diff | 101 +++- .../jsdocTemplateTagDefault.errors.txt.diff | 162 ++++++- ...cTemplateTagNameResolution.errors.txt.diff | 21 + .../conformance/jsdocThisType.errors.txt.diff | 24 +- .../jsdocTypeDefAtStartOfFile.errors.txt.diff | 13 +- .../jsdocTypeReferenceExports.errors.txt.diff | 5 +- ...jsdocTypeReferenceToImport.errors.txt.diff | 8 +- ...eToImportOfClassExpression.errors.txt.diff | 5 +- ...ImportOfFunctionExpression.errors.txt.diff | 10 +- ...TypeReferenceToMergedClass.errors.txt.diff | 5 +- .../jsdocTypeReferenceToValue.errors.txt.diff | 5 +- ...cTypeReferenceUseBeforeDef.errors.txt.diff | 15 + .../conformance/jsdocTypeTag.errors.txt.diff | 74 ++- .../jsdocTypeTagCast.errors.txt.diff | 110 ++++- .../jsdocTypeTagParameterType.errors.txt.diff | 5 +- ...cTypeTagRequiredParameters.errors.txt.diff | 5 +- ...larationWithTypeAnnotation.errors.txt.diff | 17 + .../jsdocVariadicType.errors.txt.diff | 5 +- .../conformance/linkTagEmit1.errors.txt.diff | 35 ++ .../conformance/malformedTags.errors.txt.diff | 17 + .../moduleExportAssignment.errors.txt.diff | 5 +- .../moduleExportAssignment6.errors.txt.diff | 37 ++ .../moduleExportAssignment7.errors.txt.diff | 61 ++- ...duleExportNestedNamespaces.errors.txt.diff | 8 +- ...tsElementAccessAssignment2.errors.txt.diff | 33 ++ ...lesAllowJs1(module=node16).errors.txt.diff | 259 +++++----- ...lesAllowJs1(module=node18).errors.txt.diff | 259 +++++----- ...sAllowJs1(module=nodenext).errors.txt.diff | 259 +++++----- ...tAssignment(module=node16).errors.txt.diff | 31 +- ...tAssignment(module=node18).errors.txt.diff | 31 +- ...ssignment(module=nodenext).errors.txt.diff | 31 +- ...tAssignment(module=node16).errors.txt.diff | 87 ++-- ...tAssignment(module=node18).errors.txt.diff | 87 ++-- ...ssignment(module=nodenext).errors.txt.diff | 87 ++-- ...sCallErrors(module=node16).errors.txt.diff | 48 +- ...sCallErrors(module=node18).errors.txt.diff | 48 +- ...allErrors(module=nodenext).errors.txt.diff | 74 ++- ...optionalBindingParameters3.errors.txt.diff | 24 + ...optionalBindingParameters4.errors.txt.diff | 17 + .../conformance/overloadTag1.errors.txt.diff | 45 +- .../conformance/overloadTag2.errors.txt.diff | 48 ++ .../conformance/overloadTag3.errors.txt.diff | 53 +++ ...acketsAddOptionalUndefined.errors.txt.diff | 43 ++ ...stedWithoutTopLevelObject3.errors.txt.diff | 8 +- .../paramTagTypeResolution2.errors.txt.diff | 32 ++ .../paramTagWrapping.errors.txt.diff | 26 +- ...rArrowFunctionExpression10.errors.txt.diff | 17 +- ...rArrowFunctionExpression13.errors.txt.diff | 13 +- ...rArrowFunctionExpression14.errors.txt.diff | 28 +- ...rArrowFunctionExpression15.errors.txt.diff | 19 +- ...rArrowFunctionExpression16.errors.txt.diff | 19 +- ...rArrowFunctionExpression17.errors.txt.diff | 21 +- ...mesIncompatibleModifiersJs.errors.txt.diff | 50 ++ ...enericConstructorFunctions.errors.txt.diff | 68 ++- ...tyAssignmentUseParentType2.errors.txt.diff | 22 +- ...ssignmentMergeAcrossFiles2.errors.txt.diff | 14 +- ...ignmentMergedTypeReference.errors.txt.diff | 5 +- .../recursiveTypeReferences2.errors.txt.diff | 27 ++ .../returnTagTypeGuard.errors.txt.diff | 98 ++++ .../conformance/syntaxErrors.errors.txt.diff | 31 +- .../templateInsideCallback.errors.txt.diff | 65 ++- ...ropertyAssignmentInherited.errors.txt.diff | 29 ++ .../conformance/thisTag1.errors.txt.diff | 30 ++ .../conformance/thisTag2.errors.txt.diff | 19 + .../conformance/thisTag3.errors.txt.diff | 31 ++ ...TypeOfConstructorFunctions.errors.txt.diff | 46 +- ...typeFromContextualThisType.errors.txt.diff | 8 +- .../typeFromJSInitializer.errors.txt.diff | 29 +- .../typeFromJSInitializer4.errors.txt.diff | 17 + ...ypeFromParamTagForFunction.errors.txt.diff | 40 +- ...rivatePropertyAssignmentJs.errors.txt.diff | 26 + ...typeFromPropertyAssignment.errors.txt.diff | 8 +- ...peFromPropertyAssignment10.errors.txt.diff | 5 +- ...FromPropertyAssignment10_1.errors.txt.diff | 5 +- ...peFromPropertyAssignment14.errors.txt.diff | 5 +- ...peFromPropertyAssignment15.errors.txt.diff | 5 +- ...peFromPropertyAssignment16.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment2.errors.txt.diff | 8 +- ...peFromPropertyAssignment24.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment3.errors.txt.diff | 8 +- ...peFromPropertyAssignment35.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment4.errors.txt.diff | 10 +- ...peFromPropertyAssignment40.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment5.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment6.errors.txt.diff | 5 +- ...opertyAssignmentOutOfOrder.errors.txt.diff | 5 +- ...peFromPrototypeAssignment3.errors.txt.diff | 15 +- ...peFromPrototypeAssignment4.errors.txt.diff | 37 ++ .../typeLookupInIIFE.errors.txt.diff | 12 +- .../typeSatisfaction_js.errors.txt.diff | 15 +- .../typeTagNoErasure.errors.txt.diff | 20 + ...nFunctionReferencesGeneric.errors.txt.diff | 29 ++ .../typedefCrossModule.errors.txt.diff | 11 +- .../typedefCrossModule2.errors.txt.diff | 10 +- ...edefMultipleTypeParameters.errors.txt.diff | 32 +- ...defOnSemicolonClassElement.errors.txt.diff | 17 + .../typedefOnStatements.errors.txt.diff | 96 ++++ .../conformance/typedefScope1.errors.txt.diff | 36 ++ ...pedefTagExtraneousProperty.errors.txt.diff | 5 +- .../typedefTagNested.errors.txt.diff | 56 +++ .../typedefTagTypeResolution.errors.txt.diff | 87 ++++ .../typedefTagWrapping.errors.txt.diff | 123 ++++- ...queSymbolsDeclarationsInJs.errors.txt.diff | 60 +++ ...bolsDeclarationsInJsErrors.errors.txt.diff | 39 ++ .../varRequireFromJavascript.errors.txt.diff | 39 ++ .../varRequireFromTypescript.errors.txt.diff | 38 ++ .../cases/compiler/jsSyntacticDiagnostics.ts | 102 ++++ 893 files changed, 24707 insertions(+), 2970 deletions(-) create mode 100644 testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt create mode 100644 testdata/baselines/reference/compiler/jsSyntacticDiagnostics.symbols create mode 100644 testdata/baselines/reference/compiler/jsSyntacticDiagnostics.types create mode 100644 testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt create mode 100644 testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt create mode 100644 testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.errors.txt create mode 100644 testdata/baselines/reference/conformance/typeTagForMultipleVariableDeclarations.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/constructorPropertyJs.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/decoratorInJsFile1.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationImportEqualsSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalParameter.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicParameterModifier.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/callbackTagNamespace.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag7.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/esDecorators-classDeclaration-exportModifier.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importSpecifiers_js.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag11.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag12.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag16.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag18.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag19.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag2.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag20.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag21.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag3.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag5.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag6.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag7.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag8.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTag9.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/inferThis.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsPrivateFields01.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsReexportedCjsAlias.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImplementsTag.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImplements_namespacedInterface.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImportType.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImportType2.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocLiteral.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/linkTagEmit1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/malformedTags.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment2.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/syntaxErrors.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/thisTag2.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/typedefTagNested.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/constructorPropertyJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationNonNullAssertion.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNamespace.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag7.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/exportNamespace_js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag16.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag18.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag19.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag20.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag21.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag5.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag6.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag7.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag8.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag9.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingGenerics.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsPrivateFields01.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReexportedCjsAlias.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplementsTag.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface_multiple.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_namespacedInterface.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_properties.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_signatures.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefOnSemicolonClassElement.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff create mode 100644 testdata/tests/cases/compiler/jsSyntacticDiagnostics.ts diff --git a/internal/ast/ast.go b/internal/ast/ast.go index b163ca4575..69ce69758b 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -10046,29 +10046,29 @@ type SourceFile struct { EndOfFileToken *TokenNode // TokenNode[*EndOfFileToken] // Fields set by parser - diagnostics []*Diagnostic - jsdocDiagnostics []*Diagnostic + diagnostics []*Diagnostic + jsdocDiagnostics []*Diagnostic additionalSyntacticDiagnostics []*Diagnostic - LanguageVariant core.LanguageVariant - ScriptKind core.ScriptKind - IsDeclarationFile bool - UsesUriStyleNodeCoreModules core.Tristate - Identifiers map[string]string - IdentifierCount int - imports []*LiteralLikeNode // []LiteralLikeNode - ModuleAugmentations []*ModuleName // []ModuleName - AmbientModuleNames []string - CommentDirectives []CommentDirective - jsdocCache map[*Node][]*Node - Pragmas []Pragma - ReferencedFiles []*FileReference - TypeReferenceDirectives []*FileReference - LibReferenceDirectives []*FileReference - CheckJsDirective *CheckJsDirective - NodeCount int - TextCount int - CommonJSModuleIndicator *Node - ExternalModuleIndicator *Node + LanguageVariant core.LanguageVariant + ScriptKind core.ScriptKind + IsDeclarationFile bool + UsesUriStyleNodeCoreModules core.Tristate + Identifiers map[string]string + IdentifierCount int + imports []*LiteralLikeNode // []LiteralLikeNode + ModuleAugmentations []*ModuleName // []ModuleName + AmbientModuleNames []string + CommentDirectives []CommentDirective + jsdocCache map[*Node][]*Node + Pragmas []Pragma + ReferencedFiles []*FileReference + TypeReferenceDirectives []*FileReference + LibReferenceDirectives []*FileReference + CheckJsDirective *CheckJsDirective + NodeCount int + TextCount int + CommonJSModuleIndicator *Node + ExternalModuleIndicator *Node // Fields set by binder diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 86fa4479bc..f8c253ac8d 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -380,10 +380,10 @@ func (p *Program) getSyntacticDiagnosticsForFile(ctx context.Context, sourceFile func (p *Program) getJSSyntacticDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { var diagnostics []*ast.Diagnostic - + // Walk the entire AST to find TypeScript-only constructs p.walkNodeForJSDiagnostics(sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) - + return diagnostics } @@ -391,7 +391,7 @@ func (p *Program) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node, dia if node == nil { return } - + // Handle specific parent-child relationships first switch parent.Kind { case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: @@ -409,7 +409,7 @@ func (p *Program) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node, dia return } } - + // Check node-specific constructs switch node.Kind { case ast.KindImportClause: @@ -417,75 +417,75 @@ func (p *Program) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node, dia *diags = append(*diags, p.createDiagnosticForNode(parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) return } - + case ast.KindExportDeclaration: if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) return } - + case ast.KindImportSpecifier: if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) return } - + case ast.KindExportSpecifier: if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) return } - + case ast.KindImportEqualsDeclaration: *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) return - + case ast.KindExportAssignment: if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) return } - + case ast.KindHeritageClause: if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == ast.KindImplementsKeyword { *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) return } - + case ast.KindInterfaceDeclaration: *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) return - + case ast.KindModuleDeclaration: moduleKeyword := "module" // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) return - + case ast.KindTypeAliasDeclaration: *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) return - + case ast.KindEnumDeclaration: *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) return - + case ast.KindNonNullExpression: *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) return - + case ast.KindAsExpression: if node.AsAsExpression() != nil { *diags = append(*diags, p.createDiagnosticForNode(node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) return } - + case ast.KindSatisfiesExpression: if node.AsSatisfiesExpression() != nil { *diags = append(*diags, p.createDiagnosticForNode(node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) return } - + case ast.KindConstructor, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: // Check for signature declarations (functions without bodies) if p.isSignatureDeclaration(node) { @@ -493,10 +493,10 @@ func (p *Program) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node, dia return } } - + // Check for type parameters, type arguments, and modifiers p.checkTypeParametersAndModifiers(node, diags) - + // Recursively walk children node.ForEachChild(func(child *ast.Node) bool { p.walkNodeForJSDiagnostics(child, node, diags) @@ -506,41 +506,26 @@ func (p *Program) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node, dia func (p *Program) isTypeAnnotation(parent *ast.Node, node *ast.Node) bool { switch parent.Kind { - case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction: - if parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node { - return true - } - if parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node { - return true - } - if parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node { - return true - } - case ast.KindMethodDeclaration, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindConstructor: - if parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node { - return true - } - if parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node { - return true - } - if parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node { - return true - } - if parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node { - return true - } + case ast.KindFunctionDeclaration: + return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node + case ast.KindFunctionExpression: + return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node + case ast.KindArrowFunction: + return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node + case ast.KindMethodDeclaration: + return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node + case ast.KindGetAccessor: + return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node + case ast.KindSetAccessor: + return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node + case ast.KindConstructor: + return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node case ast.KindVariableDeclaration: - if parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node { - return true - } + return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node case ast.KindParameter: - if parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node { - return true - } + return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node case ast.KindPropertyDeclaration: - if parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node { - return true - } + return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node } return false } @@ -562,47 +547,54 @@ func (p *Program) checkTypeParametersAndModifiers(node *ast.Node, diags *[]*ast. if p.hasTypeParameters(node) { *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) } - + // Check type arguments if p.hasTypeArguments(node) { *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) } - + // Check modifiers p.checkModifiers(node, diags) } func (p *Program) hasTypeParameters(node *ast.Node) bool { switch node.Kind { - case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindMethodDeclaration, ast.KindConstructor, - ast.KindGetAccessor, ast.KindSetAccessor, ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction: - // Check if node has type parameters - if node.AsClassDeclaration() != nil && node.AsClassDeclaration().TypeParameters != nil { - return true - } - if node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().TypeParameters != nil { - return true - } - if node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().TypeParameters != nil { - return true - } - // Add other cases as needed + case ast.KindClassDeclaration: + return node.AsClassDeclaration() != nil && node.AsClassDeclaration().TypeParameters != nil + case ast.KindClassExpression: + return node.AsClassExpression() != nil && node.AsClassExpression().TypeParameters != nil + case ast.KindMethodDeclaration: + return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().TypeParameters != nil + case ast.KindConstructor: + return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().TypeParameters != nil + case ast.KindGetAccessor: + return node.AsGetAccessorDeclaration() != nil && node.AsGetAccessorDeclaration().TypeParameters != nil + case ast.KindSetAccessor: + return node.AsSetAccessorDeclaration() != nil && node.AsSetAccessorDeclaration().TypeParameters != nil + case ast.KindFunctionExpression: + return node.AsFunctionExpression() != nil && node.AsFunctionExpression().TypeParameters != nil + case ast.KindFunctionDeclaration: + return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().TypeParameters != nil + case ast.KindArrowFunction: + return node.AsArrowFunction() != nil && node.AsArrowFunction().TypeParameters != nil } return false } func (p *Program) hasTypeArguments(node *ast.Node) bool { switch node.Kind { - case ast.KindCallExpression, ast.KindNewExpression, ast.KindExpressionWithTypeArguments, - ast.KindJsxSelfClosingElement, ast.KindJsxOpeningElement, ast.KindTaggedTemplateExpression: - // Check if node has type arguments - if node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil { - return true - } - if node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil { - return true - } - // Add other cases as needed + case ast.KindCallExpression: + return node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil + case ast.KindNewExpression: + return node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil + case ast.KindExpressionWithTypeArguments: + return node.AsExpressionWithTypeArguments() != nil && node.AsExpressionWithTypeArguments().TypeArguments != nil + case ast.KindJsxSelfClosingElement: + return node.AsJsxSelfClosingElement() != nil && node.AsJsxSelfClosingElement().TypeArguments != nil + case ast.KindJsxOpeningElement: + return node.AsJsxOpeningElement() != nil && node.AsJsxOpeningElement().TypeArguments != nil + case ast.KindTaggedTemplateExpression: + return node.AsTaggedTemplateExpression() != nil && node.AsTaggedTemplateExpression().TypeArguments != nil } return false } @@ -629,7 +621,7 @@ func (p *Program) checkModifierList(modifiers *ast.ModifierList, isConstValid bo if modifiers == nil { return } - + for _, modifier := range modifiers.Nodes { p.checkModifier(modifier, isConstValid, diags) } @@ -639,7 +631,7 @@ func (p *Program) checkPropertyModifiers(modifiers *ast.ModifierList, diags *[]* if modifiers == nil { return } - + for _, modifier := range modifiers.Nodes { // Property modifiers allow static and accessor, but not other TypeScript modifiers switch modifier.Kind { @@ -658,7 +650,7 @@ func (p *Program) checkParameterModifiers(modifiers *ast.ModifierList, diags *[] if modifiers == nil { return } - + for _, modifier := range modifiers.Nodes { if p.isTypeScriptOnlyModifier(modifier) { *diags = append(*diags, p.createDiagnosticForNode(modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) diff --git a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt new file mode 100644 index 0000000000..3f291eea31 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt @@ -0,0 +1,277 @@ +test.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. +test.js(2,26): error TS8010: Type annotations can only be used in TypeScript files. +test.js(4,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +test.js(10,2): error TS8008: Type aliases can only be used in TypeScript files. +test.js(13,39): error TS8006: 'enum' declarations can only be used in TypeScript files. +test.js(20,2): error TS8006: 'module' declarations can only be used in TypeScript files. +test.js(25,2): error TS8006: 'module' declarations can only be used in TypeScript files. +test.js(33,12): error TS8013: Non-null assertions can only be used in TypeScript files. +test.js(36,23): error TS8016: Type assertion expressions can only be used in TypeScript files. +test.js(39,17): error TS2741: Property 'name' is missing in type '{}' but required in type 'Config'. +test.js(39,26): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +test.js(39,34): error TS8006: 'import type' declarations can only be used in TypeScript files. +test.js(42,31): error TS2307: Cannot find module './other' or its corresponding type declarations. +test.js(42,41): error TS8006: 'export type' declarations can only be used in TypeScript files. +test.js(45,26): error TS8002: 'import ... =' can only be used in TypeScript files. +test.js(48,22): error TS2307: Cannot find module './lib' or its corresponding type declarations. +test.js(48,31): error TS8003: 'export =' can only be used in TypeScript files. +test.js(51,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +test.js(54,16): error TS8009: The 'public' modifier can only be used in TypeScript files. +test.js(55,17): error TS8010: Type annotations can only be used in TypeScript files. +test.js(55,25): error TS8009: The 'private' modifier can only be used in TypeScript files. +test.js(56,17): error TS8010: Type annotations can only be used in TypeScript files. +test.js(56,25): error TS8009: The 'protected' modifier can only be used in TypeScript files. +test.js(57,18): error TS8010: Type annotations can only be used in TypeScript files. +test.js(57,26): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +test.js(58,20): error TS8010: Type annotations can only be used in TypeScript files. +test.js(60,17): error TS8012: Parameter modifiers can only be used in TypeScript files. +test.js(60,26): error TS8010: Type annotations can only be used in TypeScript files. +test.js(60,34): error TS8012: Parameter modifiers can only be used in TypeScript files. +test.js(60,45): error TS8010: Type annotations can only be used in TypeScript files. +test.js(69,25): error TS8009: The '?' modifier can only be used in TypeScript files. +test.js(69,27): error TS8010: Type annotations can only be used in TypeScript files. +test.js(71,2): error TS8017: Signature declarations can only be used in TypeScript files. +test.js(74,43): error TS8004: Type parameter declarations can only be used in TypeScript files. +test.js(77,23): error TS8010: Type annotations can only be used in TypeScript files. +test.js(77,27): error TS8010: Type annotations can only be used in TypeScript files. +test.js(82,19): error TS2693: 'string' only refers to a type, but is being used as a value here. +test.js(82,27): error TS1109: Expression expected. +test.js(85,28): error TS8005: 'implements' clauses can only be used in TypeScript files. +test.js(90,21): error TS8010: Type annotations can only be used in TypeScript files. +test.js(92,2): error TS8006: 'interface' declarations can only be used in TypeScript files. + + +==== test.js (41 errors) ==== + // Type annotations should be flagged as errors + function func(x: number): string { + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + return x.toString(); + } + + + + // Interface declarations should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + interface Person { + ~~~~~~~~~~~~~~~~~~ + name: string; + ~~~~~~~~~~~~~~~~~ + age: number; + ~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + // Type alias declarations should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + type StringOrNumber = string | number; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8008: Type aliases can only be used in TypeScript files. + + + + // Enum declarations should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + enum Color { + ~~~~~~~~~~~~ + Red, + ~~~~~~~~ + Green, + ~~~~~~~~~~ + Blue + ~~~~~~~~ + } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + + + // Module declarations should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + module MyModule { + ~~~~~~~~~~~~~~~~~ + export var x = 1; + ~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. + + + + // Namespace declarations should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + namespace MyNamespace { + ~~~~~~~~~~~~~~~~~~~~~~~ + export var y = 2; + ~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. + + // Non-null assertions should be flagged as errors + let value = getValue()!; + ~~~~~~~~~~~~ +!!! error TS8013: Non-null assertions can only be used in TypeScript files. + + // Type assertions should be flagged as errors + let result = (value as string).toUpperCase(); + ~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + // Satisfies expressions should be flagged as errors + let config = {} satisfies Config; + ~~~~~~~~~ +!!! error TS2741: Property 'name' is missing in type '{}' but required in type 'Config'. +!!! related TS2728 test.js:95:5: 'name' is declared here. + ~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + + + // Import type should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + import type { SomeType } from './other'; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS2307: Cannot find module './other' or its corresponding type declarations. + + + + // Export type should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + export type { SomeType }; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'export type' declarations can only be used in TypeScript files. + + + + // Import equals should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + import lib = require('./lib'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~ +!!! error TS2307: Cannot find module './lib' or its corresponding type declarations. + + + + // Export equals should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + export = MyModule; + ~~~~~~~~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + + // TypeScript modifiers should be flagged as errors + class MyClass { + + public name: string; + ~~~~~~~~~~ +!!! error TS8009: The 'public' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + private age: number; + ~~~~~~~~~~~ +!!! error TS8009: The 'private' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + protected id: number; + ~~~~~~~~~~~~~ +!!! error TS8009: The 'protected' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + readonly value: number; + ~~~~~~~~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + constructor(public x: number, private y: number) { + ~~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + this.name = ''; + this.age = 0; + this.id = 0; + this.value = 0; + } + } + + // Optional parameters should be flagged as errors + function optionalParam(x?: number) { + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + return x || 0; + } + + + + // Signature declarations should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + function signatureOnly(x: number): string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + + + + // Type parameters should be flagged as errors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + function generic(x: T): T { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + return x; + ~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + // Type arguments should be flagged as errors + let array = Array(); + ~~~~~~ +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. + ~ +!!! error TS1109: Expression expected. + + // Implements clause should be flagged as errors + class MyClassWithImplements implements Person { + ~~~~~~~~~~~~~~~~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + name = ''; + age = 0; + } + + function getValue(): any { + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + return null; + } + + + + interface Config { + ~~~~~~~~~~~~~~~~~~ + name: string; + ~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.symbols b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.symbols new file mode 100644 index 0000000000..a6b8708dea --- /dev/null +++ b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.symbols @@ -0,0 +1,189 @@ +//// [tests/cases/compiler/jsSyntacticDiagnostics.ts] //// + +=== test.js === +// Type annotations should be flagged as errors +function func(x: number): string { +>func : Symbol(func, Decl(test.js, 0, 0)) +>x : Symbol(x, Decl(test.js, 1, 14)) + + return x.toString(); +>x.toString : Symbol(toString, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(test.js, 1, 14)) +>toString : Symbol(toString, Decl(lib.es5.d.ts, --, --)) +} + +// Interface declarations should be flagged as errors +interface Person { +>Person : Symbol(Person, Decl(test.js, 3, 1)) + + name: string; +>name : Symbol(name, Decl(test.js, 6, 18)) + + age: number; +>age : Symbol(age, Decl(test.js, 7, 17)) +} + +// Type alias declarations should be flagged as errors +type StringOrNumber = string | number; +>StringOrNumber : Symbol(StringOrNumber, Decl(test.js, 9, 1)) + +// Enum declarations should be flagged as errors +enum Color { +>Color : Symbol(Color, Decl(test.js, 12, 38)) + + Red, +>Red : Symbol(Red, Decl(test.js, 15, 12)) + + Green, +>Green : Symbol(Green, Decl(test.js, 16, 8)) + + Blue +>Blue : Symbol(Blue, Decl(test.js, 17, 10)) +} + +// Module declarations should be flagged as errors +module MyModule { +>MyModule : Symbol(MyModule, Decl(test.js, 19, 1)) + + export var x = 1; +>x : Symbol(x, Decl(test.js, 23, 14)) +} + +// Namespace declarations should be flagged as errors +namespace MyNamespace { +>MyNamespace : Symbol(MyNamespace, Decl(test.js, 24, 1)) + + export var y = 2; +>y : Symbol(y, Decl(test.js, 28, 14)) +} + +// Non-null assertions should be flagged as errors +let value = getValue()!; +>value : Symbol(value, Decl(test.js, 32, 3)) +>getValue : Symbol(getValue, Decl(test.js, 87, 1)) + +// Type assertions should be flagged as errors +let result = (value as string).toUpperCase(); +>result : Symbol(result, Decl(test.js, 35, 3)) +>(value as string).toUpperCase : Symbol(toUpperCase, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(test.js, 32, 3)) +>toUpperCase : Symbol(toUpperCase, Decl(lib.es5.d.ts, --, --)) + +// Satisfies expressions should be flagged as errors +let config = {} satisfies Config; +>config : Symbol(config, Decl(test.js, 38, 3)) +>Config : Symbol(Config, Decl(test.js, 91, 1)) + +// Import type should be flagged as errors +import type { SomeType } from './other'; +>SomeType : Symbol(SomeType, Decl(test.js, 41, 13)) + +// Export type should be flagged as errors +export type { SomeType }; +>SomeType : Symbol(SomeType, Decl(test.js, 44, 13)) + +// Import equals should be flagged as errors +import lib = require('./lib'); +>lib : Symbol(lib, Decl(test.js, 44, 25)) + +// Export equals should be flagged as errors +export = MyModule; +>MyModule : Symbol(MyModule, Decl(test.js, 19, 1)) + +// TypeScript modifiers should be flagged as errors +class MyClass { +>MyClass : Symbol(MyClass, Decl(test.js, 50, 18)) + + public name: string; +>name : Symbol(name, Decl(test.js, 53, 15)) + + private age: number; +>age : Symbol(age, Decl(test.js, 54, 24)) + + protected id: number; +>id : Symbol(id, Decl(test.js, 55, 24)) + + readonly value: number; +>value : Symbol(value, Decl(test.js, 56, 25)) + + constructor(public x: number, private y: number) { +>x : Symbol(x, Decl(test.js, 59, 16)) +>y : Symbol(y, Decl(test.js, 59, 33)) + + this.name = ''; +>this.name : Symbol(name, Decl(test.js, 53, 15)) +>this : Symbol(MyClass, Decl(test.js, 50, 18)) +>name : Symbol(name, Decl(test.js, 53, 15)) + + this.age = 0; +>this.age : Symbol(age, Decl(test.js, 54, 24)) +>this : Symbol(MyClass, Decl(test.js, 50, 18)) +>age : Symbol(age, Decl(test.js, 54, 24)) + + this.id = 0; +>this.id : Symbol(id, Decl(test.js, 55, 24)) +>this : Symbol(MyClass, Decl(test.js, 50, 18)) +>id : Symbol(id, Decl(test.js, 55, 24)) + + this.value = 0; +>this.value : Symbol(value, Decl(test.js, 56, 25)) +>this : Symbol(MyClass, Decl(test.js, 50, 18)) +>value : Symbol(value, Decl(test.js, 56, 25)) + } +} + +// Optional parameters should be flagged as errors +function optionalParam(x?: number) { +>optionalParam : Symbol(optionalParam, Decl(test.js, 65, 1)) +>x : Symbol(x, Decl(test.js, 68, 23)) + + return x || 0; +>x : Symbol(x, Decl(test.js, 68, 23)) +} + +// Signature declarations should be flagged as errors +function signatureOnly(x: number): string; +>signatureOnly : Symbol(signatureOnly, Decl(test.js, 70, 1)) +>x : Symbol(x, Decl(test.js, 73, 23)) + +// Type parameters should be flagged as errors +function generic(x: T): T { +>generic : Symbol(generic, Decl(test.js, 73, 42)) +>T : Symbol(T, Decl(test.js, 76, 17)) +>x : Symbol(x, Decl(test.js, 76, 20)) +>T : Symbol(T, Decl(test.js, 76, 17)) +>T : Symbol(T, Decl(test.js, 76, 17)) + + return x; +>x : Symbol(x, Decl(test.js, 76, 20)) +} + +// Type arguments should be flagged as errors +let array = Array(); +>array : Symbol(array, Decl(test.js, 81, 3)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +// Implements clause should be flagged as errors +class MyClassWithImplements implements Person { +>MyClassWithImplements : Symbol(MyClassWithImplements, Decl(test.js, 81, 28)) +>Person : Symbol(Person, Decl(test.js, 3, 1)) + + name = ''; +>name : Symbol(name, Decl(test.js, 84, 47)) + + age = 0; +>age : Symbol(age, Decl(test.js, 85, 14)) +} + +function getValue(): any { +>getValue : Symbol(getValue, Decl(test.js, 87, 1)) + + return null; +} + +interface Config { +>Config : Symbol(Config, Decl(test.js, 91, 1)) + + name: string; +>name : Symbol(name, Decl(test.js, 93, 18)) +} diff --git a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.types b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.types new file mode 100644 index 0000000000..48707ff263 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.types @@ -0,0 +1,207 @@ +//// [tests/cases/compiler/jsSyntacticDiagnostics.ts] //// + +=== test.js === +// Type annotations should be flagged as errors +function func(x: number): string { +>func : (x: number) => string +>x : number + + return x.toString(); +>x.toString() : string +>x.toString : (radix?: number) => string +>x : number +>toString : (radix?: number) => string +} + +// Interface declarations should be flagged as errors +interface Person { + name: string; +>name : string + + age: number; +>age : number +} + +// Type alias declarations should be flagged as errors +type StringOrNumber = string | number; +>StringOrNumber : StringOrNumber + +// Enum declarations should be flagged as errors +enum Color { +>Color : Color + + Red, +>Red : Color.Red + + Green, +>Green : Color.Green + + Blue +>Blue : Color.Blue +} + +// Module declarations should be flagged as errors +module MyModule { +>MyModule : typeof MyModule + + export var x = 1; +>x : number +>1 : 1 +} + +// Namespace declarations should be flagged as errors +namespace MyNamespace { +>MyNamespace : typeof MyNamespace + + export var y = 2; +>y : number +>2 : 2 +} + +// Non-null assertions should be flagged as errors +let value = getValue()!; +>value : any +>getValue()! : any +>getValue() : any +>getValue : () => any + +// Type assertions should be flagged as errors +let result = (value as string).toUpperCase(); +>result : string +>(value as string).toUpperCase() : string +>(value as string).toUpperCase : () => string +>(value as string) : string +>value as string : string +>value : any +>toUpperCase : () => string + +// Satisfies expressions should be flagged as errors +let config = {} satisfies Config; +>config : {} +>{} satisfies Config : {} +>{} : {} + +// Import type should be flagged as errors +import type { SomeType } from './other'; +>SomeType : any + +// Export type should be flagged as errors +export type { SomeType }; +>SomeType : any + +// Import equals should be flagged as errors +import lib = require('./lib'); +>lib : any + +// Export equals should be flagged as errors +export = MyModule; +>MyModule : typeof MyModule + +// TypeScript modifiers should be flagged as errors +class MyClass { +>MyClass : MyClass + + public name: string; +>name : string + + private age: number; +>age : number + + protected id: number; +>id : number + + readonly value: number; +>value : number + + constructor(public x: number, private y: number) { +>x : number +>y : number + + this.name = ''; +>this.name = '' : "" +>this.name : string +>this : this +>name : string +>'' : "" + + this.age = 0; +>this.age = 0 : 0 +>this.age : number +>this : this +>age : number +>0 : 0 + + this.id = 0; +>this.id = 0 : 0 +>this.id : number +>this : this +>id : number +>0 : 0 + + this.value = 0; +>this.value = 0 : 0 +>this.value : number +>this : this +>value : number +>0 : 0 + } +} + +// Optional parameters should be flagged as errors +function optionalParam(x?: number) { +>optionalParam : (x?: number) => number +>x : number + + return x || 0; +>x || 0 : number +>x : number +>0 : 0 +} + +// Signature declarations should be flagged as errors +function signatureOnly(x: number): string; +>signatureOnly : (x: number) => string +>x : number + +// Type parameters should be flagged as errors +function generic(x: T): T { +>generic : (x: T) => T +>x : T + + return x; +>x : T +} + +// Type arguments should be flagged as errors +let array = Array(); +>array : boolean +>Array() : boolean +>ArrayArray : ArrayConstructor +>string : any +>() : any +> : any + +// Implements clause should be flagged as errors +class MyClassWithImplements implements Person { +>MyClassWithImplements : MyClassWithImplements + + name = ''; +>name : string +>'' : "" + + age = 0; +>age : number +>0 : 0 +} + +function getValue(): any { +>getValue : () => any + + return null; +} + +interface Config { + name: string; +>name : string +} diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt new file mode 100644 index 0000000000..30ae3fa796 --- /dev/null +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt @@ -0,0 +1,31 @@ +b.js(9,24): error TS8011: Type arguments can only be used in TypeScript files. +b.js(15,24): error TS8011: Type arguments can only be used in TypeScript files. + + +==== a.ts (0 errors) ==== + export class A {} + +==== b.js (2 errors) ==== + import { A } from './a.js'; + + export class B1 extends A { + constructor() { + super(); + } + } + + export class B2 extends A { + ~~~~~~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + constructor() { + super(); + } + } + + export class B3 extends A { + ~~~~~~~~~~~~~~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + constructor() { + super(); + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).js b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).js index a8ea92d742..08d58dbbaa 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).js +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).js @@ -70,32 +70,3 @@ export declare class B2 extends A { export declare class B3 extends A { constructor(); } - - -//// [DtsFileErrors] - - -b.d.ts(2,33): error TS2314: Generic type 'A' requires 1 type argument(s). -b.d.ts(8,33): error TS2314: Generic type 'A' requires 1 type argument(s). - - -==== a.d.ts (0 errors) ==== - export declare class A { - } - -==== b.d.ts (2 errors) ==== - import { A } from './a.js'; - export declare class B1 extends A { - ~ -!!! error TS2314: Generic type 'A' requires 1 type argument(s). - constructor(); - } - export declare class B2 extends A { - constructor(); - } - export declare class B3 extends A { - ~~~~~~~~~~~~~~~~~ -!!! error TS2314: Generic type 'A' requires 1 type argument(s). - constructor(); - } - \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt index 85fc3a63f1..7bb3b52da0 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt @@ -1,11 +1,13 @@ b.js(3,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +b.js(9,24): error TS8011: Type arguments can only be used in TypeScript files. +b.js(15,24): error TS8011: Type arguments can only be used in TypeScript files. b.js(15,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== a.ts (0 errors) ==== export class A {} -==== b.js (2 errors) ==== +==== b.js (4 errors) ==== import { A } from './a.js'; export class B1 extends A { @@ -17,12 +19,16 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' } export class B2 extends A { + ~~~~~~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); } } export class B3 extends A { + ~~~~~~~~~~~~~~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. constructor() { diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt new file mode 100644 index 0000000000..3ca8afa5ec --- /dev/null +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt @@ -0,0 +1,34 @@ +b.js(11,24): error TS8011: Type arguments can only be used in TypeScript files. +b.js(18,24): error TS8011: Type arguments can only be used in TypeScript files. + + +==== a.ts (0 errors) ==== + export class A {} + +==== b.js (2 errors) ==== + import { A } from './a.js'; + + /** @extends {A} */ + export class B1 extends A { + constructor() { + super(); + } + } + + /** @extends {A} */ + export class B2 extends A { + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + constructor() { + super(); + } + } + + /** @extends {A} */ + export class B3 extends A { + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + constructor() { + super(); + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).js b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).js index 732da07a69..331070d2fe 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).js +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).js @@ -79,35 +79,3 @@ export declare class B2 extends A { export declare class B3 extends A { constructor(); } - - -//// [DtsFileErrors] - - -b.d.ts(3,33): error TS2314: Generic type 'A' requires 1 type argument(s). -b.d.ts(11,33): error TS2314: Generic type 'A' requires 1 type argument(s). - - -==== a.d.ts (0 errors) ==== - export declare class A { - } - -==== b.d.ts (2 errors) ==== - import { A } from './a.js'; - /** @extends {A} */ - export declare class B1 extends A { - ~ -!!! error TS2314: Generic type 'A' requires 1 type argument(s). - constructor(); - } - /** @extends {A} */ - export declare class B2 extends A { - constructor(); - } - /** @extends {A} */ - export declare class B3 extends A { - ~~~~~~~~~~~~~~~~~ -!!! error TS2314: Generic type 'A' requires 1 type argument(s). - constructor(); - } - \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt index a2ad36543e..06142b48bc 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt @@ -1,11 +1,13 @@ b.js(4,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +b.js(11,24): error TS8011: Type arguments can only be used in TypeScript files. +b.js(18,24): error TS8011: Type arguments can only be used in TypeScript files. b.js(18,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== a.ts (0 errors) ==== export class A {} -==== b.js (2 errors) ==== +==== b.js (4 errors) ==== import { A } from './a.js'; /** @extends {A} */ @@ -19,6 +21,8 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' /** @extends {A} */ export class B2 extends A { + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); } @@ -26,6 +30,8 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' /** @extends {A} */ export class B3 extends A { + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. constructor() { diff --git a/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.errors.txt b/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.errors.txt new file mode 100644 index 0000000000..69a7672661 --- /dev/null +++ b/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.errors.txt @@ -0,0 +1,11 @@ +/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + /** + * @param {{ a: number; b: string }} args + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f({ a, b }) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/jsdocParseAwait.errors.txt b/testdata/baselines/reference/conformance/jsdocParseAwait.errors.txt index eac1d028f9..fe0f53f431 100644 --- a/testdata/baselines/reference/conformance/jsdocParseAwait.errors.txt +++ b/testdata/baselines/reference/conformance/jsdocParseAwait.errors.txt @@ -1,24 +1,33 @@ +/a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(7,7): error TS2322: Type 'number' is not assignable to type 'T'. +/a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (1 errors) ==== +==== /a.js (4 errors) ==== /** * @typedef {object} T * @property {boolean} await */ /** @type {T} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const a = 1; ~ !!! error TS2322: Type 'number' is not assignable to type 'T'. /** @type {T} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const b = { await: false, }; /** * @param {boolean} await + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function c(await) {} \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/typeTagForMultipleVariableDeclarations.errors.txt b/testdata/baselines/reference/conformance/typeTagForMultipleVariableDeclarations.errors.txt new file mode 100644 index 0000000000..49d4f47832 --- /dev/null +++ b/testdata/baselines/reference/conformance/typeTagForMultipleVariableDeclarations.errors.txt @@ -0,0 +1,12 @@ +typeTagForMultipleVariableDeclarations.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== typeTagForMultipleVariableDeclarations.js (1 errors) ==== + /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var x,y,z; + x + y + z + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt b/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt index 1ce833f6c1..5f6cd8e252 100644 --- a/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt @@ -1,16 +1,24 @@ /test.js(3,9): error TS2322: Type '{}' is not assignable to type 'string'. +/test.js(4,6): error TS8009: The 'declare' modifier can only be used in TypeScript files. +/test.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. /test.js(9,19): error TS2339: Property 'foo' does not exist on type 'string'. -==== /test.js (2 errors) ==== +==== /test.js (4 errors) ==== class Foo { constructor() { this.prop = {}; ~~~~~~~~~ !!! error TS2322: Type '{}' is not assignable to type 'string'. } + + declare prop: string; + ~~~~~~~~~~~ +!!! error TS8009: The 'declare' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. method() { this.prop.foo diff --git a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt index 1fafa07a86..a565b3bebd 100644 --- a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt @@ -1,3 +1,4 @@ +ExtendedClass.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. ExtendedClass.js(17,5): error TS1231: An export assignment must be at the top level of a file or module declaration. 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,11 +13,13 @@ ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type } export = BaseClass; } -==== ExtendedClass.js (3 errors) ==== +==== ExtendedClass.js (4 errors) ==== define("lib/ExtendedClass", ["deps/BaseClass"], /** * {typeof import("deps/BaseClass")} * @param {typeof import("deps/BaseClass")} BaseClass + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns */ (BaseClass) => { diff --git a/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt index d0da78af1a..710789c4b3 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt @@ -1,9 +1,10 @@ main.js(3,9): error TS2554: Expected 0 arguments, but got 3. main.js(5,1): error TS2554: Expected 2 arguments, but got 0. main.js(6,16): error TS2554: Expected 2 arguments, but got 3. +main.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -==== main.js (3 errors) ==== +==== main.js (4 errors) ==== function allRest() { arguments; } allRest(); allRest(1, 2, 3); @@ -20,6 +21,8 @@ main.js(6,16): error TS2554: Expected 2 arguments, but got 3. /** * @param {number} x - a thing + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function jsdocced(x) { arguments; } jsdocced(1); diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.errors.txt new file mode 100644 index 0000000000..b70af30395 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.errors.txt @@ -0,0 +1,20 @@ +/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class A { + /** + * Constructor + * + * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(foo = {}) { + /** + * @type object + */ + this.arguments = foo; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.errors.txt new file mode 100644 index 0000000000..eff8d9204f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.errors.txt @@ -0,0 +1,20 @@ +/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class A { + /** + * Constructor + * + * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(foo = {}) { + /** + * @type object + */ + this["arguments"] = foo; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt new file mode 100644 index 0000000000..154633f65d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt @@ -0,0 +1,33 @@ +/a.js(11,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class A { + get arguments() { + return { bar: {} }; + } + } + + class B extends A { + /** + * Constructor + * + * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(foo = {}) { + super(); + + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = super.arguments.foo; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt index 30d6092c3f..258872a506 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt @@ -1,12 +1,16 @@ +/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. /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 (1 errors) ==== +==== /a.js (3 errors) ==== class A { /** * Constructor * * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(foo = {}) { const key = "bar"; @@ -18,6 +22,8 @@ /** * @type object + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const arguments = this.arguments; ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.errors.txt new file mode 100644 index 0000000000..8a6cd4bf83 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.errors.txt @@ -0,0 +1,29 @@ +/a.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + const bar = { + arguments: {} + } + + class A { + /** + * Constructor + * + * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(foo = {}) { + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = bar.arguments; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.errors.txt new file mode 100644 index 0000000000..19711439dd --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.errors.txt @@ -0,0 +1,18 @@ +/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class A { + /** + * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + m(foo = {}) { + /** + * @type object + */ + this.arguments = foo; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.errors.txt new file mode 100644 index 0000000000..c07059ff7b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.errors.txt @@ -0,0 +1,18 @@ +/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class A { + /** + * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + m(foo = {}) { + /** + * @type object + */ + this["arguments"] = foo; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt new file mode 100644 index 0000000000..7ce6ffdfa1 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt @@ -0,0 +1,29 @@ +/a.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class A { + get arguments() { + return { bar: {} }; + } + } + + class B extends A { + /** + * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + m(foo = {}) { + /** + * @type object + */ + this.x = foo; + + /** + * @type object + */ + this.y = super.arguments.bar; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt index 8c90a67da1..8afe5745a4 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt @@ -1,10 +1,14 @@ +/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. /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 (1 errors) ==== +==== /a.js (3 errors) ==== class A { /** * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ m(foo = {}) { const key = "bar"; @@ -16,6 +20,8 @@ /** * @type object + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const arguments = this.arguments; ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.errors.txt new file mode 100644 index 0000000000..fa5cea40af --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.errors.txt @@ -0,0 +1,27 @@ +/a.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + const bar = { + arguments: {} + } + + class A { + /** + * @param {object} [foo={}] + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + m(foo = {}) { + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = bar.arguments; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt index ff0349247e..a6ee9d2699 100644 --- a/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt @@ -1,16 +1,32 @@ +mytest.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +mytest.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. +mytest.js(6,13): error TS8004: Type parameter declarations can only be used in TypeScript files. +mytest.js(6,34): error TS8016: Type assertion expressions can only be used in TypeScript files. mytest.js(6,45): error TS2322: Type 'string' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. +mytest.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +mytest.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. +mytest.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. +mytest.js(13,34): error TS8016: Type assertion expressions can only be used in TypeScript files. mytest.js(13,61): error TS2322: Type 'string' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -==== mytest.js (2 errors) ==== +==== mytest.js (10 errors) ==== /** * @template T * @param {T|undefined} value value or not + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} result value + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo1 = value => /** @type {string} */({ ...value }); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. @@ -18,9 +34,17 @@ mytest.js(13,61): error TS2322: Type 'string' is not assignable to type 'T'. /** * @template T * @param {T|undefined} value value or not + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} result value + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt b/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt new file mode 100644 index 0000000000..d832f54e6a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt @@ -0,0 +1,21 @@ +mytest.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +mytest.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. +mytest.js(6,24): error TS8004: Type parameter declarations can only be used in TypeScript files. +mytest.js(6,45): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== mytest.js (4 errors) ==== + /** + * @template T + * @param {T|undefined} value value or not + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} result value + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const cloneObjectGood = value => /** @type {T} */({ ...value }); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.errors.txt b/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.errors.txt new file mode 100644 index 0000000000..6a5b9b3fd9 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.errors.txt @@ -0,0 +1,27 @@ +index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(10,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(11,18): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (3 errors) ==== + /** + * @param {any} v + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function identity(v) { + return v; + } + + const x = identity( + /** + * @param {number} param + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number=} + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + param => param + ); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt index 50e261254c..73bb691f4d 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt @@ -1,7 +1,8 @@ +file.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. -==== file.js (1 errors) ==== +==== file.js (2 errors) ==== // @ts-check const obj = { x: 1, @@ -10,6 +11,8 @@ file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. /** * @type {keyof typeof obj} + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ let selected = "x"; selected = "z"; // should fail diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt index 855d7577c6..e48af078d5 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt @@ -1,4 +1,6 @@ +something.js(3,20): error TS8010: Type annotations can only be used in TypeScript files. something.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +something.js(5,29): error TS8016: Type assertion expressions can only be used in TypeScript files. ==== file.ts (0 errors) ==== @@ -11,11 +13,15 @@ something.js(5,1): error TS2309: An export assignment cannot be used in a module } export = Foo; -==== something.js (1 errors) ==== +==== something.js (3 errors) ==== /** @typedef {typeof import("./file")} Foo */ /** @typedef {(foo: Foo) => string} FooFun */ + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. module.exports = /** @type {FooFun} */(void 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constructorPropertyJs.errors.txt b/testdata/baselines/reference/submodule/compiler/constructorPropertyJs.errors.txt new file mode 100644 index 0000000000..c678122eeb --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/constructorPropertyJs.errors.txt @@ -0,0 +1,15 @@ +/a.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class C { + /** + * @param {any} a + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + foo(a) { + this.constructor = a; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt index dbf4731034..9a2e347d44 100644 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt @@ -1,24 +1,42 @@ +index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(8,28): error TS8010: Type annotations can only be used in TypeScript files. +index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(14,6): error TS8009: The '?' modifier can only be used in TypeScript files. 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(22,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(25,6): error TS8009: The '?' modifier can only be used in TypeScript files. +index.js(25,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (2 errors) ==== +==== index.js (10 errors) ==== /** * * @param {number} num + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function acceptNum(num) {} /** * @typedef {(a: string, b: number) => void} Fn + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** @type {Fn} */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const fn1 = /** * @param [b] + ~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. */ function self(a, b) { acceptNum(b); // error @@ -30,9 +48,15 @@ index.js(28,15): error TS2345: Argument of type 'number | undefined' is not assi }; /** @type {Fn} */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const fn2 = /** * @param {number} [b] + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function self(a, b) { acceptNum(b); // error diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt index b812e341fb..1e3c878649 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt @@ -1,41 +1,76 @@ +index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(2,28): error TS2304: Cannot find name 'B'. +index.js(2,41): error TS8010: Type annotations can only be used in TypeScript files. index.js(2,42): error TS2304: Cannot find name 'A'. +index.js(2,47): error TS8010: Type annotations can only be used in TypeScript files. index.js(2,48): error TS2304: Cannot find name 'B'. index.js(2,67): error TS2304: Cannot find name 'B'. index.js(10,12): error TS2315: Type 'Funcs' is not generic. +index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. +index.js(14,21): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(20,19): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (5 errors) ==== +==== index.js (12 errors) ==== /** + ~~~ * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'B'. + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'A'. + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'B'. ~ !!! error TS2304: Cannot find name 'B'. * @template A + ~~~~~~~~~~~~~~ * @template {Record} B + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + ~~~ + /** + ~~~ * @template A + ~~~~~~~~~~~~~~ * @template {Record} B + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Funcs} fns + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2315: Type 'Funcs' is not generic. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {[A, B]} + ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function foo(fns) { + ~~~~~~~~~~~~~~~~~~~ return /** @type {any} */ (null); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. const result = foo({ bar: { fn: /** @param {string} a */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. (a) => {}, thing: "asd", }, diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt new file mode 100644 index 0000000000..aed736bfb8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt @@ -0,0 +1,65 @@ +index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. +index.js(7,21): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(12,6): error TS8009: The '?' modifier can only be used in TypeScript files. +index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,6): error TS8009: The '?' modifier can only be used in TypeScript files. +index.js(19,14): error TS8010: Type annotations can only be used in TypeScript files. +index.js(20,6): error TS8009: The '?' modifier can only be used in TypeScript files. +index.js(20,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (10 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + * @param {(value: T, index: number) => boolean} predicate + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function filter(predicate) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + return /** @type {any} */ (null); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + const a = filter( + /** + * @param {number} [pose] + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + (pose) => true + ); + + const b = filter( + /** + * @param {number} [pose] + ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} [_] + ~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + (pose, _) => true + ); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt index d525041aed..9063921a34 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt @@ -1,3 +1,4 @@ +uglify.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. uglify.js(6,7): error TS2339: Property 'val' does not exist on type '{}'. @@ -110,10 +111,12 @@ uglify.js(6,7): error TS2339: Property 'val' does not exist on type '{}'. } // Repro from #27550 (based on uglify code) -==== uglify.js (1 errors) ==== +==== uglify.js (2 errors) ==== /** @constructor */ function AtTop(val) { this.val = val } /** @type {*} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var v = 1; if (v instanceof AtTop) { v.val diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt new file mode 100644 index 0000000000..f2d8b4bc91 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt @@ -0,0 +1,97 @@ +input.js(5,30): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(7,30): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(8,34): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(10,35): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. +input.js(13,59): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(16,24): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(17,44): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +input.js(18,43): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(19,27): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. +input.js(21,46): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(23,40): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(25,33): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(29,27): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. +input.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. +input.js(37,70): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== input.js (19 errors) ==== + /** + * @typedef {{ } & { name?: string }} P + */ + + const something = /** @type {*} */(null); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export let vLet = /** @type {P} */(something); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + export const vConst = /** @type {P} */(something); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export function fn(p = /** @type {P} */(something)) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** @param {number} req */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export class C { + field = /** @type {P} */(something); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @optional */ optField = /** @type {P} */(something); // not a thing + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @readonly */ roFiled = /** @type {P} */(something); + ~~~~~~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + method(p = /** @type {P} */(something)) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @param {number} req */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + methodWithRequiredDefault(p = /** @type {P} */(something), req) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + constructor(ctorField = /** @type {P} */(something)) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + get x() { return /** @type {P} */(something) } + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + set x(v) { } + } + + export default /** @type {P} */(something); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + // allows `undefined` on the input side, thanks to the initializer + /** + * + * @param {P} x + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ 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 new file mode 100644 index 0000000000..f2d8b4bc91 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt @@ -0,0 +1,97 @@ +input.js(5,30): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(7,30): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(8,34): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(10,35): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. +input.js(13,59): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(16,24): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(17,44): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +input.js(18,43): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(19,27): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. +input.js(21,46): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(23,40): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(25,33): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(29,27): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. +input.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. +input.js(37,70): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== input.js (19 errors) ==== + /** + * @typedef {{ } & { name?: string }} P + */ + + const something = /** @type {*} */(null); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export let vLet = /** @type {P} */(something); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + export const vConst = /** @type {P} */(something); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export function fn(p = /** @type {P} */(something)) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** @param {number} req */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export class C { + field = /** @type {P} */(something); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @optional */ optField = /** @type {P} */(something); // not a thing + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @readonly */ roFiled = /** @type {P} */(something); + ~~~~~~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + method(p = /** @type {P} */(something)) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @param {number} req */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + methodWithRequiredDefault(p = /** @type {P} */(something), req) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + constructor(ctorField = /** @type {P} */(something)) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + get x() { return /** @type {P} */(something) } + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + set x(v) { } + } + + export default /** @type {P} */(something); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + // allows `undefined` on the input side, thanks to the initializer + /** + * + * @param {P} x + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.errors.txt new file mode 100644 index 0000000000..dc4ded71e1 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.errors.txt @@ -0,0 +1,26 @@ +index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/58167 + + export class VFile { + /** + * @returns {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get path() { + return '' + } + + /** + * @param {URL | string} path + ~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set path(path) { + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt new file mode 100644 index 0000000000..7dbdafd6f7 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt @@ -0,0 +1,17 @@ +foo.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.js (1 errors) ==== + // https://github.com/microsoft/TypeScript/issues/55391 + + export class Foo { + /** + * Bar. + * + * @param {string} baz Baz. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set bar(baz) {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt new file mode 100644 index 0000000000..7ac769101d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt @@ -0,0 +1,15 @@ +foo.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.js (1 errors) ==== + export class Foo { + /** + * Bar. + * + * @param {{ prop: string }} baz Baz. + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set bar({}) {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt new file mode 100644 index 0000000000..19362d33d0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt @@ -0,0 +1,15 @@ +foo.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.js (1 errors) ==== + export class Foo { + /** + * Bar. + * + * @param {{ prop: string | undefined }} baz Baz. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set bar({ prop = 'foo' }) {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.errors.txt new file mode 100644 index 0000000000..3a2f165e7f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.errors.txt @@ -0,0 +1,35 @@ +file.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== file.js (4 errors) ==== + export function foo() {} + foo.bar = 12; + const _private = Symbol(); + foo[_private] = "ok"; + const strMem = "strMemName"; + foo[strMem] = "ok"; + const dashStrMem = "dashed-str-mem"; + foo[dashStrMem] = "ok"; + const numMem = 42; + foo[numMem] = "ok"; + + /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const x = foo[_private]; + /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const y = foo[strMem]; + /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const z = foo[numMem]; + /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const a = foo[dashStrMem]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt new file mode 100644 index 0000000000..9ebbea8d8f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt @@ -0,0 +1,71 @@ +index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. +index.js(21,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(28,14): error TS8010: Type annotations can only be used in TypeScript files. +index.js(36,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(46,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (6 errors) ==== + // same type accessors + export const obj1 = { + /** + * my awesome getter (first in source order) + * @returns {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get x() { + return ""; + }, + /** + * my awesome setter (second in source order) + * @param {string} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set x(a) {}, + }; + + // divergent accessors + export const obj2 = { + /** + * my awesome getter + * @returns {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get x() { + return ""; + }, + /** + * my awesome setter + * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set x(a) {}, + }; + + export const obj3 = { + /** + * my awesome getter + * @returns {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get x() { + return ""; + }, + }; + + export const obj4 = { + /** + * my awesome setter + * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set x(a) {}, + }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt new file mode 100644 index 0000000000..b1d4e09602 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt @@ -0,0 +1,12 @@ +a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + @SomeDecorator + class SomeClass { + foo(x: number) { + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorInJsFile1.errors.txt b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile1.errors.txt new file mode 100644 index 0000000000..b1d4e09602 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile1.errors.txt @@ -0,0 +1,12 @@ +a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + @SomeDecorator + class SomeClass { + foo(x: number) { + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt index 267621261d..8936b23ce8 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt @@ -1,7 +1,10 @@ +input.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +input.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. +input.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== input.js (1 errors) ==== +==== input.js (4 errors) ==== /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ /** @@ -10,6 +13,8 @@ input.js(48,1): error TS2309: An export assignment cannot be used in a module wi /** * @type {StatelessComponent} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const MyComponent = () => /* @type {any} */(null); @@ -28,12 +33,16 @@ input.js(48,1): error TS2309: An export assignment cannot be used in a module wi /** * @type {StatelessComponent} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const check = MyComponent2; /** * * @param {{ props: MyComponentProps }} p + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function expectLiteral(p) {} diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.errors.txt b/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.errors.txt new file mode 100644 index 0000000000..77e0dc9ed8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.errors.txt @@ -0,0 +1,24 @@ +/a.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /types.ts (0 errors) ==== + export const symb = Symbol(); + + export interface TestSymb { + (): void; + readonly [symb]: boolean; + } + +==== /a.js (1 errors) ==== + import { symb } from "./types"; + + /** + * @returns {import("./types").TestSymb} + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function test() { + function inner() {} + inner[symb] = true; + return inner; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.errors.txt b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.errors.txt new file mode 100644 index 0000000000..c92317d64c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.errors.txt @@ -0,0 +1,16 @@ +a.js(6,27): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + /** + * A number, or a string containing a number. + * @typedef {(number|string)} NumberLike + */ + + export default /** @type {NumberLike[]} */([ ]); + ~~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + +==== b.ts (0 errors) ==== + import A from './a' + A[0] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt new file mode 100644 index 0000000000..6b83f1862f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt @@ -0,0 +1,17 @@ +file.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== file.js (2 errors) ==== + /** + * Adds + * @param {number} 𝑚 + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} 𝑀 + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo(𝑚, 𝑀) { + console.log(𝑀 + 𝑚); + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt index a044985514..895ee75377 100644 --- a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@ -1,6 +1,10 @@ +BaseB.js(1,29): error TS8004: Type parameter declarations can only be used in TypeScript files. BaseB.js(2,25): error TS1005: ',' expected. +BaseB.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(3,14): error TS2304: Cannot find name 'Class'. +BaseB.js(4,24): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(4,25): error TS2304: Cannot find name 'Class'. +SubB.js(3,34): error TS8011: Type arguments can only be used in TypeScript files. ==== BaseA.js (0 errors) ==== @@ -10,24 +14,38 @@ BaseB.js(4,25): error TS2304: Cannot find name 'Class'. import BaseA from './BaseA'; export default class SubA extends BaseA { } -==== BaseB.js (3 errors) ==== +==== BaseB.js (6 errors) ==== import BaseA from './BaseA'; + export default class B { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS1005: ',' expected. _AClass: Class; + ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2304: Cannot find name 'Class'. constructor(AClass: Class) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2304: Cannot find name 'Class'. this._AClass = AClass; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } + ~~~~~ } -==== SubB.js (0 errors) ==== + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. +==== SubB.js (1 errors) ==== import SubA from './SubA'; import BaseB from './BaseB'; export default class SubB extends BaseB { + ~~~~~~~~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(SubA); } 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..44c25b2b53 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.errors.txt @@ -0,0 +1,15 @@ +usage.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== interfaces.d.ts (0 errors) ==== + export interface Bar { + prop: string + } + +==== usage.js (1 errors) ==== + /** @type {Bar} */ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + export let bar; + + /** @typedef {import('./interfaces').Bar} Bar */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt new file mode 100644 index 0000000000..2ed16c4317 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt @@ -0,0 +1,35 @@ +index.js(10,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== test/Test.js (0 errors) ==== + /** @module test/Test */ + class Test {} + export default Test; +==== Test.js (0 errors) ==== + /** @module Test */ + class Test {} + export default Test; +==== index.js (1 errors) ==== + import Test from './test/Test.js' + + /** + * @typedef {Object} Options + * @property {typeof import("./Test.js").default} [test] + */ + + class X extends Test { + /** + * @param {Options} options + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(options) { + super(); + if (options.test) { + this.test = new options.test(); + } + } + } + + export default X; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt new file mode 100644 index 0000000000..d0f7b071ee --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt @@ -0,0 +1,43 @@ +a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. +a.js(20,15): error TS8010: Type annotations can only be used in TypeScript files. +a.js(27,15): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (3 errors) ==== + /** + * @typedef A + * @property {string} a + */ + + /** + * @typedef B + * @property {number} b + */ + + class C1 { + /** + * @type {A} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + value; + } + + class C2 extends C1 { + /** + * @type {A} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + value; + } + + class C3 extends C1 { + /** + * @type {A & B} + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + value; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt new file mode 100644 index 0000000000..e9ad58087a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt @@ -0,0 +1,51 @@ +index.js(7,8): error TS8009: The '?' modifier can only be used in TypeScript files. +index.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== 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 (2 errors) ==== + /** + * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit + */ + + export class NewAjax { + /** + * @param {LionRequestInit} [init] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + case5_unexpectedlyResolvesPathToNodeModules(init) {} + } + + /** + * @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/jsEnumCrossFileExport.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt index 3be4b9a200..ef0503fe04 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt @@ -1,8 +1,11 @@ enumDef.js(16,18): error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. +index.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. 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(13,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(18,11): error TS2503: Cannot find namespace 'Host'. +index.js(18,11): error TS8010: Type annotations can only be used in TypeScript files. ==== enumDef.js (1 errors) ==== @@ -26,11 +29,13 @@ index.js(18,11): error TS2503: Cannot find namespace 'Host'. !!! error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. x: 12 } -==== index.js (4 errors) ==== +==== index.js (7 errors) ==== var Other = {}; Other.Cls = class { /** * @param {!Host.UserMetrics.Action} p + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~ !!! error TS2503: Cannot find namespace 'Host'. */ @@ -46,6 +51,8 @@ index.js(18,11): error TS2503: Cannot find namespace 'Host'. * @type {Host.UserMetrics.Bargh} ~~~~ !!! error TS2503: Cannot find namespace 'Host'. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var x = "ok"; @@ -53,6 +60,8 @@ index.js(18,11): error TS2503: Cannot find namespace 'Host'. * @type {Host.UserMetrics.Blah} ~~~~ !!! error TS2503: Cannot find namespace 'Host'. + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var y = "ok"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt index 2d268cb5a4..e3d63583c6 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt @@ -1,8 +1,11 @@ index.js(10,12): error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? +index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(17,16): error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? +usage.js(12,16): error TS8010: Type annotations can only be used in TypeScript files. -==== usage.js (0 errors) ==== +==== usage.js (1 errors) ==== const { Thing, useThing, cbThing } = require("./index"); useThing(Thing.a); @@ -15,13 +18,15 @@ index.js(17,16): error TS2749: 'Thing' refers to a value, but is being used as a cbThing(type => { /** @type {LogEntry} */ + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const logEntry = { time: Date.now(), type, }; }); -==== index.js (2 errors) ==== +==== index.js (4 errors) ==== /** @enum {string} */ const Thing = Object.freeze({ a: "thing", @@ -34,6 +39,8 @@ index.js(17,16): error TS2749: 'Thing' refers to a value, but is being used as a * @param {Thing} x ~~~~~ !!! error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function useThing(x) {} @@ -41,6 +48,8 @@ index.js(17,16): error TS2749: 'Thing' refers to a value, but is being used as a /** * @param {(x: Thing) => void} x + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? */ diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt index b210254502..3b92affccd 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt @@ -1,11 +1,14 @@ /index.ts(1,23): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. /index.ts(3,16): error TS2671: Cannot augment module './test' because it resolves to a non-module entity. /index.ts(11,10): error TS2749: 'Abcde' refers to a value, but is being used as a type here. Did you mean 'typeof Abcde'? +/test.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. -==== /test.js (0 errors) ==== +==== /test.js (1 errors) ==== class Abcde { /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. x; } diff --git a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt index 82c630fced..509b83a4a5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt @@ -1,12 +1,13 @@ /b.js(1,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. /b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +/b.js(9,16): error TS8011: Type arguments can only be used in TypeScript files. /b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== /a.d.ts (0 errors) ==== declare class A { x: T; } -==== /b.js (3 errors) ==== +==== /b.js (4 errors) ==== class B extends A {} ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -20,6 +21,8 @@ /** @augments A */ class D extends A {} + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new D().x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt new file mode 100644 index 0000000000..04fe429763 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt @@ -0,0 +1,67 @@ +jsFileAlternativeUseOfOverloadTag.js(7,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileAlternativeUseOfOverloadTag.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileAlternativeUseOfOverloadTag.js(25,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileAlternativeUseOfOverloadTag.js(38,7): error TS8017: Signature declarations can only be used in TypeScript files. + + +==== jsFileAlternativeUseOfOverloadTag.js (4 errors) ==== + // These are a few examples of existing alternative uses of @overload tag. + // They will not work as expected with our implementation, but we are + // trying to make sure that our changes do not result in any crashes here. + + const example1 = { + /** + * @overload Example1(value) + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * Creates Example1 + * @param value [String] + */ + constructor: function Example1(value, options) {}, + }; + + const example2 = { + /** + * Example 2 + * + * @overload Example2(value) + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * Creates Example2 + * @param value [String] + * @param secretAccessKey [String] + * @param sessionToken [String] + * @example Creates with string value + * const example = new Example(''); + * @overload Example2(options) + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * Creates Example2 + * @option options value [String] + * @example Creates with options object + * const example = new Example2({ + * value: '', + * }); + */ + constructor: function Example2() {}, + }; + + const example3 = { + /** + * @overload evaluate(options = {}, [callback]) + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * Evaluate something + * @note Something interesting + * @param options [map] + * @return [string] returns evaluation result + * @return [null] returns nothing if callback provided + * @callback callback function (error, result) + * If callback is provided it will be called with evaluation result + * @param error [Error] + * @param result [String] + * @see callback + */ + evaluate: function evaluate(options, callback) {}, + }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js index 30fd9c4e05..13ef5bec9b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js @@ -109,16 +109,3 @@ const example3 = { //// [jsFileAlternativeUseOfOverloadTag.d.ts] export type callback = (error: any, result: any) ; - - -//// [DtsFileErrors] - - -dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected. - - -==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ==== - export type callback = (error: any, result: any) ; - ~ -!!! error TS1005: '=>' expected. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff index 72bb7b12fe..6e8d9cbba7 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff @@ -83,17 +83,4 @@ - * If callback is provided it will be called with evaluation result - */ -type callback = (error: any, result: any) => any; -+export type callback = (error: any, result: any) ; -+ -+ -+//// [DtsFileErrors] -+ -+ -+dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected. -+ -+ -+==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ==== -+ export type callback = (error: any, result: any) ; -+ ~ -+!!! error TS1005: '=>' expected. -+ \ No newline at end of file ++export type callback = (error: any, result: any) ; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt new file mode 100644 index 0000000000..b446fc3a1e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt @@ -0,0 +1,10 @@ +a.js(1,19): error TS8009: The 'abstract' modifier can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + abstract class c { + + abstract x; + ~~~~~~~~~~~~ +!!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt new file mode 100644 index 0000000000..85c0726c51 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt @@ -0,0 +1,7 @@ +a.js(1,1): error TS8009: The 'declare' modifier can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + declare var v; + ~~~~~~~ +!!! error TS8009: The 'declare' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt new file mode 100644 index 0000000000..b431db5082 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt @@ -0,0 +1,11 @@ +a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class A { + + constructor(); + ~~~~~~~~~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt new file mode 100644 index 0000000000..b6b379725e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt @@ -0,0 +1,7 @@ +a.js(1,1): error TS8006: 'enum' declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + enum E { } + ~~~~~~~~~~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt new file mode 100644 index 0000000000..e3dff95dcf --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt @@ -0,0 +1,7 @@ +a.js(1,1): error TS8003: 'export =' can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + export = b; + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt new file mode 100644 index 0000000000..5af6399a20 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt @@ -0,0 +1,8 @@ +a.js(1,1): error TS8017: Signature declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + function foo(); + ~~~~~~~~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt new file mode 100644 index 0000000000..c7c83910d7 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt @@ -0,0 +1,7 @@ +a.js(1,8): error TS8005: 'implements' clauses can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class C implements D { } + ~~~~~~~~~~~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationImportEqualsSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationImportEqualsSyntax.errors.txt new file mode 100644 index 0000000000..9b7d70f10c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationImportEqualsSyntax.errors.txt @@ -0,0 +1,7 @@ +a.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + import a = b; + ~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt new file mode 100644 index 0000000000..1ac15ecbbc --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt @@ -0,0 +1,7 @@ +a.js(1,1): error TS8006: 'interface' declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + interface I { } + ~~~~~~~~~~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt new file mode 100644 index 0000000000..ac4dcee555 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt @@ -0,0 +1,11 @@ +a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class A { + + foo(); + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt new file mode 100644 index 0000000000..28d9ad8889 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt @@ -0,0 +1,7 @@ +a.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + module M { } + ~~~~~~~~~~~~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.errors.txt new file mode 100644 index 0000000000..68250662d8 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.errors.txt @@ -0,0 +1,8 @@ +/src/a.js(1,1): error TS8013: Non-null assertions can only be used in TypeScript files. + + +==== /src/a.js (1 errors) ==== + 0! + ~~ +!!! error TS8013: Non-null assertions can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalParameter.errors.txt new file mode 100644 index 0000000000..a83a9ae624 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalParameter.errors.txt @@ -0,0 +1,7 @@ +a.js(1,13): error TS8009: The '?' modifier can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + function F(p?) { } + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicParameterModifier.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicParameterModifier.errors.txt new file mode 100644 index 0000000000..dbbda42497 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicParameterModifier.errors.txt @@ -0,0 +1,7 @@ +a.js(1,23): error TS8012: Parameter modifiers can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class C { constructor(public x) { }} + ~~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt new file mode 100644 index 0000000000..a6202acb9d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt @@ -0,0 +1,7 @@ +a.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + function F(): number { } + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.errors.txt new file mode 100644 index 0000000000..f3297c29b3 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.errors.txt @@ -0,0 +1,12 @@ +a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + /** + * @type {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @type {string} + */ + var v; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt new file mode 100644 index 0000000000..42fde88372 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt @@ -0,0 +1,7 @@ +a.js(1,1): error TS8008: Type aliases can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + type a = b; + ~~~~~~~~~~~ +!!! error TS8008: Type aliases can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.types b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.types index 616eb435af..06124a6082 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.types @@ -2,5 +2,5 @@ === a.js === type a = b; ->a : error +>a : b diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt index b4e67ebf93..cb2816c47f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt @@ -1,9 +1,12 @@ +/src/a.js(1,5): error TS8016: Type assertion expressions can only be used in TypeScript files. /src/a.js(2,10): error TS17008: JSX element 'string' has no corresponding closing tag. /src/a.js(3,1): error TS1005: 'undefined; ~~~~~~ !!! error TS17008: JSX element 'string' has no corresponding closing tag. diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt new file mode 100644 index 0000000000..df82865bb6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt @@ -0,0 +1,7 @@ +a.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + function F(a: number) { } + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt new file mode 100644 index 0000000000..bf7b029203 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt @@ -0,0 +1,7 @@ +a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class C { } + ~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt new file mode 100644 index 0000000000..aeba725884 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt @@ -0,0 +1,8 @@ +a.js(1,12): error TS8004: Type parameter declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + const Bar = class {}; + ~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt new file mode 100644 index 0000000000..8edbd7e8b6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt @@ -0,0 +1,7 @@ +a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + function F() { } + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt new file mode 100644 index 0000000000..2239b21291 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt @@ -0,0 +1,7 @@ +a.js(1,7): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + var v: () => number; + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt new file mode 100644 index 0000000000..6a3458a11a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt @@ -0,0 +1,106 @@ +jsFileFunctionOverloads.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads.js(12,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads.js(27,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads.js(29,17): error TS8004: Type parameter declarations can only be used in TypeScript files. +jsFileFunctionOverloads.js(34,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads.js(41,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads.js(48,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads.js(51,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads.js(54,31): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== jsFileFunctionOverloads.js (15 errors) ==== + /** + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {number} x + * @returns {'number'} + */ + /** + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {string} x + * @returns {'string'} + */ + /** + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {boolean} x + * @returns {'boolean'} + */ + /** + * @param {unknown} x + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function getTypeName(x) { + return typeof x; + } + + /** + * @template T + * @param {T} x + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const identity = x => x; + ~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + * @template T + * @template U + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {T[]} array + * @param {(x: T) => U[]} iterable + * @returns {U[]} + */ + /** + * @template T + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {T[][]} array + * @returns {T[]} + */ + /** + * @param {unknown[]} array + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {(x: unknown) => unknown} iterable + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {unknown[]} + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function flatMap(array, iterable = identity) { + /** @type {unknown[]} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const result = []; + for (let i = 0; i < array.length; i += 1) { + result.push(.../** @type {unknown[]} */(iterable(array[i]))); + ~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + return result; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt new file mode 100644 index 0000000000..d829abbfdf --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt @@ -0,0 +1,101 @@ +jsFileFunctionOverloads2.js(3,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(11,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(25,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(27,17): error TS8004: Type parameter declarations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(32,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(37,5): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(41,12): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(42,12): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(43,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(46,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(49,31): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== jsFileFunctionOverloads2.js (15 errors) ==== + // Also works if all @overload tags are combined in one comment. + /** + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {number} x + * @returns {'number'} + * + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {string} x + * @returns {'string'} + * + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {boolean} x + * @returns {'boolean'} + * + * @param {unknown} x + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function getTypeName(x) { + return typeof x; + } + + /** + * @template T + * @param {T} x + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const identity = x => x; + ~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + * @template T + * @template U + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {T[]} array + * @param {(x: T) => U[]} iterable + * @returns {U[]} + * + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {T[][]} array + * @returns {T[]} + * + * @param {unknown[]} array + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {(x: unknown) => unknown} iterable + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {unknown[]} + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function flatMap(array, iterable = identity) { + /** @type {unknown[]} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const result = []; + for (let i = 0; i < array.length; i += 1) { + result.push(.../** @type {unknown[]} */(iterable(array[i]))); + ~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + return result; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js index 91b2848fb0..335d3bf65f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js @@ -120,29 +120,3 @@ declare function getTypeName(x: boolean): 'boolean'; declare const identity: (x: T) => T; declare function flatMap(array: T[], iterable: (x: T) => U[]): U[]; declare function flatMap(array: T[][]): T[]; - - -//// [DtsFileErrors] - - -dist/jsFileFunctionOverloads2.d.ts(11,33): error TS2304: Cannot find name 'T'. -dist/jsFileFunctionOverloads2.d.ts(11,41): error TS2304: Cannot find name 'T'. - - -==== dist/jsFileFunctionOverloads2.d.ts (2 errors) ==== - declare function getTypeName(x: number): 'number'; - declare function getTypeName(x: string): 'string'; - declare function getTypeName(x: boolean): 'boolean'; - /** - * @template T - * @param {T} x - * @returns {T} - */ - declare const identity: (x: T) => T; - declare function flatMap(array: T[], iterable: (x: T) => U[]): U[]; - declare function flatMap(array: T[][]): T[]; - ~ -!!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS2304: Cannot find name 'T'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js.diff b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js.diff index 9356c66d0d..3ed214f8c8 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js.diff @@ -108,30 +108,4 @@ -declare function identity(x: T): T; +declare const identity: (x: T) => T; +declare function flatMap(array: T[], iterable: (x: T) => U[]): U[]; -+declare function flatMap(array: T[][]): T[]; -+ -+ -+//// [DtsFileErrors] -+ -+ -+dist/jsFileFunctionOverloads2.d.ts(11,33): error TS2304: Cannot find name 'T'. -+dist/jsFileFunctionOverloads2.d.ts(11,41): error TS2304: Cannot find name 'T'. -+ -+ -+==== dist/jsFileFunctionOverloads2.d.ts (2 errors) ==== -+ declare function getTypeName(x: number): 'number'; -+ declare function getTypeName(x: string): 'string'; -+ declare function getTypeName(x: boolean): 'boolean'; -+ /** -+ * @template T -+ * @param {T} x -+ * @returns {T} -+ */ -+ declare const identity: (x: T) => T; -+ declare function flatMap(array: T[], iterable: (x: T) => U[]): U[]; -+ declare function flatMap(array: T[][]): T[]; -+ ~ -+!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS2304: Cannot find name 'T'. -+ \ No newline at end of file ++declare function flatMap(array: T[][]): T[]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt new file mode 100644 index 0000000000..93f7034cec --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt @@ -0,0 +1,35 @@ +index.js(6,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== dash.d.ts (0 errors) ==== + type ObjectIterator = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; + + interface LoDashStatic { + mapValues(obj: T | null | undefined, callback: ObjectIterator): { [P in keyof T]: TResult }; + } + declare const _: LoDashStatic; + export = _; +==== Consts.ts (0 errors) ==== + export const INDEX_FIELD = '__INDEX'; +==== index.js (2 errors) ==== + import * as _ from './dash'; + import { INDEX_FIELD } from './Consts'; + + export class Test { + /** + * @param {object} obj + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {object} vm + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + test(obj, vm) { + let index = 0; + vm.objects = _.mapValues( + obj, + object => ({ ...object, [INDEX_FIELD]: index++ }), + ); + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt new file mode 100644 index 0000000000..ba633b3e86 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt @@ -0,0 +1,126 @@ +jsFileMethodOverloads.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +jsFileMethodOverloads.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileMethodOverloads.js(13,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileMethodOverloads.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileMethodOverloads.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. +jsFileMethodOverloads.js(31,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileMethodOverloads.js(36,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileMethodOverloads.js(40,6): error TS8009: The '?' modifier can only be used in TypeScript files. +jsFileMethodOverloads.js(40,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== jsFileMethodOverloads.js (10 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + */ + ~~~ + class Example { + ~~~~~~~~~~~~~~~~ + /** + ~~~~~ + * @param {T} value + ~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + constructor(value) { + ~~~~~~~~~~~~~~~~~~~~~~ + this.value = value; + ~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~ + + + /** + ~~~~~ + * @overload + ~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {Example} this + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {'number'} + ~~~~~~~~~~~~~~~~~~~~~~~~ + */ + ~~~~~ + /** + ~~~~~ + * @overload + ~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {Example} this + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {'string'} + ~~~~~~~~~~~~~~~~~~~~~~~~ + */ + ~~~~~ + /** + ~~~~~ + * @returns {string} + ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + getTypeName() { + ~~~~~~~~~~~~~~~~~ + return typeof this.value; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~ + + + /** + ~~~~~ + * @template U + ~~~~~~~~~~~~~~~~ + * @overload + ~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {(y: T) => U} fn + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {U} + ~~~~~~~~~~~~~~~~~ + */ + ~~~~~ + /** + ~~~~~ + * @overload + ~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~~~ + */ + ~~~~~ + /** + ~~~~~ + * @param {(y: T) => unknown} [fn] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {unknown} + ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + transform(fn) { + ~~~~~~~~~~~~~~~~~ + return fn ? fn(this.value) : this.value; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt new file mode 100644 index 0000000000..de0e8c7b33 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt @@ -0,0 +1,120 @@ +jsFileMethodOverloads2.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +jsFileMethodOverloads2.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileMethodOverloads2.js(14,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileMethodOverloads2.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileMethodOverloads2.js(22,16): error TS8010: Type annotations can only be used in TypeScript files. +jsFileMethodOverloads2.js(30,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileMethodOverloads2.js(34,7): error TS8017: Signature declarations can only be used in TypeScript files. +jsFileMethodOverloads2.js(37,6): error TS8009: The '?' modifier can only be used in TypeScript files. +jsFileMethodOverloads2.js(37,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== jsFileMethodOverloads2.js (10 errors) ==== + // Also works if all @overload tags are combined in one comment. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + */ + ~~~ + class Example { + ~~~~~~~~~~~~~~~~ + /** + ~~~~~ + * @param {T} value + ~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + constructor(value) { + ~~~~~~~~~~~~~~~~~~~~~~ + this.value = value; + ~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~ + + + /** + ~~~~~ + * @overload + ~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {Example} this + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {'number'} + ~~~~~~~~~~~~~~~~~~~~~~~~ + * + ~~~~ + * @overload + ~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {Example} this + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {'string'} + ~~~~~~~~~~~~~~~~~~~~~~~~ + * + ~~~~ + * @returns {string} + ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + getTypeName() { + ~~~~~~~~~~~~~~~~~ + return typeof this.value; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~ + + + /** + ~~~~~ + * @template U + ~~~~~~~~~~~~~~~~ + * @overload + ~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {(y: T) => U} fn + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {U} + ~~~~~~~~~~~~~~~~~ + * + ~~~~ + * @overload + ~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~~~ + * + ~~~~ + * @param {(y: T) => unknown} [fn] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {unknown} + ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + transform(fn) { + ~~~~~~~~~~~~~~~~~ + return fn ? fn(this.value) : this.value; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt index edc21e0e06..2a0c68a364 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt @@ -1,12 +1,18 @@ /a.js(2,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. +/a.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. /a.js(7,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. +/a.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. +/a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (6 errors) ==== /** * @overload ~~~~~~~~ !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} x */ @@ -14,12 +20,18 @@ * @overload ~~~~~~~~ !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} x */ /** * @param {string | number} x + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string | number} + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id(x) { return x; diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.errors.txt new file mode 100644 index 0000000000..8f5dbb85e2 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.errors.txt @@ -0,0 +1,37 @@ +/a.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. +/a.js(8,5): error TS8017: Signature declarations can only be used in TypeScript files. +/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(16,4): error TS8009: The '?' modifier can only be used in TypeScript files. +/a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (5 errors) ==== + /** + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {string} a + * @return {void} + */ + + /** + * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {number} a + * @param {number} [b] + * @return {void} + */ + + /** + * @param {string | number} a + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} [b] + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export const foo = function (a, b) { } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.errors.txt new file mode 100644 index 0000000000..6179099634 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.errors.txt @@ -0,0 +1,13 @@ +/b.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.ts (0 errors) ==== + export enum E { A } + +==== /b.js (1 errors) ==== + import { E } from "./a"; + /** @type {E} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const e = E.A; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt index 1cc294cbf3..77e72d7c06 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt @@ -1,37 +1,67 @@ +jsdocArrayObjectPromiseImplicitAny.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(23,13): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. 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(32,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseImplicitAny.js(37,13): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocArrayObjectPromiseImplicitAny.js (2 errors) ==== +==== jsdocArrayObjectPromiseImplicitAny.js (14 errors) ==== /** @type {Array} */ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var anyArray = [5]; /** @type {Array} */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var numberArray = [5]; /** * @param {Array} arr + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Array} + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnAnyArray(arr) { return arr; } /** @type {Promise} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var anyPromise = Promise.resolve(5); /** @type {Promise} */ + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var numberPromise = Promise.resolve(5); /** * @param {Promise} pr + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Promise} + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnAnyPromise(pr) { return pr; } /** @type {Object} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var anyObject = {valueOf: 1}; // not an error since assigning to any. ~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type '() => Object'. @@ -39,11 +69,17 @@ jsdocArrayObjectPromiseImplicitAny.js(32,12): error TS2315: Type 'Object' is not /** @type {Object} */ ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var paramedObject = {valueOf: 1}; /** * @param {Object} obj + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Object} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnAnyObject(obj) { return obj; diff --git a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt index 5940696a86..ba87c8a5e2 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt @@ -1,29 +1,49 @@ jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS2314: Generic type 'Array' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseNoImplicitAny.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS2314: Generic type 'Array' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS2314: Generic type 'Array' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseNoImplicitAny.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS2314: Generic type 'Promise' requires 1 type argument(s). +jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseNoImplicitAny.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. 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(32,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseNoImplicitAny.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocArrayObjectPromiseNoImplicitAny.js(37,13): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocArrayObjectPromiseNoImplicitAny.js (8 errors) ==== +==== jsdocArrayObjectPromiseNoImplicitAny.js (20 errors) ==== /** @type {Array} */ ~~~~~ !!! error TS2314: Generic type 'Array' requires 1 type argument(s). + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var notAnyArray = [5]; /** @type {Array} */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var numberArray = [5]; /** * @param {Array} arr ~~~~~ !!! error TS2314: Generic type 'Array' requires 1 type argument(s). + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Array} ~~~~~ !!! error TS2314: Generic type 'Array' requires 1 type argument(s). + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnNotAnyArray(arr) { return arr; @@ -32,24 +52,34 @@ jsdocArrayObjectPromiseNoImplicitAny.js(32,12): error TS2315: Type 'Object' is n /** @type {Promise} */ ~~~~~~~ !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var notAnyPromise = Promise.resolve(5); /** @type {Promise} */ + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var numberPromise = Promise.resolve(5); /** * @param {Promise} pr ~~~~~~~ !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Promise} ~~~~~~~ !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnNotAnyPromise(pr) { return pr; } /** @type {Object} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. ~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type '() => Object'. @@ -57,11 +87,17 @@ jsdocArrayObjectPromiseNoImplicitAny.js(32,12): error TS2315: Type 'Object' is n /** @type {Object} */ ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var paramedObject = {valueOf: 1}; /** * @param {Object} obj + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Object} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnNotAnyObject(obj) { return obj; diff --git a/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt index d8a5fdf957..c74e98002d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt @@ -1,8 +1,10 @@ index.js(12,14): error TS7006: Parameter 'arg' implicitly has an 'any' type. +index.js(16,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(20,16): error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. -==== index.js (2 errors) ==== +==== index.js (4 errors) ==== /** @type () => string */ function fn1() { return 42; @@ -21,9 +23,13 @@ index.js(20,16): error TS2322: Type '"other"' is not assignable to type '"bar" | } /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const obj1 = { type: "foo", prop: 10 }; /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const obj2 = { type: "other", prop: 10 }; ~~~~ !!! error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. diff --git a/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt index b3a6719491..7aa0ea517b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt @@ -1,12 +1,15 @@ +/a.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(8,3): error TS2554: Expected 0 arguments, but got 1. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** * @template T * @callback B */ /** @type {B} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. let b; b(); b(1); diff --git a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt index ae966c3990..d8741ee681 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt @@ -1,12 +1,19 @@ +/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. /a.js(4,13): error TS2314: Generic type 'C' requires 1 type argument(s). +/a.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (1 errors) ==== +==== /a.js (3 errors) ==== /** @template T */ + ~~~~~~~~~~~~~~~~~~ class C {} + ~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @param {C} p */ ~ !!! error TS2314: Generic type 'C' requires 1 type argument(s). + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(p) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt index eef47833f9..b379063415 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt @@ -1,13 +1,19 @@ +/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. /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 (4 errors) ==== +==== /a.js (6 errors) ==== /** * @param {number | undefined} x + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number | undefined} y + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function Foo(x, y) { if (!(this instanceof Foo)) { diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt index 4147bce1d5..455e6373fa 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt @@ -1,8 +1,11 @@ +/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. /a.js(1,13): error TS1098: Type parameter list cannot be empty. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** @param {<} x */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~ !!! error TS1098: Type parameter list cannot be empty. function f(x) {} diff --git a/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt index 018ec07e52..5c841db181 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt @@ -1,18 +1,26 @@ +/a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. /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(6,18): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (4 errors) ==== class C { + /** @template T */ + ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor() { } + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. } class D { /** @return {number} */ ~~~~~~ !!! error TS1093: Type annotation cannot appear on a constructor declaration. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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 index ba53f8f4d7..6317bb3a85 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.errors.txt @@ -1,3 +1,4 @@ +Main.js(2,21): error TS8016: Type assertion expressions can only be used in TypeScript files. Main.js(2,49): error TS2694: Namespace '"GeometryType"' has no exported member 'default'. @@ -7,9 +8,11 @@ Main.js(2,49): error TS2694: Namespace '"GeometryType"' has no exported member ' } export default _default; -==== Main.js (1 errors) ==== +==== Main.js (2 errors) ==== export default function () { return /** @type {import('./GeometryType.js').default} */ ('Point'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~ !!! error TS2694: Namespace '"GeometryType"' has no exported member 'default'. } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.errors.txt new file mode 100644 index 0000000000..a4dde98c04 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.errors.txt @@ -0,0 +1,16 @@ +usage.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== module.js (0 errors) ==== + export class MyClass { + } + +==== usage.js (1 errors) ==== + /** + * @typedef {Object} options + * @property {import("./module").MyClass} option + */ + /** @type {options} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + let v; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.errors.txt new file mode 100644 index 0000000000..0a6294dbe2 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.errors.txt @@ -0,0 +1,11 @@ +/a.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class Foo { + /**@param {string} x */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + m = x => x.toLowerCase(); + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt index 1b0b2a8cd2..1c2aba3722 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt @@ -1,12 +1,15 @@ example.js(3,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +example.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -==== example.js (1 errors) ==== +==== example.js (2 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ let x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt index e265271517..8d67fad378 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt @@ -1,7 +1,8 @@ /a.js(3,15): error TS2552: Cannot find name 'sting'. Did you mean 'string'? +/a.js(6,13): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** * @typedef MyType * @property {sting} [x] @@ -10,6 +11,8 @@ */ /** @param {MyType} p */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export function f(p) { } ==== /b.js (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt index 5db1b60f68..cd1699ba7a 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt @@ -1,9 +1,12 @@ +a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(4,1): error TS2686: 'Puppeteer' refers to a UMD global, but the current file is a module. Consider adding an import instead. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== const other = require('./other'); /** @type {Puppeteer.Keyboard} */ + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var ppk; Puppeteer.connect; ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt index 220be597bd..14a84ea7f4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt @@ -1,9 +1,12 @@ +/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(7,14): error TS2304: Cannot find name 'CantResolveThis'. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** * @param {Ty} x + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(x) {} diff --git a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt index 40e75b1fda..bbfd3a3054 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt @@ -1,9 +1,12 @@ +/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. /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 */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(a) { a; // number | undefined // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. diff --git a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.errors.txt new file mode 100644 index 0000000000..513fc0e8f0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.errors.txt @@ -0,0 +1,11 @@ +/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + /** @param {...number} a */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(...a) { + a; // number[] + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt index c104964181..01bcefaa58 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt @@ -1,26 +1,41 @@ +jsdocTypeCast.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocTypeCast.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. jsdocTypeCast.js(6,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. +jsdocTypeCast.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. jsdocTypeCast.js(10,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. +jsdocTypeCast.js(13,16): error TS8010: Type annotations can only be used in TypeScript files. +jsdocTypeCast.js(14,24): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== jsdocTypeCast.js (2 errors) ==== +==== jsdocTypeCast.js (7 errors) ==== /** * @param {string} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(x) { /** @type {'a' | 'b'} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. let a = (x); // Error ~ !!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. a; /** @type {'a' | 'b'} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. let b = (((x))); // Error ~ !!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. b; /** @type {'a' | 'b'} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. let c = /** @type {'a' | 'b'} */ (x); // Ok + ~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. c; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt new file mode 100644 index 0000000000..9b921928ad --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt @@ -0,0 +1,13 @@ +index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + /** + * @param {Array<*>} list + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function thing(list) { + return list; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt index 095a8b3c6b..6e9bdbe4cd 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt @@ -1,17 +1,27 @@ +index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(2,19): error TS2315: Type 'Boolean' is not generic. +index2.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index2.js(2,19): error TS2304: Cannot find name 'Void'. +index3.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index3.js(2,19): error TS2304: Cannot find name 'Undefined'. +index4.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index4.js(2,19): error TS2315: Type 'Function' is not generic. +index5.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index5.js(2,19): error TS2315: Type 'String' is not generic. +index6.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index6.js(2,19): error TS2315: Type 'Number' is not generic. +index7.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index7.js(2,19): error TS2315: Type 'Object' is not generic. 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,12): error TS8010: Type annotations can only be used in TypeScript files. index8.js(4,15): error TS2304: Cannot find name 'T'. -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== /** * @param {(m: Boolean) => string} somebody + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~ !!! error TS2315: Type 'Boolean' is not generic. */ @@ -19,9 +29,11 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. return 'Hello ' + somebody; } -==== index2.js (1 errors) ==== +==== index2.js (2 errors) ==== /** * @param {(m: Void) => string} somebody + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~ !!! error TS2304: Cannot find name 'Void'. */ @@ -30,9 +42,11 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index3.js (1 errors) ==== +==== index3.js (2 errors) ==== /** * @param {(m: Undefined) => string} somebody + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2304: Cannot find name 'Undefined'. */ @@ -41,9 +55,11 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index4.js (1 errors) ==== +==== index4.js (2 errors) ==== /** * @param {(m: Function) => string} somebody + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~ !!! error TS2315: Type 'Function' is not generic. */ @@ -52,9 +68,11 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index5.js (1 errors) ==== +==== index5.js (2 errors) ==== /** * @param {(m: String) => string} somebody + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2315: Type 'String' is not generic. */ @@ -63,9 +81,11 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index6.js (1 errors) ==== +==== index6.js (2 errors) ==== /** * @param {(m: Number) => string} somebody + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2315: Type 'Number' is not generic. */ @@ -74,9 +94,11 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index7.js (1 errors) ==== +==== index7.js (2 errors) ==== /** * @param {(m: Object) => string} somebody + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. */ @@ -84,13 +106,15 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. return 'Hello ' + somebody; } -==== index8.js (2 errors) ==== +==== index8.js (3 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 TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'T'. */ diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt new file mode 100644 index 0000000000..1fc29f1c18 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt @@ -0,0 +1,26 @@ +test.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. +test.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== test.js (2 errors) ==== + // @ts-check + /** @typedef {number} NotADuplicateIdentifier */ + + (2 * 2); + + /** @typedef {number} AlsoNotADuplicate */ + + (2 * 2) + 1; + + + /** + * + * @param a {NotADuplicateIdentifier} + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param b {AlsoNotADuplicate} + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function makeSureTypedefsAreStillRecognized(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt new file mode 100644 index 0000000000..609b81fb99 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt @@ -0,0 +1,20 @@ +/a.js(12,11): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + // Bad: missing a type + /** @typedef T */ + + const t = 0; + + // OK: missing a type, but have property tags. + /** + * @typedef Person + * @property {string} name + */ + + /** @type Person */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const person = { name: "" }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt new file mode 100644 index 0000000000..b0d2ab3a88 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt @@ -0,0 +1,12 @@ +export.js(1,1): error TS8008: Type aliases can only be used in TypeScript files. + + +==== export.js (1 errors) ==== + export type foo = 5; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS8008: Type aliases can only be used in TypeScript files. + /** + * @typedef {{ + * }} + */ + export const foo = 5; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.errors.txt new file mode 100644 index 0000000000..1c04ce3660 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.errors.txt @@ -0,0 +1,14 @@ +/a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + /** + * @typedef Foo + * @property foo + */ + + /** @type {Foo} */ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const x = { foo: 0 }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt b/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt index a0ef9a937d..420f1cd7bd 100644 --- a/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt @@ -8,6 +8,7 @@ /main2.mts(14,8): error TS1192: Module '"/e"' has no default export. /main3.cjs(1,10): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(1,13): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. +/main3.cjs(1,28): error TS8002: 'import ... =' can only be used in TypeScript files. /main3.cjs(5,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(8,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(10,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. @@ -112,13 +113,16 @@ import g1 from "./g"; // { default: 0 } import g2 = require("./g"); // { default: 0 } -==== /main3.cjs (8 errors) ==== +==== /main3.cjs (9 errors) ==== import { x, y } from "./a"; // No y ~ !!! error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. ~ !!! error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. + ~~~~~~~~ import a1 = require("./a"); // Error in JS + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. const a2 = require("./a"); // { x: 0 } import b1 from "./b"; // 0 diff --git a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt new file mode 100644 index 0000000000..8352788abe --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt @@ -0,0 +1,28 @@ +index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. +index.js(10,23): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== index.js (4 errors) ==== + /** @type {Map>} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const cache = new Map() + + /** + * @param {string} key + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {() => string} + ~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const getStringGetter = (key) => { + return () => { + return /** @type {string} */ (cache.get(key)) + ~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt index c50bcf83c9..e611537c22 100644 --- a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt @@ -1,10 +1,13 @@ +index.js(3,20): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(12,8): error TS2678: Type '"invalid"' is not comparable to type '"bar" | "foo"'. -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== let value = ""; switch (/** @type {"foo" | "bar"} */ (value)) { + ~~~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. case "bar": value; break; diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.errors.txt b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.errors.txt index 247aaa31b5..0f38871554 100644 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.errors.txt @@ -1,16 +1,20 @@ /user.js(2,7): error TS2339: Property 'b' does not exist on type '{ a: number; }'. +/user.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. /user.js(5,7): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. /user.js(9,7): error TS2339: Property 'b' does not exist on type '{ a: number; }'. +/user.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. /user.js(12,7): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. -==== /user.js (4 errors) ==== +==== /user.js (6 errors) ==== const json0 = require("./json.json"); json0.b; // Error (good) ~ !!! error TS2339: Property 'b' does not exist on type '{ a: number; }'. /** @type {{ b: number }} */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const json1 = require("./json.json"); // No error (bad) ~~~~~ !!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. @@ -23,6 +27,8 @@ !!! error TS2339: Property 'b' does not exist on type '{ a: number; }'. /** @type {{ b: number }} */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const js1 = require("./js.js"); // Error (good) ~~~ !!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. diff --git a/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.errors.txt b/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.errors.txt new file mode 100644 index 0000000000..a28d718802 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.errors.txt @@ -0,0 +1,30 @@ +file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. +file.js(10,23): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== file.js (4 errors) ==== + // Don't peek into conditional return expression if it's wrapped in a cast + /** @type {Map} */ + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const sources = new Map(); + /** + + * @param {string=} type the type of source that should be generated + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {String} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function source(type = "javascript") { + return /** @type {String} */ ( + ~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + type + ? sources.get(type) + : sources.get("some other thing") + ); + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt index 8ff969056a..4ae57460a2 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt @@ -1,18 +1,22 @@ +a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. 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(13,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. Types of property 'value' are incompatible. Type 'undefined' is not assignable to type 'number'. -==== a.js (2 errors) ==== +==== a.js (4 errors) ==== /** * @typedef {object} A * @property {number} [value] */ /** @type {A} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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. @@ -24,6 +28,8 @@ a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type */ /** @type {B} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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. diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.errors.txt b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.errors.txt new file mode 100644 index 0000000000..22bb3f9e68 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.errors.txt @@ -0,0 +1,20 @@ +a.js(6,22): error TS8016: Type assertion expressions can only be used in TypeScript files. +a.js(9,22): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== a.js (2 errors) ==== + /** + * @typedef Foo + * @property {number} [foo] + */ + + const x = /** @type {Foo} */ ({}); + ~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + x.foo; // number | undefined + + const y = /** @type {Required} */ ({}); + ~~~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + y.foo; // number + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt index e97bdfb5ac..c83d18d3df 100644 --- a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt @@ -1,3 +1,4 @@ +file1.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -58,8 +59,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 (1 errors) ==== +==== file1.js (2 errors) ==== /** @type {ClassComponent} */ + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const test9 = new C(); ~~~~~ !!! error TS2322: Type 'C' is not assignable to type 'ClassComponent'. diff --git a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.errors.txt b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.errors.txt new file mode 100644 index 0000000000..f5367336f4 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.errors.txt @@ -0,0 +1,38 @@ +file1.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== tile1.ts (0 errors) ==== + interface Lifecycle> { + oninit?(vnode: Vnode): number; + [_: number]: any; + } + + interface Vnode> { + tag: Component; + } + + interface Component> { + view(this: State, vnode: Vnode): number; + } + + interface ClassComponent extends Lifecycle> { + oninit?(vnode: Vnode): number; + view(vnode: Vnode): number; + } + + interface MyAttrs { id: number } + class C implements ClassComponent { + view(v: Vnode) { return 0; } + + // Must declare a compatible-ish index signature or else + // we won't correctly implement ClassComponent. + [_: number]: unknown; + } + + const test8: ClassComponent = new C(); +==== file1.js (1 errors) ==== + /** @type {ClassComponent} */ + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const test9 = new C(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt b/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt index 914c08744a..9c939b76f0 100644 --- a/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt @@ -1,18 +1,28 @@ +a.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. a.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. +b.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. b.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== module foo { + ~~~~~~~~~~~~ this.bar = 4; + ~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2331: 'this' cannot be referenced in a module or namespace body. } + ~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. -==== b.js (1 errors) ==== +==== b.js (2 errors) ==== namespace blah { + ~~~~~~~~~~~~~~~~ this.prop = 42; + ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2331: 'this' cannot be referenced in a module or namespace body. } + ~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt index d752c5ddc4..9c144e6eb8 100644 --- a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt @@ -1,8 +1,10 @@ /a.js(9,26): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. /a.js(15,31): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +/a.js(21,20): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(29,20): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (4 errors) ==== class Test { constructor() { /** @type {number[]} */ @@ -30,6 +32,8 @@ forEacher() { this.data.forEach( /** @this {Test} */ + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function (d) { console.log(d === this.data.length) }, this) @@ -38,6 +42,8 @@ finder() { this.data.find( /** @this {Test} */ + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function (d) { return d === this.data.length }, this) diff --git a/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.errors.txt b/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.errors.txt new file mode 100644 index 0000000000..b5528326fc --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.errors.txt @@ -0,0 +1,47 @@ +check.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== check.ts (0 errors) ==== + // https://github.com/microsoft/TypeScript/issues/31972 + interface Person { + first: string; + last: string; + } + + { + const dice = () => Math.floor(Math.random() * 6); + dice.first = 'Rando'; + dice.last = 'Calrissian'; + const diceP: Person = dice; + } + +==== check.js (1 errors) ==== + // Creates a type { first:string, last: string } + /** + * @typedef {Object} Human - creates a new type named 'SpecialType' + * @property {string} first - a string property of SpecialType + * @property {string} last - a number property of SpecialType + */ + + /** + * @param {Human} param used as a validation tool + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function doHumanThings(param) {} + + const dice1 = () => Math.floor(Math.random() * 6); + // dice1.first = 'Rando'; + dice1.last = 'Calrissian'; + + // doHumanThings(dice) + + // but inside a block... you can't call a human + { + const dice2 = () => Math.floor(Math.random() * 6); + dice2.first = 'Rando'; + dice2.last = 'Calrissian'; + + doHumanThings(dice2) + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.errors.txt new file mode 100644 index 0000000000..1bd8adcb17 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.errors.txt @@ -0,0 +1,31 @@ +file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== file.js (4 errors) ==== + /** + * @param {number} \u0061 + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} a\u0061 + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo(a, aa) { + console.log(a + aa); + } + + /** + * @param {number} \u{0061} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} a\u{0061} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function bar(a, aa) { + console.log(a + aa); + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/uniqueSymbolJs.errors.txt b/testdata/baselines/reference/submodule/compiler/uniqueSymbolJs.errors.txt index 162596d71b..8cf9a0f7a6 100644 --- a/testdata/baselines/reference/submodule/compiler/uniqueSymbolJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/uniqueSymbolJs.errors.txt @@ -1,15 +1,21 @@ +a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(5,18): error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type. +a.js(5,22): error TS8010: Type annotations can only be used in TypeScript files. a.js(5,23): error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? -==== a.js (2 errors) ==== +==== a.js (4 errors) ==== /** @type {unique symbol} */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const foo = Symbol(); /** @typedef {{ [foo]: boolean }} A */ /** @typedef {{ [key: foo] boolean }} B */ ~~~ !!! error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type. + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? \ 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 index cfd276ebcd..b9aa9cb689 100644 --- a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.errors.txt @@ -1,9 +1,13 @@ +/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. /a.js(1,15): error TS6196: 'T' is declared but never used. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** @template T */ + ~~~~~~~~~~~~~~~~~~ ~ !!! error TS6196: 'T' is declared but never used. function f() {} + ~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt index 941b063cbf..1238a6c296 100644 --- a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt @@ -1,49 +1,84 @@ +/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. /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(10,2): error TS8004: Type parameter declarations can only be used in TypeScript files. /a.js(13,3): error TS6205: All type parameters are unused. +/a.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. /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 (5 errors) ==== +==== /a.js (8 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 TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + ~~~ * @template T,V + ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ */ + ~~~ ~~ !!! error TS6205: All type parameters are unused. class C2 { + ~~~~~~~~~~ constructor() { } + ~~~~~~~~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + ~~~ * @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'. } - } \ No newline at end of file + ~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt b/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt new file mode 100644 index 0000000000..82bae20398 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt @@ -0,0 +1,23 @@ +Compilation.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. +Compilation.js(7,33): error TS8010: Type annotations can only be used in TypeScript files. + + +==== Compilation.js (2 errors) ==== + // from webpack/lib/Compilation.js and filed at #26427 + /** @param {{ [s: string]: number }} map */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + function mappy(map) {} + + export class C { + constructor() { + /** @type {{ [assetName: string]: number}} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + this.assets = {}; + } + m() { + mappy(this.assets) + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt index 1ae40a0c49..433ff9717a 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt @@ -1,7 +1,11 @@ +assertionTypePredicates2.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +assertionTypePredicates2.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. +assertionTypePredicates2.js(14,20): error TS8016: Type assertion expressions can only be used in TypeScript files. +assertionTypePredicates2.js(19,16): error TS8010: Type annotations can only be used in TypeScript files. assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. -==== assertionTypePredicates2.js (1 errors) ==== +==== assertionTypePredicates2.js (5 errors) ==== /** * @typedef {{ x: number }} A */ @@ -12,15 +16,23 @@ assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name i /** * @param {A} a + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns { asserts a is B } + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo = (a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); + ~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. return undefined; }; export const main = () => { /** @type { A } */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const a = { x: 1 }; foo(a); ~~~ diff --git a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt index 7925bfb827..45b3dbf312 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt @@ -1,11 +1,22 @@ +assertionsAndNonReturningFunctions.js(1,22): error TS8010: Type annotations can only be used in TypeScript files. +assertionsAndNonReturningFunctions.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +assertionsAndNonReturningFunctions.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. +assertionsAndNonReturningFunctions.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. +assertionsAndNonReturningFunctions.js(22,14): error TS8010: Type annotations can only be used in TypeScript files. +assertionsAndNonReturningFunctions.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. assertionsAndNonReturningFunctions.js(46,9): error TS7027: Unreachable code detected. +assertionsAndNonReturningFunctions.js(51,12): error TS8010: Type annotations can only be used in TypeScript files. assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code detected. -==== assertionsAndNonReturningFunctions.js (2 errors) ==== +==== assertionsAndNonReturningFunctions.js (9 errors) ==== /** @typedef {(check: boolean) => asserts check} AssertFunc */ + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {AssertFunc} */ + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const assert = check => { if (!check) throw new Error(); } @@ -17,7 +28,11 @@ assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code dete /** * @param {boolean} check + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {asserts check} + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function assert2(check) { if (!check) throw new Error(); @@ -25,6 +40,8 @@ assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code dete /** * @returns {never} + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function fail() { throw new Error(); @@ -32,6 +49,8 @@ assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code dete /** * @param {*} x + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f1(x) { if (!!true) { @@ -56,6 +75,8 @@ assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code dete /** * @param {boolean} b + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f2(b) { switch (b) { diff --git a/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt b/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt index 6dc5427f14..b1623a20e1 100644 --- a/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt @@ -1,16 +1,23 @@ file.js(2,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(6,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +file.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +file.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -==== file.js (5 errors) ==== +==== file.js (10 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const a = () => 0 // Error (good) @@ -18,6 +25,8 @@ file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Functio ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const b = async () => 0 // No error (bad) @@ -25,6 +34,8 @@ file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Functio ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const c = async () => { return 0 } @@ -34,6 +45,8 @@ file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Functio ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const d = async () => { return "" } @@ -42,6 +55,8 @@ file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Functio ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (p) => {} // Error (good) diff --git a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt index edd678f512..60a4a4e6fd 100644 --- a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt @@ -1,41 +1,63 @@ +/a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. /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(21,14): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(28,7): error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. Type 'Promise' is not assignable to type 'string'. +/a.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(34,14): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.d.ts (0 errors) ==== declare class Thenable { then(): void; } -==== /a.js (2 errors) ==== +==== /a.js (12 errors) ==== /** * @callback T1 * @param {string} str + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string} */ /** * @callback T2 * @param {string} str + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {Promise} */ /** * @callback T3 * @param {string} str + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {Thenable} */ /** * @param {string} str + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @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'? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const f1 = async str => { return str; } /** @type {T1} */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const f2 = async str => { ~~ !!! error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. @@ -45,18 +67,26 @@ /** * @param {string} str + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {Promise} + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const f3 = async str => { return str; } /** @type {T2} */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const f4 = async str => { return str; } /** @type {T3} */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const f5 = async str => { return str; } diff --git a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt index 5a59e1a49e..199df83367 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt @@ -1,10 +1,14 @@ +mod1.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +use.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. -==== mod1.js (1 errors) ==== +==== mod1.js (2 errors) ==== /** @callback Con - some kind of continuation * @param {object | undefined} error + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {any} I don't even know what this should return */ module.exports = C @@ -14,8 +18,10 @@ use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. this.p = 1 } -==== use.js (1 errors) ==== +==== use.js (2 errors) ==== /** @param {import('./mod1').Con} k */ + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace 'C' has no exported member 'Con'. function f(k) { diff --git a/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt index 9b0c649c61..6e71f37aab 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt @@ -1,12 +1,16 @@ +callbackOnConstructor.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. callbackOnConstructor.js(12,12): error TS2304: Cannot find name 'ValueGetter_2'. +callbackOnConstructor.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -==== callbackOnConstructor.js (1 errors) ==== +==== callbackOnConstructor.js (3 errors) ==== export class Preferences { assignability = "no" /** * @callback ValueGetter_2 * @param {string} name + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean|number|string|undefined} */ constructor() {} @@ -16,5 +20,7 @@ callbackOnConstructor.js(12,12): error TS2304: Cannot find name 'ValueGetter_2'. /** @type {ValueGetter_2} */ ~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'ValueGetter_2'. + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var ooscope2 = s => s.length > 0 \ No newline at end of file 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..d038d2a366 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt @@ -0,0 +1,33 @@ +cb.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== cb.js (4 errors) ==== + /** @callback Sid + * @param {string} s + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string} What were you expecting + */ + var x = 1 + + /** @type {Sid} smallId */ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var sid = s => s + "!"; + + + /** @type {NoReturn} */ + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var noreturn = obj => void obj.title + + /** + * @callback NoReturn + * @param {{ e: number, m: number, title: string }} s - Knee deep, shores, etc + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt index 2dbccc172d..1e4a502f9e 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt @@ -1,20 +1,34 @@ +cb.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. +cb.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. -==== cb.js (1 errors) ==== +==== cb.js (9 errors) ==== /** @template T * @callback Id * @param {T} t + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} Maybe just return 120 and cast it? */ var x = 1 /** @type {Id} I actually wanted to write `const "120"` */ + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var one_twenty = s => "120"; /** @template S * @callback SharedId * @param {S} ego + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {S} */ class SharedClass { @@ -26,17 +40,27 @@ cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. } } /** @type {SharedId} */ + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var outside = n => n + 1; /** @type {Final<{ fantasy }, { heroes }>} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var noreturn = (barts, tidus, noctis) => "cecil" /** * @template V,X * @callback Final * @param {V} barts - "Barts" + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {X} tidus - Titus + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {X & V} noctis - "Prince Noctis Lucius Caelum" + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {"cecil" | "zidane"} */ \ No newline at end of file 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..7a623fc91d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt @@ -0,0 +1,13 @@ +cb.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== cb.js (1 errors) ==== + /** @callback Miracle + * @returns {string} What were you expecting + */ + /** @type {Miracle} smallId */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var sid = () => "!"; + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt new file mode 100644 index 0000000000..e954de0262 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt @@ -0,0 +1,29 @@ +a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (4 errors) ==== + /** + * @callback C + * @this {{ a: string, b: number }} + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {boolean} + */ + + /** @type {C} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const cb = function (a, b) { + this + return true + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagNamespace.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTagNamespace.errors.txt new file mode 100644 index 0000000000..4e2173acbd --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/callbackTagNamespace.errors.txt @@ -0,0 +1,21 @@ +namespaced.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +namespaced.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== namespaced.js (2 errors) ==== + /** + * @callback NS.Nested.Inner + * @param {Object} space - spaaaaaaaaace + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {Object} peace - peaaaaaaaaace + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {string | number} + */ + var x = 1; + /** @type {NS.Nested.Inner} */ + function f(space, peace) { + return '1' + } + \ No newline at end of file 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..f80630c317 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt @@ -0,0 +1,31 @@ +cb_nested.js(4,4): error TS8010: Type annotations can only be used in TypeScript files. +cb_nested.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +cb_nested.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== cb_nested.js (3 errors) ==== + /** + * @callback WorksWithPeopleCallback + * @param {Object} person + * @param {string} person.name + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {number} [person.age] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {void} + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + /** + * For each person, calls your callback. + * @param {WorksWithPeopleCallback} callback + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {void} + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function eachPerson(callback) { + callback({ name: "Empty" }); + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt index b6e60aa623..bd5c4a55ea 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt @@ -1,14 +1,20 @@ +callbackTagVariadicType.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +callbackTagVariadicType.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. callbackTagVariadicType.js(9,18): error TS2554: Expected 1 arguments, but got 2. -==== callbackTagVariadicType.js (1 errors) ==== +==== callbackTagVariadicType.js (3 errors) ==== /** * @callback Foo * @param {...string} args + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number} */ /** @type {Foo} */ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const x = () => 1 var res = x('a', 'b') ~~~ diff --git a/testdata/baselines/reference/submodule/conformance/chainedPrototypeAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/chainedPrototypeAssignment.errors.txt index 54fcff7501..df7b1cc637 100644 --- a/testdata/baselines/reference/submodule/conformance/chainedPrototypeAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/chainedPrototypeAssignment.errors.txt @@ -1,3 +1,4 @@ +mod.js(11,17): error TS8010: Type annotations can only be used in TypeScript files. use.js(3,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. use.js(4,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. @@ -17,7 +18,7 @@ use.js(4,9): error TS7009: 'new' expression, whose target lacks a construct sign ==== types.d.ts (0 errors) ==== declare function require(name: string): any; declare var exports: any; -==== mod.js (0 errors) ==== +==== mod.js (1 errors) ==== /// var A = function A() { this.a = 1 @@ -29,6 +30,8 @@ use.js(4,9): error TS7009: 'new' expression, whose target lacks a construct sign exports.B = B A.prototype = B.prototype = { /** @param {number} n */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. m(n) { return n + 1 } diff --git a/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignProperty.errors.txt index db9ca448b3..415c04b63f 100644 --- a/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignProperty.errors.txt @@ -1,15 +1,19 @@ +index.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(4,19): error TS2306: File 'mod1.js' is not a module. +index.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(9,19): error TS2306: File 'mod2.js' is not a module. mod1.js(1,23): error TS2304: Cannot find name 'exports'. mod1.js(2,23): error TS2304: Cannot find name 'exports'. mod1.js(3,23): error TS2304: Cannot find name 'exports'. mod1.js(4,23): error TS2304: Cannot find name 'exports'. mod1.js(5,23): error TS2304: Cannot find name 'exports'. +mod1.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. mod2.js(1,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. mod2.js(2,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. mod2.js(3,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. mod2.js(4,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. mod2.js(5,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +mod2.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. validator.ts(3,21): error TS2306: File 'mod1.js' is not a module. validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. @@ -61,7 +65,7 @@ validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. m2.rwAccessors = "no"; m2.setonlyAccessor = 0; -==== mod1.js (5 errors) ==== +==== mod1.js (6 errors) ==== Object.defineProperty(exports, "thing", { value: 42, writable: true }); ~~~~~~~ !!! error TS2304: Cannot find name 'exports'. @@ -78,12 +82,14 @@ validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. ~~~~~~~ !!! error TS2304: Cannot find name 'exports'. /** @param {string} str */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } }); -==== mod2.js (5 errors) ==== +==== mod2.js (6 errors) ==== Object.defineProperty(module.exports, "thing", { value: "yes", writable: true }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -100,14 +106,18 @@ validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @param {string} str */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } }); -==== index.js (2 errors) ==== +==== index.js (4 errors) ==== /** * @type {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const q = require("./mod1").thing; ~~~~~~~~ @@ -115,6 +125,8 @@ validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. /** * @type {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const u = require("./mod2").thing; ~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt index 15c06af9b4..4b4f0824b7 100644 --- a/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt @@ -1,4 +1,6 @@ +mod1.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. mod1.js(6,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +mod1.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. validator.ts(5,12): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. @@ -30,10 +32,12 @@ validator.ts(5,12): error TS7009: 'new' expression, whose target lacks a constru m1.setonlyAccessor = 0; -==== mod1.js (1 errors) ==== +==== mod1.js (3 errors) ==== /** * @constructor * @param {string} name + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Person(name) { this.name = name; @@ -49,6 +53,8 @@ validator.ts(5,12): error TS7009: 'new' expression, whose target lacks a constru Object.defineProperty(Person.prototype, "readonlyAccessor", { get() { return 21.75 } }); Object.defineProperty(Person.prototype, "setonlyAccessor", { /** @param {string} str */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt index b29c988e17..5cd4a951fc 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt @@ -1,12 +1,25 @@ +0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. +0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(7,20): error TS1016: A required parameter cannot follow an optional parameter. -==== 0.js (1 errors) ==== +==== 0.js (5 errors) ==== // @ts-check /** * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} [b] + ~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} c + ~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function foo(a, b, c) {} ~ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt new file mode 100644 index 0000000000..378fed3054 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt @@ -0,0 +1,36 @@ +0.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. +0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. +0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== 0.js (5 errors) ==== + // @ts-check + /** + * @param {number=} n + ~~~~~~~~~~~~~~~~~~ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} [s] + ~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var x = function foo(n, s) {} + var y; + /** + * @param {boolean!} b + */ + y = function bar(b) {} + + /** + * @param {string} s + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var one = function (s) { }, two = function (untyped) { }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.errors.txt new file mode 100644 index 0000000000..db9e3ee341 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.errors.txt @@ -0,0 +1,26 @@ +0.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. +0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. +0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== 0.js (4 errors) ==== + // @ts-check + /** + * @param {number=} n + ~~~~~~~~~~~~~~~~~~ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} [s] + ~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo(n, s) {} + + foo(); + foo(1); + foo(1, "hi"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.errors.txt index 47f1a3209d..01aae892fd 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.errors.txt @@ -1,10 +1,15 @@ +returns.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. +returns.js(10,14): error TS8010: Type annotations can only be used in TypeScript files. +returns.js(17,14): error TS8010: Type annotations can only be used in TypeScript files. returns.js(20,12): error TS2872: This kind of expression is always truthy. -==== returns.js (1 errors) ==== +==== returns.js (4 errors) ==== // @ts-check /** * @returns {string} This comment is not currently exposed + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f() { return "hello"; @@ -12,6 +17,8 @@ returns.js(20,12): error TS2872: This kind of expression is always truthy. /** * @returns {string=} This comment is not currently exposed + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f1() { return "hello world"; @@ -19,6 +26,8 @@ returns.js(20,12): error TS2872: This kind of expression is always truthy. /** * @returns {string|number} This comment is not currently exposed + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f2() { return 5 || "hello"; diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt index c5ab204ed8..f4ff7b544b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt @@ -1,13 +1,17 @@ +returns.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. returns.js(6,5): error TS2322: Type 'number' is not assignable to type 'string'. +returns.js(10,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (5 errors) ==== // @ts-check /** * @returns {string} This comment is not currently exposed + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f() { return 5; @@ -17,6 +21,8 @@ returns.js(13,12): error TS2872: This kind of expression is always truthy. /** * @returns {string | number} This comment is not currently exposed + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f1() { return 5 || true; diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt index 501d8cad97..50cf3ee028 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt @@ -1,9 +1,20 @@ +/a.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(20,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/a.js(21,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(21,44): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. +/a.js(22,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(22,38): error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. +/a.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(25,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(28,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/a.js(29,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/a.js(30,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/a.js(31,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(31,49): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. -==== /a.js (3 errors) ==== +==== /a.js (14 errors) ==== /** * @typedef {Object} T1 * @property {number} a @@ -16,6 +27,8 @@ /** * @typedef {(x: string) => string} T3 + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** @@ -24,22 +37,42 @@ */ const t1 = /** @satisfies {T1} */ ({ a: 1 }); + ~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); + ~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ~ !!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. const t3 = /** @satisfies {T1} */ ({}); + ~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ~ !!! error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. !!! related TS2728 /a.js:3:23: 'a' is declared here. /** @type {T2} */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const t4 = /** @satisfies {T2} */ ({ a: "a" }); + ~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. /** @type {(m: string) => string} */ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const t5 = /** @satisfies {T3} */((m) => m.substring(0)); + ~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. const t6 = /** @satisfies {[number, number]} */ ([1, 2]); + ~~~~~~~~~~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. const t7 = /** @satisfies {T4} */ ({ a: 'test' }); + ~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); + ~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ~ !!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt index 4b23f0cb68..3bbbbcf766 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt @@ -1,11 +1,14 @@ +/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. -==== /a.js (2 errors) ==== +==== /a.js (3 errors) ==== /** @typedef {"a" | "b" | "c" | "d"} Keys */ const p = /** @satisfies {Partial>} */ ({ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.errors.txt new file mode 100644 index 0000000000..819418995f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.errors.txt @@ -0,0 +1,27 @@ +/a.js(20,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + /** + * @typedef {Object} T1 + * @property {number} a + */ + + /** + * @typedef {Object} T2 + * @property {number} a + */ + + /** + * @satisfies {T1} + * @satisfies {T2} + */ + const t1 = { a: 1 }; + + /** + * @satisfies {number} + */ + const t2 = /** @satisfies {number} */ (1); + ~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.errors.txt new file mode 100644 index 0000000000..2e6505907f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.errors.txt @@ -0,0 +1,17 @@ +/a.js(10,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + /** + * @typedef {Object} T1 + * @property {number} a + */ + + /** + * @satisfies T1 + */ + const t1 = { a: 1 }; + const t2 = /** @satisfies T1 */ ({ a: 1 }); + ~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt index c3c65f4fb8..105399008c 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt @@ -1,15 +1,21 @@ /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,34): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (4 errors) ==== /** @typedef {Object. boolean>} Predicates */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const p = /** @satisfies {Predicates} */ ({ + ~~~~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1 }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt index bb8cbbe319..99553fbb9c 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt @@ -1,9 +1,16 @@ +/a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(2,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(3,7): error TS7006: Parameter 's' implicitly has an 'any' type. +/a.js(8,17): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -==== /a.js (1 errors) ==== +==== /a.js (4 errors) ==== /** @type {{ f(s: string): void } & Record }} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. f(s) { }, // "incorrect" implicit any on 's' ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. @@ -12,4 +19,6 @@ // This needs to not crash (outer node is not expression) /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt index 17573f218b..56579a341a 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt @@ -1,20 +1,26 @@ +/a.js(5,32): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(5,43): error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. +/b.js(6,32): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** * @typedef {Object} Foo * @property {number} a */ export default /** @satisfies {Foo} */ ({}); + ~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ~ !!! error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. !!! related TS2728 /a.js:3:23: 'a' is declared here. -==== /b.js (0 errors) ==== +==== /b.js (1 errors) ==== /** * @typedef {Object} Foo * @property {number} a */ - export default /** @satisfies {Foo} */ ({ a: 1 }); \ No newline at end of file + export default /** @satisfies {Foo} */ ({ a: 1 }); + ~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.errors.txt new file mode 100644 index 0000000000..bea5a7f98f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.errors.txt @@ -0,0 +1,19 @@ +/a.js(1,31): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(3,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + +==== /a.js (2 errors) ==== + /** @typedef {{ move(distance: number): void }} Movable */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + const car = /** @satisfies {Movable & Record} */ ({ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + start() { }, + move(d) { + // d should be number + }, + stop() { } + }) + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt index 81d15c6038..419811ba64 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt @@ -1,7 +1,8 @@ +/a.js(8,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(14,11): error TS2339: Property 'y' does not exist on type '{ x: number; }'. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** * @typedef {Object} Point2d * @property {number} x @@ -10,6 +11,8 @@ // Undesirable behavior today with type annotation const a = /** @satisfies {Partial} */ ({ x: 10 }); + ~~~~~~~~~~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. // Should OK console.log(a.x.toFixed()); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt index 509ca8498b..6027645310 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt @@ -1,11 +1,14 @@ +/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. -==== /a.js (2 errors) ==== +==== /a.js (3 errors) ==== /** @typedef {"a" | "b" | "c" | "d"} Keys */ const p = /** @satisfies {Record} */ ({ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt index cc59dca024..d244830f7a 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt @@ -1,8 +1,9 @@ /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(4,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (3 errors) ==== /** @typedef {Object.} Facts */ ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. @@ -11,6 +12,8 @@ // Should be able to detect a failure here const x = /** @satisfies {Facts} */ ({ + ~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. m: true, s: "false" }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt index 41ef78bd24..4d80f8a161 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt @@ -1,7 +1,8 @@ +/a.js(9,40): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(11,26): error TS2353: Object literal may only specify known properties, and 'd' does not exist in type 'Color'. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** * @typedef {Object} Color * @property {number} r @@ -11,6 +12,8 @@ // All of these should be Colors, but I only use some of them here. export const Palette = /** @satisfies {Record} */ ({ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' ~ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt index beeb1723a4..2ee8c3fe3d 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt @@ -1,26 +1,46 @@ +0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(20,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(24,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(28,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(33,11): error TS8010: Type annotations can only be used in TypeScript files. +0.js(38,11): error TS8010: Type annotations can only be used in TypeScript files. 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 (4 errors) ==== +==== 0.js (14 errors) ==== // @ts-check /** @type {String} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var S = "hello world"; /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = 10; /** @type {*} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var anyT = 2; anyT = "hello"; /** @type {?} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var anyT1 = 2; anyT1 = "hi"; /** @type {Function} */ + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const x = (a) => a + 1; x(1); @@ -28,6 +48,8 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const y = (a) => a + 1; y(1); @@ -35,6 +57,8 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const x1 = (a) => a + 1; x1(0); @@ -42,16 +66,22 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const x2 = (a) => a + 1; x2(0); /** * @type {object} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var props = {}; /** * @type {Object} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var props = {}; ~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt index 76933dc06a..0037830996 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt @@ -1,19 +1,30 @@ +0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(3,5): error TS2322: Type 'boolean' is not assignable to type 'String'. +0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. 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(8,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(12,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(23,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (6 errors) ==== +==== 0.js (13 errors) ==== // @ts-check /** @type {String} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var S = true; ~ !!! error TS2322: Type 'boolean' is not assignable to type 'String'. /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = "hello"; ~ !!! error TS2322: Type 'string' is not assignable to type 'number'. @@ -22,6 +33,8 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const x1 = (a) => a + 1; x1("string"); @@ -29,9 +42,13 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const x2 = (a) => a + 1; /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var a; a = x2(0); @@ -39,6 +56,8 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const x3 = (a) => a.concat("hi"); x3(0); @@ -46,5 +65,7 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const x4 = (a) => a + 1; x4(0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.errors.txt new file mode 100644 index 0000000000..9c9c1482a7 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.errors.txt @@ -0,0 +1,9 @@ +test.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== test.js (1 errors) ==== + /** @type {Array} */ + ~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var nns; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt index 6735c424bd..34fe05424b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt @@ -1,20 +1,26 @@ +test.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(5,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. +test.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (2 errors) ==== +==== test.js (4 errors) ==== /** Also should error for jsdoc typedefs * @template {string} U * @typedef {{ b: U }} B */ /** @type {A} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'string'. var a; /** @type {B} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'string'. var b; diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt index 285e2ac7c4..4c6ab8cfea 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt @@ -1,24 +1,37 @@ +test.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(5,14): error TS2322: Type 'number' is not assignable to type 'string'. +test.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. 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(11,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(12,14): error TS2322: Type 'number' is not assignable to type 'string'. +test.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. 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(17,18): error TS8010: Type annotations can only be used in TypeScript files. +test.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(24,5): error TS2322: Type 'number' is not assignable to type '0 | 1 | 2'. +test.js(26,19): error TS8010: Type annotations can only be used in TypeScript files. +test.js(26,39): error TS8010: Type annotations can only be used in TypeScript files. +test.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. 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) ==== +==== test.js (15 errors) ==== // all 6 should error on return statement/expression /** @type {(x: number) => string} */ function h(x) { return x } /** @type {(x: number) => string} */ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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} */ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var g = function (x) { return x } ~ !!! error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. @@ -27,11 +40,15 @@ test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. /** @type {{ (x: number): string }} */ function i(x) { return x } /** @type {{ (x: number): string }} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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 }} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var k = function (x) { return x } ~ !!! error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. @@ -39,17 +56,25 @@ test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Argle} */ function blargle(s) { return 0; } /** @type {0 | 1 | 2} - assignment should not error */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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 */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Gioconda} */ function monaLisa(sb) { @@ -57,6 +82,8 @@ test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. } /** @type {2 | 3} - overloads are not supported, so there will be an error */ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var twothree = monaLisa(false); ~~~~~~~~ !!! error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt index 34a62935d5..5728863037 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt @@ -1,17 +1,22 @@ +test.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(7,5): error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. +test.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. 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(29,12): error TS8010: Type annotations can only be used in TypeScript files. 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) ==== +==== test.js (6 errors) ==== /** @type {number} */ function f() { return 1 } /** @type {{ prop: string }} */ + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var g = function (prop) { ~ !!! error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. @@ -34,12 +39,16 @@ test.js(30,7): error TS2322: Type '(more: any) => void' is not assignable to typ function funcWithMoreParameters(more) {} // error /** @type {() => void} */ + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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} */ + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const arrowWithMoreParameters = (more) => {}; // error ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag7.errors.txt new file mode 100644 index 0000000000..d55ab67029 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag7.errors.txt @@ -0,0 +1,21 @@ +test.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. +test.js(2,28): error TS8010: Type annotations can only be used in TypeScript files. + + +==== test.js (2 errors) ==== + /** + * @typedef {(a: string, b: number) => void} Foo + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + class C { + /** @type {Foo} */ + foo(a, b) {} + + /** @type {(optional?) => void} */ + methodWithOptionalParameters() {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag8.errors.txt index 0003987b1f..7edae23af4 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag8.errors.txt @@ -1,11 +1,14 @@ +index.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. index.js(4,20): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== // https://github.com/microsoft/TypeScript/issues/57953 /** * @param {Number|BigInt} n + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. */ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt index 0eb1d13321..b35214d3bd 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt @@ -1,9 +1,11 @@ 0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string'. 0.js(10,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? 0.js(12,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +0.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (3 errors) ==== +==== 0.js (5 errors) ==== // @ts-check var lol; const obj = { @@ -30,7 +32,11 @@ } lol = "string" /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var s = obj.method1(0); /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var s1 = obj.method2("0"); \ No newline at end of file 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..9ffb5fb668 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt @@ -0,0 +1,55 @@ +0.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== 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 + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo(opts) { + opts.x; + } + + foo({x: 'abc'}); + + /** + * @typedef {Object} AnotherOpts + * @property anotherX {string} + * @property anotherY {string=} + * + * @param {AnotherOpts} opts + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo1(opts) { + opts.anotherX; + } + + foo1({anotherX: "world"}); + + /** + * @typedef {object} Opts1 + * @property {string} x + * @property {string=} y + * @property {string} [z] + * @property {string} [w="hi"] + * + * @param {Opts1} opts + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo2(opts) { + opts.x; + } + foo2({x: 'abc'}); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt index 7cb22b9170..7b4ffa2e5c 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt @@ -1,9 +1,10 @@ 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(10,12): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (3 errors) ==== +==== 0.js (4 errors) ==== // @ts-check var exports = {}; @@ -20,5 +21,7 @@ /** @type {exports.SomeName} */ ~~~~~~~ !!! error TS2503: Cannot find namespace 'exports'. + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const myString = 'str'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkObjectDefineProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/checkObjectDefineProperty.errors.txt index 26d070eca5..4ec82ca6fb 100644 --- a/testdata/baselines/reference/submodule/conformance/checkObjectDefineProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkObjectDefineProperty.errors.txt @@ -1,6 +1,13 @@ +index.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(19,10): error TS2741: Property 'name' is missing in type '{}' but required in type '{ name: string; }'. +index.js(21,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(23,11): error TS2339: Property 'zip' does not exist on type '{}'. +index.js(26,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(28,11): error TS2339: Property 'houseNumber' does not exist on type '{}'. +index.js(33,29): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(38,12): error TS8010: Type annotations can only be used in TypeScript files. validate.ts(3,3): error TS2339: Property 'name' does not exist on type '{}'. validate.ts(4,3): error TS2339: Property 'middleInit' does not exist on type '{}'. validate.ts(5,3): error TS2339: Property 'lastName' does not exist on type '{}'. @@ -61,7 +68,7 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ ~~~~~~~~~~ !!! error TS2339: Property 'middleInit' does not exist on type '{}'. -==== index.js (3 errors) ==== +==== index.js (10 errors) ==== const x = {}; Object.defineProperty(x, "name", { value: "Charles", writable: true }); Object.defineProperty(x, "middleInit", { value: "H" }); @@ -70,6 +77,8 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ Object.defineProperty(x, "houseNumber", { get() { return 21.75 } }); Object.defineProperty(x, "zipStr", { /** @param {string} str */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.zip = Number(str) } @@ -77,6 +86,8 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ /** * @param {{name: string}} named + ~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function takeName(named) { return named.name; } @@ -86,6 +97,8 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ !!! related TS2728 index.js:15:13: 'name' is declared here. /** * @type {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var a = x.zip; ~~~ @@ -93,6 +106,8 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ /** * @type {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var b = x.houseNumber; ~~~~~~~~~~~ @@ -102,11 +117,17 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ const needsExemplar = (_ = x) => void 0; const expected = /** @type {{name: string, readonly middleInit: string, readonly lastName: string, zip: number, readonly houseNumber: number, zipStr: string}} */(/** @type {*} */(null)); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** * * @param {typeof returnExemplar} a + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof needsExemplar} b + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function match(a, b) {} diff --git a/testdata/baselines/reference/submodule/conformance/checkOtherObjectAssignProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/checkOtherObjectAssignProperty.errors.txt index b339a4e9ee..d705696e41 100644 --- a/testdata/baselines/reference/submodule/conformance/checkOtherObjectAssignProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkOtherObjectAssignProperty.errors.txt @@ -1,5 +1,7 @@ importer.js(1,21): error TS2306: File 'mod1.js' is not a module. mod1.js(2,23): error TS2304: Cannot find name 'exports'. +mod1.js(5,11): error TS8010: Type annotations can only be used in TypeScript files. +mod1.js(7,22): error TS8016: Type assertion expressions can only be used in TypeScript files. mod1.js(8,23): error TS2304: Cannot find name 'exports'. mod1.js(11,23): error TS2304: Cannot find name 'exports'. mod1.js(14,23): error TS2304: Cannot find name 'exports'. @@ -26,7 +28,7 @@ mod1.js(16,23): error TS2304: Cannot find name 'exports'. mod.bad2 = 0; mod.bad3 = 0; -==== mod1.js (6 errors) ==== +==== mod1.js (8 errors) ==== const obj = { value: 42, writable: true }; Object.defineProperty(exports, "thing", obj); ~~~~~~~ @@ -34,8 +36,12 @@ mod1.js(16,23): error TS2304: Cannot find name 'exports'. /** * @type {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ let str = /** @type {string} */("other"); + ~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. Object.defineProperty(exports, str, { value: 42, writable: true }); ~~~~~~~ !!! error TS2304: Cannot find name 'exports'. diff --git a/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt b/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt index b5466ed2eb..13dca913e1 100644 --- a/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt @@ -1,14 +1,20 @@ +bug24252.js(4,20): error TS8010: Type annotations can only be used in TypeScript files. +bug24252.js(6,20): error TS8010: Type annotations can only be used in TypeScript files. 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 (3 errors) ==== var A = {}; A.B = class { m() { /** @type {string[]} */ + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x = []; /** @type {number[]} */ + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var y; y = x; ~ diff --git a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt index 321592a027..a927e4935d 100644 --- a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt @@ -1,7 +1,13 @@ +first.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. +first.js(27,16): error TS8010: Type annotations can only be used in TypeScript files. first.js(27,21): error TS8020: JSDoc types can only be used inside documentation comments. +first.js(28,16): error TS8010: Type annotations can only be used in TypeScript files. first.js(44,4): error TS2339: Property 'numberOxen' does not exist on type 'Sql'. first.js(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. +generic.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +generic.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +generic.js(9,22): error TS8011: Type arguments can only be used in TypeScript files. 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. @@ -12,10 +18,12 @@ second.ts(14,25): error TS2507: Type '{ (numberOxen: number): void; circle: (wag second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== first.js (4 errors) ==== +==== first.js (7 errors) ==== /** * @constructor * @param {number} numberOxen + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Wagon(numberOxen) { this.numberOxen = numberOxen @@ -42,9 +50,13 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con } /** * @param {Array.} files + ~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. * @param {"csv" | "json" | "xmlolololol"} format + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * This is not assignable, so should have a type error */ load(files, format) { @@ -105,16 +117,28 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con ~~~~~~~~~~ !!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (5 errors) ==== +==== generic.js (8 errors) ==== /** + ~~~ * @template T + ~~~~~~~~~~~~~~ * @param {T} flavour + ~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function Soup(flavour) { + ~~~~~~~~~~~~~~~~~~~~~~~~ this.flavour = flavour + ~~~~~~~~~~~~~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { + ~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. ~~~~ !!! error TS2507: Type '(flavour: T) => void' is not a constructor function type. log() { diff --git a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.errors.txt index 9702659e53..b777eed4c2 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.errors.txt @@ -1,13 +1,16 @@ bug43713.js(1,9): error TS2305: Module '"./commonJSAliasedExport"' has no exported member 'funky'. +bug43713.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. commonJSAliasedExport.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. commonJSAliasedExport.js(7,16): error TS2339: Property 'funky' does not exist on type '(ast: any) => any'. -==== bug43713.js (1 errors) ==== +==== bug43713.js (2 errors) ==== const { funky } = require('./commonJSAliasedExport'); ~~~~~ !!! error TS2305: Module '"./commonJSAliasedExport"' has no exported member 'funky'. /** @type {boolean} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var diddy var diddy = funky(1) diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt index c197d18d54..86c5a0bc37 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt @@ -1,11 +1,14 @@ main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? +main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -==== main.js (1 errors) ==== +==== main.js (2 errors) ==== const { K } = require("./mod1"); /** @param {K} k */ ~ !!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(k) { k.values() } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt index 6b47881065..67b4896a77 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt @@ -1,11 +1,14 @@ main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? +main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -==== main.js (1 errors) ==== +==== main.js (2 errors) ==== const { K } = require("./mod1"); /** @param {K} k */ ~ !!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(k) { k.values() } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt index 109a57b0b7..a7631a2d1c 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt @@ -1,11 +1,14 @@ main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? +main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -==== main.js (1 errors) ==== +==== main.js (2 errors) ==== const { K } = require("./mod1"); /** @param {K} k */ ~ !!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(k) { k.values() } diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt index 051cf5113e..e9f9548286 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt @@ -1,15 +1,31 @@ +constructorFunctionMethodTypeParameters.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +constructorFunctionMethodTypeParameters.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +constructorFunctionMethodTypeParameters.js(19,30): error TS8004: Type parameter declarations can only be used in TypeScript files. constructorFunctionMethodTypeParameters.js(22,16): error TS2304: Cannot find name 'T'. +constructorFunctionMethodTypeParameters.js(22,16): error TS8010: Type annotations can only be used in TypeScript files. +constructorFunctionMethodTypeParameters.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find name 'T'. +constructorFunctionMethodTypeParameters.js(24,17): error TS8010: Type annotations can only be used in TypeScript files. -==== constructorFunctionMethodTypeParameters.js (2 errors) ==== +==== constructorFunctionMethodTypeParameters.js (8 errors) ==== /** + ~~~ * @template {string} T + ~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} t + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function Cls(t) { + ~~~~~~~~~~~~~~~~~ this.t = t; + ~~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @template {string} V @@ -22,19 +38,36 @@ constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find nam }; Cls.prototype.nestedComment = + /** + ~~~~~~~ * @template {string} U + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} t + ~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} u + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} + ~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~~~~~ function (t, u) { + ~~~~~~~~~~~~~~~~~~~~~ return t + ~~~~~~~~~~~~~~~~ }; + ~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. var c = new Cls('a'); const s = c.topLevelComment('a', 'b'); diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorFunctions.errors.txt index 5f9dbe9c67..4b88dc27f2 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctions.errors.txt @@ -6,10 +6,11 @@ index.js(19,39): error TS2350: Only a void function can be called with the 'new' index.js(23,15): error TS2350: Only a void function can be called with the 'new' keyword. index.js(27,39): error TS2350: Only a void function can be called with the 'new' keyword. index.js(31,15): error TS2350: Only a void function can be called with the 'new' keyword. +index.js(51,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(55,13): error TS2554: Expected 1 arguments, but got 0. -==== index.js (9 errors) ==== +==== index.js (10 errors) ==== function C1() { if (!(this instanceof C1)) return new C1(); ~~~~~~~~ @@ -77,6 +78,8 @@ index.js(55,13): error TS2554: Expected 1 arguments, but got 0. /** * @constructor * @param {number} num + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function C7(num) {} diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt index 0744aa6348..c04db7e412 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt @@ -1,10 +1,14 @@ +a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. a.js(8,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. +a.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. 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 (3 errors) ==== +==== a.js (5 errors) ==== /** @param {number} x */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function C(x) { this.x = x } @@ -18,6 +22,8 @@ a.js(20,9): error TS7009: 'new' expression, whose target lacks a construct signa c.y = undefined // ok /** @param {number} x */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function A(x) { if (!(this instanceof A)) { return new A(x) diff --git a/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.errors.txt new file mode 100644 index 0000000000..94aa8c76e0 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.errors.txt @@ -0,0 +1,15 @@ +classthisboth.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + +==== classthisboth.js (1 errors) ==== + /** + * @class + * @this {{ e: number, m: number }} + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * this-tag should win, both 'e' and 'm' should be defined. + */ + function C() { + this.e = this.m + 1 + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.errors.txt b/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.errors.txt new file mode 100644 index 0000000000..01b19be75d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.errors.txt @@ -0,0 +1,36 @@ +index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. +index.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (3 errors) ==== + /** @type {Array<[string, {x?:number, y?:number}]>} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const arr = [ + ['a', { x: 1 }], + ['b', { y: 2 }] + ]; + + /** @return {Array<[string, {x?:number, y?:number}]>} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + function f() { + return [ + ['a', { x: 1 }], + ['b', { y: 2 }] + ]; + } + + class C { + /** @param {Array<[string, {x?:number, y?:number}]>} value */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + set x(value) { } + get x() { + return [ + ['a', { x: 1 }], + ['b', { y: 2 }] + ]; + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt index 104d117c37..2119300f7b 100644 --- a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt @@ -1,13 +1,17 @@ +mod.js(2,34): error TS8010: Type annotations can only be used in TypeScript files. +test.js(3,9): error TS8010: Type annotations can only be used in TypeScript files. test.js(15,5): error TS2322: Type 'string' is not assignable to type '"done"'. test.js(16,7): error TS7006: Parameter 'n' implicitly has an 'any' type. test.js(57,17): error TS2339: Property 'x' does not exist on type 'Thing'. test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. -==== test.js (4 errors) ==== +==== test.js (5 errors) ==== /** @typedef {{ status: 'done' m(n: number): void + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. }} DoneStatus */ // property assignment @@ -85,9 +89,11 @@ test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. m(n) { } } -==== mod.js (0 errors) ==== +==== mod.js (1 errors) ==== // module.exports assignment /** @type {{ status: 'done', m(n: number): void }} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. module.exports = { status: "done", m(n) { } diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).errors.txt b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).errors.txt new file mode 100644 index 0000000000..fc60e1398b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).errors.txt @@ -0,0 +1,60 @@ +index.js(3,4): error TS8010: Type annotations can only be used in TypeScript files. +index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (4 errors) ==== + /** + * @param {Object} [config] + * @param {Partial>} [config.additionalFiles] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function prepareConfig({ + additionalFiles: { + json = [] + } = {} + } = {}) { + json // string[] + } + + export function prepareConfigWithoutAnnotation({ + additionalFiles: { + json = [] + } = {} + } = {}) { + json + } + + /** @type {(param: { + ~~~~~~~~~ + additionalFiles?: Partial>; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }) => void} */ + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + export const prepareConfigWithContextualSignature = ({ + additionalFiles: { + json = [] + } = {} + } = {})=> { + json // string[] + } + + // Additional repros from https://github.com/microsoft/TypeScript/issues/59936 + + /** + * @param {{ a?: { json?: string[] }}} [config] + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f1({ a: { json = [] } = {} } = {}) { return json } + + /** + * @param {[[string[]?]?]} [x] + ~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f2([[json = []] = []] = []) { return json } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).errors.txt b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).errors.txt index 6f0315e559..3919e83d80 100644 --- a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).errors.txt @@ -1,10 +1,16 @@ +index.js(3,4): error TS8010: Type annotations can only be used in TypeScript files. index.js(15,9): error TS7031: Binding element 'json' implicitly has an 'any[]' type. +index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (1 errors) ==== +==== index.js (5 errors) ==== /** * @param {Object} [config] * @param {Partial>} [config.additionalFiles] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function prepareConfig({ additionalFiles: { @@ -25,8 +31,12 @@ index.js(15,9): error TS7031: Binding element 'json' implicitly has an 'any[]' t } /** @type {(param: { + ~~~~~~~~~ additionalFiles?: Partial>; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }) => void} */ + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const prepareConfigWithContextualSignature = ({ additionalFiles: { json = [] @@ -39,11 +49,15 @@ index.js(15,9): error TS7031: Binding element 'json' implicitly has an 'any[]' t /** * @param {{ a?: { json?: string[] }}} [config] + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f1({ a: { json = [] } = {} } = {}) { return json } /** * @param {[[string[]?]?]} [x] + ~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f2([[json = []] = []] = []) { return json } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt index 800958af53..85291e5660 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt @@ -1,11 +1,19 @@ 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(24,13): error TS8010: Type annotations can only be used in TypeScript files. 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(25,12): error TS8010: Type annotations can only be used in TypeScript files. 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(26,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(29,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(31,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(33,16): error TS8010: Type annotations can only be used in TypeScript files. 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(35,16): error TS8010: Type annotations can only be used in TypeScript files. 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(41,13): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (5 errors) ==== +==== a.js (13 errors) ==== /** @enum {string} */ const Target = { START: "start", @@ -32,23 +40,37 @@ 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'? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Second} s ~~~~~~ !!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Fs} f ~~ !!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function consume(t,s,f) { /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var str = t /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var num = s /** @type {(n: number) => number} */ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var v = Target.START v = Target.UNKNOWN // error, can't find 'UNKNOWN' ~~~~~~~ @@ -57,6 +79,8 @@ a.js(37,16): error TS2339: Property 'UNKNOWN' does not exist on type '{ START: s v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums } /** @param {string} s */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function ff(s) { // element access with arbitrary string is an error only with noImplicitAny if (!Target[s]) { diff --git a/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt index 5180e90595..0dd2853c71 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt @@ -1,24 +1,33 @@ type.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. +type.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +type.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. 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'? +value.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -==== type.js (2 errors) ==== +==== type.js (4 errors) ==== /** @typedef {import("./mod1").TestEnum} TE */ ~~~~~~~~ !!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. /** @type {TE} */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const test = 'add' /** @type {import("./mod1").TestEnum} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~ !!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. const tost = 'remove' -==== value.js (1 errors) ==== +==== value.js (2 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'? + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const tist = TestEnum.ADD diff --git a/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt index 5aebbf567d..77fb494250 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt @@ -1,7 +1,8 @@ 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(7,11): error TS8010: Type annotations can only be used in TypeScript files. -==== bug27134.js (1 errors) ==== +==== bug27134.js (2 errors) ==== /** * @enum {number} */ @@ -11,6 +12,8 @@ bug27134.js(7,11): error TS2749: 'foo' refers to a value, but is being used as a * @type {foo} ~~~ !!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var s; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt index ba00327c67..d836ce588b 100644 --- a/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt @@ -1,10 +1,12 @@ +foo.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. foo.js(21,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. Type 'void' is not assignable to type 'Promise'. +foo.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. Type 'void' is not assignable to type 'never'. -==== foo.js (2 errors) ==== +==== foo.js (4 errors) ==== /** * @callback FunctionReturningPromise * @returns {Promise} @@ -25,6 +27,8 @@ foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'Functio } /** @type {FunctionReturningPromise} */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var testPromise4 = function() { ~~~~~~~~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. @@ -52,6 +56,8 @@ foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'Functio } /** @type {FunctionReturningNever} */ + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var testNever4 = function() { ~~~~~~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. diff --git a/testdata/baselines/reference/submodule/conformance/esDecorators-classDeclaration-exportModifier.errors.txt b/testdata/baselines/reference/submodule/conformance/esDecorators-classDeclaration-exportModifier.errors.txt new file mode 100644 index 0000000000..0b4320fc34 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/esDecorators-classDeclaration-exportModifier.errors.txt @@ -0,0 +1,37 @@ +global.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== global.js (1 errors) ==== + /** @type {*} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var dec; + +==== file1.js (0 errors) ==== + // ok + @dec export class C1 { } + +==== file2.js (0 errors) ==== + // ok + @dec export default class C2 {} + +==== file3.js (0 errors) ==== + // error + export @dec default class C3 {} + +==== file4.js (0 errors) ==== + // ok + export @dec class C4 {} + +==== file5.js (0 errors) ==== + // ok + export default @dec class C5 {} + +==== file6.js (0 errors) ==== + // error + @dec export @dec class C6 {} + +==== file7.js (0 errors) ==== + // error + @dec export default @dec class C7 {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/exportNamespace_js.errors.txt b/testdata/baselines/reference/submodule/conformance/exportNamespace_js.errors.txt index bea8c5ca84..245e895c73 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNamespace_js.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportNamespace_js.errors.txt @@ -1,11 +1,14 @@ +b.js(1,1): error TS8006: 'export type' declarations can only be used in TypeScript files. c.js(2,1): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'. ==== a.js (0 errors) ==== export class A {} -==== b.js (0 errors) ==== +==== b.js (1 errors) ==== export type * from './a'; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'export type' declarations can only be used in TypeScript files. ==== c.js (1 errors) ==== import { A } from './b'; diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt index de19b01701..2c7f39bc4d 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt @@ -1,7 +1,9 @@ mod.js(2,11): error TS2339: Property 'K' does not exist on type '{}'. use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. +use.js(8,13): error TS8010: Type annotations can only be used in TypeScript files. use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? +use.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. ==== mod.js (1 errors) ==== @@ -17,7 +19,7 @@ use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as } } -==== use.js (3 errors) ==== +==== use.js (5 errors) ==== import * as s from './mod' var k = new s.n.K() @@ -28,11 +30,15 @@ use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as /** @param {s.n.K} c + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2694: Namespace '"mod"' has no exported member 'n'. @param {s.Classic} classic */ ~~~~~~~~~ !!! error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(c, classic) { c.x classic.p diff --git a/testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt b/testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt new file mode 100644 index 0000000000..cf7c46793e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt @@ -0,0 +1,9 @@ +a.js(2,9): error TS8006: 'export...type' declarations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + const foo = 0; + export { type foo }; + ~~~~~~~~~ +!!! error TS8006: 'export...type' declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt b/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt index 3e7597d212..3b932a0925 100644 --- a/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt @@ -1,4 +1,5 @@ use.js(3,12): error TS2749: 'MyEnum' refers to a value, but is being used as a type here. Did you mean 'typeof MyEnum'? +use.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ==== def.js (0 errors) ==== @@ -9,11 +10,13 @@ use.js(3,12): error TS2749: 'MyEnum' refers to a value, but is being used as a t }; export default MyEnum; -==== use.js (1 errors) ==== +==== use.js (2 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'? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const v = MyEnum.b; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt new file mode 100644 index 0000000000..272456d93e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt @@ -0,0 +1,19 @@ +bug25101.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +bug25101.js(5,17): error TS8011: Type arguments can only be used in TypeScript files. + + +==== bug25101.js (2 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + * @extends {Set} Should prefer this Set, not the Set in the heritage clause + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + ~~~ + class My extends Set {} + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt index 8c2c3e3e07..d02d586fdd 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt @@ -1,30 +1,57 @@ +/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +/a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(26,16): error TS8011: Type arguments can only be used in TypeScript files. /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(34,16): error TS8011: Type arguments can only be used in TypeScript files. +/a.js(39,16): error TS8011: Type arguments can only be used in TypeScript files. /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(44,16): error TS8011: Type arguments can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (8 errors) ==== /** + ~~~ * @typedef {{ + ~~~~~~~~~~~~~~ * a: number | string; + ~~~~~~~~~~~~~~~~~~~~~~~~~ * b: boolean | string[]; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * }} Foo + ~~~~~~~~ */ + ~~ + /** + ~~~ * @template {Foo} T + ~~~~~~~~~~~~~~~~~~~ */ + ~~ class A { + ~~~~~~~~~ /** + ~~~~~~ * @param {T} a + ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~~~~ constructor(a) { + ~~~~~~~~~~~~~~~~~~~ return a + ~~~~~~~~~~~~~~~ } + ~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @extends {A<{ @@ -33,6 +60,8 @@ * }>} */ class B extends A {} + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. /** * @extends {A<{ @@ -48,11 +77,15 @@ !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. */ class C extends A {} + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. /** * @extends {A<{a: string, b: string[]}>} */ class D extends A {} + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. /** * @extends {A<{a: string, b: string}>} @@ -62,4 +95,6 @@ !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. */ class E extends A {} + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt b/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt new file mode 100644 index 0000000000..7cca88f625 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt @@ -0,0 +1,51 @@ +genericSetterInClassTypeJsDoc.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +genericSetterInClassTypeJsDoc.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== genericSetterInClassTypeJsDoc.js (2 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + */ + ~~~ + class Box { + ~~~~~~~~~~~~ + #value; + ~~~~~~~~~~~ + + + /** @param {T} initialValue */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor(initialValue) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + this.#value = initialValue; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ + + ~~~~ + /** @type {T} */ + ~~~~~~~~~~~~~~~~~~~~ + get value() { + ~~~~~~~~~~~~~~~~~ + return this.#value; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ + + + set value(value) { + ~~~~~~~~~~~~~~~~~~~~~~ + this.#value = value; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + new Box(3).value = 3; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt index 7203d4ae5f..1f468f2305 100644 --- a/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt @@ -1,3 +1,5 @@ +/a.js(1,1): error TS8006: 'import type' declarations can only be used in TypeScript files. +/a.js(1,26): error TS8006: 'export type' declarations can only be used in TypeScript files. /b.ts(1,8): error TS1363: A type-only import can specify a default import or named bindings, but not both. /c.ts(4,1): error TS1392: An import alias cannot use 'import type' @@ -12,9 +14,14 @@ ~~~~~~~~~~~~~~~~ !!! error TS1363: A type-only import can specify a default import or named bindings, but not both. -==== /a.js (0 errors) ==== +==== /a.js (2 errors) ==== import type A from './a'; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + export type { A }; + ~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'export type' declarations can only be used in TypeScript files. ==== /c.ts (1 errors) ==== namespace ns { diff --git a/testdata/baselines/reference/submodule/conformance/importSpecifiers_js.errors.txt b/testdata/baselines/reference/submodule/conformance/importSpecifiers_js.errors.txt new file mode 100644 index 0000000000..0afa3e7219 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importSpecifiers_js.errors.txt @@ -0,0 +1,11 @@ +a.js(1,9): error TS8006: 'import...type' declarations can only be used in TypeScript files. + + +==== a.ts (0 errors) ==== + export interface A {} + +==== a.js (1 errors) ==== + import { type A } from "./a"; + ~~~~~~~ +!!! error TS8006: 'import...type' declarations can only be used in TypeScript files. + \ No newline at end of file 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..3af1a68f43 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag1.errors.txt @@ -0,0 +1,23 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /types.ts (0 errors) ==== + export interface Foo { + a: number; + } + +==== /foo.js (2 errors) ==== + /** + * @import { Foo } from "./types" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param { Foo } foo + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(foo) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag11.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag11.errors.txt new file mode 100644 index 0000000000..c9b5bd4721 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag11.errors.txt @@ -0,0 +1,10 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. + + +==== /foo.js (1 errors) ==== + /** + * @import foo + ~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag12.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag12.errors.txt new file mode 100644 index 0000000000..3baf3abbb3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag12.errors.txt @@ -0,0 +1,10 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. + + +==== /foo.js (1 errors) ==== + /** + * @import foo from + ~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag13.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag13.errors.txt index 958d6225ec..e4ca640f68 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag13.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag13.errors.txt @@ -1,8 +1,11 @@ +/foo.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. /foo.js(1,15): error TS1141: String literal expected. -==== /foo.js (1 errors) ==== +==== /foo.js (2 errors) ==== /** @import x = require("types") */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~ !!! error TS1141: String literal expected. diff --git a/testdata/baselines/reference/submodule/conformance/importTag14.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag14.errors.txt index b2aace2a64..081a17b460 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag14.errors.txt @@ -1,10 +1,13 @@ +/foo.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. /foo.js(1,25): error TS2306: File '/foo.js' is not a module. /foo.js(1,33): error TS1464: Type import attributes should have exactly one key - 'resolution-mode' - with value 'import' or 'require'. /foo.js(1,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. -==== /foo.js (3 errors) ==== +==== /foo.js (4 errors) ==== /** @import * as f from "./foo" with */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~ !!! error TS2306: File '/foo.js' is not a module. ~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt b/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt index 45e47c28ad..bcf9743c9c 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt @@ -1,18 +1,27 @@ +1.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. 1.js(1,30): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. +1.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. 1.js(2,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. +1.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. ==== 0.ts (0 errors) ==== export interface I { } -==== 1.js (2 errors) ==== +==== 1.js (5 errors) ==== /** @import { I } from './0' with { type: "json" } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. /** @import * as foo from './0' with { type: "json" } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. /** @param {I} a */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(a) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt b/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt index 3b98c15768..20988474b6 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt @@ -1,18 +1,27 @@ +1.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. 1.js(1,30): error TS2857: Import attributes cannot be used with type-only imports or exports. +1.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. 1.js(2,33): error TS2857: Import attributes cannot be used with type-only imports or exports. +1.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. ==== 0.ts (0 errors) ==== export interface I { } -==== 1.js (2 errors) ==== +==== 1.js (5 errors) ==== /** @import { I } from './0' with { type: "json" } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2857: Import attributes cannot be used with type-only imports or exports. /** @import * as foo from './0' with { type: "json" } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2857: Import attributes cannot be used with type-only imports or exports. /** @param {I} a */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(a) {} \ No newline at end of file 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..8957179bec --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag16.errors.txt @@ -0,0 +1,24 @@ +b.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. +b.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +b.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.ts (0 errors) ==== + export default interface Foo {} + export interface I {} + +==== b.js (3 errors) ==== + /** @import Foo, { I } from "./a" */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + + /** + * @param {Foo} a + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {I} b + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function foo(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag16.js b/testdata/baselines/reference/submodule/conformance/importTag16.js index b086bf0a00..fb3f1bd1b8 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag16.js +++ b/testdata/baselines/reference/submodule/conformance/importTag16.js @@ -29,28 +29,3 @@ import type Foo, { I } from "./a"; * @param {I} b */ export declare function foo(a: Foo, b: I): void; - - -//// [DtsFileErrors] - - -b.d.ts(1,8): error TS1363: A type-only import can specify a default import or named bindings, but not both. - - -==== a.d.ts (0 errors) ==== - export default interface Foo { - } - export interface I { - } - -==== b.d.ts (1 errors) ==== - import type Foo, { I } from "./a"; - ~~~~~~~~~~~~~~~ -!!! error TS1363: A type-only import can specify a default import or named bindings, but not both. - /** @import Foo, { I } from "./a" */ - /** - * @param {Foo} a - * @param {I} b - */ - export declare function foo(a: Foo, b: I): void; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag16.js.diff b/testdata/baselines/reference/submodule/conformance/importTag16.js.diff index 72602ad3cf..05093643ec 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag16.js.diff +++ b/testdata/baselines/reference/submodule/conformance/importTag16.js.diff @@ -13,29 +13,4 @@ -export function foo(a: Foo, b: I): void; -import type Foo from "./a"; -import type { I } from "./a"; -+export declare function foo(a: Foo, b: I): void; -+ -+ -+//// [DtsFileErrors] -+ -+ -+b.d.ts(1,8): error TS1363: A type-only import can specify a default import or named bindings, but not both. -+ -+ -+==== a.d.ts (0 errors) ==== -+ export default interface Foo { -+ } -+ export interface I { -+ } -+ -+==== b.d.ts (1 errors) ==== -+ import type Foo, { I } from "./a"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS1363: A type-only import can specify a default import or named bindings, but not both. -+ /** @import Foo, { I } from "./a" */ -+ /** -+ * @param {Foo} a -+ * @param {I} b -+ */ -+ export declare function foo(a: Foo, b: I): void; -+ \ No newline at end of file ++export declare function foo(a: Foo, b: I): void; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt index defcfc35bc..9d38acca34 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt @@ -1,4 +1,8 @@ +/a.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. +/a.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. +/a.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. /a.js(5,15): error TS2749: 'Import' refers to a value, but is being used as a type here. Did you mean 'typeof Import'? +/a.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. /a.js(12,15): error TS2749: 'Require' refers to a value, but is being used as a type here. Did you mean 'typeof Require'? @@ -20,12 +24,18 @@ ==== /node_modules/@types/foo/index.d.cts (0 errors) ==== export declare const Require: "script"; -==== /a.js (2 errors) ==== +==== /a.js (6 errors) ==== /** @import { Import } from 'foo' with { 'resolution-mode': 'import' } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. /** @import { Require } from 'foo' with { 'resolution-mode': 'require' } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. /** * @returns { Import } + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2749: 'Import' refers to a value, but is being used as a type here. Did you mean 'typeof Import'? */ @@ -35,6 +45,8 @@ /** * @returns { Require } + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~ !!! error TS2749: 'Require' refers to a value, but is being used as a type here. Did you mean 'typeof Require'? */ 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..c74cb5dd57 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag18.errors.txt @@ -0,0 +1,25 @@ +b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +b.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.ts (0 errors) ==== + export interface Foo {} + +==== b.js (2 errors) ==== + /** + * @import { + ~~~~~~~~~ + * Foo + ~~~~~~~~~ + * } from "./a" + ~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param {Foo} a + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function foo(a) {} + \ No newline at end of file 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..4911aa13d6 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag19.errors.txt @@ -0,0 +1,23 @@ +b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +b.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.ts (0 errors) ==== + export interface Foo {} + +==== b.js (2 errors) ==== + /** + * @import { Foo } + ~~~~~~~~~~~~~~~ + * from "./a" + ~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param {Foo} a + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function foo(a) {} + \ No newline at end of file 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..352f0888c9 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag2.errors.txt @@ -0,0 +1,23 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /types.ts (0 errors) ==== + export interface Foo { + a: number; + } + +==== /foo.js (2 errors) ==== + /** + * @import * as types from "./types" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param { types.Foo } foo + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function f(foo) {} + \ No newline at end of file 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..638b4c606b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag20.errors.txt @@ -0,0 +1,25 @@ +b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +b.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.ts (0 errors) ==== + export interface Foo {} + +==== b.js (2 errors) ==== + /** + * @import + ~~~~~~~ + * { Foo + ~~~~~~~~ + * } from './a' + ~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param {Foo} a + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function foo(a) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag21.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag21.errors.txt new file mode 100644 index 0000000000..e6924e1a42 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag21.errors.txt @@ -0,0 +1,37 @@ +test.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. + + +==== node_modules/tslib/package.json (0 errors) ==== + { + "name": "tslib", + "exports": { + ".": { + "module": { + "types": "./modules/index.d.ts", + "default": "./tslib.es6.mjs" + }, + "import": { + "node": "./modules/index.js", + "default": { + "types": "./modules/index.d.ts", + "default": "./tslib.es6.mjs" + } + }, + "default": "./tslib.js" + }, + "./*": "./*", + "./": "./" + } + } + +==== node_modules/tslib/modules/index.d.ts (0 errors) ==== + export {}; + +==== node_modules/tslib/tslib.d.ts (0 errors) ==== + export {}; + +==== test.js (1 errors) ==== + /** @import * as tslib from "tslib" */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + /** @type {typeof tslib} T */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt index 03bedf5694..8354b35caf 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt @@ -1,3 +1,5 @@ +/b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +/b.js(5,18): error TS8005: 'implements' clauses can only be used in TypeScript files. /b.js(6,14): error TS2420: Class 'C' incorrectly implements interface 'I'. Property 'foo' is missing in type 'C' but required in type 'I'. @@ -7,12 +9,16 @@ foo(): void; } -==== /b.js (1 errors) ==== +==== /b.js (3 errors) ==== /** * @import * as NS from './a' + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. */ /** @implements {NS.I} */ + ~~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. export class C {} ~ !!! error TS2420: Class 'C' incorrectly implements interface 'I'. 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..281bec33d3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag3.errors.txt @@ -0,0 +1,23 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /types.ts (0 errors) ==== + export default interface Foo { + a: number; + } + +==== /foo.js (2 errors) ==== + /** + * @import Foo from "./types" + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param { Foo } foo + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function f(foo) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt index dbfd8ad5b4..0888f0f549 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt @@ -1,5 +1,8 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. /foo.js(2,14): error TS2300: Duplicate identifier 'Foo'. +/foo.js(6,4): error TS8006: 'import type' declarations can only be used in TypeScript files. /foo.js(6,14): error TS2300: Duplicate identifier 'Foo'. +/foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.ts (0 errors) ==== @@ -7,21 +10,27 @@ a: number; } -==== /foo.js (2 errors) ==== +==== /foo.js (5 errors) ==== /** * @import { Foo } from "./types" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~ !!! error TS2300: Duplicate identifier 'Foo'. */ /** * @import { Foo } from "./types" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~ !!! error TS2300: Duplicate identifier 'Foo'. */ /** * @param { Foo } foo + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(foo) {} \ No newline at end of file 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..3af1a68f43 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag5.errors.txt @@ -0,0 +1,23 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /types.ts (0 errors) ==== + export interface Foo { + a: number; + } + +==== /foo.js (2 errors) ==== + /** + * @import { Foo } from "./types" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param { Foo } foo + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(foo) {} + \ No newline at end of file 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..2f47546def --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag6.errors.txt @@ -0,0 +1,36 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +/foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /types.ts (0 errors) ==== + export interface A { + a: number; + } + export interface B { + a: number; + } + +==== /foo.js (3 errors) ==== + /** + * @import { + ~~~~~~~~~ + * A, + ~~~~~~~~~ + * B, + ~~~~~~~~~ + * } from "./types" + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param { A } a + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param { B } b + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(a, b) {} + \ No newline at end of file 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..3a2da4dc64 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag7.errors.txt @@ -0,0 +1,34 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /types.ts (0 errors) ==== + export interface A { + a: number; + } + export interface B { + a: number; + } + +==== /foo.js (3 errors) ==== + /** + * @import { + ~~~~~~~~~ + * A, + ~~~~~ + * B } from "./types" + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param { A } a + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param { B } b + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(a, b) {} + \ No newline at end of file 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..6e83fa9137 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag8.errors.txt @@ -0,0 +1,34 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /types.ts (0 errors) ==== + export interface A { + a: number; + } + export interface B { + a: number; + } + +==== /foo.js (3 errors) ==== + /** + * @import + ~~~~~~~ + * { A, B } + ~~~~~~~~~~~ + * from "./types" + ~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param { A } a + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param { B } b + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(a, b) {} + \ No newline at end of file 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..949bcf7a45 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTag9.errors.txt @@ -0,0 +1,34 @@ +/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /types.ts (0 errors) ==== + export interface A { + a: number; + } + export interface B { + a: number; + } + +==== /foo.js (3 errors) ==== + /** + * @import + ~~~~~~~ + * * as types + ~~~~~~~~~~~~~ + * from "./types" + ~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** + * @param { types.A } a + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param { types.B } b + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.errors.txt b/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.errors.txt new file mode 100644 index 0000000000..8a490ca77c --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.errors.txt @@ -0,0 +1,36 @@ +index.js(5,20): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(7,22): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(8,22): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== externs.d.ts (0 errors) ==== + declare namespace MyClass { + export interface Bar { + doer: (x: string) => void; + } + } + declare class MyClass { + field: string; + static Bar: (x: string, y?: number) => void; + constructor(x: MyClass.Bar); + } + declare global { + const Foo: typeof MyClass; + } + export = MyClass; +==== index.js (3 errors) ==== + /** + * @typedef {import("./externs")} Foo + */ + + let a = /** @type {Foo} */(/** @type {*} */(undefined)); + ~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + a = new Foo({doer: Foo.Bar}); + const q = /** @type {import("./externs").Bar} */({ doer: q => q }); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + const r = /** @type {typeof import("./externs").Bar} */(r => r); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + \ No newline at end of file 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..62ce9fe76f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt @@ -0,0 +1,65 @@ +/a.js(1,17): error TS8004: Type parameter declarations can only be used in TypeScript files. +/a.js(4,15): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(9,6): error TS8004: Type parameter declarations can only be used in TypeScript files. +/a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(14,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (6 errors) ==== + export class C { + + /** + ~~~~~~~ + * @template T + ~~~~~~~~~~~~~~~~~~ + * @this {T} + ~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T} + ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static a() { + ~~~~~~~~~~~~~~~~ + return this; + ~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + + + /** + ~~~~~~~ + * @template T + ~~~~~~~~~~~~~~~~~~ + * @this {T} + ~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T} + ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + b() { + ~~~~~~~~~ + return this; + ~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + } + + 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/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt new file mode 100644 index 0000000000..b43eba6b31 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt @@ -0,0 +1,28 @@ +instantiateTemplateTagTypeParameterOnVariableStatement.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +instantiateTemplateTagTypeParameterOnVariableStatement.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. +instantiateTemplateTagTypeParameterOnVariableStatement.js(6,12): error TS8004: Type parameter declarations can only be used in TypeScript files. +instantiateTemplateTagTypeParameterOnVariableStatement.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== instantiateTemplateTagTypeParameterOnVariableStatement.js (4 errors) ==== + /** + * @template T + * @param {T} a + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {(b: T) => T} + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const seq = a => b => b; + ~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + const text1 = "hello"; + const text2 = "world"; + + /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var text3 = seq(text1)(text2); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt new file mode 100644 index 0000000000..20aac67c9b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt @@ -0,0 +1,44 @@ +argument.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. +argument.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== supplement.d.ts (0 errors) ==== + export { }; + declare module "./argument.js" { + interface Argument { + idlType: any; + default: null; + } + } +==== base.js (0 errors) ==== + export class Base { + constructor() { } + + toJSON() { + const json = { type: undefined, name: undefined, inheritance: undefined }; + return json; + } + } +==== argument.js (2 errors) ==== + import { Base } from "./base.js"; + export class Argument extends Base { + /** + * @param {*} tokeniser + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + static parse(tokeniser) { + return; + } + + get type() { + return "argument"; + } + + /** + * @param {*} defs + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + *validate(defs) { } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt new file mode 100644 index 0000000000..1caaac6dad --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt @@ -0,0 +1,45 @@ +lib.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +lib.js(3,17): error TS8005: 'implements' clauses can only be used in TypeScript files. +lib.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== interface.ts (0 errors) ==== + export interface Encoder { + encode(value: T): Uint8Array + } +==== lib.js (3 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + * @implements {IEncoder} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + */ + ~~~ + export class Encoder { + ~~~~~~~~~~~~~~~~~~~~~~ + /** + ~~~~~~~ + * @param {T} value + ~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + encode(value) { + ~~~~~~~~~~~~~~~~~~~ + return new Uint8Array(0) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + + /** + * @template T + * @typedef {import('./interface').Encoder} IEncoder + */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt index 57d5ec44df..b6d0dec2c9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt @@ -4,6 +4,9 @@ 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(36,16): error TS8010: Type annotations can only be used in TypeScript files. +jsDeclarationsClassMethod.js(37,16): error TS8010: Type annotations can only be used in TypeScript files. +jsDeclarationsClassMethod.js(38,18): error TS8010: Type annotations can only be used in TypeScript files. 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. @@ -11,7 +14,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 (11 errors) ==== +==== jsDeclarationsClassMethod.js (14 errors) ==== function C1() { /** * A comment prop @@ -60,8 +63,14 @@ jsDeclarationsClassMethod.js(61,30): error TS7006: Parameter 'y' implicitly has /** * A comment method1 * @param {number} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} y + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ method1(x, y) { return x + y; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt new file mode 100644 index 0000000000..0a3209f691 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt @@ -0,0 +1,438 @@ +index.js(13,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(24,15): error TS8010: Type annotations can only be used in TypeScript files. +index.js(30,15): error TS8010: Type annotations can only be used in TypeScript files. +index.js(31,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +index.js(38,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(40,34): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(43,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(48,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(50,34): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(53,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(58,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(59,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(65,15): error TS8010: Type annotations can only be used in TypeScript files. +index.js(71,15): error TS8010: Type annotations can only be used in TypeScript files. +index.js(72,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +index.js(79,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(84,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(89,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(94,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(97,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(104,15): error TS8010: Type annotations can only be used in TypeScript files. +index.js(108,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(109,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(111,25): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(115,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(116,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(153,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(161,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(167,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(173,23): error TS8011: Type arguments can only be used in TypeScript files. +index.js(175,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(183,20): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== index.js (34 errors) ==== + export class A {} + + export class B { + static cat = "cat"; + } + + export class C { + static Cls = class {} + } + + export class D { + /** + * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(a, b) {} + } + + + + /** + ~~~ + * @template T,U + ~~~~~~~~~~~~~~~~ + */ + ~~~ + export class E { + ~~~~~~~~~~~~~~~~ + /** + ~~~~~~~ + * @type {T & U} + ~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + field; + ~~~~~~~~~~ + + + // @readonly is currently unsupported, it seems - included here just in case that changes + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** + ~~~~~~~ + * @type {T & U} + ~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @readonly + ~~~~~~~~~~~~~~~~ + ~~~~~~~~~ + */ + ~~~~~~~ + ~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + readonlyField; + ~~~~~~~~~~~~~~~~~~ + + + initializedField = 12; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + /** + ~~~~~~~ + * @return {U} + ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + get f1() { return /** @type {*} */(null); } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + + /** + ~~~~~~~ + * @param {U} _p + ~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + set f1(_p) {} + ~~~~~~~~~~~~~~~~~ + + + /** + ~~~~~~~ + * @return {U} + ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + get f2() { return /** @type {*} */(null); } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + + /** + ~~~~~~~ + * @param {U} _p + ~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + set f3(_p) {} + ~~~~~~~~~~~~~~~~~ + + + /** + ~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(a, b) {} + ~~~~~~~~~~~~~~~~~~~~~~~~ + + + + + /** + ~~~~~~~ + * @type {string} + ~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static staticField; + ~~~~~~~~~~~~~~~~~~~~~~~ + + + // @readonly is currently unsupported, it seems - included here just in case that changes + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** + ~~~~~~~ + * @type {string} + ~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @readonly + ~~~~~~~~~~~~~~~~ + ~~~~~~~~~ + */ + ~~~~~~~ + ~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + static staticReadonlyField; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + static staticInitializedField = 12; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + /** + ~~~~~~~ + * @return {string} + ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static get s1() { return ""; } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + /** + ~~~~~~~ + * @param {string} _p + ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static set s1(_p) {} + ~~~~~~~~~~~~~~~~~~~~~~~~ + + + /** + ~~~~~~~ + * @return {string} + ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static get s2() { return ""; } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + /** + ~~~~~~~ + * @param {string} _p + ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static set s3(_p) {} + ~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + + + /** + ~~~ + * @template T,U + ~~~~~~~~~~~~~~~~ + */ + ~~~ + export class F { + ~~~~~~~~~~~~~~~~ + /** + ~~~~~~~ + * @type {T & U} + ~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + field; + ~~~~~~~~~~ + /** + ~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(a, b) {} + ~~~~~~~~~~~~~~~~~~~~~~~~ + + + + + /** + ~~~~~~~ + ~~~~~~~ + * @template A,B + ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ + * @param {A} a + ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {B} b + ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + ~~~~~~~ + static create(a, b) { return new F(a, b); } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + class G {} + + export { G }; + + class HH {} + + export { HH as H }; + + export class I {} + export { I as II }; + + export { J as JJ }; + export class J {} + + + export class K { + constructor() { + this.p1 = 12; + this.p2 = "ok"; + } + + method() { + return this.p1; + } + } + + export class L extends K {} + + export class M extends null { + constructor() { + this.prop = 12; + } + } + + + + + + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + */ + ~~~ + export class N extends L { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** + ~~~~~~~ + * @param {T} param + ~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(param) { + ~~~~~~~~~~~~~~~~~~~~~~~~ + super(); + ~~~~~~~~~~~~~~~~ + this.another = param; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + + + /** + ~~~ + * @template U + ~~~~~~~~~~~~~~ + * @extends {N} + ~~~~~~~~~~~~~~~~~~ + */ + ~~~ + export class O extends N { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + /** + ~~~~~~~ + * @param {U} param + ~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(param) { + ~~~~~~~~~~~~~~~~~~~~~~~~ + super(param); + ~~~~~~~~~~~~~~~~~~~~~ + this.another2 = param; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + var x = /** @type {*} */(null); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export class VariableBase extends x {} + + export class HasStatics { + static staticMethod() {} + } + + export class ExtendsStatics extends HasStatics { + static also() {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt new file mode 100644 index 0000000000..bafa8ccd78 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt @@ -0,0 +1,145 @@ +index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(5,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(6,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(8,26): error TS8011: Type arguments can only be used in TypeScript files. +index.js(9,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(13,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(23,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(27,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(28,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(32,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(39,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(43,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(47,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(48,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(52,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(53,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(59,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(63,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(67,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(68,10): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (21 errors) ==== + // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // but we should be able to synthesize declarations from the symbols regardless + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + export class M { + ~~~~~~~~~~~~~~~~~~~ + field: T; + ~~~~~~~~~~~~~ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + + + export class N extends M { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + other: U; + ~~~~~~~~~~~~~ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + export class O { + [idx: string]: string; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class P extends O {} + + export class Q extends O { + [idx: string]: "ok"; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class R extends O { + [idx: number]: "ok"; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class S extends O { + [idx: string]: "ok"; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: never; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class T { + [idx: number]: string; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class U extends T {} + + + export class V extends T { + [idx: string]: string; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class W extends T { + [idx: number]: "ok"; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class X extends T { + [idx: string]: string; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: "ok"; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class Y { + [idx: string]: {x: number}; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: {x: number, y: number}; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class Z extends Y {} + + export class AA extends Y { + [idx: string]: {x: number, y: number}; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class BB extends Y { + [idx: number]: {x: 0, y: 0}; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class CC extends Y { + [idx: string]: {x: number, y: number}; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: {x: 0, y: 0}; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.errors.txt new file mode 100644 index 0000000000..fdaeb2a1ed --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.errors.txt @@ -0,0 +1,32 @@ +index2.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (0 errors) ==== + const TopLevelSym = Symbol(); + const InnerSym = Symbol(); + module.exports = { + [TopLevelSym](x = 12) { + return x; + }, + items: { + [InnerSym]: (arg = {x: 12}) => arg.x + } + } + +==== index2.js (1 errors) ==== + const TopLevelSym = Symbol(); + const InnerSym = Symbol(); + + export class MyClass { + static [TopLevelSym] = 12; + [InnerSym] = "ok"; + /** + * @param {typeof TopLevelSym | typeof InnerSym} _p + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(_p = InnerSym) { + // switch on _p + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt new file mode 100644 index 0000000000..259adab29d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt @@ -0,0 +1,46 @@ +index3.js(2,20): error TS8016: Type assertion expressions can only be used in TypeScript files. +index4.js(3,20): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== index1.js (0 errors) ==== + export default 12; + +==== index2.js (0 errors) ==== + export default function foo() { + return foo; + } + export const x = foo; + export { foo as bar }; + +==== index3.js (1 errors) ==== + export default class Foo { + a = /** @type {Foo} */(null); + ~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + }; + export const X = Foo; + export { Foo as Bar }; + +==== index4.js (1 errors) ==== + import Fab from "./index3"; + class Bar extends Fab { + x = /** @type {Bar} */(null); + ~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + export default Bar; + +==== index5.js (0 errors) ==== + // merge type alias and const (OK) + export default 12; + /** + * @typedef {string | number} default + */ + +==== index6.js (0 errors) ==== + // merge type alias and function (OK) + export default function func() {}; + /** + * @typedef {string | number} default + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js index fabe4f7586..bafa2fc294 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js @@ -113,79 +113,3 @@ export type default = string | number; // merge type alias and function (OK) export default function func(): void; export type default = string | number; - - -//// [DtsFileErrors] - - -out/index5.d.ts(3,1): error TS1128: Declaration or statement expected. -out/index5.d.ts(3,8): error TS2304: Cannot find name 'type'. -out/index5.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. -out/index5.d.ts(3,21): error TS1128: Declaration or statement expected. -out/index5.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. -out/index5.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. -out/index6.d.ts(3,1): error TS1128: Declaration or statement expected. -out/index6.d.ts(3,8): error TS2304: Cannot find name 'type'. -out/index6.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. -out/index6.d.ts(3,21): error TS1128: Declaration or statement expected. -out/index6.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. -out/index6.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. - - -==== out/index1.d.ts (0 errors) ==== - declare const _default: number; - export default _default; - -==== out/index2.d.ts (0 errors) ==== - export default function foo(): typeof foo; - export declare const x: typeof foo; - export { foo as bar }; - -==== out/index3.d.ts (0 errors) ==== - export default class Foo { - a: Foo; - } - export declare const X: typeof Foo; - export { Foo as Bar }; - -==== out/index4.d.ts (0 errors) ==== - import Fab from "./index3"; - declare class Bar extends Fab { - x: Bar; - } - export default Bar; - -==== out/index5.d.ts (6 errors) ==== - declare const _default: number; - export default _default; - export type default = string | number; - ~~~~~~ -!!! error TS1128: Declaration or statement expected. - ~~~~ -!!! error TS2304: Cannot find name 'type'. - ~~~~~~~ -!!! error TS2457: Type alias name cannot be 'default'. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~ -!!! error TS2693: 'string' only refers to a type, but is being used as a value here. - ~~~~~~ -!!! error TS2693: 'number' only refers to a type, but is being used as a value here. - -==== out/index6.d.ts (6 errors) ==== - // merge type alias and function (OK) - export default function func(): void; - export type default = string | number; - ~~~~~~ -!!! error TS1128: Declaration or statement expected. - ~~~~ -!!! error TS2304: Cannot find name 'type'. - ~~~~~~~ -!!! error TS2457: Type alias name cannot be 'default'. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~ -!!! error TS2693: 'string' only refers to a type, but is being used as a value here. - ~~~~~~ -!!! error TS2693: 'number' only refers to a type, but is being used as a value here. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff index 913922e847..c9e29891cb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff @@ -81,80 +81,4 @@ -export default func; +// merge type alias and function (OK) +export default function func(): void; -+export type default = string | number; -+ -+ -+//// [DtsFileErrors] -+ -+ -+out/index5.d.ts(3,1): error TS1128: Declaration or statement expected. -+out/index5.d.ts(3,8): error TS2304: Cannot find name 'type'. -+out/index5.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. -+out/index5.d.ts(3,21): error TS1128: Declaration or statement expected. -+out/index5.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. -+out/index5.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. -+out/index6.d.ts(3,1): error TS1128: Declaration or statement expected. -+out/index6.d.ts(3,8): error TS2304: Cannot find name 'type'. -+out/index6.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. -+out/index6.d.ts(3,21): error TS1128: Declaration or statement expected. -+out/index6.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. -+out/index6.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. -+ -+ -+==== out/index1.d.ts (0 errors) ==== -+ declare const _default: number; -+ export default _default; -+ -+==== out/index2.d.ts (0 errors) ==== -+ export default function foo(): typeof foo; -+ export declare const x: typeof foo; -+ export { foo as bar }; -+ -+==== out/index3.d.ts (0 errors) ==== -+ export default class Foo { -+ a: Foo; -+ } -+ export declare const X: typeof Foo; -+ export { Foo as Bar }; -+ -+==== out/index4.d.ts (0 errors) ==== -+ import Fab from "./index3"; -+ declare class Bar extends Fab { -+ x: Bar; -+ } -+ export default Bar; -+ -+==== out/index5.d.ts (6 errors) ==== -+ declare const _default: number; -+ export default _default; -+ export type default = string | number; -+ ~~~~~~ -+!!! error TS1128: Declaration or statement expected. -+ ~~~~ -+!!! error TS2304: Cannot find name 'type'. -+ ~~~~~~~ -+!!! error TS2457: Type alias name cannot be 'default'. -+ ~ -+!!! error TS1128: Declaration or statement expected. -+ ~~~~~~ -+!!! error TS2693: 'string' only refers to a type, but is being used as a value here. -+ ~~~~~~ -+!!! error TS2693: 'number' only refers to a type, but is being used as a value here. -+ -+==== out/index6.d.ts (6 errors) ==== -+ // merge type alias and function (OK) -+ export default function func(): void; -+ export type default = string | number; -+ ~~~~~~ -+!!! error TS1128: Declaration or statement expected. -+ ~~~~ -+!!! error TS2304: Cannot find name 'type'. -+ ~~~~~~~ -+!!! error TS2457: Type alias name cannot be 'default'. -+ ~ -+!!! error TS1128: Declaration or statement expected. -+ ~~~~~~ -+!!! error TS2693: 'string' only refers to a type, but is being used as a value here. -+ ~~~~~~ -+!!! error TS2693: 'number' only refers to a type, but is being used as a value here. -+ \ No newline at end of file ++export type default = string | number; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt index 7312ed2c66..46095ddf92 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt @@ -1,10 +1,18 @@ 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(23,12): error TS8010: Type annotations can only be used in TypeScript files. 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(24,12): error TS8010: Type annotations can only be used in TypeScript files. 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(25,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(28,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(30,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(32,16): error TS8010: Type annotations can only be used in TypeScript files. 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(34,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(38,13): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (4 errors) ==== +==== index.js (12 errors) ==== /** @enum {string} */ export const Target = { START: "start", @@ -30,27 +38,43 @@ index.js(34,16): error TS2749: 'Target' refers to a value, but is being used as * @param {Target} t ~~~~~~ !!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Second} s ~~~~~~ !!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Fs} f ~~ !!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function consume(t,s,f) { /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var str = t /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var num = s /** @type {(n: number) => number} */ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var v = Target.START v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums } /** @param {string} s */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export function ff(s) { // element access with arbitrary string is an error only with noImplicitAny if (!Target[s]) { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt new file mode 100644 index 0000000000..8a109dfe27 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt @@ -0,0 +1,154 @@ +index.js(1,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(4,17): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(8,2): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(12,14): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(16,20): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(21,20): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(22,17): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(28,2): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(33,2): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(39,2): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(45,2): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript files. + + +==== index.js (12 errors) ==== + // Pretty much all of this should be an error, (since enums are forbidden in js), + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // but we should be able to synthesize declarations from the symbols regardless + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + export enum A {} + ~~~~~~~~~~~~~~~~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + + + export enum B { + ~~~~~~~~~~~~~~~ + Member + ~~~~~~~~~~ + } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + + + enum C {} + ~~~~~~~~~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + export { C }; + + + + enum DD {} + ~~~~~~~~~~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + export { DD as D }; + + + + export enum E {} + ~~~~~~~~~~~~~~~~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + export { E as EE }; + + export { F as FF }; + + export enum F {} + ~~~~~~~~~~~~~~~~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + + + export enum G { + ~~~~~~~~~~~~~~~ + A = 1, + ~~~~~~~~~~ + B, + ~~~~~~ + C + ~~~~~ + } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + + + export enum H { + ~~~~~~~~~~~~~~~ + A = "a", + ~~~~~~~~~~~~ + B = "b" + ~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + + + export enum I { + ~~~~~~~~~~~~~~~ + A = "a", + ~~~~~~~~~~~~ + B = 0, + ~~~~~~~~~~ + C + ~~~~~ + } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + + + export const enum J { + ~~~~~~~~~~~~~~~~~~~~~ + A = 1, + ~~~~~~~~~~ + B, + ~~~~~~ + C + ~~~~~ + } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + + + export enum K { + ~~~~~~~~~~~~~~~ + None = 0, + ~~~~~~~~~~~~~~~ + A = 1 << 0, + ~~~~~~~~~~~~~~~ + B = 1 << 1, + ~~~~~~~~~~~~~~~ + C = 1 << 2, + ~~~~~~~~~~~~~~~ + Mask = A | B | C, + ~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + + + export const enum L { + ~~~~~~~~~~~~~~~~~~~~~ + None = 0, + ~~~~~~~~~~~~~~~ + A = 1 << 0, + ~~~~~~~~~~~~~~~ + B = 1 << 1, + ~~~~~~~~~~~~~~~ + C = 1 << 2, + ~~~~~~~~~~~~~~~ + Mask = A | B | C, + ~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt new file mode 100644 index 0000000000..284aac91f5 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt @@ -0,0 +1,14 @@ +index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + module.exports = class Thing { + /** + * @param {number} p + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(p) { + this.t = 12 + p; + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js index 57400ad02e..d72f029c4f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js @@ -26,19 +26,3 @@ declare const _default: { new (p: number): import("."); }; export = _default; - - -//// [DtsFileErrors] - - -out/index.d.ts(2,22): error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? - - -==== out/index.d.ts (1 errors) ==== - declare const _default: { - new (p: number): import("."); - ~~~~~~~~~~~ -!!! error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? - }; - export = _default; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js.diff index d30ea0a4a7..b241b7da65 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js.diff @@ -15,20 +15,4 @@ +declare const _default: { + new (p: number): import("."); +}; -+export = _default; -+ -+ -+//// [DtsFileErrors] -+ -+ -+out/index.d.ts(2,22): error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? -+ -+ -+==== out/index.d.ts (1 errors) ==== -+ declare const _default: { -+ new (p: number): import("."); -+ ~~~~~~~~~~~ -+!!! error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? -+ }; -+ export = _default; -+ \ No newline at end of file ++export = _default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt new file mode 100644 index 0000000000..678a855563 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt @@ -0,0 +1,14 @@ +index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + module.exports = class { + /** + * @param {number} p + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(p) { + this.t = 12 + p; + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js index b6ac685f16..88c972a765 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js @@ -26,19 +26,3 @@ declare const _default: { new (p: number): import("."); }; export = _default; - - -//// [DtsFileErrors] - - -out/index.d.ts(2,22): error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? - - -==== out/index.d.ts (1 errors) ==== - declare const _default: { - new (p: number): import("."); - ~~~~~~~~~~~ -!!! error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? - }; - export = _default; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js.diff index e6561361bb..67efa37324 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js.diff @@ -15,20 +15,4 @@ +declare const _default: { + new (p: number): import("."); +}; -+export = _default; -+ -+ -+//// [DtsFileErrors] -+ -+ -+out/index.d.ts(2,22): error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? -+ -+ -+==== out/index.d.ts (1 errors) ==== -+ declare const _default: { -+ new (p: number): import("."); -+ ~~~~~~~~~~~ -+!!! error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? -+ }; -+ export = _default; -+ \ No newline at end of file ++export = _default; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt index 22d27100d3..0f328f4d77 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt @@ -1,14 +1,17 @@ index.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(9,16): error TS2339: Property 'Sub' does not exist on type 'typeof exports'. -==== index.js (2 errors) ==== +==== index.js (3 errors) ==== module.exports = class { ~~~~~~~~~~~~~~~~~~~~~~~~ /** ~~~~~~~ * @param {number} p ~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ constructor(p) { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt index fbb512e76b..2dd0d5a6d1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt @@ -1,13 +1,28 @@ index.js(1,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(3,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(4,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(7,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. +index.js(11,38): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(12,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(12,58): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,13): error TS8010: Type annotations can only be used in TypeScript files. +index.js(21,38): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(22,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(22,58): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. 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(35,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. 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(45,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. 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`. @@ -18,7 +33,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 (18 errors) ==== +==== index.js (33 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`. @@ -32,33 +47,72 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} b + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function d(a, b) { return /** @type {*} */(null); } + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. Object.defineProperty(module.exports, "d", { value: d }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + + /** + ~~~ * @template T,U + ~~~~~~~~~~~~~~~~ * @param {T} a + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T & U} + ~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function e(a, b) { return /** @type {*} */(null); } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. Object.defineProperty(module.exports, "e", { value: e }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + /** + ~~~ * @template T + ~~~~~~~~~~~~~~ * @param {T} a + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f(a) { + ~~~~~~~~~~~~~~~ return a; + ~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Object.defineProperty(module.exports, "f", { value: f }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -70,7 +124,11 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof module.exports.b}} b + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ @@ -84,7 +142,11 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof module.exports.b}} b + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt index 8bc742d706..7463616df4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt @@ -1,12 +1,19 @@ +bar.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. +bar.js(1,30): error TS8003: 'export =' can only be used in TypeScript files. globalNs.js(2,1): error TS1315: Global module exports may only appear in declaration files. ==== cls.js (0 errors) ==== export class Foo {} -==== bar.js (0 errors) ==== +==== bar.js (2 errors) ==== import ns = require("./cls"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + export = ns; // TS Only + ~~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. ==== bin.js (0 errors) ==== import * as ns from "./cls"; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt index 3331f7cf27..233640da0e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt @@ -1,28 +1,41 @@ context.js(4,14): error TS1340: Module './timer' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./timer')'? 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(6,31): error TS2694: Namespace 'Hook' has no exported member 'HookHandler'. +context.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. context.js(34,14): error TS2350: Only a void function can be called with the 'new' keyword. +context.js(40,16): error TS8010: Type annotations can only be used in TypeScript files. +context.js(41,16): error TS8010: Type annotations can only be used in TypeScript files. +context.js(42,18): error TS8010: Type annotations can only be used in TypeScript files. context.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +hook.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. 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(5,12): error TS8010: Type annotations can only be used in TypeScript files. hook.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +timer.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -==== timer.js (0 errors) ==== +==== timer.js (1 errors) ==== /** * @param {number} timeout + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Timer(timeout) { this.timeout = timeout; } module.exports = Timer; -==== hook.js (2 errors) ==== +==== hook.js (4 errors) ==== /** * @typedef {(arg: import("./context")) => void} HookHandler + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~ !!! 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 + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Hook(handle) { this.handle = handle; @@ -31,7 +44,7 @@ hook.js(10,1): error TS2309: An export assignment cannot be used in a module wit ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== context.js (5 errors) ==== +==== context.js (9 errors) ==== /** * Imports * @@ -67,6 +80,8 @@ hook.js(10,1): error TS2309: An export assignment cannot be used in a module wit * * @class * @param {Input} input + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Context(input) { @@ -80,8 +95,14 @@ hook.js(10,1): error TS2309: An export assignment cannot be used in a module wit Context.prototype = { /** * @param {Input} input + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {HookHandler=} handle + ~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {State} + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ construct(input, handle = () => void 0) { return input; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.errors.txt new file mode 100644 index 0000000000..987611553a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.errors.txt @@ -0,0 +1,53 @@ +source.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +source.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +source.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. +source.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. +source.js(26,18): error TS8010: Type annotations can only be used in TypeScript files. + + +==== source.js (5 errors) ==== + /** + * Foos a bar together using an `a` and a `b` + * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} b + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function foo(a, b) {} + + /** + * Legacy - DO NOT USE + */ + export class Aleph { + /** + * Impossible to construct. + * @param {Aleph} a + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {null} b + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(a, b) { + /** + * Field is always null + */ + this.field = b; + } + + /** + * Doesn't actually do anything + * @returns {void} + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + doIt() {} + } + + /** + * Not the speed of light + */ + export const c = 12; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt index cd9c5cdf28..811928d788 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt @@ -1,11 +1,18 @@ referencer.js(4,12): error TS2749: 'Point' refers to a value, but is being used as a type here. Did you mean 'typeof Point'? +referencer.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +source.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +source.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. source.js(7,16): error TS2350: Only a void function can be called with the 'new' keyword. -==== source.js (1 errors) ==== +==== source.js (3 errors) ==== /** * @param {number} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} y + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function Point(x, y) { if (!(this instanceof Point)) { @@ -17,13 +24,15 @@ source.js(7,16): error TS2350: Only a void function can be called with the 'new' this.y = y; } -==== referencer.js (1 errors) ==== +==== referencer.js (2 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'? + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function magnitude(p) { return Math.sqrt(p.x ** 2 + p.y ** 2); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt index ab252908a8..5c65377f0e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt @@ -1,11 +1,19 @@ referencer.js(3,23): error TS2350: Only a void function can be called with the 'new' keyword. +source.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. 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(13,16): error TS8010: Type annotations can only be used in TypeScript files. +source.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. +source.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. source.js(40,16): error TS2350: Only a void function can be called with the 'new' keyword. +source.js(53,16): error TS8010: Type annotations can only be used in TypeScript files. +source.js(62,16): error TS8010: Type annotations can only be used in TypeScript files. -==== source.js (2 errors) ==== +==== source.js (8 errors) ==== /** * @param {number} len + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function Vec(len) { /** @@ -19,6 +27,8 @@ source.js(40,16): error TS2350: Only a void function can be called with the 'new * @param {Vec} other ~~~ !!! error TS2749: 'Vec' refers to a value, but is being used as a type here. Did you mean 'typeof Vec'? + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ dot(other) { if (other.storage.length !== this.storage.length) { @@ -41,7 +51,11 @@ source.js(40,16): error TS2350: Only a void function can be called with the 'new /** * @param {number} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} y + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function Point2D(x, y) { if (!(this instanceof Point2D)) { @@ -61,6 +75,8 @@ source.js(40,16): error TS2350: Only a void function can be called with the 'new }, /** * @param {number} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ set x(x) { this.storage[0] = x; @@ -70,6 +86,8 @@ source.js(40,16): error TS2350: Only a void function can be called with the 'new }, /** * @param {number} y + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ set y(y) { this.storage[1] = y; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt index 0b7c06dc92..c11eccc426 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt @@ -1,7 +1,8 @@ source.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +source.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -==== source.js (1 errors) ==== +==== source.js (2 errors) ==== module.exports = MyClass; ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -16,4 +17,6 @@ source.js(1,1): error TS2309: An export assignment cannot be used in a module wi * * @callback DoneCB * @param {number} failures - Number of failures that occurred. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt index 237c0f2e6f..d6a37d4559 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt @@ -1,10 +1,25 @@ +index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. +index.js(14,45): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(14,59): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(20,13): error TS8010: Type annotations can only be used in TypeScript files. +index.js(22,45): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(22,59): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(38,21): error TS2349: This expression is not callable. Type '{ y: any; }' has no call signatures. +index.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(48,21): error TS2349: This expression is not callable. Type '{ y: any; }' has no call signatures. -==== index.js (2 errors) ==== +==== index.js (17 errors) ==== export function a() {} export function b() {} @@ -15,31 +30,73 @@ index.js(48,21): error TS2349: This expression is not callable. /** * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} b + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {string} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function d(a, b) { return /** @type {*} */(null); } + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** + ~~~ * @template T,U + ~~~~~~~~~~~~~~~~ * @param {T} a + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T & U} + ~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ export function e(a, b) { return /** @type {*} */(null); } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** + ~~~ * @template T + ~~~~~~~~~~~~~~ * @param {T} a + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ export function f(a) { + ~~~~~~~~~~~~~~~~~~~~~~ return a; + ~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. f.self = f; /** * @param {{x: string}} a + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof b}} b + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function g(a, b) { return a.x && b.y(); @@ -52,7 +109,11 @@ index.js(48,21): error TS2349: This expression is not callable. /** * @param {{x: string}} a + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof b}} b + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function hh(a, b) { return a.x && b.y(); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt index e4e224acd2..835bd25779 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt @@ -1,11 +1,17 @@ index.js(4,18): error TS2339: Property 'cat' does not exist on type '() => void'. index.js(7,18): error TS2339: Property 'Cls' does not exist on type '() => void'. +index.js(14,57): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(22,57): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(31,18): error TS2339: Property 'self' does not exist on type '(a: any) => any'. +index.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. 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(44,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (5 errors) ==== +==== index.js (11 errors) ==== module.exports.a = function a() {} module.exports.b = function b() {} @@ -24,6 +30,8 @@ index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install * @return {string} */ module.exports.d = function d(a, b) { return /** @type {*} */(null); } + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** * @template T,U @@ -32,6 +40,8 @@ index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install * @return {T & U} */ module.exports.e = function e(a, b) { return /** @type {*} */(null); } + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** * @template T @@ -46,7 +56,11 @@ index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof module.exports.b}} b + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ @@ -58,7 +72,11 @@ index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof module.exports.b}} b + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt new file mode 100644 index 0000000000..61478e833e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt @@ -0,0 +1,157 @@ +index.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(33,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(44,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(52,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(66,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(72,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(81,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(85,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(94,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(98,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(107,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(111,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (12 errors) ==== + export class A { + get x() { + return 12; + } + } + + export class B { + /** + * @param {number} _arg + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set x(_arg) { + } + } + + export class C { + get x() { + return 12; + } + set x(_arg) { + } + } + + export class D {} + Object.defineProperty(D.prototype, "x", { + get() { + return 12; + } + }); + + export class E {} + Object.defineProperty(E.prototype, "x", { + /** + * @param {number} _arg + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set(_arg) {} + }); + + export class F {} + Object.defineProperty(F.prototype, "x", { + get() { + return 12; + }, + /** + * @param {number} _arg + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set(_arg) {} + }); + + export class G {} + Object.defineProperty(G.prototype, "x", { + /** + * @param {number[]} args + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set(...args) {} + }); + + export class H {} + Object.defineProperty(H.prototype, "x", { + set() {} + }); + + + export class I {} + Object.defineProperty(I.prototype, "x", { + /** + * @param {number} v + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set: (v) => {} + }); + + /** + * @param {number} v + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const jSetter = (v) => {} + export class J {} + Object.defineProperty(J.prototype, "x", { + set: jSetter + }); + + /** + * @param {number} v + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const kSetter1 = (v) => {} + /** + * @param {number} v + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const kSetter2 = (v) => {} + export class K {} + Object.defineProperty(K.prototype, "x", { + set: Math.random() ? kSetter1 : kSetter2 + }); + + /** + * @param {number} v + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const lSetter1 = (v) => {} + /** + * @param {string} v + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const lSetter2 = (v) => {} + export class L {} + Object.defineProperty(L.prototype, "x", { + set: Math.random() ? lSetter1 : lSetter2 + }); + + /** + * @param {number | boolean} v + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const mSetter1 = (v) => {} + /** + * @param {string | boolean} v + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const mSetter2 = (v) => {} + export class M {} + Object.defineProperty(M.prototype, "x", { + set: Math.random() ? mSetter1 : mSetter2 + }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt index 4fca94994d..ae5714a2fb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt @@ -1,21 +1,27 @@ file.js(4,11): error TS2315: Type 'Object' is not generic. +file.js(4,11): error TS8010: Type annotations can only be used in TypeScript files. file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. 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(6,11): error TS8010: Type annotations can only be used in TypeScript files. 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. +file2.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. +file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. -==== file.js (6 errors) ==== +==== file.js (7 errors) ==== /** * @namespace myTypes * @global * @type {Object} ~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const myTypes = { // SOME PROPS HERE @@ -42,7 +48,7 @@ file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being !!! error TS2300: Duplicate identifier 'myTypes'. export {myTypes}; -==== file2.js (3 errors) ==== +==== file2.js (6 errors) ==== import {myTypes} from './file.js'; /** @@ -51,6 +57,8 @@ file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being * @type {Object} ~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const testFnTypes = { // SOME PROPS HERE @@ -66,7 +74,11 @@ file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being * @param {testFnTypes.input} input - Input. ~~~~~~~~~~~ !!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number|null} Result. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function testFn(input) { if (typeof input === 'number') { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt index e25ccebe0d..3d4538f04f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt @@ -1,16 +1,20 @@ file.js(4,11): error TS2315: Type 'Object' is not generic. +file.js(4,11): error TS8010: Type annotations can only be used in TypeScript files. file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. 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(6,11): error TS8010: Type annotations can only be used in TypeScript files. 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. +file2.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. +file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. file2.js(28,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== file2.js (4 errors) ==== +==== file2.js (7 errors) ==== const {myTypes} = require('./file.js'); /** @@ -19,6 +23,8 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi * @type {Object} ~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const testFnTypes = { // SOME PROPS HERE @@ -34,7 +40,11 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi * @param {testFnTypes.input} input - Input. ~~~~~~~~~~~ !!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number|null} Result. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function testFn(input) { if (typeof input === 'number') { @@ -47,13 +57,15 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi module.exports = {testFn, testFnTypes}; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== file.js (6 errors) ==== +==== file.js (7 errors) ==== /** * @namespace myTypes * @global * @type {Object} ~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const myTypes = { // SOME PROPS HERE diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt index 8634dc2259..8c103d7bf9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt @@ -1,9 +1,12 @@ +file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(2,29): error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. -==== file.js (1 errors) ==== +==== file.js (2 errors) ==== import { dummy } from './mod1' /** @type {import('./mod1').Dotted.Name} - should work */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. var dot2 diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt new file mode 100644 index 0000000000..86a240b454 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt @@ -0,0 +1,310 @@ +index.js(1,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(4,22): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(8,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(29,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(33,14): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(37,20): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(42,20): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(43,22): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(47,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(51,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(55,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(59,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(63,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(65,32): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(69,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(73,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(78,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(82,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(84,32): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(89,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(93,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(98,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(103,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(105,32): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(109,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(113,2): error TS8006: 'interface' declarations can only be used in TypeScript files. + + +==== index.js (26 errors) ==== + // Pretty much all of this should be an error, (since interfaces are forbidden in js), + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // but we should be able to synthesize declarations from the symbols regardless + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + export interface A {} + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface B { + ~~~~~~~~~~~~~~~~~~~~ + cat: string; + ~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface C { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + field: T & U; + ~~~~~~~~~~~~~~~~~ + optionalField?: T; + ~~~~~~~~~~~~~~~~~~~~~~ + readonly readonlyField: T & U; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + readonly readonlyOptionalField?: U; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + (): number; + ~~~~~~~~~~~~~~~ + (x: T): U; + ~~~~~~~~~~~~~~ + (x: Q): T & Q; + ~~~~~~~~~~~~~~~~~~~~~ + + + new (): string; + ~~~~~~~~~~~~~~~~~~~ + new (x: T): U; + ~~~~~~~~~~~~~~~~~~ + new (x: Q): T & Q; + ~~~~~~~~~~~~~~~~~~~~~~~~~ + + + method(): number; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + method(a: T & Q): Q & number; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + method(a?: number): number; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + method(...args: any[]): number; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + optMethod?(): number; + ~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + interface G {} + ~~~~~~~~~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + export { G }; + + + + interface HH {} + ~~~~~~~~~~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + export { HH as H }; + + + + export interface I {} + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + export { I as II }; + + export { J as JJ }; + + export interface J {} + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface K extends I,J { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + x: string; + ~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface L extends K { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + y: string; + ~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface M { + ~~~~~~~~~~~~~~~~~~~~~~~ + field: T; + ~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface N extends M { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + other: U; + ~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface O { + ~~~~~~~~~~~~~~~~~~~~ + [idx: string]: string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface P extends O {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface Q extends O { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: "ok"; + ~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface R extends O { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: "ok"; + ~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface S extends O { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: "ok"; + ~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: never; + ~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface T { + ~~~~~~~~~~~~~~~~~~~~ + [idx: number]: string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface U extends T {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + + + export interface V extends T { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface W extends T { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: "ok"; + ~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface X extends T { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: "ok"; + ~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface Y { + ~~~~~~~~~~~~~~~~~~~~ + [idx: string]: {x: number}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: {x: number, y: number}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface Z extends Y {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface AA extends Y { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: {x: number, y: number}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface BB extends Y { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: {x: 0, y: 0}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + + + export interface CC extends Y { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: {x: number, y: number}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: {x: 0, y: 0}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt index 38ff884b7d..a998c2975b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt @@ -1,60 +1,111 @@ +index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(5,12): error TS2304: Cannot find name 'Void'. +index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(6,12): error TS2304: Cannot find name 'Undefined'. +index.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(7,12): error TS2304: Cannot find name 'Null'. +index.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(11,12): error TS2552: Cannot find name 'array'. Did you mean 'Array'? +index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(12,12): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? +index.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,12): error TS2315: Type 'Object' is not generic. +index.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. 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(30,12): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (8 errors) ==== +==== index.js (25 errors) ==== // these are recognized as TS concepts by the checker /** @type {String} */const a = ""; + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Number} */const b = 0; + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Boolean} */const c = true; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Void} */const d = undefined; ~~~~ !!! error TS2304: Cannot find name 'Void'. + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Undefined} */const e = undefined; ~~~~~~~~~ !!! error TS2304: Cannot find name 'Undefined'. + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Null} */const f = null; ~~~~ !!! error TS2304: Cannot find name 'Null'. + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Function} */const g = () => void 0; + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {array} */const i = []; ~~~~~ !!! error TS2552: Cannot find name 'array'. Did you mean 'Array'? !!! related TS2728 lib.es5.d.ts:--:--: 'Array' is declared here. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @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. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Object} */const k = {x: "x"}; ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. // 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; + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. // @ts-ignore /** @type {bool} */const m = true; + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. // @ts-ignore /** @type {int} */const n = true; + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. // @ts-ignore /** @type {float} */const o = true; + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. // @ts-ignore /** @type {integer} */const p = true; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. // 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 +!!! error TS2749: 'event' refers to a value, but is being used as a type here. Did you mean 'typeof event'? + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file 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..bfa6424fd3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.errors.txt @@ -0,0 +1,17 @@ +file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== file.js (2 errors) ==== + /** + * @param {Array} x + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function x(x) {} + /** + * @param {Promise} x + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function y(x) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js index 2c0479618c..aeb030f791 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js @@ -30,26 +30,3 @@ declare function x(x: Array): void; * @param {Promise} x */ declare function y(x: Promise): void; - - -//// [DtsFileErrors] - - -out/file.d.ts(4,23): error TS2314: Generic type 'Array' requires 1 type argument(s). -out/file.d.ts(8,23): error TS2314: Generic type 'Promise' requires 1 type argument(s). - - -==== out/file.d.ts (2 errors) ==== - /** - * @param {Array} x - */ - declare function x(x: Array): void; - ~~~~~ -!!! error TS2314: Generic type 'Array' requires 1 type argument(s). - /** - * @param {Promise} x - */ - declare function y(x: Promise): void; - ~~~~~~~ -!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js.diff index 2b4a65312f..3b0d2bc189 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js.diff @@ -10,27 +10,4 @@ * @param {Promise} x */ -declare function y(x: Promise): void; -+declare function y(x: Promise): void; -+ -+ -+//// [DtsFileErrors] -+ -+ -+out/file.d.ts(4,23): error TS2314: Generic type 'Array' requires 1 type argument(s). -+out/file.d.ts(8,23): error TS2314: Generic type 'Promise' requires 1 type argument(s). -+ -+ -+==== out/file.d.ts (2 errors) ==== -+ /** -+ * @param {Array} x -+ */ -+ declare function x(x: Array): void; -+ ~~~~~ -+!!! error TS2314: Generic type 'Array' requires 1 type argument(s). -+ /** -+ * @param {Promise} x -+ */ -+ declare function y(x: Promise): void; -+ ~~~~~~~ -+!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). -+ \ No newline at end of file ++declare function y(x: Promise): void; \ 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 index 7d37afc7c5..1b1c69fbf4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.errors.txt @@ -1,11 +1,20 @@ +file.js(2,5): error TS8009: The '?' modifier can only be used in TypeScript files. +file.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. +file.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. 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,13): error TS8010: Type annotations can only be used in TypeScript files. -==== file.js (2 errors) ==== +==== file.js (6 errors) ==== /** * @param {Array=} y desc + ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. function x(y) { } // @ts-ignore @@ -15,6 +24,8 @@ file.js(12,20): error TS1099: Type argument list cannot be empty. /** * @return {(Array.<> | null)} list of devices + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. ~~ @@ -25,5 +36,7 @@ file.js(12,20): error TS1099: Type argument list cannot be empty. /** * * @return {?Promise} A promise + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function w() { return null; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt index 30a9f935a7..e88c9122c1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt @@ -1,7 +1,8 @@ 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(9,11): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== /** * @module A */ @@ -13,6 +14,8 @@ index.js(9,11): error TS2580: Cannot find name 'module'. Do you need to install * @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`. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export let el = null; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt index 6874eb5fa6..e35e04bb1f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt @@ -1,15 +1,25 @@ +file.js(5,9): error TS8010: Type annotations can only be used in TypeScript files. +file.js(7,19): error TS8010: Type annotations can only be used in TypeScript files. file.js(7,26): error TS8020: JSDoc types can only be used inside documentation comments. +file.js(16,9): error TS8010: Type annotations can only be used in TypeScript files. +file.js(20,19): error TS8010: Type annotations can only be used in TypeScript files. file.js(20,26): error TS8020: JSDoc types can only be used inside documentation comments. -==== file.js (2 errors) ==== +==== file.js (6 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 TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. */ @@ -21,10 +31,18 @@ file.js(20,26): error TS8020: JSDoc types can only be used inside documentation * 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 TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt new file mode 100644 index 0000000000..f4b11a3dbf --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt @@ -0,0 +1,20 @@ +foo.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.js (1 errors) ==== + /** + * foo + * + * @public + * @param {object} opts + * @param {number} opts.a + * @param {number} [opts.b] + * @param {number} [opts.c] + * @returns {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo({ a, b, c }) { + return a + b + c; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt index b9d1131349..c21df17ed0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt @@ -1,9 +1,10 @@ +foo.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. foo.js(11,16): error TS7031: Binding element 'a' implicitly has an 'any' type. foo.js(11,19): error TS7031: Binding element 'b' implicitly has an 'any' type. foo.js(11,22): error TS7031: Binding element 'c' implicitly has an 'any' type. -==== foo.js (3 errors) ==== +==== foo.js (4 errors) ==== /** * foo * @@ -13,6 +14,8 @@ foo.js(11,22): error TS7031: Binding element 'c' implicitly has an 'any' type. * @param {number} [opts.b] * @param {number} [opts.c] * @returns {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function foo({ a, b, c }) { ~ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt index 810b53ae05..0b482248a9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt @@ -1,6 +1,9 @@ base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. file.js(1,15): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? file.js(4,12): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? +file.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. ==== base.js (1 errors) ==== @@ -18,7 +21,7 @@ file.js(4,12): error TS1340: Module './base' does not refer to a type, but is us ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -==== file.js (2 errors) ==== +==== file.js (5 errors) ==== /** @typedef {import('./base')} BaseFactory */ ~~~~~~~~~~~~~~~~ !!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? @@ -27,6 +30,8 @@ file.js(4,12): error TS1340: Module './base' does not refer to a type, but is us * @param {import('./base')} factory ~~~~~~~~~~~~~~~~ !!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** @enum {import('./base')} */ const couldntThinkOfAny = {} @@ -34,7 +39,11 @@ file.js(4,12): error TS1340: Module './base' does not refer to a type, but is us /** * * @param {InstanceType} base + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {InstanceType} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const test = (base) => { return base; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt index fef4bd8c6b..d77a96cd6e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt @@ -1,4 +1,6 @@ base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +file.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. ==== base.js (1 errors) ==== @@ -16,13 +18,17 @@ base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -==== file.js (0 errors) ==== +==== file.js (2 errors) ==== /** @typedef {typeof import('./base')} BaseFactory */ /** * * @param {InstanceType} base + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {InstanceType} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const test = (base) => { return base; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsPrivateFields01.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsPrivateFields01.errors.txt new file mode 100644 index 0000000000..19c468ba24 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsPrivateFields01.errors.txt @@ -0,0 +1,27 @@ +file.js(12,23): error TS8010: Type annotations can only be used in TypeScript files. + + +==== file.js (1 errors) ==== + export class C { + #hello = "hello"; + #world = 100; + + #calcHello() { + return this.#hello; + } + + get #screamingHello() { + return this.#hello.toUpperCase(); + } + /** @param value {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + set #screamingHello(value) { + throw "NO"; + } + + getWorld() { + return this.#world; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.errors.txt new file mode 100644 index 0000000000..7cc5111a4f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.errors.txt @@ -0,0 +1,102 @@ +jsDeclarationsReactComponents2.jsx(3,11): error TS8010: Type annotations can only be used in TypeScript files. +jsDeclarationsReactComponents3.jsx(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + +==== jsDeclarationsReactComponents1.jsx (0 errors) ==== + /// + import React from "react"; + import PropTypes from "prop-types" + + const TabbedShowLayout = ({ + }) => { + return ( +
+ ); + }; + + TabbedShowLayout.propTypes = { + version: PropTypes.number, + + }; + + TabbedShowLayout.defaultProps = { + tabs: undefined + }; + + export default TabbedShowLayout; + +==== jsDeclarationsReactComponents2.jsx (1 errors) ==== + import React from "react"; + /** + * @type {React.SFC} + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const TabbedShowLayout = () => { + return ( +
+ ok +
+ ); + }; + + TabbedShowLayout.defaultProps = { + tabs: "default value" + }; + + export default TabbedShowLayout; + +==== jsDeclarationsReactComponents3.jsx (1 errors) ==== + import React from "react"; + /** + * @type {{defaultProps: {tabs: string}} & ((props?: {elem: string}) => JSX.Element)} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const TabbedShowLayout = () => { + return ( +
+ ok +
+ ); + }; + + TabbedShowLayout.defaultProps = { + tabs: "default value" + }; + + export default TabbedShowLayout; + +==== jsDeclarationsReactComponents4.jsx (0 errors) ==== + import React from "react"; + const TabbedShowLayout = (/** @type {{className: string}}*/prop) => { + return ( +
+ ok +
+ ); + }; + + TabbedShowLayout.defaultProps = { + tabs: "default value" + }; + + export default TabbedShowLayout; +==== jsDeclarationsReactComponents5.jsx (0 errors) ==== + import React from 'react'; + import PropTypes from 'prop-types'; + + function Tree({ allowDropOnRoot }) { + return
+ } + + Tree.propTypes = { + classes: PropTypes.object, + }; + + Tree.defaultProps = { + classes: {}, + parentSource: 'parent_id', + }; + + export default Tree; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js index d7751ce4d7..9f7053416e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js @@ -227,77 +227,3 @@ declare function Tree({ allowDropOnRoot }: { allowDropOnRoot: any; }): JSX.Element; export default Tree; - - -//// [DtsFileErrors] - - -out/jsDeclarationsReactComponents1.d.ts(1,23): error TS2307: Cannot find module 'prop-types' or its corresponding type declarations. -out/jsDeclarationsReactComponents1.d.ts(3,15): error TS2503: Cannot find namespace 'JSX'. -out/jsDeclarationsReactComponents2.d.ts(1,19): error TS2307: Cannot find module 'react' or its corresponding type declarations. -out/jsDeclarationsReactComponents3.d.ts(10,7): error TS2503: Cannot find namespace 'JSX'. -out/jsDeclarationsReactComponents4.d.ts(2,18): error TS2503: Cannot find namespace 'JSX'. -out/jsDeclarationsReactComponents5.d.ts(3,5): error TS2503: Cannot find namespace 'JSX'. - - -==== out/jsDeclarationsReactComponents1.d.ts (2 errors) ==== - import PropTypes from "prop-types"; - ~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'prop-types' or its corresponding type declarations. - declare const TabbedShowLayout: { - ({}: {}): JSX.Element; - ~~~ -!!! error TS2503: Cannot find namespace 'JSX'. - propTypes: { - version: PropTypes.Requireable; - }; - defaultProps: { - tabs: undefined; - }; - }; - export default TabbedShowLayout; - -==== out/jsDeclarationsReactComponents2.d.ts (1 errors) ==== - import React from "react"; - ~~~~~~~ -!!! error TS2307: Cannot find module 'react' or its corresponding type declarations. - /** - * @type {React.SFC} - */ - declare const TabbedShowLayout: React.SFC; - export default TabbedShowLayout; - -==== out/jsDeclarationsReactComponents3.d.ts (1 errors) ==== - /** - * @type {{defaultProps: {tabs: string}} & ((props?: {elem: string}) => JSX.Element)} - */ - declare const TabbedShowLayout: { - defaultProps: { - tabs: string; - }; - } & ((props?: { - elem: string; - }) => JSX.Element); - ~~~ -!!! error TS2503: Cannot find namespace 'JSX'. - export default TabbedShowLayout; - -==== out/jsDeclarationsReactComponents4.d.ts (1 errors) ==== - declare const TabbedShowLayout: { - (prop: any): JSX.Element; - ~~~ -!!! error TS2503: Cannot find namespace 'JSX'. - defaultProps: { - tabs: string; - }; - }; - export default TabbedShowLayout; - -==== out/jsDeclarationsReactComponents5.d.ts (1 errors) ==== - declare function Tree({ allowDropOnRoot }: { - allowDropOnRoot: any; - }): JSX.Element; - ~~~ -!!! error TS2503: Cannot find namespace 'JSX'. - export default Tree; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js.diff index 2fed74569e..0ebe91954f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js.diff @@ -144,78 +144,4 @@ - } -} -import PropTypes from 'prop-types'; -+export default Tree; -+ -+ -+//// [DtsFileErrors] -+ -+ -+out/jsDeclarationsReactComponents1.d.ts(1,23): error TS2307: Cannot find module 'prop-types' or its corresponding type declarations. -+out/jsDeclarationsReactComponents1.d.ts(3,15): error TS2503: Cannot find namespace 'JSX'. -+out/jsDeclarationsReactComponents2.d.ts(1,19): error TS2307: Cannot find module 'react' or its corresponding type declarations. -+out/jsDeclarationsReactComponents3.d.ts(10,7): error TS2503: Cannot find namespace 'JSX'. -+out/jsDeclarationsReactComponents4.d.ts(2,18): error TS2503: Cannot find namespace 'JSX'. -+out/jsDeclarationsReactComponents5.d.ts(3,5): error TS2503: Cannot find namespace 'JSX'. -+ -+ -+==== out/jsDeclarationsReactComponents1.d.ts (2 errors) ==== -+ import PropTypes from "prop-types"; -+ ~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'prop-types' or its corresponding type declarations. -+ declare const TabbedShowLayout: { -+ ({}: {}): JSX.Element; -+ ~~~ -+!!! error TS2503: Cannot find namespace 'JSX'. -+ propTypes: { -+ version: PropTypes.Requireable; -+ }; -+ defaultProps: { -+ tabs: undefined; -+ }; -+ }; -+ export default TabbedShowLayout; -+ -+==== out/jsDeclarationsReactComponents2.d.ts (1 errors) ==== -+ import React from "react"; -+ ~~~~~~~ -+!!! error TS2307: Cannot find module 'react' or its corresponding type declarations. -+ /** -+ * @type {React.SFC} -+ */ -+ declare const TabbedShowLayout: React.SFC; -+ export default TabbedShowLayout; -+ -+==== out/jsDeclarationsReactComponents3.d.ts (1 errors) ==== -+ /** -+ * @type {{defaultProps: {tabs: string}} & ((props?: {elem: string}) => JSX.Element)} -+ */ -+ declare const TabbedShowLayout: { -+ defaultProps: { -+ tabs: string; -+ }; -+ } & ((props?: { -+ elem: string; -+ }) => JSX.Element); -+ ~~~ -+!!! error TS2503: Cannot find namespace 'JSX'. -+ export default TabbedShowLayout; -+ -+==== out/jsDeclarationsReactComponents4.d.ts (1 errors) ==== -+ declare const TabbedShowLayout: { -+ (prop: any): JSX.Element; -+ ~~~ -+!!! error TS2503: Cannot find namespace 'JSX'. -+ defaultProps: { -+ tabs: string; -+ }; -+ }; -+ export default TabbedShowLayout; -+ -+==== out/jsDeclarationsReactComponents5.d.ts (1 errors) ==== -+ declare function Tree({ allowDropOnRoot }: { -+ allowDropOnRoot: any; -+ }): JSX.Element; -+ ~~~ -+!!! error TS2503: Cannot find namespace 'JSX'. -+ export default Tree; -+ \ No newline at end of file ++export default Tree; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReexportedCjsAlias.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReexportedCjsAlias.errors.txt new file mode 100644 index 0000000000..0e2caeb326 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReexportedCjsAlias.errors.txt @@ -0,0 +1,30 @@ +lib.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== main.js (0 errors) ==== + const { SomeClass, SomeClass: Another } = require('./lib'); + + module.exports = { + SomeClass, + Another + } +==== lib.js (1 errors) ==== + /** + * @param {string} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function bar(a) { + return a + a; + } + + class SomeClass { + a() { + return 1; + } + } + + module.exports = { + bar, + SomeClass + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt index f263e9f33f..9e9c17045f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt @@ -1,5 +1,6 @@ index.js(7,19): error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? index.js(14,18): error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? +index.js(14,18): error TS8010: Type annotations can only be used in TypeScript files. ==== test.js (0 errors) ==== @@ -16,7 +17,7 @@ index.js(14,18): error TS2749: 'Rectangle' refers to a value, but is being used } module.exports = { Rectangle }; -==== index.js (2 errors) ==== +==== index.js (3 errors) ==== const {Rectangle} = require('./rectangle'); class Render { @@ -35,6 +36,8 @@ index.js(14,18): error TS2749: 'Rectangle' refers to a value, but is being used * @returns {Rectangle} the rect ~~~~~~~~~ !!! error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ addRectangle() { const obj = new Rectangle(); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt index 42bdb51664..51d795ae7f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt @@ -1,40 +1,64 @@ +index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +index.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(22,12): error TS2315: Type 'Object' is not generic. +index.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(22,18): error TS8020: JSDoc types can only be used inside documentation comments. -==== index.js (4 errors) ==== +==== index.js (12 errors) ==== /** @type {?} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const a = null; /** @type {*} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const b = null; /** @type {string?} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const c = null; /** @type {string=} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const d = null; /** @type {string!} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const g = null; /** @type {Object.} */ ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. 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 4734b8e4b1..ee3503cd91 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt @@ -1,19 +1,41 @@ +index.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(11,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(44,9): error TS1051: A 'set' accessor cannot have an optional parameter. +index.js(44,9): error TS8009: The '?' modifier can only be used in TypeScript files. +index.js(44,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(54,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(64,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(74,17): error TS8010: Type annotations can only be used in TypeScript files. index.js(82,9): error TS1051: A 'set' accessor cannot have an optional parameter. +index.js(82,9): error TS8009: The '?' modifier can only be used in TypeScript files. +index.js(82,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(87,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(92,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(97,17): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (2 errors) ==== +==== index.js (16 errors) ==== class С1 { /** @type {string=} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. p1 = undefined; /** @type {string | undefined} */ + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. p2 = undefined; /** @type {?string} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. p3 = null; /** @type {string | null} */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. p4 = null; } @@ -49,6 +71,10 @@ index.js(82,9): error TS1051: A 'set' accessor cannot have an optional parameter /** @param {string=} value */ ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1051: A 'set' accessor cannot have an optional parameter. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set p1(value) { this.p1 = value; } @@ -59,6 +85,8 @@ index.js(82,9): error TS1051: A 'set' accessor cannot have an optional parameter } /** @param {string | undefined} value */ + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set p2(value) { this.p2 = value; } @@ -69,6 +97,8 @@ index.js(82,9): error TS1051: A 'set' accessor cannot have an optional parameter } /** @param {?string} value */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set p3(value) { this.p3 = value; } @@ -79,6 +109,8 @@ index.js(82,9): error TS1051: A 'set' accessor cannot have an optional parameter } /** @param {string | null} value */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set p4(value) { this.p4 = value; } @@ -89,21 +121,31 @@ index.js(82,9): error TS1051: A 'set' accessor cannot have an optional parameter /** @param {string=} value */ ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1051: A 'set' accessor cannot have an optional parameter. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set p1(value) { this.p1 = value; } /** @param {string | undefined} value */ + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set p2(value) { this.p2 = value; } /** @param {?string} value */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set p3(value) { this.p3 = value; } /** @param {string | null} value */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. set p4(value) { this.p4 = value; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt new file mode 100644 index 0000000000..7b708a7261 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt @@ -0,0 +1,22 @@ +index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (2 errors) ==== + export class Super { + /** + * @param {string} firstArg + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} secondArg + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(firstArg, secondArg) { } + } + + export class Sub extends Super { + constructor() { + super('first', 'second'); + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt new file mode 100644 index 0000000000..c4236c5118 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt @@ -0,0 +1,16 @@ +index.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + export class A { + /** @returns {this} */ + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + method() { + return this; + } + } + export default class Base extends A { + // This method is required to reproduce #35932 + verify() { } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt index 324fb0ae0d..b4904279c5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt @@ -1,7 +1,11 @@ +index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. +mixed.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +mixed.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. mixed.js(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== index.js (0 errors) ==== +==== index.js (2 errors) ==== export {}; // flag file as module /** * @typedef {string | number | symbol} PropName @@ -12,6 +16,8 @@ mixed.js(14,1): error TS2309: An export assignment cannot be used in a module wi * * @callback NumberToStringCb * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string} */ @@ -26,16 +32,22 @@ mixed.js(14,1): error TS2309: An export assignment cannot be used in a module wi * @template T * @callback Identity * @param {T} x + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} */ -==== mixed.js (1 errors) ==== +==== mixed.js (3 errors) ==== /** * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType */ /** * @param {number} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {SomeType} + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function doTheThing(x) { return {x: ""+x}; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt new file mode 100644 index 0000000000..f6682d013d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt @@ -0,0 +1,15 @@ +index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /some-mod.d.ts (0 errors) ==== + interface Item { + x: string; + } + declare const items: Item[]; + export = items; +==== index.js (1 errors) ==== + /** @type {typeof import("/some-mod")} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const items = []; + module.exports = items; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js index be70025cd8..a299370c13 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js @@ -20,22 +20,3 @@ module.exports = items; //// [index.d.ts] export = items; - - -//// [DtsFileErrors] - - -/out/index.d.ts(1,10): error TS2304: Cannot find name 'items'. - - -==== /some-mod.d.ts (0 errors) ==== - interface Item { - x: string; - } - declare const items: Item[]; - export = items; -==== /out/index.d.ts (1 errors) ==== - export = items; - ~~~~~ -!!! error TS2304: Cannot find name 'items'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js.diff index 046f34d1e2..d980260319 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js.diff @@ -11,23 +11,4 @@ //// [index.d.ts] export = items; -/** @type {typeof import("/some-mod")} */ --declare const items: typeof import("/some-mod"); -+ -+ -+//// [DtsFileErrors] -+ -+ -+/out/index.d.ts(1,10): error TS2304: Cannot find name 'items'. -+ -+ -+==== /some-mod.d.ts (0 errors) ==== -+ interface Item { -+ x: string; -+ } -+ declare const items: Item[]; -+ export = items; -+==== /out/index.d.ts (1 errors) ==== -+ export = items; -+ ~~~~~ -+!!! error TS2304: Cannot find name 'items'. -+ \ No newline at end of file +-declare const items: typeof import("/some-mod"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt new file mode 100644 index 0000000000..a304654b55 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt @@ -0,0 +1,33 @@ +index.js(2,28): error TS8006: 'module' declarations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + /// + export const Something = 2; // to show conflict that can occur + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // @ts-ignore + ~~~~~~~~~~~~~ + export namespace A { + ~~~~~~~~~~~~~~~~~~~~ + // @ts-ignore + ~~~~~~~~~~~~~~~~~ + export namespace B { + ~~~~~~~~~~~~~~~~~~~~~~~~ + const Something = require("fs").Something; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const thing = new Something(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // @ts-ignore + ~~~~~~~~~~~~~~~~~~~~~ + export { thing }; + ~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ + } + ~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. + +==== node_modules/@types/node/index.d.ts (0 errors) ==== + declare module "fs" { + export class Something {} + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt index 23837dfb7d..0fc20f0ff0 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 TS2309: An export assignment cannot be used in a module with other exported elements. +usage.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. usage.js(11,37): error TS2694: Namespace 'Conn' has no exported member 'Whatever'. usage.js(16,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -18,7 +19,7 @@ usage.js(16,1): error TS2309: An export assignment cannot be used in a module wi ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== usage.js (2 errors) ==== +==== usage.js (3 errors) ==== /** * @typedef {import("./conn")} Conn */ @@ -26,6 +27,8 @@ usage.js(16,1): error TS2309: An export assignment cannot be used in a module wi class Wrap { /** * @param {Conn} c + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(c) { this.connItem = c.item; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt index 4c105d6974..0fe7f869b6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt @@ -1,15 +1,19 @@ +LazySet.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. LazySet.js(13,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (0 errors) ==== +==== index.js (1 errors) ==== const LazySet = require("./LazySet"); /** @type {LazySet} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const stringSet = undefined; stringSet.addAll(stringSet); -==== LazySet.js (1 errors) ==== +==== LazySet.js (2 errors) ==== // Comment out this JSDoc, and note that the errors index.js go away. /** * @typedef {Object} SomeObject @@ -17,6 +21,8 @@ LazySet.js(13,1): error TS2309: An export assignment cannot be used in a module class LazySet { /** * @param {LazySet} iterable + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ addAll(iterable) {} [Symbol.iterator]() {} diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.errors.txt new file mode 100644 index 0000000000..5c14f33baf --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.errors.txt @@ -0,0 +1,27 @@ +foo.js(3,10): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.js (3 errors) ==== + /** + * @typedef {{ + * [id: string]: [Function, Function]; + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * }} ResolveRejectMap + */ + + let id = 0 + + /** + * @param {ResolveRejectMap} handlers + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {Promise} + ~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const send = handlers => new Promise((resolve, reject) => { + handlers[++id] = [resolve, reject] + }) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt index 0bb4eb949a..d4efe653ab 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt @@ -1,10 +1,14 @@ index.js(3,37): error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. +index.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(16,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(21,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +module.js(11,11): error TS8010: Type annotations can only be used in TypeScript files. module.js(24,12): error TS2315: Type 'Object' is not generic. +module.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. module.js(27,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== index.js (2 errors) ==== +==== index.js (4 errors) ==== const {taskGroups, taskNameToGroup} = require('./module.js'); /** @typedef {import('./module.js').TaskGroup} TaskGroup */ @@ -22,7 +26,11 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w class MainThreadTasks { /** * @param {TaskGroup} x + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {TaskNode} y + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(x, y){} } @@ -30,7 +38,7 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w module.exports = MainThreadTasks; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== module.js (2 errors) ==== +==== module.js (4 errors) ==== /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ /** @@ -42,6 +50,8 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w /** * @type {{[P in TaskGroupIds]: {id: P, label: string}}} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const taskGroups = { parseHTML: { @@ -57,6 +67,8 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w /** @type {Object} */ ~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const taskNameToGroup = {}; module.exports = { 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..83c112d3a8 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt @@ -0,0 +1,23 @@ +b.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. +b.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (0 errors) ==== + export const kSymbol = Symbol("my-symbol"); + + /** + * @typedef {{[kSymbol]: true}} WithSymbol + */ +==== b.js (2 errors) ==== + /** + * @returns {import('./a').WithSymbol} + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {import('./a').WithSymbol} value + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function b(value) { + return value; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt index 6386334b80..fda9e046de 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt @@ -1,3 +1,6 @@ +jsdocAccessibilityTag.js(5,8): error TS8009: The 'private' modifier can only be used in TypeScript files. +jsdocAccessibilityTag.js(11,8): error TS8009: The 'protected' modifier can only be used in TypeScript files. +jsdocAccessibilityTag.js(17,8): error TS8009: The 'public' modifier can only be used in TypeScript files. jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. @@ -10,25 +13,34 @@ jsdocAccessibilityTag.js(61,9): error TS2341: Property 'priv2' is private and on jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. -==== jsdocAccessibilityTag.js (10 errors) ==== +==== jsdocAccessibilityTag.js (13 errors) ==== class A { /** * Ap docs * * @private + ~~~~~~~~ */ + ~~~~~ +!!! error TS8009: The 'private' modifier can only be used in TypeScript files. priv = 4; /** * Aq docs * * @protected + ~~~~~~~~~~ */ + ~~~~~ +!!! error TS8009: The 'protected' modifier can only be used in TypeScript files. prot = 5; /** * Ar docs * * @public + ~~~~~~~ */ + ~~~~~ +!!! error TS8009: The 'public' modifier can only be used in TypeScript files. pub = 6; /** @public */ get ack() { return this.priv } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt new file mode 100644 index 0000000000..31094fd912 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt @@ -0,0 +1,16 @@ +/b.js(2,16): error TS8011: Type arguments can only be used in TypeScript files. + + +==== /a.d.ts (0 errors) ==== + declare class A { x: T } + +==== /b.js (1 errors) ==== + /** @augments A */ + class B extends A { + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + m() { + return this.x; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.errors.txt new file mode 100644 index 0000000000..baacb4d3c7 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.errors.txt @@ -0,0 +1,14 @@ +bug27341.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== bug27341.js (1 errors) ==== + if (false) { + /** + * @param {string} s + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const x = function (s) { + }; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt index 38388986e6..a9f5fa3ec7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt @@ -1,15 +1,36 @@ +foo.js(11,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(12,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(13,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(14,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(16,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(17,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(18,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(19,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(20,31): error TS8010: Type annotations can only be used in TypeScript files. foo.js(20,54): error TS2339: Property 'foo' does not exist on type 'unknown'. +foo.js(21,31): error TS8010: Type annotations can only be used in TypeScript files. 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(22,31): error TS8010: Type annotations can only be used in TypeScript files. foo.js(23,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. +foo.js(23,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(27,23): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(34,14): error TS8010: Type annotations can only be used in TypeScript files. foo.js(35,7): error TS2492: Cannot redeclare identifier 'err' in catch clause. +foo.js(39,14): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(44,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(45,31): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(46,31): error TS8010: Type annotations can only be used in TypeScript files. foo.js(46,45): error TS2339: Property 'x' does not exist on type '{}'. +foo.js(47,31): error TS8010: Type annotations can only be used in TypeScript files. 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(48,31): error TS8010: Type annotations can only be used in TypeScript files. foo.js(49,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. +foo.js(49,31): error TS8010: Type annotations can only be used in TypeScript files. -==== foo.js (9 errors) ==== +==== foo.js (30 errors) ==== /** * @typedef {any} Any */ @@ -21,30 +42,56 @@ foo.js(49,31): error TS1196: Catch clause variable type annotation must be 'any' function fn() { try { } catch (x) { } // should be OK try { } catch (/** @type {any} */ err) { } // should be OK + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Any} */ err) { } // should be OK + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {unknown} */ err) { } // should be OK + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Unknown} */ err) { } // should be OK + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (err) { err.foo; } // should be OK try { } catch (/** @type {any} */ err) { err.foo; } // should be OK + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Any} */ err) { err.foo; } // should be OK + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {unknown} */ err) { console.log(err); } // should be OK + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Unknown} */ err) { console.log(err); } // should be OK + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {unknown} */ err) { err.foo; } // error in the body + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2339: Property 'foo' does not exist on type 'unknown'. try { } catch (/** @type {Unknown} */ err) { err.foo; } // error in the body + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! 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. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {object} */ err) { } // error in the type ~~~~~~ !!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { console.log(); } // @ts-ignore catch (/** @type {number} */ err) { // e should not be a `number` + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. console.log(err.toLowerCase()); } @@ -52,6 +99,8 @@ foo.js(49,31): error TS1196: Catch clause variable type annotation must be 'any' try { } catch (err) { /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. let err; ~~~ !!! error TS2492: Cannot redeclare identifier 'err' in catch clause. @@ -59,23 +108,37 @@ foo.js(49,31): error TS1196: Catch clause variable type annotation must be 'any' try { } catch (err) { /** @type {boolean} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var err; } try { } catch ({ x }) { } // should be OK try { } catch (/** @type {any} */ { x }) { x.foo; } // should be OK + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Any} */ { x }) { x.foo;} // should be OK + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {unknown} */ { x }) { console.log(x); } // error in the destructure + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2339: Property 'x' does not exist on type '{}'. try { } catch (/** @type {Unknown} */ { x }) { console.log(x); } // error in the destructure + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! 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. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {object} */ { x }) { } // error in the type ~~~~~~ !!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt index 0ecef16650..46e867bc80 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt @@ -1,7 +1,8 @@ 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(8,12): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocConstructorFunctionTypeReference.js (1 errors) ==== +==== jsdocConstructorFunctionTypeReference.js (2 errors) ==== var Validator = function VFunc() { this.flags = "gim" }; @@ -12,6 +13,8 @@ jsdocConstructorFunctionTypeReference.js(8,12): error TS2749: 'Validator' refers * @param {Validator} state ~~~~~~~~~ !!! error TS2749: 'Validator' refers to a value, but is being used as a type here. Did you mean 'typeof Validator'? + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var validateRegExpFlags = function(state) { return state.flags diff --git a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt index bed5688d1f..37c7202738 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt @@ -1,23 +1,32 @@ functions.js(3,13): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +functions.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. 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(13,13): error TS8010: Type annotations can only be used in TypeScript files. functions.js(15,14): error TS7006: Parameter 'c' implicitly has an 'any' type. +functions.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. functions.js(30,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +functions.js(30,12): error TS8010: Type annotations can only be used in TypeScript files. 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(36,12): error TS8010: Type annotations can only be used in TypeScript files. 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(49,13): error TS8010: Type annotations can only be used in TypeScript files. functions.js(51,26): error TS7006: Parameter 'dref' implicitly has an 'any' type. +functions.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. -==== functions.js (11 errors) ==== +==== functions.js (18 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id1(c) { ~ @@ -35,6 +44,8 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id2(c) { ~ @@ -44,6 +55,8 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ class C { /** @param {number} n */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor(n) { this.length = n; } @@ -57,6 +70,8 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var f = function (ab, onetwo) { return ab === "a" ? 3 : 4; } ~~ !!! error TS7006: Parameter 'ab' implicitly has an 'any' type. @@ -67,6 +82,8 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ /** * @constructor * @param {number} n + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function D(n) { this.length = n; @@ -82,6 +99,8 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ * @return {D} ~ !!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var construct = function(dref) { return new dref(33); } ~~~~ @@ -93,6 +112,8 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ /** * @constructor * @param {number} n + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var E = function(n) { this.not_length_on_purpose = n; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplementsTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplementsTag.errors.txt new file mode 100644 index 0000000000..1da7f3e732 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplementsTag.errors.txt @@ -0,0 +1,17 @@ +/a.js(6,17): error TS8005: 'implements' clauses can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + /** + * @typedef { { foo: string } } A + */ + + /** + * @implements { A } + ~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + */ + class B { + foo = '' + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.errors.txt index 8581f9865b..a43a519a00 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.errors.txt @@ -1,23 +1,36 @@ +/a.js(2,18): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(5,18): error TS8005: 'implements' clauses can only be used in TypeScript files. +/a.js(10,17): error TS8005: 'implements' clauses can only be used in TypeScript files. +/a.js(12,18): error TS8010: Type annotations can only be used in TypeScript files. /a.js(13,5): error TS2416: Property 'method' in type 'B2' is not assignable to the same property in base type 'A'. Type '() => string' is not assignable to type '() => number'. Type 'string' is not assignable to type 'number'. +/a.js(16,18): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(17,7): error TS2720: Class 'B3' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? Property 'method' is missing in type 'B3' but required in type 'A'. -==== /a.js (2 errors) ==== +==== /a.js (7 errors) ==== class A { /** @return {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. method() { throw new Error(); } } /** @implements {A} */ + ~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B { method() { return 0 } } /** @implements A */ + ~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B2 { /** @return {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. method() { return "" } ~~~~~~ !!! error TS2416: Property 'method' in type 'B2' is not assignable to the same property in base type 'A'. @@ -26,6 +39,8 @@ } /** @implements {A} */ + ~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B3 { ~~ !!! error TS2720: Class 'B3' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface.errors.txt index ed55466360..f765111c90 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface.errors.txt @@ -1,6 +1,9 @@ +/a.js(1,17): error TS8005: 'implements' clauses can only be used in TypeScript files. +/a.js(7,18): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(9,5): error TS2416: Property 'mNumber' in type 'B2' is not assignable to the same property in base type 'A'. Type '() => string' is not assignable to type '() => number'. Type 'string' is not assignable to type 'number'. +/a.js(13,17): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(14,7): error TS2420: Class 'B3' incorrectly implements interface 'A'. Property 'mNumber' is missing in type 'B3' but required in type 'A'. @@ -9,14 +12,18 @@ interface A { mNumber(): number; } -==== /a.js (2 errors) ==== +==== /a.js (5 errors) ==== /** @implements A */ + ~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B { mNumber() { return 0; } } /** @implements {A} */ + ~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B2 { mNumber() { ~~~~~~~ @@ -27,6 +34,8 @@ } } /** @implements A */ + ~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B3 { ~~ !!! error TS2420: Class 'B3' incorrectly implements interface 'A'. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface_multiple.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface_multiple.errors.txt index 334422ee60..946e60604a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface_multiple.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface_multiple.errors.txt @@ -1,3 +1,5 @@ +/a.js(2,17): error TS8005: 'implements' clauses can only be used in TypeScript files. +/a.js(14,16): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(17,7): error TS2420: Class 'BadSquare' incorrectly implements interface 'Drawable'. Property 'draw' is missing in type 'BadSquare' but required in type 'Drawable'. @@ -9,9 +11,11 @@ interface Sizable { size(): number; } -==== /a.js (1 errors) ==== +==== /a.js (3 errors) ==== /** * @implements {Drawable} + ~~~~~~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. * @implements Sizable **/ class Square { @@ -24,6 +28,8 @@ } /** * @implements Drawable + ~~~~~~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. * @implements {Sizable} **/ class BadSquare { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.errors.txt new file mode 100644 index 0000000000..2a8c36723f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.errors.txt @@ -0,0 +1,11 @@ +/a.js(2,16): error TS8005: 'implements' clauses can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class A { constructor() { this.x = 0; } } + /** @implements */ + +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B { + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js index 0d5243e60c..222dea0291 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js @@ -16,21 +16,3 @@ declare class A { /** @implements */ declare class B implements { } - - -//// [DtsFileErrors] - - -out/a.d.ts(5,27): error TS1097: 'implements' list cannot be empty. - - -==== out/a.d.ts (1 errors) ==== - declare class A { - constructor(); - } - /** @implements */ - declare class B implements { - -!!! error TS1097: 'implements' list cannot be empty. - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js.diff b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js.diff index 643e190e6e..0f948ec122 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js.diff @@ -10,22 +10,4 @@ /** @implements */ -declare class B { +declare class B implements { - } -+ -+ -+//// [DtsFileErrors] -+ -+ -+out/a.d.ts(5,27): error TS1097: 'implements' list cannot be empty. -+ -+ -+==== out/a.d.ts (1 errors) ==== -+ declare class A { -+ constructor(); -+ } -+ /** @implements */ -+ declare class B implements { -+ -+!!! error TS1097: 'implements' list cannot be empty. -+ } -+ \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_namespacedInterface.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_namespacedInterface.errors.txt new file mode 100644 index 0000000000..577f1a2988 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_namespacedInterface.errors.txt @@ -0,0 +1,31 @@ +/a.js(1,17): error TS8005: 'implements' clauses can only be used in TypeScript files. +/a.js(7,18): error TS8005: 'implements' clauses can only be used in TypeScript files. + + +==== /defs.d.ts (0 errors) ==== + declare namespace N { + interface A { + mNumber(): number; + } + interface AT { + gen(): T; + } + } +==== /a.js (2 errors) ==== + /** @implements N.A */ + ~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B { + mNumber() { + return 0; + } + } + /** @implements {N.AT} */ + ~~~~~~~~~~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class BAT { + gen() { + return ""; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_properties.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_properties.errors.txt index 5d509a500f..159012fca2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_properties.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_properties.errors.txt @@ -1,10 +1,15 @@ +/a.js(2,17): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(3,7): error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? Property 'x' is missing in type 'B' but required in type 'A'. +/a.js(5,17): error TS8005: 'implements' clauses can only be used in TypeScript files. +/a.js(10,18): error TS8005: 'implements' clauses can only be used in TypeScript files. -==== /a.js (1 errors) ==== +==== /a.js (4 errors) ==== class A { constructor() { this.x = 0; } } /** @implements A*/ + ~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B {} ~ !!! error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? @@ -12,11 +17,15 @@ !!! related TS2728 /a.js:1:27: 'x' is declared here. /** @implements A*/ + ~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B2 { x = 10 } /** @implements {A}*/ + ~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B3 { constructor() { this.x = 10 } } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_signatures.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_signatures.errors.txt index 1ababbc2c2..56fcb0bd9c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_signatures.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_signatures.errors.txt @@ -1,3 +1,4 @@ +/a.js(1,18): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(2,7): error TS2420: Class 'B' incorrectly implements interface 'Sig'. Index signature for type 'string' is missing in type 'B'. @@ -6,8 +7,10 @@ interface Sig { [index: string]: string } -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** @implements {Sig} */ + ~~~ +!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B { ~ !!! error TS2420: Class 'B' incorrectly implements interface 'Sig'. 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..166ff64c9a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportType.errors.txt @@ -0,0 +1,33 @@ +use.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. +use.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== use.js (2 errors) ==== + /// + /** @typedef {import("./mod1")} C + * @type {C} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var c; + c.chunk; + + const D = require("./mod1"); + /** @type {D} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + 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/jsdocImportType2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportType2.errors.txt new file mode 100644 index 0000000000..30f9404c8d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportType2.errors.txt @@ -0,0 +1,32 @@ +use.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. +use.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== use.js (2 errors) ==== + /// + /** @typedef {import("./mod1")} C + * @type {C} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var c; + c.chunk; + + const D = require("./mod1"); + /** @type {D} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + 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/jsdocImportTypeReferenceToClassAlias.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt index 0a42dea7d4..b8355a36f6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt @@ -1,4 +1,5 @@ test.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'C'. +test.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. ==== mod1.js (0 errors) ==== @@ -7,11 +8,13 @@ test.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'C'. } module.exports.C = C -==== test.js (1 errors) ==== +==== test.js (2 errors) ==== /** @typedef {import('./mod1').C} X */ ~ !!! error TS2694: Namespace '"mod1"' has no exported member 'C'. /** @param {X} c */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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 index 7cfc65e1df..fd692f18ae 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt @@ -1,4 +1,5 @@ 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')'? +test.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. ==== ex.d.ts (0 errors) ==== @@ -7,10 +8,12 @@ test.js(1,13): error TS1340: Module './ex' does not refer to a type, but is used } export = config; -==== test.js (1 errors) ==== +==== test.js (2 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')'? + ~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function demo(a) { a.fix } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt index b5f2e2a2bf..b8c79dc5f0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt @@ -1,13 +1,16 @@ 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')'? +test.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. ==== ex.d.ts (0 errors) ==== export var config: {} -==== test.js (1 errors) ==== +==== test.js (2 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')'? + ~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function demo(a) { a.config } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt index 84a4804709..a491c8d50d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt @@ -1,11 +1,14 @@ +a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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) ==== +==== a.js (2 errors) ==== /** @type {import('./b').FOO} */ + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"b"' has no exported member 'FOO'. let x; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt index 0572ee15d8..bcc6e31b3c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt @@ -1,35 +1,47 @@ indices.js(1,12): error TS2315: Type 'Object' is not generic. +indices.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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,12): error TS8010: Type annotations can only be used in TypeScript files. 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,12): error TS8010: Type annotations can only be used in TypeScript files. 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,13): error TS8010: Type annotations can only be used in TypeScript files. indices.js(7,19): error TS8020: JSDoc types can only be used inside documentation comments. -==== indices.js (8 errors) ==== +==== indices.js (12 errors) ==== /** @type {Object.} */ ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. var o1; /** @type {Object.} */ ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. var o2; /** @type {Object.} */ ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. var o3; /** @param {Object.} o */ ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. function f(o) { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocLiteral.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocLiteral.errors.txt new file mode 100644 index 0000000000..1ba28333e0 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocLiteral.errors.txt @@ -0,0 +1,29 @@ +in.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +in.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +in.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +in.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +in.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== in.js (5 errors) ==== + /** + * @param {'literal'} p1 + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {"literal"} p2 + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {'literal' | 'other'} p3 + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {'literal' | number} p4 + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {12 | true | 'str'} p5 + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(p1, p2, p3, p4, p5) { + return p1 + p2 + p3 + p4 + p5 + '.'; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.errors.txt new file mode 100644 index 0000000000..e452be0f5a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.errors.txt @@ -0,0 +1,24 @@ +in.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +in.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +in.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +in.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== in.js (4 errors) ==== + /** + * @param {never} p1 + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {undefined} p2 + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {null} p3 + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {void} nothing + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(p1, p2, p3) { + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt index c0a05d7652..e20efba707 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt @@ -1,11 +1,14 @@ jsdocOuterTypeParameters1.js(1,14): error TS2304: Cannot find name 'T'. +jsdocOuterTypeParameters1.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. jsdocOuterTypeParameters1.js(7,35): error TS2339: Property 'foo' does not exist on type 'Bar'. -==== jsdocOuterTypeParameters1.js (2 errors) ==== +==== jsdocOuterTypeParameters1.js (3 errors) ==== /** @return {T} */ ~ !!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const dedupingMixin = function(mixin) {}; /** @template {T} */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt index f78e45da6b..be5eb731dd 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt @@ -1,11 +1,14 @@ jsdocOuterTypeParameters1.js(1,14): error TS2304: Cannot find name 'T'. +jsdocOuterTypeParameters1.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. jsdocOuterTypeParameters1.js(7,35): error TS2339: Property 'foo' does not exist on type 'Bar'. -==== jsdocOuterTypeParameters1.js (2 errors) ==== +==== jsdocOuterTypeParameters1.js (3 errors) ==== /** @return {T} */ ~ !!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const dedupingMixin = function(mixin) {}; /** @template T */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt index d6655383b2..f31b733fc3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt @@ -1,15 +1,23 @@ +0.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. +0.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. +0.js(20,16): error TS8010: Type annotations can only be used in TypeScript files. +0.js(21,18): error TS8010: Type annotations can only be used in TypeScript files. 0.js(27,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'A'. 0.js(32,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. 0.js(40,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. -==== 0.js (3 errors) ==== +==== 0.js (7 errors) ==== class A { /** * @method * @param {string | number} a + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean} + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ foo (a) { return typeof a === 'string' @@ -24,7 +32,11 @@ * @override * @method * @param {string | number} a + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean} + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ foo (a) { return super.foo(a) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.errors.txt index f796c7c463..3ae3296eb6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.errors.txt @@ -1,26 +1,61 @@ +0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(26,4): error TS8010: Type annotations can only be used in TypeScript files. +0.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(33,4): error TS8010: Type annotations can only be used in TypeScript files. +0.js(36,4): error TS8010: Type annotations can only be used in TypeScript files. +0.js(41,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(43,4): error TS8010: Type annotations can only be used in TypeScript files. +0.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(50,4): error TS8010: Type annotations can only be used in TypeScript files. +0.js(56,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(66,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(70,20): error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name. +0.js(71,12): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (1 errors) ==== +==== 0.js (20 errors) ==== // Object literal syntax /** * @param {{a: string, b: string}} obj + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good1({a, b}, x) {} /** * @param {{a: string, b: string}} obj + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{c: number, d: number}} OBJECTION + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good2({a, b}, {c, d}) {} /** * @param {number} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{a: string, b: string}} obj + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} y + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good3(x, {a, b}, y) {} /** * @param {{a: string, b: string}} obj + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good4({a, b}) {} @@ -28,36 +63,64 @@ /** * @param {Object} obj * @param {string} obj.a - this is like the saddest way to specify a type + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} obj.b - but it sure does allow a lot of documentation + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} x + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good5({a, b}, x) {} /** * @param {Object} obj * @param {string} obj.a + ~~~~~~~~~~~~~~~~~~~~~ * @param {string} obj.b - but it sure does allow a lot of documentation + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Object} OBJECTION - documentation here too + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} OBJECTION.c + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} OBJECTION.d - meh + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function good6({a, b}, {c, d}) {} /** * @param {number} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Object} obj * @param {string} obj.a + ~~~~~~~~~~~~~~~~~~~~~ * @param {string} obj.b + ~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} y + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good7(x, {a, b}, y) {} /** * @param {Object} obj * @param {string} obj.a + ~~~~~~~~~~~~~~~~~~~~~ * @param {string} obj.b + ~~~~~~~~~~~~~~~~~~~~~~~~ */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function good8({a, b}) {} /** * @param {{ a: string }} argument + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good9({ a }) { console.log(arguments, a); @@ -68,6 +131,8 @@ * @param {string} obj.a * @param {string} obj.b - and x's type gets used for both parameters * @param {string} x + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function bad1(x, {a, b}) {} /** @@ -75,6 +140,8 @@ ~ !!! error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name. * @param {{a: string, b: string}} obj + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function bad2(x, {a, b}) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt index 7a62f459cb..7a8acf159d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt @@ -1,9 +1,17 @@ +0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(3,20): error TS8024: JSDoc '@param' tag has name 'unrelated', but there is no parameter with that name. +0.js(12,4): error TS8010: Type annotations can only be used in TypeScript files. +0.js(25,4): error TS8010: Type annotations can only be used in TypeScript files. +0.js(36,4): error TS8010: Type annotations can only be used in TypeScript files. +0.js(45,4): error TS8010: Type annotations can only be used in TypeScript files. +0.js(58,4): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (1 errors) ==== +==== 0.js (7 errors) ==== /** * @param {Object} notSpecial + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @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. @@ -16,10 +24,16 @@ /** * @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 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function foo1(opts1) { opts1.x; } @@ -29,8 +43,12 @@ /** * @param {Object[]} opts2 * @param {string} opts2[].anotherX + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string=} opts2[].anotherY + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function foo2(/** @param opts2 bad idea theatre! */opts2) { opts2[0].anotherX; } @@ -40,7 +58,10 @@ /** * @param {object} opts3 * @param {string} opts3.x + ~~~~~~~~~~~~~~~~~~~~~~~ */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function foo3(opts3) { opts3.x; } @@ -49,9 +70,14 @@ /** * @param {object[]} opts4 * @param {string} opts4[].x + ~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string=} opts4[].y + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} [opts4[].z] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} [opts4[].w="hi"] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function foo4(opts4) { opts4[0].x; @@ -62,13 +88,22 @@ /** * @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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function foo5(opts5) { opts5[0].what.bad[0].idea; opts5[0].unnest; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt index 4a853ebcdf..db753b7b9d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt @@ -1,10 +1,20 @@ +a.js(2,4): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(3,20): error TS8010: Type annotations can only be used in TypeScript files. a.js(5,18): error TS1016: A required parameter cannot follow an optional parameter. -==== a.js (1 errors) ==== +==== a.js (4 errors) ==== /** * @param {string=} `args` + ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param `bwarg` {?number?} + ~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(args, bwarg) { ~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt index 4d4beab51f..7e11a2a1b4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt @@ -1,8 +1,9 @@ a.js(3,12): error TS7006: Parameter 'callback' implicitly has an 'any' type. +a.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. a.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -==== a.js (2 errors) ==== +==== a.js (3 errors) ==== // from bcryptjs /** @param {function(...[*])} callback */ function g(callback) { @@ -13,6 +14,8 @@ a.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? /** * @type {!function(...number):string} + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt index ff420a46d1..2f537e498f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt @@ -1,13 +1,16 @@ paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +paren.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (3 errors) ==== +==== paren.js (4 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x = (s, id) => id(s) ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.errors.txt new file mode 100644 index 0000000000..4e8aa1f93b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.errors.txt @@ -0,0 +1,36 @@ +jsdocParseMatchingBackticks.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocParseMatchingBackticks.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +jsdocParseMatchingBackticks.js(7,19): error TS8010: Type annotations can only be used in TypeScript files. +jsdocParseMatchingBackticks.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. +jsdocParseMatchingBackticks.js(9,24): error TS8010: Type annotations can only be used in TypeScript files. +jsdocParseMatchingBackticks.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== jsdocParseMatchingBackticks.js (6 errors) ==== + /** + * `@param` initial at-param is OK in title comment + * @param {string} x hi there `@param` + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} y hi there `@ * param + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * this is the margin + * so we'll drop everything before it + `@param` @param {string} z hello??? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * `@param` @param {string} alpha hello??? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * `@ * param` @param {string} beta hello??? + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} gamma + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function f(x, y, z, alpha, beta, gamma) { + return x + y + z + alpha + beta + gamma + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt index 89b948713c..e875fad048 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt @@ -1,12 +1,15 @@ paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +paren.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. paren.js(2,9): error TS7006: Parameter 's' implicitly has an 'any' type. -==== paren.js (2 errors) ==== +==== paren.js (3 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x = s => s.toString() ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt index b4c0510f9b..6d388ca6ec 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt @@ -1,14 +1,25 @@ a.js(1,5): error TS1047: A rest parameter cannot be optional. +a.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. +a.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. a.js(3,12): error TS2370: A rest parameter must be of an array type. +a.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. a.js(12,14): error TS7006: Parameter 'f' implicitly has an 'any' type. -==== a.js (3 errors) ==== +==== a.js (7 errors) ==== /** @param {...*=} args ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. @return {*=} */ ~~~~ !!! error TS1047: A rest parameter cannot be optional. + ~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(...args) { ~~~~~~~ !!! error TS2370: A rest parameter must be of an array type. @@ -16,6 +27,8 @@ a.js(12,14): error TS7006: Parameter 'f' implicitly has an 'any' type. } /** @type *= */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt index 718c106001..3c242247a5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt @@ -1,9 +1,17 @@ +a.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. 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(12,5): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (6 errors) ==== /** @param {number=} a */ + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(a) { a = 1 a = null // should not be allowed @@ -19,6 +27,10 @@ a.js(8,3): error TS2345: Argument of type 'null' is not assignable to parameter f(1) /** @param {???!?number?=} a */ + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function g(a) { a = 1 a = null diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt index f6d00af955..81683026ae 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt @@ -1,25 +1,61 @@ +prefixPostfix.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +prefixPostfix.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. prefixPostfix.js(18,21): error TS7006: Parameter 'a' implicitly has an 'any' type. prefixPostfix.js(18,39): error TS7006: Parameter 'h' implicitly has an 'any' type. prefixPostfix.js(18,48): error TS7006: Parameter 'k' implicitly has an 'any' type. -==== prefixPostfix.js (3 errors) ==== +==== prefixPostfix.js (15 errors) ==== /** * @param {number![]} x - number[] + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {!number[]} y - number[] + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(number[])!} z - number[] + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number?[]} a - parse error without parentheses * @param {?number[]} b - number[] | null + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(number[])?} c - number[] | null + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...?number} e - (number | null)[] + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?} f - number[] | null + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number!?} g - number[] | null + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?!} h - parse error without parentheses (also nonsensical) * @param {...number[]} i - number[][] + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number![]?} j - number[][] | null + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?[]!} k - parse error without parentheses * @param {number extends number ? true : false} l - conditional types work + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {[number, number?]} m - [number, (number | undefined)?] + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(x, y, z, a, b, c, e, f, g, h, i, j, k, l, m) { ~ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt index d6c7a99ac5..7ea0393e0d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt @@ -1,9 +1,12 @@ +jsdocPrivateName1.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. jsdocPrivateName1.js(3,5): error TS2322: Type 'number' is not assignable to type 'boolean'. -==== jsdocPrivateName1.js (1 errors) ==== +==== jsdocPrivateName1.js (2 errors) ==== class A { /** @type {boolean} some number value */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. #foo = 3 // Error because not assignable to boolean ~~~~ !!! error TS2322: Type 'number' is not assignable to type 'boolean'. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt index 3cce555727..1284cb8387 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt @@ -1,18 +1,35 @@ +jsdocReadonly.js(3,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +jsdocReadonly.js(4,8): error TS8009: The 'private' modifier can only be used in TypeScript files. +jsdocReadonly.js(5,15): error TS8010: Type annotations can only be used in TypeScript files. +jsdocReadonly.js(9,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +jsdocReadonly.js(11,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. jsdocReadonly.js(23,3): error TS2540: Cannot assign to 'y' because it is a read-only property. -==== jsdocReadonly.js (1 errors) ==== +==== jsdocReadonly.js (6 errors) ==== class LOL { /** * @readonly + ~~~~~~~~~ * @private + ~~~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + ~~~~~~~~ * @type {number} + ~~~~~~~ +!!! error TS8009: The 'private' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * Order rules do not apply to JSDoc */ x = 1 /** @readonly */ + ~~~~~~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. y = 2 /** @readonly Definitely not here */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. static z = 3 /** @readonly This is OK too */ constructor() { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.errors.txt index fcceb47726..7da3ec1063 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.errors.txt @@ -1,9 +1,12 @@ +jsdocReadonlyDeclarations.js(2,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. jsdocReadonlyDeclarations.js(14,1): error TS2554: Expected 1 arguments, but got 0. -==== jsdocReadonlyDeclarations.js (1 errors) ==== +==== jsdocReadonlyDeclarations.js (2 errors) ==== class C { /** @readonly */ + ~~~~~~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. x = 6 /** @readonly */ constructor(n) { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt new file mode 100644 index 0000000000..1dddcd094b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt @@ -0,0 +1,33 @@ +returns.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. +returns.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. +returns.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== returns.js (3 errors) ==== + /** + * @returns {string} This comment is not currently exposed + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f() { + return 5; + } + + /** + * @returns {string=} This comment is not currently exposed + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f1() { + return 5; + } + + /** + * @returns {string|number} This comment is not currently exposed + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f2() { + return 5 || "hello"; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.errors.txt new file mode 100644 index 0000000000..29b0ca1188 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.errors.txt @@ -0,0 +1,63 @@ +jsdocSignatureOnReturnedFunction.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. +jsdocSignatureOnReturnedFunction.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. +jsdocSignatureOnReturnedFunction.js(5,18): error TS8010: Type annotations can only be used in TypeScript files. +jsdocSignatureOnReturnedFunction.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. +jsdocSignatureOnReturnedFunction.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. +jsdocSignatureOnReturnedFunction.js(16,18): error TS8010: Type annotations can only be used in TypeScript files. +jsdocSignatureOnReturnedFunction.js(24,16): error TS8016: Type assertion expressions can only be used in TypeScript files. +jsdocSignatureOnReturnedFunction.js(31,16): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== jsdocSignatureOnReturnedFunction.js (8 errors) ==== + function f1() { + /** + * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + return (a, b) => { + return a + b; + } + } + + function f2() { + /** + * @param {number} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + return function (a, b){ + return a + b; + } + } + + function f3() { + /** @type {(a: number, b: number) => number} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + return (a, b) => { + return a + b; + } + } + + function f4() { + /** @type {(a: number, b: number) => number} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + return function (a, b){ + return a + b; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt index 75303c2689..3d7b368d69 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt @@ -1,29 +1,74 @@ +templateTagOnClasses.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +templateTagOnClasses.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. +templateTagOnClasses.js(7,22): error TS8010: Type annotations can only be used in TypeScript files. +templateTagOnClasses.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. +templateTagOnClasses.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. +templateTagOnClasses.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. +templateTagOnClasses.js(16,16): error TS8010: Type annotations can only be used in TypeScript files. +templateTagOnClasses.js(17,17): error TS8010: Type annotations can only be used in TypeScript files. templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to type 'number'. -==== templateTagOnClasses.js (1 errors) ==== +==== templateTagOnClasses.js (9 errors) ==== /** + ~~~ * @template T + ~~~~~~~~~~~~~~ * @typedef {(t: T) => T} Id + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ /** @template T */ + ~~~~~~~~~~~~~~~~~~ class Foo { + ~~~~~~~~~~~ /** @typedef {(t: T) => T} Id2 */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @param {T} x */ + ~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor (x) { + ~~~~~~~~~~~~~~~~~~~~~ this.a = x + ~~~~~~~~~~~~~~~~~~ } + ~~~~~ /** + ~~~~~~~ * + ~~~~~~~ * @param {T} x + ~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Id} y + ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Id2} alpha + ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} + ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~~~~~ foo(x, y, alpha) { + ~~~~~~~~~~~~~~~~~~~~~~ return alpha(y(x)) + ~~~~~~~~~~~~~~~~~~~~~~~~~~ } + ~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. var f = new Foo(1) var g = new Foo(false) f.a = g.a diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt new file mode 100644 index 0000000000..d362e11e78 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt @@ -0,0 +1,49 @@ +templateTagOnConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +templateTagOnConstructorFunctions.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. +templateTagOnConstructorFunctions.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== templateTagOnConstructorFunctions.js (3 errors) ==== + /** + ~~~ + * @template U + ~~~~~~~~~~~~~~ + * @typedef {(u: U) => U} Id + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + /** + ~~~ + * @param {T} t + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @template T + ~~~~~~~~~~~~~~ + */ + ~~~ + function Zet(t) { + ~~~~~~~~~~~~~~~~~ + /** @type {T} */ + ~~~~~~~~~~~~~~~~~~~~ + this.u + ~~~~~~~~~~ + this.t = t + ~~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + /** + * @param {T} v + * @param {Id} id + */ + Zet.prototype.add = function(v, id) { + this.u = v || this.t + return id(this.u) + } + var z = new Zet(1) + z.t = 2 + z.u = false + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt index db4a9a3064..9fe82440e2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt @@ -1,16 +1,32 @@ +templateTagWithNestedTypeLiteral.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +templateTagWithNestedTypeLiteral.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +templateTagWithNestedTypeLiteral.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. +templateTagWithNestedTypeLiteral.js(30,12): error TS8010: Type annotations can only be used in TypeScript files. -==== templateTagWithNestedTypeLiteral.js (1 errors) ==== +==== templateTagWithNestedTypeLiteral.js (5 errors) ==== /** + ~~~ * @param {T} t + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T + ~~~~~~~~~~~~~~ */ + ~~~ function Zet(t) { + ~~~~~~~~~~~~~~~~~ /** @type {T} */ + ~~~~~~~~~~~~~~~~~~~~ this.u + ~~~~~~~~~~ this.t = t + ~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @param {T} v * @param {object} o @@ -24,6 +40,8 @@ templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. z.t = 2 z.u = false /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. let answer = z.add(3, { nested: 4 }) // lookup in typedef should not crash the compiler, even when the type is unknown @@ -34,5 +52,7 @@ templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. !!! error TS2304: Cannot find name 'T'. */ /** @type {A} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const options = { value: null }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt index b60487ba5b..20e84085b6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt @@ -1,29 +1,59 @@ +forgot.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +forgot.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +forgot.js(8,15): error TS8004: Type parameter declarations can only be used in TypeScript files. +forgot.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. forgot.js(13,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +forgot.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (2 errors) ==== +==== forgot.js (7 errors) ==== /** + ~~~ * @param {T} a + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T + ~~~~~~~~~~~~~~ */ + ~~~ function f(a) { + ~~~~~~~~~~~~~~~ return () => a + ~~~~~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. let n = f(1)() + + /** + ~~~ * @param {T} a + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function g(a) { + ~~~~~~~~~~~~~~~ return () => a + ~~~~~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. let s = g('hi')() /** diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt new file mode 100644 index 0000000000..734af7a3bf --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt @@ -0,0 +1,25 @@ +github17339.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. +github17339.js(5,15): error TS8010: Type annotations can only be used in TypeScript files. +github17339.js(7,4): error TS8004: Type parameter declarations can only be used in TypeScript files. + + +==== github17339.js (3 errors) ==== + var obj = { + /** + * @template T + * @param {T} a + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + x: function (a) { + ~~~~~~~~~~~~~~~ + return a; + ~~~~~~~~~~~ + }, + ~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt index acd63b1e17..04c6b96d39 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt @@ -1,43 +1,94 @@ +a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(11,13): error TS8010: Type annotations can only be used in TypeScript files. 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 TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. +a.js(21,50): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (3 errors) ==== +==== a.js (12 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 + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} u + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {V} v + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {W} w + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {X} x + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {W | X} + ~~~~~~~~~~~~~~~~~~ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ 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; + ~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. 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 + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function g(x) { } + ~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt index b365cc2208..f4bf25c322 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt @@ -1,6 +1,8 @@ +a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(8,16): error TS2315: Type 'Object' is not generic. a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. a.js(16,36): error TS7006: Parameter 'key' implicitly has an 'any' type. +a.js(26,16): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(27,16): error TS2315: Type 'Object' is not generic. a.js(28,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. a.js(35,37): error TS7006: Parameter 'key' implicitly has an 'any' type. @@ -9,21 +11,32 @@ a.js(48,10): error TS2339: Property '_map' does not exist on type '{ Multimap3: a.js(55,40): error TS7006: Parameter 'key' implicitly has an 'any' type. -==== a.js (9 errors) ==== +==== a.js (11 errors) ==== /** + ~~~ * Should work for function declarations + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @constructor + ~~~~~~~~~~~~~~~ * @template {string} K + ~~~~~~~~~~~~~~~~~~~~~~~ * @template V + ~~~~~~~~~~~~~~ */ + ~~~ function Multimap() { + ~~~~~~~~~~~~~~~~~~~~~ /** @type {Object} TODO: Remove the prototype from the fresh object */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. this._map = {}; + ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. }; + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @param {K} key the key ok @@ -42,13 +55,18 @@ a.js(55,40): error TS7006: Parameter 'key' implicitly has an 'any' type. * @template V */ var Multimap2 = function() { + ~~~~~~~~~~~~~ /** @type {Object} TODO: Remove the prototype from the fresh object */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. this._map = {}; + ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. }; + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @param {K} key the key ok diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt index 1c664fdd19..58751af3dd 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt @@ -1,44 +1,67 @@ +a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(8,16): error TS2315: Type 'Object' is not generic. a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. a.js(14,16): error TS2304: Cannot find name 'K'. +a.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. a.js(15,18): error TS2304: Cannot find name 'V'. +a.js(15,18): error TS8010: Type annotations can only be used in TypeScript files. a.js(18,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. +a.js(28,16): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(29,16): error TS2315: Type 'Object' is not generic. a.js(30,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. a.js(35,16): error TS2304: Cannot find name 'K'. +a.js(35,16): error TS8010: Type annotations can only be used in TypeScript files. a.js(36,18): error TS2304: Cannot find name 'V'. +a.js(36,18): error TS8010: Type annotations can only be used in TypeScript files. a.js(39,21): error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. a.js(51,16): error TS2315: Type 'Object' is not generic. a.js(52,10): error TS2339: Property '_map' does not exist on type '{ Multimap3: { (): void; prototype: { get(key: K): V; }; }; }'. a.js(57,16): error TS2304: Cannot find name 'K'. +a.js(57,16): error TS8010: Type annotations can only be used in TypeScript files. a.js(58,18): error TS2304: Cannot find name 'V'. +a.js(58,18): error TS8010: Type annotations can only be used in TypeScript files. a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. -==== a.js (15 errors) ==== +==== a.js (23 errors) ==== /** + ~~~ * Should work for function declarations + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @constructor + ~~~~~~~~~~~~~~~ * @template {string} K + ~~~~~~~~~~~~~~~~~~~~~~~ * @template V + ~~~~~~~~~~~~~~ */ + ~~~ function Multimap() { + ~~~~~~~~~~~~~~~~~~~~~ /** @type {Object} TODO: Remove the prototype from the fresh object */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. this._map = {}; + ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. }; + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Multimap.prototype = { /** * @param {K} key the key ok ~ !!! error TS2304: Cannot find name 'K'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {V} the value ok ~ !!! error TS2304: Cannot find name 'V'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ get(key) { return this._map[key + '']; @@ -54,22 +77,31 @@ a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K) * @template V */ var Multimap2 = function() { + ~~~~~~~~~~~~~ /** @type {Object} TODO: Remove the prototype from the fresh object */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. this._map = {}; + ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. }; + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Multimap2.prototype = { /** * @param {K} key the key ok ~ !!! error TS2304: Cannot find name 'K'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {V} the value ok ~ !!! error TS2304: Cannot find name 'V'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ get: function(key) { return this._map[key + '']; @@ -99,9 +131,13 @@ a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K) * @param {K} key the key ok ~ !!! error TS2304: Cannot find name 'K'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {V} the value ok ~ !!! error TS2304: Cannot find name 'V'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ get(key) { return this._map[key + '']; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt new file mode 100644 index 0000000000..e724a31559 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt @@ -0,0 +1,235 @@ +a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(11,64): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(23,64): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(28,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(34,24): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(38,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(39,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(45,54): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(50,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(56,62): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(63,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(65,22): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(69,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(77,40): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(81,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (22 errors) ==== + /** + ~~~ + * @template const T + ~~~~~~~~~~~~~~~~~~~~ + * @param {T} x + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f1(x) { + ~~~~~~~~~~~~~~~~ + return x; + ~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + 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 + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f2(x) { + ~~~~~~~~~~~~~~~~ + return x; + ~~~~~~~~~~~~~ + }; + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + 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 + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T[]} + ~~~~~~~~~~~~~~~~~ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f3(x) { + ~~~~~~~~~~~~~~~~ + return [x]; + ~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + const t7 = f3("hello"); + const t8 = f3("hello"); + + + + /** + ~~~ + * @template const T + ~~~~~~~~~~~~~~~~~~~~ + * @param {[T, T]} x + ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f4(x) { + ~~~~~~~~~~~~~~~~ + return x[0]; + ~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + 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 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f5(obj) { + ~~~~~~~~~~~~~~~~~~ + return obj.x; + ~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + 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 + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(x) {} + ~~~~~~~~~~~~~~~~~~~~~ + + + + + /** + ~~~~~~~ + ~~~~~~~ + * @template const U + ~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {U} x + ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + ~~~~~~~ + foo(x) { + ~~~~~~~~~~~~ + ~~~~~~~~~~~~ + return x; + ~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ + } + ~~~~~ + ~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + 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 + ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f6(...args) { + ~~~~~~~~~~~~~~~~~~~~~~ + return args; + ~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + const t15 = f6(1, 'b', { a: 1, b: 'x' }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt index 6d5770242e..2a7998035b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt @@ -1,28 +1,57 @@ +a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(9,12): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter +a.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (6 errors) ==== /** + ~~~ * @template const T + ~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class * @typedef {[T]} X + ~~~~~~~~~~~~~~~~~~~ */ + ~~~ + /** + ~~~ * @template const T + ~~~~~~~~~~~~~~~~~~~~ */ + ~~~ class C { } + ~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + ~~~ * @template private T + ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~ !!! error TS1273: 'private' modifier cannot appear on a type parameter * @param {T} x + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f(x) { + ~~~~~~~~~~~~~~~ return x; + ~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt index 5c9e0ed33d..350fe00154 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt @@ -1,10 +1,18 @@ a.js(2,14): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias +a.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. 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(23,18): error TS8010: Type annotations can only be used in TypeScript files. +a.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. 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(42,18): error TS8010: Type annotations can only be used in TypeScript files. +a.js(46,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(51,11): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -13,10 +21,12 @@ a.js(55,1): error TS2322: Type 'Invariant' is not assignable to type 'In 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(56,33): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias +a.js(60,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (8 errors) ==== +==== a.js (18 errors) ==== /** * @template out T ~~~ @@ -27,11 +37,15 @@ a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of /** * @type {Covariant} + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ let super_covariant = { x: 1 }; /** * @type {Covariant} + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ let sub_covariant = { x: '' }; @@ -47,15 +61,21 @@ a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of !!! 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 + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** * @type {Contravariant} + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ let super_contravariant = { f: (x) => {} }; /** * @type {Contravariant} + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ let sub_contravariant = { f: (x) => {} }; @@ -71,15 +91,21 @@ a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of !!! 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 + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** * @type {Invariant} + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ let super_invariant = { f: (x) => {} }; /** * @type {Invariant} + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ let sub_invariant = { f: (x) => { return "" } }; @@ -95,12 +121,22 @@ a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of !!! 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'. + ~~~~~~~~~~ + /** + ~~~ * @template in T + ~~~~~~~~~~~~~~~~~ ~~ !!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @param {T} x + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f(x) {} + ~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt index 6ad768a099..36ffe95d38 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt @@ -1,84 +1,175 @@ +file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(9,20): error TS2322: Type 'number' is not assignable to type 'string'. +file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(13,21): error TS8004: Type parameter declarations can only be used in TypeScript files. 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(46,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(49,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. +file.js(54,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(57,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. +file.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(63,12): error TS8010: Type annotations can only be used in TypeScript files. -==== file.js (5 errors) ==== +==== file.js (18 errors) ==== /** * @template {string | number} [T=string] - ok: defaults are permitted * @typedef {[T]} A */ /** @type {A} */ // ok, default for `T` in `A` is `string` + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const aDefault1 = [""]; /** @type {A} */ // error: `number` is not assignable to string` + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const aDefault2 = [0]; ~ !!! error TS2322: Type 'number' is not assignable to type 'string'. /** @type {A} */ // ok, `T` is provided for `A` + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const aString = [""]; /** @type {A} */ // ok, `T` is provided for `A` + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} a + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f1(a, b) {} + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + ~~~~ * @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 + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f2(a, b) {} + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + ~~~ * @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 + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f3(a, b) {} + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt index 64df35ea66..f537a718bb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt @@ -1,7 +1,8 @@ +file.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(10,7): error TS2322: Type 'string' is not assignable to type 'number'. -==== file.js (1 errors) ==== +==== file.js (2 errors) ==== /** * @template T * @template {keyof T} K @@ -11,6 +12,8 @@ file.js(10,7): error TS2322: Type 'string' is not assignable to type 'number'. const x = { a: 1 }; /** @type {Foo} */ + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const y = "a"; ~ !!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt index 94ee1d5f47..42dfb99747 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt @@ -1,6 +1,9 @@ +/a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(3,10): error TS2339: Property 'test' does not exist on type 'Foo'. +/a.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. /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'? +/a.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.d.ts (0 errors) ==== @@ -10,8 +13,10 @@ export type M = (this: Foo) => void; -==== /a.js (3 errors) ==== +==== /a.js (6 errors) ==== /** @type {import('./types').M} */ + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const f1 = function() { this.test(); ~~~~ @@ -24,6 +29,8 @@ } /** @type {(this: import('./types').Foo) => void} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const f3 = function() { this.test(); ~~~~ @@ -39,6 +46,8 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const f5 = function() { this.test(); } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt index be8a7c7817..76400daa8b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt @@ -1,17 +1,26 @@ +dtsEquivalent.js(1,19): error TS8010: Type annotations can only be used in TypeScript files. index.js(1,12): error TS2304: Cannot find name 'AnyEffect'. +index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(3,12): error TS2304: Cannot find name 'Third'. +index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -==== dtsEquivalent.js (0 errors) ==== +==== dtsEquivalent.js (1 errors) ==== /** @typedef {{[k: string]: any}} AnyEffect */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @typedef {number} Third */ -==== index.js (2 errors) ==== +==== index.js (4 errors) ==== /** @type {AnyEffect} */ ~~~~~~~~~ !!! error TS2304: Cannot find name 'AnyEffect'. + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. let b; /** @type {Third} */ ~~~~~ !!! error TS2304: Cannot find name 'Third'. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. let c; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt index edfbb88499..7316217e08 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(3,11): error TS2709: Cannot use namespace 'exports' as a type. +bug27342.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -==== bug27342.js (1 errors) ==== +==== bug27342.js (2 errors) ==== module.exports = {} /** * @type {exports} ~~~~~~~ !!! error TS2709: Cannot use namespace 'exports' as a type. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var x diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt index f5b86a1c28..d320911fca 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt @@ -1,13 +1,17 @@ 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(3,12): error TS8010: Type annotations can only be used in TypeScript files. 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(8,12): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocTypeReferenceToImport.js (2 errors) ==== +==== jsdocTypeReferenceToImport.js (4 errors) ==== const C = require('./ex').C; const D = require('./ex')?.C; /** @type {C} c */ ~ !!! error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var c = new C() c.start c.end @@ -15,6 +19,8 @@ jsdocTypeReferenceToImport.js(8,12): error TS2749: 'D' refers to a value, but is /** @type {D} c */ ~ !!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var d = new D() d.start d.end diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt index d5614f6c67..4f8dedb966 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt @@ -1,4 +1,5 @@ MC.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +MW.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -19,12 +20,14 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with ~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== MW.js (1 errors) ==== +==== MW.js (2 errors) ==== /** @typedef {import("./MC")} MC */ class MW { /** * @param {MC} compiler the compiler + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(compiler) { this.compiler = compiler; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt index 38ff7cb972..457939b4a3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt @@ -1,9 +1,11 @@ MC.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +MC.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. MW.js(1,15): error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? +MW.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== MC.js (1 errors) ==== +==== MC.js (2 errors) ==== const MW = require("./MW"); /** @typedef {number} Meyerhauser */ @@ -13,6 +15,8 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** @type {any} */ ~~~~~~~~~~~~~~~~~~~~~~ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x = {} ~~~~~~~~~~~~~~ return new MW(x); @@ -21,7 +25,7 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with ~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== MW.js (2 errors) ==== +==== MW.js (3 errors) ==== /** @typedef {import("./MC")} MC */ ~~~~~~~~~~~~~~ !!! error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? @@ -29,6 +33,8 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with class MW { /** * @param {MC} compiler the compiler + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(compiler) { this.compiler = compiler; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt index 84eb478f76..c80fc447ac 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt @@ -1,11 +1,14 @@ jsdocTypeReferenceToMergedClass.js(2,12): error TS2503: Cannot find namespace 'Workspace'. +jsdocTypeReferenceToMergedClass.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocTypeReferenceToMergedClass.js (1 errors) ==== +==== jsdocTypeReferenceToMergedClass.js (2 errors) ==== var Workspace = {} /** @type {Workspace.Project} */ ~~~~~~~~~ !!! error TS2503: Cannot find namespace 'Workspace'. + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var p; p.isServiceProject() diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt index bee4d86738..4075900f03 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt @@ -1,10 +1,13 @@ 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,13): error TS8010: Type annotations can only be used in TypeScript files. -==== foo.js (1 errors) ==== +==== foo.js (2 errors) ==== /** @param {Image} image */ ~~~~~ !!! error TS2749: 'Image' refers to a value, but is being used as a type here. Did you mean 'typeof Image'? + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function process(image) { return new image(1, 1) } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt new file mode 100644 index 0000000000..297f4d1c9d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt @@ -0,0 +1,11 @@ +bug25097.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== bug25097.js (1 errors) ==== + /** @type {C | null} */ + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const c = null + class C { + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt index 00b96eaed6..43f1bb940d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt @@ -1,3 +1,27 @@ +a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(52,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(61,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(67,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(70,12): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -6,77 +30,125 @@ b.ts(20,5): error TS2403: Subsequent variable declarations must have the same ty b.ts(21,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 (24 errors) ==== /** @type {String} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var S; /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var s; /** @type {Number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var N; /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n; /** @type {BigInt} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var BI; /** @type {bigint} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var bi; /** @type {Boolean} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var B; /** @type {boolean} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var b; /** @type {Void} */ + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var V; /** @type {void} */ + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var v; /** @type {Undefined} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var U; /** @type {undefined} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var u; /** @type {Null} */ + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var Nl; /** @type {null} */ + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var nl; /** @type {Array} */ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var A; /** @type {array} */ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var a; /** @type {Promise} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var P; /** @type {promise} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var p; /** @type {?number} */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var nullable; /** @type {Object} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var Obj; /** @type {object} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var obj; /** @type {Function} */ + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var Func; /** @type {(s: string) => number} */ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var f; /** @type {new (s: string) => { s: string }} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var ctor; ==== b.ts (6 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt index 5ca40c9e5b..b5820c483c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt @@ -1,34 +1,67 @@ +b.js(2,20): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(4,20): error TS8016: Type assertion expressions can only be used in TypeScript files. 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(6,12): error TS8010: Type annotations can only be used in TypeScript files. +b.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +b.js(12,20): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(13,25): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(43,23): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(44,23): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(45,23): error TS8016: Type assertion expressions can only be used in TypeScript files. b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. +b.js(47,26): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(48,26): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(49,26): error TS8016: Type assertion expressions can only be used in TypeScript files. b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x +b.js(51,24): error TS8016: Type assertion expressions can only be used in TypeScript files. b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. +b.js(52,24): error TS8016: Type assertion expressions can only be used in TypeScript files. b.js(52,38): error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. +b.js(53,24): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(59,23): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. +b.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. +b.js(66,15): error TS8016: Type assertion expressions can only be used in TypeScript files. 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(71,27): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(72,27): error TS8016: Type assertion expressions can only be used in TypeScript files. ==== a.ts (0 errors) ==== var W: string; -==== b.js (9 errors) ==== +==== b.js (30 errors) ==== // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); + ~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. var W = /** @type {string} */(4); // Error + ~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~ !!! 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 {*} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var a; /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var s; var a = /** @type {*} */("" + 4); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. var s = "" + /** @type {*} */(4); + ~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. class SomeBase { constructor() { @@ -59,42 +92,68 @@ b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. var someFakeClass = new SomeFakeClass(); someBase = /** @type {SomeBase} */(someDerived); + ~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someBase = /** @type {SomeBase} */(someBase); + ~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someBase = /** @type {SomeBase} */(someOther); // Error + ~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. !!! related TS2728 b.js:17:9: 'p' is declared here. someDerived = /** @type {SomeDerived} */(someDerived); + ~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someDerived = /** @type {SomeDerived} */(someBase); + ~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someDerived = /** @type {SomeDerived} */(someOther); // Error + ~~~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x someOther = /** @type {SomeOther} */(someDerived); // Error + ~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~~~ !!! error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someBase); // Error + ~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~ !!! error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someOther); + ~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someFakeClass = someBase; someFakeClass = someDerived; someBase = someFakeClass; // Error someBase = /** @type {SomeBase} */(someFakeClass); + ~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. // Type assertion cannot be a type-predicate type /** @type {number | string} */ + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var numOrStr; /** @type {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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 TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~ !!! error TS2454: Variable 'numOrStr' is used before being assigned. str = numOrStr; // Error, no narrowing occurred @@ -107,6 +166,10 @@ b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. var asConst1 = /** @type {const} */(1); + ~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. var asConst2 = /** @type {const} */({ + ~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. x: 1 }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt index 4b79a3d468..2981a9a97a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt @@ -1,13 +1,16 @@ a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (3 errors) ==== +==== a.js (4 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (value) => { ~~~~~ !!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt index 96a1ffda77..7bcea37453 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt @@ -1,4 +1,5 @@ a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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. @@ -6,11 +7,13 @@ 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) ==== +==== a.js (7 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (value) => { ~~~~~ !!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt new file mode 100644 index 0000000000..eda597adb2 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt @@ -0,0 +1,13 @@ +foo.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.js (2 errors) ==== + /** @type {boolean} */ + var /** @type {string} */ x, + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {number} */ y; + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt index 908bca4dda..576757de2d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt @@ -1,12 +1,15 @@ a.js(2,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +a.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (1 errors) ==== +==== a.js (2 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. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo = function (a, b, ...r) { }; diff --git a/testdata/baselines/reference/submodule/conformance/linkTagEmit1.errors.txt b/testdata/baselines/reference/submodule/conformance/linkTagEmit1.errors.txt new file mode 100644 index 0000000000..46f2899173 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/linkTagEmit1.errors.txt @@ -0,0 +1,31 @@ +linkTagEmit1.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== declarations.d.ts (0 errors) ==== + declare namespace NS { + type R = number + } +==== linkTagEmit1.js (1 errors) ==== + /** @typedef {number} N */ + /** + * @typedef {Object} D1 + * @property {1} e Just link to {@link NS.R} this time + * @property {1} m Wyatt Earp loved {@link N integers} I bet. + */ + + /** @typedef {number} Z @see N {@link N} */ + + /** + * @param {number} integer {@link Z} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function computeCommonSourceDirectoryOfFilenames(integer) { + return integer + 1 // pls pls pls + } + + /** {@link https://hvad} */ + var see3 = true + + /** @typedef {number} Attempt {@link https://wat} {@linkcode I think lingcod is better} {@linkplain or lutefisk}*/ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/malformedTags.errors.txt b/testdata/baselines/reference/submodule/conformance/malformedTags.errors.txt new file mode 100644 index 0000000000..6dadd48632 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/malformedTags.errors.txt @@ -0,0 +1,13 @@ +myFile02.js(4,10): error TS8010: Type annotations can only be used in TypeScript files. + + +==== myFile02.js (1 errors) ==== + /** + * Checks if `value` is classified as an `Array` object. + * + * @type Function + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var isArray = Array.isArray; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment.errors.txt index 8472709b9b..82e3ea212c 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment.errors.txt @@ -1,3 +1,4 @@ +npmlog.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. npmlog.js(5,14): error TS2741: Property 'y' is missing in type 'EE' but required in type 'typeof import("npmlog")'. npmlog.js(8,16): error TS2339: Property 'on' does not exist on type 'typeof import("npmlog")'. npmlog.js(10,8): error TS2339: Property 'x' does not exist on type 'EE'. @@ -16,9 +17,11 @@ use.js(3,8): error TS2339: Property 'on' does not exist on type 'typeof import(" ~~ !!! error TS2339: Property 'on' does not exist on type 'typeof import("npmlog")'. -==== npmlog.js (5 errors) ==== +==== npmlog.js (6 errors) ==== class EE { /** @param {string} s */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. on(s) { } } var npmlog = module.exports = new EE() diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.errors.txt new file mode 100644 index 0000000000..c8cc7510e8 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.errors.txt @@ -0,0 +1,33 @@ +webpackLibNormalModule.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. +webpackLibNormalModule.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== webpackLibNormalModule.js (2 errors) ==== + class C { + /** @param {number} x */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor(x) { + this.x = x + this.exports = [x] + } + /** @param {number} y */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + m(y) { + return this.x + y + } + } + function exec() { + const module = new C(12); + return module.exports; // should be fine because `module` is defined locally + } + + function tricky() { + // (a trickier variant of what webpack does) + const module = new C(12); + return () => { + return module.exports; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt index 88bbc580cf..a6d7b08281 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt @@ -6,14 +6,28 @@ index.ts(6,24): error TS2694: Namespace '"mod".export=' has no exported member ' index.ts(7,24): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. 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(2,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(2,28): error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. +main.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(3,28): error TS2694: Namespace '"mod".export=' has no exported member 'AnotherThing'. +main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(4,28): error TS2694: Namespace '"mod".export=' has no exported member 'foo'. +main.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(5,28): error TS2694: Namespace '"mod".export=' has no exported member 'qux'. +main.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(6,28): error TS2694: Namespace '"mod".export=' has no exported member 'baz'. +main.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(7,28): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. +main.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(8,28): error TS2694: Namespace '"mod".export=' has no exported member 'literal'. +main.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(20,35): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. +main.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. mod.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -40,27 +54,41 @@ mod.js(6,1): error TS2309: An export assignment cannot be used in a module with } ~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== main.js (8 errors) ==== +==== main.js (22 errors) ==== /** * @param {import("./mod").Thing} a + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. * @param {import("./mod").AnotherThing} b + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'AnotherThing'. * @param {import("./mod").foo} c + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'foo'. * @param {import("./mod").qux} d + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'qux'. * @param {import("./mod").baz} e + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. * @param {import("./mod").buz} f + ~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. * @param {import("./mod").literal} g + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'literal'. */ @@ -70,14 +98,28 @@ mod.js(6,1): error TS2309: An export assignment cannot be used in a module with /** * @param {typeof import("./mod").Thing} a + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").AnotherThing} b + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").foo} c + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").qux} d + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").baz} e + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").buz} f + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. * @param {typeof import("./mod").literal} g + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function jsvalues(a, b, c, d, e, f, g) { return a.length + b.length + c() + d() + e() + f() + g.length diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt index b3f788da0c..ac254aad3d 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt @@ -1,7 +1,9 @@ mod.js(2,18): error TS2339: Property 'K' does not exist on type '{}'. use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. +use.js(8,13): error TS8010: Type annotations can only be used in TypeScript files. use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? +use.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. ==== mod.js (1 errors) ==== @@ -17,7 +19,7 @@ use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as } } -==== use.js (3 errors) ==== +==== use.js (5 errors) ==== import * as s from './mod' var k = new s.n.K() @@ -28,11 +30,15 @@ use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as /** @param {s.n.K} c + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2694: Namespace '"mod"' has no exported member 'n'. @param {s.Classic} classic */ ~~~~~~~~~ !!! error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(c, classic) { c.x classic.p diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment2.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment2.errors.txt new file mode 100644 index 0000000000..076d9091ed --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment2.errors.txt @@ -0,0 +1,29 @@ +file1.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +file1.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +file1.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== file1.js (3 errors) ==== + // this file _should_ be a global file + var GlobalThing = { x: 12 }; + + /** + * @param {*} type + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {*} ctor + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {*} exports + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(type, ctor, exports) { + 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/nodeModulesAllowJs1(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node16).errors.txt index 7cbf2626ec..c50a44976a 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node16).errors.txt @@ -9,10 +9,21 @@ index.cjs(16,22): error TS1479: The current file is a CommonJS module whose impo index.cjs(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. +index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -36,10 +47,21 @@ index.js(21,22): error TS2835: Relative import paths need explicit file extensio index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -63,10 +85,21 @@ index.mjs(21,22): error TS2835: Relative import paths need explicit file extensi index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -117,7 +150,7 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // esm format file const x = 1; export {x}; -==== index.js (27 errors) ==== +==== index.js (38 errors) ==== import * as m1 from "./index.js"; import * as m2 from "./index.mjs"; import * as m3 from "./index.cjs"; @@ -187,27 +220,62 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; @@ -259,7 +327,7 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // esm format file const x = 1; export {x}; -==== index.cjs (27 errors) ==== +==== index.cjs (38 errors) ==== // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ @@ -330,27 +398,62 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; @@ -402,7 +505,7 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // cjs format file const x = 1; export {x}; -==== index.mjs (27 errors) ==== +==== index.mjs (38 errors) ==== import * as m1 from "./index.js"; import * as m2 from "./index.mjs"; import * as m3 from "./index.cjs"; @@ -472,27 +575,62 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node18).errors.txt index 7cbf2626ec..c50a44976a 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node18).errors.txt @@ -9,10 +9,21 @@ index.cjs(16,22): error TS1479: The current file is a CommonJS module whose impo index.cjs(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. +index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -36,10 +47,21 @@ index.js(21,22): error TS2835: Relative import paths need explicit file extensio index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -63,10 +85,21 @@ index.mjs(21,22): error TS2835: Relative import paths need explicit file extensi index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -117,7 +150,7 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // esm format file const x = 1; export {x}; -==== index.js (27 errors) ==== +==== index.js (38 errors) ==== import * as m1 from "./index.js"; import * as m2 from "./index.mjs"; import * as m3 from "./index.cjs"; @@ -187,27 +220,62 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; @@ -259,7 +327,7 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // esm format file const x = 1; export {x}; -==== index.cjs (27 errors) ==== +==== index.cjs (38 errors) ==== // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ @@ -330,27 +398,62 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; @@ -402,7 +505,7 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // cjs format file const x = 1; export {x}; -==== index.mjs (27 errors) ==== +==== index.mjs (38 errors) ==== import * as m1 from "./index.js"; import * as m2 from "./index.mjs"; import * as m3 from "./index.cjs"; @@ -472,27 +575,62 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt index f766eb28b5..8e9807b2ac 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt @@ -1,3 +1,14 @@ +index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? index.cjs(77,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -20,6 +31,17 @@ index.js(21,22): error TS2835: Relative import paths need explicit file extensio index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? index.js(76,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -42,6 +64,17 @@ index.mjs(21,22): error TS2835: Relative import paths need explicit file extensi index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? index.mjs(76,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -91,7 +124,7 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // esm format file const x = 1; export {x}; -==== index.js (22 errors) ==== +==== index.js (33 errors) ==== import * as m1 from "./index.js"; import * as m2 from "./index.mjs"; import * as m3 from "./index.cjs"; @@ -161,19 +194,54 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. void m24; void m25; void m26; @@ -223,7 +291,7 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // esm format file const x = 1; export {x}; -==== index.cjs (11 errors) ==== +==== index.cjs (22 errors) ==== // ESM-format imports below should issue errors import * as m1 from "./index.js"; import * as m2 from "./index.mjs"; @@ -272,19 +340,54 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. void m24; void m25; void m26; @@ -334,7 +437,7 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // cjs format file const x = 1; export {x}; -==== index.mjs (22 errors) ==== +==== index.mjs (33 errors) ==== import * as m1 from "./index.js"; import * as m2 from "./index.mjs"; import * as m3 from "./index.cjs"; @@ -404,19 +507,54 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. void m24; void m25; void m26; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt index b80fa4321a..cfec91f6b5 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt @@ -1,20 +1,28 @@ file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. -==== subfolder/index.js (0 errors) ==== +==== subfolder/index.js (1 errors) ==== // cjs format file const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. ==== subfolder/file.js (0 errors) ==== // cjs format file const a = {}; module.exports = a; -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== // esm format file const a = {}; + export = a; ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. + ~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== file.js (1 errors) ==== // esm format file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt index b80fa4321a..cfec91f6b5 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt @@ -1,20 +1,28 @@ file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. -==== subfolder/index.js (0 errors) ==== +==== subfolder/index.js (1 errors) ==== // cjs format file const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. ==== subfolder/file.js (0 errors) ==== // cjs format file const a = {}; module.exports = a; -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== // esm format file const a = {}; + export = a; ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. + ~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== file.js (1 errors) ==== // esm format file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt index b80fa4321a..cfec91f6b5 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt @@ -1,20 +1,28 @@ file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. -==== subfolder/index.js (0 errors) ==== +==== subfolder/index.js (1 errors) ==== // cjs format file const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. ==== subfolder/file.js (0 errors) ==== // cjs format file const a = {}; module.exports = a; -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== // esm format file const a = {}; + export = a; ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. + ~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== file.js (1 errors) ==== // esm format file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt new file mode 100644 index 0000000000..4cb7a62505 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt @@ -0,0 +1,55 @@ +file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. +file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== subfolder/index.js (2 errors) ==== + // cjs format file + ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== index.js (2 errors) ==== + // esm format file + ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== file.js (2 errors) ==== + // esm format file + const __require = null; + const _createRequire = null; + + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== types.d.ts (0 errors) ==== + declare module "fs"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt new file mode 100644 index 0000000000..4cb7a62505 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt @@ -0,0 +1,55 @@ +file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. +file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== subfolder/index.js (2 errors) ==== + // cjs format file + ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== index.js (2 errors) ==== + // esm format file + ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== file.js (2 errors) ==== + // esm format file + const __require = null; + const _createRequire = null; + + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== types.d.ts (0 errors) ==== + declare module "fs"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt new file mode 100644 index 0000000000..4cb7a62505 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt @@ -0,0 +1,55 @@ +file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. +file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== subfolder/index.js (2 errors) ==== + // cjs format file + ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== index.js (2 errors) ==== + // esm format file + ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== file.js (2 errors) ==== + // esm format file + const __require = null; + const _createRequire = null; + + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== types.d.ts (0 errors) ==== + declare module "fs"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt index 4c4797fb6c..5c2e18b118 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt @@ -1,33 +1,49 @@ +index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. +subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. -==== subfolder/index.js (2 errors) ==== +==== subfolder/index.js (4 errors) ==== // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. !!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. + import mod = require("../index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; + import mod2 = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. export async function f() { const mod3 = await import ("../index.js"); const mod4 = await import ("./index.js"); h(); } -==== index.js (1 errors) ==== +==== index.js (3 errors) ==== // esm format file import {h as _h} from "./index.js"; + import mod = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; + import mod2 = require("./subfolder/index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. export async function h() { const mod3 = await import ("./index.js"); const mod4 = await import ("./subfolder/index.js"); diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt index 4c4797fb6c..5c2e18b118 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt @@ -1,33 +1,49 @@ +index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. +subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. -==== subfolder/index.js (2 errors) ==== +==== subfolder/index.js (4 errors) ==== // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. !!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. + import mod = require("../index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; + import mod2 = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. export async function f() { const mod3 = await import ("../index.js"); const mod4 = await import ("./index.js"); h(); } -==== index.js (1 errors) ==== +==== index.js (3 errors) ==== // esm format file import {h as _h} from "./index.js"; + import mod = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; + import mod2 = require("./subfolder/index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. export async function h() { const mod3 = await import ("./index.js"); const mod4 = await import ("./subfolder/index.js"); diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt new file mode 100644 index 0000000000..d5cb2a2793 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt @@ -0,0 +1,50 @@ +index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== subfolder/index.js (2 errors) ==== + // cjs format file + import {h} from "../index.js"; + + import mod = require("../index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import {f as _f} from "./index.js"; + + import mod2 = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); + } +==== index.js (2 errors) ==== + // esm format file + import {h as _h} from "./index.js"; + + import mod = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import {f} from "./subfolder/index.js"; + + import mod2 = require("./subfolder/index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); + } +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt index 3e8e002141..f3adde836d 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt @@ -1,7 +1,9 @@ +/a.js(7,4): error TS8009: The '?' modifier can only be used in TypeScript files. +/a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(9,12): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -==== /a.js (1 errors) ==== +==== /a.js (3 errors) ==== /** * @typedef Foo * @property {string} a @@ -9,6 +11,10 @@ /** * @param {Foo} [options] + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f({ a = "a" }) {} ~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt new file mode 100644 index 0000000000..cd3cefdc7a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt @@ -0,0 +1,13 @@ +/a.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + /** + * @param {{ cause?: string }} [options] + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo({ cause } = {}) { + return cause; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt index c9b3fb4a96..bef1101f75 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt @@ -1,21 +1,38 @@ +overloadTag1.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. +overloadTag1.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. +overloadTag1.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +overloadTag1.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +overloadTag1.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. overloadTag1.js(26,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. +overloadTag1.js(29,5): error TS8017: Signature declarations can only be used in TypeScript files. +overloadTag1.js(34,5): error TS8017: Signature declarations can only be used in TypeScript files. -==== overloadTag1.js (1 errors) ==== +==== overloadTag1.js (8 errors) ==== /** * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} a * @param {number} b * @returns {number} * * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a * @param {boolean} b * @returns {string} * * @param {string | number} a + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string | number} b + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string | number} + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function overloaded(a,b) { if (typeof a === "string" && typeof b === "string") { @@ -33,11 +50,15 @@ overloadTag1.js(26,25): error TS2345: Argument of type 'boolean' is not assignab /** * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} a * @param {number} b * @returns {number} * * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a * @param {boolean} b * @returns {string} diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt index c45c97b5eb..bf6ba6af1a 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt @@ -1,9 +1,13 @@ +overloadTag2.js(8,9): error TS8017: Signature declarations can only be used in TypeScript files. overloadTag2.js(14,9): error TS2394: This overload signature is not compatible with its implementation signature. +overloadTag2.js(14,9): error TS8017: Signature declarations can only be used in TypeScript files. +overloadTag2.js(19,9): error TS8017: Signature declarations can only be used in TypeScript files. +overloadTag2.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. 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 (3 errors) ==== +==== overloadTag2.js (7 errors) ==== export class Foo { #a = true ? 1 : "1" #b @@ -12,6 +16,8 @@ overloadTag2.js(30,9): error TS2554: Expected 1-2 arguments, but got 0. * Should not have an implicit any error, because constructor's return type is always implicit * @constructor * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a * @param {number} b */ @@ -21,15 +27,21 @@ overloadTag2.js(30,9): error TS2554: Expected 1-2 arguments, but got 0. ~~~~~~~~ !!! error TS2394: This overload signature is not compatible with its implementation signature. !!! related TS2750 overloadTag2.js:25:5: The implementation signature is declared here. + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} a */ /** * @constructor * @overload + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a *//** * @constructor * @param {number | string} a + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(a, b) { ~ diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt new file mode 100644 index 0000000000..b0b69f1a02 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt @@ -0,0 +1,49 @@ +/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +/a.js(7,9): error TS8017: Signature declarations can only be used in TypeScript files. +/a.js(12,16): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (4 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + */ + ~~~ + export class Foo { + ~~~~~~~~~~~~~~~~~~ + /** + ~~~~~~~ + * @constructor + ~~~~~~~~~~~~~~~~~~~ + * @overload + ~~~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor() { } + ~~~~~~~~~~~~~~~~~~~~~ + + + /** + ~~~~~~~ + * @param {T} value + ~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + bar(value) { } + ~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** @type {Foo} */ + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + let foo; + foo = new Foo(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.errors.txt new file mode 100644 index 0000000000..4db1632b27 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.errors.txt @@ -0,0 +1,39 @@ +a.js(2,4): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (6 errors) ==== + /** + * @param {number} [p] + ~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number=} q + ~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} [r=101] + ~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(p, q, r) { + 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() + f(undefined, undefined, undefined) + f(1, 2, 3) + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt index 2694186a29..2b6b4fafc4 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt @@ -1,10 +1,13 @@ +paramTagNestedWithoutTopLevelObject3.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. paramTagNestedWithoutTopLevelObject3.js(3,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. paramTagNestedWithoutTopLevelObject3.js(6,16): error TS2339: Property 'bar' does not exist on type 'object'. -==== paramTagNestedWithoutTopLevelObject3.js (2 errors) ==== +==== paramTagNestedWithoutTopLevelObject3.js (3 errors) ==== /** * @param {object} xyz + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} xyz.bar.p ~~~~~~~~~ !!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. 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..394caf4255 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt @@ -0,0 +1,28 @@ +38572.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +38572.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +38572.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== 38572.js (3 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{[K in keyof T]: (value: T[K]) => void }} b + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f(a, b) { + ~~~~~~~~~~~~~~~~~~ + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + f({ x: 42 }, { x(param) { param.toFixed() } }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt index bc43cc7750..a5288d8ed5 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt @@ -1,15 +1,24 @@ 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(3,5): error TS8010: Type annotations can only be used in TypeScript files. +good.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +good.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -==== good.js (0 errors) ==== +==== good.js (3 errors) ==== /** * @param * {number} x Arg x. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * y Arg y. * @param {number} z + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * Arg z. */ function good(x, y, z) { diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt index 7982f84869..7c45d5dbd5 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt @@ -1,4 +1,5 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. +fileJs.js(1,10): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,11): error TS2304: Cannot find name 'c'. fileJs.js(1,17): error TS2304: Cannot find name 'd'. fileJs.js(1,27): error TS2304: Cannot find name 'f'. @@ -8,10 +9,12 @@ fileTs.ts(1,17): error TS2304: Cannot find name 'd'. fileTs.ts(1,27): error TS2304: Cannot find name 'f'. -==== fileJs.js (4 errors) ==== +==== fileJs.js (5 errors) ==== a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon ~ !!! error TS2304: Cannot find name 'a'. + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'c'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt index fdda202361..87521aaabd 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt @@ -1,15 +1,18 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. fileJs.js(1,11): error TS2304: Cannot find name 'a'. +fileJs.js(1,20): error TS8010: Type annotations can only be used in TypeScript files. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. fileTs.ts(1,11): error TS2304: Cannot find name 'a'. -==== fileJs.js (2 errors) ==== +==== fileJs.js (3 errors) ==== a ? () => a() : (): any => null; // Not legal JS; "Unexpected token ')'" at last paren ~ !!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'a'. + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ==== fileTs.ts (2 errors) ==== a ? () => a() : (): any => null; diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt index a604d5e706..0961c06454 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt @@ -1,4 +1,8 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. +fileJs.js(1,10): error TS8010: Type annotations can only be used in TypeScript files. +fileJs.js(1,20): error TS8009: The '?' modifier can only be used in TypeScript files. +fileJs.js(1,22): error TS8010: Type annotations can only be used in TypeScript files. +fileJs.js(1,31): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,40): error TS2304: Cannot find name 'd'. fileJs.js(1,46): error TS2304: Cannot find name 'e'. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. @@ -6,10 +10,18 @@ fileTs.ts(1,40): error TS2304: Cannot find name 'd'. fileTs.ts(1,46): error TS2304: Cannot find name 'e'. -==== fileJs.js (3 errors) ==== +==== fileJs.js (7 errors) ==== a() ? (b: number, c?: string): void => d() : e; // Not legal JS; "Unexpected token ':'" at first colon ~ !!! error TS2304: Cannot find name 'a'. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'd'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt new file mode 100644 index 0000000000..3df29f8c63 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt @@ -0,0 +1,11 @@ +fileJs.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== fileJs.js (1 errors) ==== + false ? (param): string => param : null // Not legal JS; "Unexpected token ':'" at last colon + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + +==== fileTs.ts (0 errors) ==== + false ? (param): string => param : null + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt new file mode 100644 index 0000000000..598acb3d84 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt @@ -0,0 +1,11 @@ +fileJs.js(1,24): error TS8010: Type annotations can only be used in TypeScript files. + + +==== fileJs.js (1 errors) ==== + true ? false ? (param): string => param : null : null // Not legal JS; "Unexpected token ':'" at last colon + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + +==== fileTs.ts (0 errors) ==== + true ? false ? (param): string => param : null : null + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt index 4d437b6b6c..910cef3733 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt @@ -1,5 +1,6 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. fileJs.js(1,5): error TS2304: Cannot find name 'b'. +fileJs.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,15): error TS2304: Cannot find name 'd'. fileJs.js(1,20): error TS2304: Cannot find name 'e'. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. @@ -8,12 +9,14 @@ fileTs.ts(1,15): error TS2304: Cannot find name 'd'. fileTs.ts(1,20): error TS2304: Cannot find name 'e'. -==== fileJs.js (4 errors) ==== +==== fileJs.js (5 errors) ==== a ? b : (c) : d => e // Not legal JS; "Unexpected token ':'" at last colon ~ !!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'b'. + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'd'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt b/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt index 267ad3982c..f3c6dfb553 100644 --- a/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt @@ -1,5 +1,8 @@ +privateNamesIncompatibleModifiersJs.js(3,8): error TS8009: The 'public' modifier can only be used in TypeScript files. privateNamesIncompatibleModifiersJs.js(3,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(8,8): error TS8009: The 'private' modifier can only be used in TypeScript files. privateNamesIncompatibleModifiersJs.js(8,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(13,8): error TS8009: The 'protected' modifier can only be used in TypeScript files. privateNamesIncompatibleModifiersJs.js(13,8): error TS18010: An accessibility modifier cannot be used with a private identifier. privateNamesIncompatibleModifiersJs.js(18,8): error TS18010: An accessibility modifier cannot be used with a private identifier. privateNamesIncompatibleModifiersJs.js(23,8): error TS18010: An accessibility modifier cannot be used with a private identifier. @@ -12,29 +15,38 @@ privateNamesIncompatibleModifiersJs.js(51,7): error TS18010: An accessibility mo privateNamesIncompatibleModifiersJs.js(55,8): error TS18010: An accessibility modifier cannot be used with a private identifier. -==== privateNamesIncompatibleModifiersJs.js (12 errors) ==== +==== privateNamesIncompatibleModifiersJs.js (15 errors) ==== class A { /** * @public ~~~~~~~ + ~~~~~~~ */ ~~~~~ +!!! error TS8009: The 'public' modifier can only be used in TypeScript files. + ~~~~~ !!! error TS18010: An accessibility modifier cannot be used with a private identifier. #a = 1; /** * @private ~~~~~~~~ + ~~~~~~~~ */ ~~~~~ +!!! error TS8009: The 'private' modifier can only be used in TypeScript files. + ~~~~~ !!! error TS18010: An accessibility modifier cannot be used with a private identifier. #b = 1; /** * @protected ~~~~~~~~~~ + ~~~~~~~~~~ */ ~~~~~ +!!! error TS8009: The 'protected' modifier can only be used in TypeScript files. + ~~~~~ !!! error TS18010: An accessibility modifier cannot be used with a private identifier. #c = 1; diff --git a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt index ccc2bc954c..6df4d6017e 100644 --- a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt @@ -1,45 +1,103 @@ +propertiesOfGenericConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. 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(14,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(26,24): error TS8004: Type parameter declarations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. -==== propertiesOfGenericConstructorFunctions.js (1 errors) ==== +==== propertiesOfGenericConstructorFunctions.js (16 errors) ==== /** + ~~~ * @template {string} K + ~~~~~~~~~~~~~~~~~~~~~~~ * @template V + ~~~~~~~~~~~~~~ * @param {string} ik + ~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {V} iv + ~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function Multimap(ik, iv) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** @type {{ [s: string]: V }} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. this._map = {}; + ~~~~~~~~~~~~~~~~~~~ // without type annotation + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this._map2 = { [ik]: iv }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @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'? + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const map = new Multimap("a", 1); // without type annotation const map2 = new Multimap("m", 2); /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = map._map['hi'] /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = map._map2['hi'] /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = map2._map['hi'] /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = map._map2['hi'] + + /** + ~~~ * @class + ~~~~~~~~~ * @template T + ~~~~~~~~~~~~~~ * @param {T} t + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function Cp(t) { + ~~~~~~~~~~~~~~~~ this.x = 1 + ~~~~~~~~~~~~~~ this.y = t + ~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Cp.prototype = { m1() { return this.x }, m2() { this.z = this.x + 1; return this.y } @@ -47,12 +105,20 @@ propertiesOfGenericConstructorFunctions.js(14,12): error TS2749: 'Multimap' refe var cp = new Cp(1) /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = cp.x /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = cp.y /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = cp.m1() /** @type {number} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n = cp.m2() \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt index af718cddbf..3cb3cec4d4 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt @@ -1,19 +1,28 @@ +propertyAssignmentUseParentType2.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +propertyAssignmentUseParentType2.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +propertyAssignmentUseParentType2.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. propertyAssignmentUseParentType2.js(11,14): error TS2322: Type '{ (): true; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. Types of property 'nuo' are incompatible. Type '1000' is not assignable to type '789'. -==== propertyAssignmentUseParentType2.js (1 errors) ==== +==== propertyAssignmentUseParentType2.js (4 errors) ==== /** @type {{ (): boolean; nuo: 789 }} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const inlined = () => true inlined.nuo = 789 /** @type {{ (): boolean; nuo: 789 }} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const duplicated = () => true /** @type {789} */ duplicated.nuo = 789 /** @type {{ (): boolean; nuo: 789 }} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export const conflictingDuplicated = () => true ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ (): true; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. diff --git a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt index d7cd47b9f3..1fa6526ad3 100644 --- a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt @@ -1,5 +1,7 @@ other.js(2,11): error TS2503: Cannot find namespace 'Ns'. +other.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. other.js(7,11): error TS2503: Cannot find namespace 'Ns'. +other.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. ==== prototypePropertyAssignmentMergeAcrossFiles2.js (0 errors) ==== @@ -13,11 +15,13 @@ other.js(7,11): error TS2503: Cannot find namespace 'Ns'. Ns.Two.prototype = { } -==== other.js (2 errors) ==== +==== other.js (4 errors) ==== /** * @type {Ns.One} ~~ !!! error TS2503: Cannot find namespace 'Ns'. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var one; one.wat; @@ -25,6 +29,8 @@ other.js(7,11): error TS2503: Cannot find namespace 'Ns'. * @type {Ns.Two} ~~ !!! error TS2503: Cannot find namespace 'Ns'. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ var two; two.wat; diff --git a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt index fcf4d43ce1..bde9cba210 100644 --- a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt @@ -1,9 +1,10 @@ +prototypePropertyAssignmentMergedTypeReference.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. 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) ==== +==== prototypePropertyAssignmentMergedTypeReference.js (3 errors) ==== var f = function() { return 12; }; @@ -11,6 +12,8 @@ prototypePropertyAssignmentMergedTypeReference.js(8,5): error TS2322: Type '() = f.prototype.a = "a"; /** @type {new () => f} */ + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2749: 'f' refers to a value, but is being used as a type here. Did you mean 'typeof f'? var x = f; diff --git a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt index 9c2df0fa3e..4b26205ee0 100644 --- a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt @@ -1,10 +1,14 @@ +bug39372.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. +bug39372.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -==== bug39372.js (1 errors) ==== +==== bug39372.js (3 errors) ==== /** @typedef {ReadonlyArray} JsonArray */ /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ /** @@ -27,6 +31,8 @@ bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type 'XMLObject< }} XMLObject */ /** @type {XMLObject<{foo:string}>} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const p = {}; ~ !!! error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. diff --git a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt new file mode 100644 index 0000000000..682666b0a2 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt @@ -0,0 +1,94 @@ +bug25127.js(6,16): error TS8010: Type annotations can only be used in TypeScript files. +bug25127.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. +bug25127.js(18,16): error TS8010: Type annotations can only be used in TypeScript files. +bug25127.js(19,17): error TS8010: Type annotations can only be used in TypeScript files. +bug25127.js(25,13): error TS8010: Type annotations can only be used in TypeScript files. +bug25127.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. +bug25127.js(33,13): error TS8010: Type annotations can only be used in TypeScript files. +bug25127.js(39,13): error TS8010: Type annotations can only be used in TypeScript files. +bug25127.js(48,12): error TS8010: Type annotations can only be used in TypeScript files. +bug25127.js(55,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== bug25127.js (10 errors) ==== + class Entry { + constructor() { + this.c = 1 + } + /** + * @param {any} x + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {this is Entry} + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + isInit(x) { + return true + } + } + class Group { + constructor() { + this.d = 'no' + } + /** + * @param {any} x + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {false} + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + isInit(x) { + return false + } + } + /** @param {Entry | Group} chunk */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(chunk) { + let x = chunk.isInit(chunk) ? chunk.c : chunk.d + return x + } + + /** + * @param {any} value + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {value is boolean} + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function isBoolean(value) { + return typeof value === "boolean"; + } + + /** @param {boolean | number} val */ + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + function foo(val) { + if (isBoolean(val)) { + val; + } + } + + /** + * @callback Cb + * @param {unknown} x + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {x is number} + */ + + /** @type {Cb} */ + function isNumber(x) { return typeof x === "number" } + + /** @param {unknown} x */ + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + function g(x) { + if (isNumber(x)) { + x * 2; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/syntaxErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/syntaxErrors.errors.txt new file mode 100644 index 0000000000..ed9e7d8d5b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/syntaxErrors.errors.txt @@ -0,0 +1,18 @@ +badTypeArguments.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== dummyType.d.ts (0 errors) ==== + declare class C { t: T } + +==== badTypeArguments.js (1 errors) ==== + /** @param {C.<>} x */ + /** @param {C.} y */ + // @ts-ignore + /** @param {C.} skipped */ + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(x, y, skipped) { + return x.t + y.t; + } + var x = f({ t: 1000 }, { t: 3000 }, { t: 5000 }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt index 48940af384..d616b6c166 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt @@ -1,11 +1,20 @@ templateInsideCallback.js(15,11): error TS2315: Type 'Call' is not generic. +templateInsideCallback.js(15,11): error TS8010: Type annotations can only be used in TypeScript files. templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. +templateInsideCallback.js(17,17): error TS8004: Type parameter declarations can only be used in TypeScript files. templateInsideCallback.js(17,18): error TS7006: Parameter 'x' implicitly has an 'any' type. templateInsideCallback.js(29,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. +templateInsideCallback.js(29,5): error TS8017: Signature declarations can only be used in TypeScript files. templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. +templateInsideCallback.js(37,5): error TS8017: Signature declarations can only be used in TypeScript files. +templateInsideCallback.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. +templateInsideCallback.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. +templateInsideCallback.js(45,14): error TS8010: Type annotations can only be used in TypeScript files. +templateInsideCallback.js(48,14): error TS8010: Type annotations can only be used in TypeScript files. +templateInsideCallback.js(51,31): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== templateInsideCallback.js (5 errors) ==== +==== templateInsideCallback.js (14 errors) ==== /** * @typedef Oops * @template T @@ -23,10 +32,14 @@ templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns * @type {Call} ~~~~~~~ !!! error TS2315: Type 'Call' is not generic. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'T'. */ const identity = x => x; + ~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ !!! error TS7006: Parameter 'x' implicitly has an 'any' type. @@ -43,6 +56,8 @@ templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns * @overload ~~~~~~~~ !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @template T * @template U * @param {T[]} array @@ -53,20 +68,32 @@ templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns * @overload ~~~~~~~~ !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. + ~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. * @template T * @param {T[][]} array * @returns {T[]} */ /** * @param {unknown[]} array + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(x: unknown) => unknown} iterable + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {unknown[]} + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function flatMap(array, iterable = identity) { /** @type {unknown[]} */ + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const result = []; for (let i = 0; i < array.length; i += 1) { result.push(.../** @type {unknown[]} */(iterable(array[i]))); + ~~~~~~~~~ +!!! error TS8016: Type assertion expressions can only be used in TypeScript files. } return result; } diff --git a/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt b/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt new file mode 100644 index 0000000000..c72a3549d6 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt @@ -0,0 +1,25 @@ +thisPropertyAssignmentInherited.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== thisPropertyAssignmentInherited.js (1 errors) ==== + export class Element { + /** + * @returns {String} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get textContent() { + return '' + } + set textContent(x) {} + cloneNode() { return this} + } + export class HTMLElement extends Element {} + export class TextElement extends HTMLElement { + get innerHTML() { return this.textContent; } + set innerHTML(html) { this.textContent = html; } + toString() { + } + } + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt new file mode 100644 index 0000000000..ce65e2b664 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt @@ -0,0 +1,26 @@ +a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (3 errors) ==== + /** @this {{ n: number }} Mount Holyoke Preparatory School + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} s + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {number} + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(s) { + return this.n + s.length + } + + const o = { + f, + n: 1 + } + o.f('hi') + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTag2.errors.txt new file mode 100644 index 0000000000..6e86e460d4 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/thisTag2.errors.txt @@ -0,0 +1,15 @@ +a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(4,10): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (2 errors) ==== + /** @this {string} */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + export function f1() {} + + /** @this */ + +!!! error TS8010: Type annotations can only be used in TypeScript files. + export function f2() {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag2.js b/testdata/baselines/reference/submodule/conformance/thisTag2.js index dd2582eb78..7c2c5ca1b6 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag2.js +++ b/testdata/baselines/reference/submodule/conformance/thisTag2.js @@ -15,19 +15,3 @@ export function f2() {} export declare function f1(this: string): void; /** @this */ export declare function f2(this: ): void; - - -//// [DtsFileErrors] - - -a.d.ts(4,34): error TS1110: Type expected. - - -==== a.d.ts (1 errors) ==== - /** @this {string} */ - export declare function f1(this: string): void; - /** @this */ - export declare function f2(this: ): void; - ~ -!!! error TS1110: Type expected. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag2.js.diff b/testdata/baselines/reference/submodule/conformance/thisTag2.js.diff index 5835164347..673962e838 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag2.js.diff +++ b/testdata/baselines/reference/submodule/conformance/thisTag2.js.diff @@ -8,20 +8,4 @@ +export declare function f1(this: string): void; /** @this */ -export function f2(this: any): void; -+export declare function f2(this: ): void; -+ -+ -+//// [DtsFileErrors] -+ -+ -+a.d.ts(4,34): error TS1110: Type expected. -+ -+ -+==== a.d.ts (1 errors) ==== -+ /** @this {string} */ -+ export declare function f1(this: string): void; -+ /** @this */ -+ export declare function f2(this: ): void; -+ ~ -+!!! error TS1110: Type expected. -+ \ No newline at end of file ++export declare function f2(this: ): void; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt index 81623b16ce..8d31eaf609 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt @@ -1,10 +1,15 @@ +/a.js(2,20): error TS8010: Type annotations can only be used in TypeScript files. /a.js(7,9): error TS2730: An arrow function cannot have a 'this' parameter. +/a.js(7,15): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. /a.js(10,21): error TS2339: Property 'fn' does not exist on type 'C'. -==== /a.js (2 errors) ==== +==== /a.js (5 errors) ==== /** * @typedef {{fn(a: string): void}} T + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ class C { @@ -12,7 +17,11 @@ * @this {T} ~~~~ !!! error TS2730: An arrow function cannot have a 'this' parameter. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} a + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ p = (a) => this.fn("" + a); ~~ diff --git a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt index 0961be452d..fa72e8b073 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt @@ -1,40 +1,78 @@ +thisTypeOfConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +thisTypeOfConstructorFunctions.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. thisTypeOfConstructorFunctions.js(15,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +thisTypeOfConstructorFunctions.js(15,18): error TS8010: Type annotations can only be used in TypeScript files. +thisTypeOfConstructorFunctions.js(19,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +thisTypeOfConstructorFunctions.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. 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(38,12): error TS8010: Type annotations can only be used in TypeScript files. 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(41,12): error TS8010: Type annotations can only be used in TypeScript files. 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(43,12): error TS8010: Type annotations can only be used in TypeScript files. -==== thisTypeOfConstructorFunctions.js (4 errors) ==== +==== thisTypeOfConstructorFunctions.js (12 errors) ==== /** + ~~~ * @class + ~~~~~~~~~ * @template T + ~~~~~~~~~~~~~~ * @param {T} t + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function Cp(t) { + ~~~~~~~~~~~~~~~~ /** @type {this} */ + ~~~~~~~~~~~~~~~~~~~~~~~ this.dit = this + ~~~~~~~~~~~~~~~~~~~ this.y = t + ~~~~~~~~~~~~~~ /** @return {this} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~ this.m3 = () => this + ~~~~~~~~~~~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Cp.prototype = { /** @return {this} */ ~~~~ !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. m4() { this.z = this.y; return this } } + + /** + ~~~ * @class + ~~~~~~~~~ * @template T + ~~~~~~~~~~~~~~ * @param {T} t + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function Cpp(t) { + ~~~~~~~~~~~~~~~~~ this.y = t + ~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @return {this} */ Cpp.prototype.m2 = function () { this.z = this.y; return this @@ -47,15 +85,21 @@ thisTypeOfConstructorFunctions.js(43,12): error TS2749: 'Cp' refers to a value, /** @type {Cpp} */ ~~~ !!! error TS2749: 'Cpp' refers to a value, but is being used as a type here. Did you mean 'typeof Cpp'? + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var cpn = cp.m4() \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt index 204843acf2..d14c932bc3 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt @@ -1,9 +1,13 @@ +bug25926.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. bug25926.js(4,18): error TS7006: Parameter 'n' implicitly has an 'any' type. +bug25926.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. bug25926.js(11,27): error TS7006: Parameter 'm' implicitly has an 'any' type. -==== bug25926.js (2 errors) ==== +==== bug25926.js (4 errors) ==== /** @type {{ a(): void; b?(n: number): number; }} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const o1 = { a() { this.b = n => n; @@ -13,6 +17,8 @@ bug25926.js(11,27): error TS7006: Parameter 'm' implicitly has an 'any' type. }; /** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const o2 = { d() { this.e = this.f = m => this.g || m; diff --git a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt index ed898025a1..8132992835 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt @@ -1,4 +1,5 @@ a.js(7,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. +a.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(25,29): error TS7006: Parameter 'l' 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'. @@ -6,9 +7,10 @@ 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(55,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (8 errors) ==== +==== a.js (10 errors) ==== function A () { // should get any on this-assignments in constructor this.unknown = null @@ -32,6 +34,8 @@ a.js(37,5): error TS2322: Type 'string' is not assignable to type 'number'. a.empty.push('hi') /** @type {number | undefined} */ + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n; // should get any on parameter initialisers @@ -80,6 +84,8 @@ a.js(37,5): error TS2322: Type 'string' is not assignable to type 'number'. l.push('ok') /** @type {(v: unknown) => v is undefined} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const isUndef = v => v === undefined; const e = [1, undefined]; diff --git a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt index 58532b712f..2420e98bc6 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt @@ -1,10 +1,13 @@ +a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(5,12): error TS7006: Parameter 'a' 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} */ + ~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var n; // should get any on parameter initialisers diff --git a/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt index e8effaa456..140cb31c8c 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt @@ -1,9 +1,17 @@ a.js(3,13): error TS2749: 'A' refers to a value, but is being used as a type here. Did you mean 'typeof A'? +a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. b.js(3,13): error TS2749: 'B' refers to a value, but is being used as a type here. Did you mean 'typeof B'? +b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. c.js(3,13): error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? +c.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. d.js(3,13): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? +d.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +e.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. f.js(5,13): error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? +f.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? +g.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. +h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. ==== node.d.ts (0 errors) ==== @@ -15,12 +23,14 @@ g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type her this.x = 1; }; -==== a.js (1 errors) ==== +==== a.js (2 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'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function a(p) { p.x; } ==== b-ext.js (0 errors) ==== @@ -30,12 +40,14 @@ g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type her } }; -==== b.js (1 errors) ==== +==== b.js (2 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'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function b(p) { p.x; } ==== c-ext.js (0 errors) ==== @@ -43,12 +55,14 @@ g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type her this.x = 1; } -==== c.js (1 errors) ==== +==== c.js (2 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'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function c(p) { p.x; } ==== d-ext.js (0 errors) ==== @@ -56,12 +70,14 @@ g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type her this.x = 1; }; -==== d.js (1 errors) ==== +==== d.js (2 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'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function d(p) { p.x; } ==== e-ext.js (0 errors) ==== @@ -71,13 +87,15 @@ g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type her } } -==== e.js (0 errors) ==== +==== e.js (1 errors) ==== const { E } = require("./e-ext"); /** @param {E} p */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function e(p) { p.x; } -==== f.js (1 errors) ==== +==== f.js (2 errors) ==== var F = function () { this.x = 1; }; @@ -85,9 +103,11 @@ g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type her /** @param {F} p */ ~ !!! error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function f(p) { p.x; } -==== g.js (1 errors) ==== +==== g.js (2 errors) ==== function G() { this.x = 1; } @@ -95,9 +115,11 @@ g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type her /** @param {G} p */ ~ !!! error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function g(p) { p.x; } -==== h.js (0 errors) ==== +==== h.js (1 errors) ==== class H { constructor() { this.x = 1; @@ -105,4 +127,6 @@ g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type her } /** @param {H} p */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function h(p) { p.x; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt new file mode 100644 index 0000000000..47cfde701e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt @@ -0,0 +1,22 @@ +a.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== typeFromPrivatePropertyAssignmentJs.js (0 errors) ==== + +==== a.js (2 errors) ==== + class C { + /** @type {{ foo?: string } | undefined } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + #a; + /** @type {{ foo?: string } | undefined } */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + #b; + m() { + const a = this.#a || {}; + this.#b = this.#b || {}; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt index 1419e4c079..960917e2ab 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt @@ -1,8 +1,10 @@ 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(8,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(11,12): error TS2503: Cannot find namespace 'Outer'. +a.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (4 errors) ==== var Outer = class O { m(x, y) { } } @@ -13,11 +15,15 @@ a.js(11,12): error TS2503: Cannot find namespace 'Outer'. /** @type {Outer} */ ~~~~~ !!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var si si.m /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var oi oi.n diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt index c21a2f0d69..5f37a1a95c 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt @@ -1,4 +1,5 @@ main.js(4,12): error TS2503: Cannot find namespace 'Outer'. +main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ==== module.js (0 errors) ==== @@ -37,13 +38,15 @@ main.js(4,12): error TS2503: Cannot find namespace 'Outer'. }; return Application; })(); -==== main.js (1 errors) ==== +==== main.js (2 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'. + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x; x.y; 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 4bad2fe72d..121f976dcf 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.errors.txt @@ -1,4 +1,5 @@ main.js(4,12): error TS2503: Cannot find namespace 'Outer'. +main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ==== module.js (0 errors) ==== @@ -37,13 +38,15 @@ main.js(4,12): error TS2503: Cannot find namespace 'Outer'. }; return Application; })(); -==== main.js (1 errors) ==== +==== main.js (2 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'. + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x; x.y; 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 aa43d4abec..edfb33ec5c 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt @@ -1,4 +1,5 @@ use.js(1,12): error TS2503: Cannot find namespace 'Outer'. +use.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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 '{}'. @@ -18,10 +19,12 @@ work.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. m() { } } -==== use.js (2 errors) ==== +==== use.js (3 errors) ==== /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var inner inner.x inner.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt index 3b6a9cb547..a2e98e904f 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt @@ -1,7 +1,8 @@ a.js(10,12): error TS2503: Cannot find namespace 'Outer'. +a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== var Outer = {}; Outer.Inner = class { @@ -14,6 +15,8 @@ a.js(10,12): error TS2503: Cannot find namespace 'Outer'. /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var inner inner.x inner.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt index c1019b00ed..985e91c5d9 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt @@ -1,7 +1,8 @@ a.js(9,12): error TS2503: Cannot find namespace 'Outer'. +a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== var Outer = {}; Outer.Inner = function () {} @@ -13,6 +14,8 @@ a.js(9,12): error TS2503: Cannot find namespace 'Outer'. /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var inner inner.x inner.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt index 6226eec805..4bab2a25af 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt @@ -1,8 +1,10 @@ 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(9,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(12,12): error TS2503: Cannot find namespace 'Outer'. +a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (4 errors) ==== function Outer() { this.y = 2 } @@ -14,11 +16,15 @@ a.js(12,12): error TS2503: Cannot find namespace 'Outer'. /** @type {Outer} */ ~~~~~ !!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var ok ok.y /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var oc oc.x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt index 34809387cc..fc34af3b5d 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt @@ -1,8 +1,9 @@ usage.js(2,13): error TS2339: Property 'Message' does not exist on type 'typeof Inner'. usage.js(7,12): error TS2503: Cannot find namespace 'Outer'. +usage.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -==== usage.js (2 errors) ==== +==== usage.js (3 errors) ==== // note that usage is first in the compilation Outer.Inner.Message = function() { ~~~~~~~ @@ -14,6 +15,8 @@ usage.js(7,12): error TS2503: Cannot find namespace 'Outer'. /** @type {Outer.Inner} should be instance type, not static type */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x; x.name diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt index da2e5fcef7..2e3325886a 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(9,12): error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? +a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(12,12): error TS2503: Cannot find namespace 'Outer'. +a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (4 errors) ==== var Outer = function O() { this.y = 2 } @@ -14,11 +16,15 @@ a.js(12,12): error TS2503: Cannot find namespace 'Outer'. /** @type {Outer} */ ~~~~~ !!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var ja ja.y /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var da da.x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt index 5b0afce0fd..85cbd4dfec 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt @@ -1,14 +1,17 @@ bug26877.js(1,13): error TS2503: Cannot find namespace 'Emu'. +bug26877.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. 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 '{}'. 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'. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function ollKorrect(x) { x._model 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 1b87c06947..0c138c8576 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt @@ -1,14 +1,16 @@ a.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. a.js(8,12): error TS2503: Cannot find namespace 'Outer'. +a.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. 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(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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 '{}'. @@ -21,6 +23,8 @@ b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var local local.y var inner = new Outer.Inner() @@ -28,10 +32,12 @@ 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 (2 errors) ==== +==== b.js (3 errors) ==== /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x x.y 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 index 9e6a8111a7..ac4e72e7ac 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.errors.txt @@ -1,7 +1,8 @@ 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(5,12): error TS8010: Type annotations can only be used in TypeScript files. -==== typeFromPropertyAssignment40.js (1 errors) ==== +==== typeFromPropertyAssignment40.js (2 errors) ==== function Outer() { var self = this self.y = 2 @@ -9,6 +10,8 @@ typeFromPropertyAssignment40.js(5,12): error TS2749: 'Outer' refers to a value, /** @type {Outer} */ ~~~~~ !!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var ok ok.y \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt index d247630d9d..29aa3d30d1 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt @@ -1,4 +1,5 @@ b.js(3,12): error TS2503: Cannot find namespace 'MC'. +b.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ==== a.js (0 errors) ==== @@ -8,11 +9,13 @@ b.js(3,12): error TS2503: Cannot find namespace 'MC'. } MyClass.bar -==== b.js (1 errors) ==== +==== b.js (2 errors) ==== import MC from './a' MC.bar /** @type {MC.bar} */ ~~ !!! error TS2503: Cannot find namespace 'MC'. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt index 48dce5754d..131d5ef72a 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt @@ -2,6 +2,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. +b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. ==== def.js (0 errors) ==== @@ -18,7 +19,7 @@ b.js(3,13): error TS2702: 'Outer' only refers to a type, but is being used as a ~ !!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. -==== b.js (2 errors) ==== +==== b.js (3 errors) ==== var msgs = Outer.i.messages() ~ !!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. @@ -26,6 +27,8 @@ b.js(3,13): error TS2702: 'Outer' only refers to a type, but is being used as a /** @param {Outer.Inner} inner */ ~~~~~ !!! error TS2702: 'Outer' only refers to a type, but is being used as a namespace here. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. function x(inner) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt index c10ea07ed6..c130193ccb 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt @@ -4,9 +4,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(6,12): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (6 errors) ==== +==== index.js (7 errors) ==== First.Item = class I {} ~~~~ !!! error TS2339: Property 'Item' does not exist on type '{}'. @@ -25,6 +26,8 @@ index.js(6,12): error TS2503: Cannot find namespace 'Workspace'. /** @type {Workspace.Object} */ ~~~~~~~~~ !!! error TS2503: Cannot find namespace 'Workspace'. + ~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var am; ==== roots.js (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt index b10885cf37..236d0b8917 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt @@ -1,10 +1,13 @@ bug26885.js(2,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +bug26885.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. +bug26885.js(8,18): error TS8010: Type annotations can only be used in TypeScript files. 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(15,12): error TS8010: Type annotations can only be used in TypeScript files. bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -==== bug26885.js (4 errors) ==== +==== bug26885.js (7 errors) ==== function Multimap3() { this._map = {}; ~~~~ @@ -14,7 +17,11 @@ bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a constru Multimap3.prototype = { /** * @param {string} key + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number} the value ok + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ get(key) { return this._map[key + '']; @@ -26,6 +33,8 @@ bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a constru /** @type {Multimap3} */ ~~~~~~~~~ !!! error TS2749: 'Multimap3' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap3'? + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. 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/typeFromPrototypeAssignment4.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.errors.txt new file mode 100644 index 0000000000..c0e6bca225 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.errors.txt @@ -0,0 +1,33 @@ +a.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (2 errors) ==== + function Multimap4() { + this._map = {}; + }; + + Multimap4["prototype"] = { + /** + * @param {string} key + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number} the value ok + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get(key) { + return this._map[key + '']; + } + }; + + Multimap4["prototype"]["add-on"] = function() {}; + Multimap4["prototype"]["addon"] = function() {}; + Multimap4["prototype"]["__underscores__"] = function() {}; + + const map4 = new Multimap4(); + map4.get(""); + map4["add-on"](); + map4.addon(); + map4.__underscores__(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt b/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt index b8f89f9c63..099947c796 100644 --- a/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt @@ -1,11 +1,14 @@ a.js(3,12): error TS2503: Cannot find namespace 'ns'. +a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== // #22973 var ns = (function() {})(); /** @type {ns.NotFound} */ ~~ !!! error TS2503: Cannot find namespace 'ns'. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var crash; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt b/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt new file mode 100644 index 0000000000..dc3b3d773a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt @@ -0,0 +1,8 @@ +/src/a.js(1,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + +==== /src/a.js (1 errors) ==== + var v = undefined satisfies 1; + ~~ +!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt index 6104c81d3a..aa2f3adc03 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt @@ -1,10 +1,16 @@ +typeTagNoErasure.js(1,47): error TS8010: Type annotations can only be used in TypeScript files. +typeTagNoErasure.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. typeTagNoErasure.js(7,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -==== typeTagNoErasure.js (1 errors) ==== +==== typeTagNoErasure.js (3 errors) ==== /** @template T @typedef {(data: T1) => T1} Test */ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Test} */ + ~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const test = dibbity => dibbity test(1) // ok, T=1 diff --git a/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.errors.txt b/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.errors.txt new file mode 100644 index 0000000000..2f3f0daa0a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.errors.txt @@ -0,0 +1,25 @@ +typeTagOnFunctionReferencesGeneric.js(2,21): error TS8010: Type annotations can only be used in TypeScript files. +typeTagOnFunctionReferencesGeneric.js(11,11): error TS8010: Type annotations can only be used in TypeScript files. + + +==== typeTagOnFunctionReferencesGeneric.js (2 errors) ==== + /** + * @typedef {(m : T) => T} IFn + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + /**@type {IFn}*/ + export function inJs(l) { + return l; + } + inJs(1); // lints error. Why? + + /**@type {IFn}*/ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const inJsArrow = (j) => { + return j; + } + inJsArrow(2); // no error gets linted as expected + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt index cec769759b..d7f4773664 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt @@ -1,5 +1,8 @@ mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +use.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. use.js(1,29): error TS2694: Namespace 'C' has no exported member 'Both'. +use.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +use.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ==== commonjs.d.ts (0 errors) ==== @@ -36,14 +39,20 @@ use.js(1,29): error TS2694: Namespace 'C' has no exported member 'Both'. this.p = 1 } -==== use.js (1 errors) ==== +==== use.js (4 errors) ==== /** @type {import('./mod1').Both} */ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~ !!! error TS2694: Namespace 'C' has no exported member 'Both'. var both1 = { type: 'a', x: 1 }; /** @type {import('./mod2').Both} */ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var both2 = both1; /** @type {import('./mod3').Both} */ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var both3 = both2; diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt index d48c75aeb1..32621780e8 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt @@ -6,19 +6,25 @@ mod1.js(10,1): error TS2309: An export assignment cannot be used in a module wit mod1.js(20,9): error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. mod1.js(23,1): error TS2300: Duplicate identifier 'export='. mod1.js(24,5): error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. +use.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. use.js(2,32): error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. use.js(4,12): error TS2503: Cannot find namespace 'mod'. +use.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -==== use.js (2 errors) ==== +==== use.js (4 errors) ==== var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. var b; /** @type {mod.Baz} */ ~~~ !!! error TS2503: Cannot find namespace 'mod'. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var bb; var bbb = new mod.Baz(); diff --git a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt index 430e0df3e9..a14ac15276 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt @@ -1,9 +1,12 @@ +a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. 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). +a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. test.ts(1,23): error TS2304: Cannot find name 'Everything'. -==== a.js (2 errors) ==== +==== a.js (5 errors) ==== /** * @template {{ a: number, b: string }} T,U A Comment * @template {{ c: boolean }} V uh ... are comments even supported?? @@ -13,9 +16,13 @@ test.ts(1,23): error TS2304: Cannot find name 'Everything'. */ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var tuvwx; /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~~~~ !!! 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. @@ -24,6 +31,8 @@ test.ts(1,23): error TS2304: Cannot find name 'Everything'. /** @type {Everything<{ a: number }>} */ ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2314: Generic type 'Everything' requires 5 type argument(s). + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var insufficient; ==== test.ts (1 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.errors.txt new file mode 100644 index 0000000000..c8fd5c0f55 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.errors.txt @@ -0,0 +1,13 @@ +typedefOnSemicolonClassElement.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== typedefOnSemicolonClassElement.js (1 errors) ==== + export class Preferences { + /** @typedef {string} A */ + ; + /** @type {A} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + a = 'ok' + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js index 68931be143..cacffe05a6 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js +++ b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js @@ -28,26 +28,3 @@ export declare class Preferences { /** @type {A} */ a: A; } - - -//// [DtsFileErrors] - - -dist/typedefOnSemicolonClassElement.d.ts(2,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -dist/typedefOnSemicolonClassElement.d.ts(4,8): error TS2693: 'A' only refers to a type, but is being used as a value here. -dist/typedefOnSemicolonClassElement.d.ts(5,1): error TS1128: Declaration or statement expected. - - -==== dist/typedefOnSemicolonClassElement.d.ts (3 errors) ==== - export declare class Preferences { - export type A = string; - ~~~~~~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. - /** @type {A} */ - a: A; - ~ -!!! error TS2693: 'A' only refers to a type, but is being used as a value here. - } - ~ -!!! error TS1128: Declaration or statement expected. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js.diff b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js.diff index b1d29ecaf0..627fc205d3 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js.diff @@ -23,27 +23,4 @@ /** @type {A} */ - a: string; + a: A; - } -+ -+ -+//// [DtsFileErrors] -+ -+ -+dist/typedefOnSemicolonClassElement.d.ts(2,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -+dist/typedefOnSemicolonClassElement.d.ts(4,8): error TS2693: 'A' only refers to a type, but is being used as a value here. -+dist/typedefOnSemicolonClassElement.d.ts(5,1): error TS1128: Declaration or statement expected. -+ -+ -+==== dist/typedefOnSemicolonClassElement.d.ts (3 errors) ==== -+ export declare class Preferences { -+ export type A = string; -+ ~~~~~~ -+!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -+ /** @type {A} */ -+ a: A; -+ ~ -+!!! error TS2693: 'A' only refers to a type, but is being used as a value here. -+ } -+ ~ -+!!! error TS1128: Declaration or statement expected. -+ \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt index d6726678a1..8fafd56565 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt @@ -2,9 +2,27 @@ 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(53,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(54,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(56,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(57,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(59,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(60,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(61,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(63,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(65,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(66,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(67,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(68,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(69,12): error TS8010: Type annotations can only be used in TypeScript files. +typedefOnStatements.js(73,16): error TS8010: Type annotations can only be used in TypeScript files. -==== typedefOnStatements.js (4 errors) ==== +==== typedefOnStatements.js (22 errors) ==== /** @typedef {{a: string}} A */ ; /** @typedef {{ b: string }} B */ @@ -66,26 +84,62 @@ typedefOnStatements.js(33,1): error TS2410: The 'with' statement is not supporte /** * @param {A} a + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {B} b + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {C} c + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {D} d + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {E} e + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {F} f + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {G} g + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {H} h + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {I} i + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {J} j + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {K} k + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {L} l + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {M} m + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {N} n + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {O} o + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {P} p + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Q} q + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,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) /** @type {Alpha} */ + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var alpha = { alpha: "aleph" } /** @typedef {{ alpha: string }} Alpha */ return diff --git a/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt index 78efa2ed36..9e860099ca 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt @@ -1,21 +1,30 @@ +typedefScope1.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. +typedefScope1.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. typedefScope1.js(13,12): error TS2304: Cannot find name 'B'. +typedefScope1.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -==== typedefScope1.js (1 errors) ==== +==== typedefScope1.js (4 errors) ==== function B1() { /** @typedef {number} B */ /** @type {B} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var ok1 = 0; } function B2() { /** @typedef {string} B */ /** @type {B} */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var ok2 = 'hi'; } /** @type {B} */ ~ !!! error TS2304: Cannot find name 'B'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var notOK = 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt index ab86dff568..8d8a80c58b 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt @@ -1,8 +1,9 @@ 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(5,12): error TS8010: Type annotations can only be used in TypeScript files. -==== typedefTagExtraneousProperty.js (2 errors) ==== +==== typedefTagExtraneousProperty.js (3 errors) ==== /** @typedef {Object.} Mmap ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. @@ -12,6 +13,8 @@ typedefTagExtraneousProperty.js(1,21): error TS8020: JSDoc types can only be use */ /** @type {Mmap} */ + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. var y = { bye: "no" }; y y.ignoreMe = "ok but just because of the index signature" diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagNested.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagNested.errors.txt new file mode 100644 index 0000000000..9f35474160 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/typedefTagNested.errors.txt @@ -0,0 +1,52 @@ +a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (3 errors) ==== + /** @typedef {Object} App + * @property {string} name + * @property {Object} icons + * @property {string} icons.image32 + * @property {string} icons.image64 + */ + var ex; + + /** @type {App} */ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const app = { + name: 'name', + icons: { + image32: 'x.png', + image64: 'y.png', + } + } + + /** @typedef {Object} Opp + * @property {string} name + * @property {Object} oops + * @property {string} horrible + * @type {string} idea + */ + var intercessor = 1 + + /** @type {Opp} */ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var mistake; + + /** @typedef {Object} Upp + * @property {string} name + * @property {Object} not + * @property {string} nested + */ + + /** @type {Upp} */ + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + var sala = { name: 'uppsala', not: 0, nested: "ok" }; + sala.name + sala.not + sala.nested + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt index 3372ce2456..00b89304f2 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt @@ -1,37 +1,81 @@ +github20832.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. github20832.js(2,15): error TS2304: Cannot find name 'U'. +github20832.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +github20832.js(6,13): error TS8010: Type annotations can only be used in TypeScript files. +github20832.js(12,11): error TS8010: Type annotations can only be used in TypeScript files. +github20832.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. github20832.js(17,12): error TS2304: Cannot find name 'V'. +github20832.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. +github20832.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. +github20832.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -==== github20832.js (2 errors) ==== +==== github20832.js (10 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 + ~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} + ~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f(x) { + ~~~~~~~~~~~~~~~ return x; + ~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type T - should be fine, since T will be any */ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const x = 3; + + /** + ~~~ * @callback Cb + ~~~~~~~~~~~~~~~ * @param {V} firstParam + ~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'V'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ /** + ~~~ * @template V + ~~~~~~~~~~~~~~ * @param {V} vvvvv + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function g(vvvvv) { + ~~~~~~~~~~~~~~~~~~~ } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type {Cb} */ + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. const cb = x => {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt index 6b2506e05c..15ebfd7180 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt @@ -1,12 +1,31 @@ mod1.js(2,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? mod1.js(9,12): error TS2304: Cannot find name 'Type1'. +mod1.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +mod1.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +mod1.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. +mod2.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +mod2.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. mod3.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? mod3.js(10,12): error TS2304: Cannot find name 'StringOrNumber1'. +mod3.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +mod3.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +mod3.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +mod3.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +mod3.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. mod4.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. +mod4.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +mod4.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +mod4.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +mod4.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. +mod4.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. +mod5.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. +mod5.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. +mod6.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. -==== mod1.js (2 errors) ==== +==== mod1.js (5 errors) ==== /** * @typedef {function(string): boolean} ~~~~~~~~ @@ -21,14 +40,20 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. * @param {Type1} func The function to call. ~~~~~ !!! error TS2304: Cannot find name 'Type1'. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} arg The argument to call it with. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean} The return. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function callIt(func, arg) { return func(arg); } -==== mod2.js (0 errors) ==== +==== mod2.js (2 errors) ==== /** * @typedef {{ * num: number, @@ -40,13 +65,17 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. /** * Makes use of a type with a multiline type expression. * @param {Type2} obj The object. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string|number} The return. + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function check(obj) { return obj.boo ? obj.num : obj.str; } -==== mod3.js (2 errors) ==== +==== mod3.js (7 errors) ==== /** * A function whose signature is very long. * @@ -62,16 +91,26 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. * @param {StringOrNumber1} func The function. ~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'StringOrNumber1'. + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {boolean} bool The condition. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} str The string. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} num The number. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string|number} The return. + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function use1(func, bool, str, num) { return func(bool, str, num) } -==== mod4.js (2 errors) ==== +==== mod4.js (7 errors) ==== /** * A function whose signature is very long. * @@ -88,16 +127,26 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. * @param {StringOrNumber2} func The function. ~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'StringOrNumber2'. + ~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {boolean} bool The condition. + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} str The string. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} num The number. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string|number} The return. + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function use2(func, bool, str, num) { return func(bool, str, num) } -==== mod5.js (0 errors) ==== +==== mod5.js (2 errors) ==== /** * @typedef {{ * num: @@ -112,13 +161,17 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. /** * Makes use of a type with a multiline type expression. * @param {Type5} obj The object. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string|number} The return. + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function check5(obj) { return obj.boo ? obj.num : obj.str; } -==== mod6.js (0 errors) ==== +==== mod6.js (2 errors) ==== /** * @typedef {{ * foo: @@ -131,7 +184,11 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. /** * Makes use of a type with a multiline type expression. * @param {Type6} obj The object. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {*} The return. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ function check6(obj) { return obj.foo; 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..0cbf74bd2f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt @@ -0,0 +1,56 @@ +uniqueSymbolsDeclarationsInJs.js(4,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJs.js(8,15): error TS8010: Type annotations can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJs.js(9,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJs.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJs.js(14,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJs.js(20,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJs.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== uniqueSymbolsDeclarationsInJs.js (7 errors) ==== + // classes + class C { + /** + * @readonly + ~~~~~~~~~ + */ + ~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + static readonlyStaticCall = Symbol(); + /** + * @type {unique symbol} + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @readonly + ~~~~~~~~~ + */ + ~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + static readonlyStaticType; + /** + * @type {unique symbol} + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @readonly + ~~~~~~~~~ + */ + ~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + static readonlyStaticTypeAndCall = Symbol(); + static readwriteStaticCall = Symbol(); + + /** + * @readonly + ~~~~~~~~~ + */ + ~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + readonlyCall = Symbol(); + readwriteCall = Symbol(); + } + + /** @type {unique symbol} */ + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + const a = Symbol(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt index 681f7c5f3e..d90bb47220 100644 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt @@ -1,22 +1,35 @@ +uniqueSymbolsDeclarationsInJsErrors.js(3,15): error TS8010: Type annotations can only be used in TypeScript files. 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(7,15): error TS8010: Type annotations can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJsErrors.js(8,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJsErrors.js(12,15): error TS8010: Type annotations can only be used in TypeScript files. 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) ==== +==== uniqueSymbolsDeclarationsInJsErrors.js (6 errors) ==== class C { /** * @type {unique symbol} + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ 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} + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. * @readonly + ~~~~~~~~~ */ + ~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. static readonlyType; /** * @type {unique symbol} + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. */ static readwriteType; ~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt b/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt new file mode 100644 index 0000000000..48cf899dce --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt @@ -0,0 +1,35 @@ +ex.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. +use.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== use.js (1 errors) ==== + var ex = require('./ex') + + // values work + var crunch = new ex.Crunch(1); + crunch.n + + + // types work + /** + * @param {ex.Crunch} wrap + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(wrap) { + wrap.n + } + +==== ex.js (1 errors) ==== + export class Crunch { + /** @param {number} n */ + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor(n) { + this.n = n + } + m() { + return this.n + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt b/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt new file mode 100644 index 0000000000..9f8b937fb6 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt @@ -0,0 +1,34 @@ +use.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +use.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== use.js (2 errors) ==== + var ex = require('./ex') + + // values work + var crunch = new ex.Crunch(1); + crunch.n + + + // types work + /** + * @param {ex.Greatest} greatest + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {ex.Crunch} wrap + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(greatest, wrap) { + greatest.day + wrap.n + } + +==== ex.d.ts (0 errors) ==== + export type Greatest = { day: 1 } + export class Crunch { + n: number + m(): number + constructor(n: number) + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff index 188fc9829d..5e205787a2 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff @@ -4,22 +4,24 @@ /test.js(3,9): error TS2322: Type '{}' is not assignable to type 'string'. -/test.js(6,5): error TS8009: The 'declare' modifier can only be used in TypeScript files. -/test.js(6,19): error TS8010: Type annotations can only be used in TypeScript files. ++/test.js(4,6): error TS8009: The 'declare' modifier can only be used in TypeScript files. ++/test.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. /test.js(9,19): error TS2339: Property 'foo' does not exist on type 'string'. --==== /test.js (4 errors) ==== -+==== /test.js (2 errors) ==== - class Foo { - constructor() { - this.prop = {}; -@@= skipped -12, +10 lines =@@ +@@= skipped -10, +10 lines =@@ + ~~~~~~~~~ + !!! error TS2322: Type '{}' is not assignable to type 'string'. } ++ ++ declare prop: string; - ~~~~~~~ --!!! error TS8009: The 'declare' modifier can only be used in TypeScript files. ++ ~~~~~~~~~~~ + !!! error TS8009: The 'declare' modifier can only be used in TypeScript files. - ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. - method() { - this.prop.foo \ No newline at end of file + method() { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff index c2a498e7f1..e97b67e851 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff @@ -2,6 +2,7 @@ +++ new.amdLikeInputDeclarationEmit.errors.txt @@= skipped -0, +0 lines =@@ - ++ExtendedClass.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. +ExtendedClass.js(17,5): error TS1231: An export assignment must be at the top level of a file or module declaration. +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 '{}'. @@ -16,11 +17,13 @@ + } + export = BaseClass; + } -+==== ExtendedClass.js (3 errors) ==== ++==== ExtendedClass.js (4 errors) ==== + define("lib/ExtendedClass", ["deps/BaseClass"], + /** + * {typeof import("deps/BaseClass")} + * @param {typeof import("deps/BaseClass")} BaseClass ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns + */ + (BaseClass) => { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff index a310bbe6cb..c567267282 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff @@ -5,9 +5,10 @@ +main.js(3,9): error TS2554: Expected 0 arguments, but got 3. +main.js(5,1): error TS2554: Expected 2 arguments, but got 0. +main.js(6,16): error TS2554: Expected 2 arguments, but got 3. ++main.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== main.js (3 errors) ==== ++==== main.js (4 errors) ==== + function allRest() { arguments; } + allRest(); + allRest(1, 2, 3); @@ -24,6 +25,8 @@ + + /** + * @param {number} x - a thing ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function jsdocced(x) { arguments; } + jsdocced(1); diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.errors.txt.diff new file mode 100644 index 0000000000..a55d6adb72 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.argumentsReferenceInConstructor1_Js.errors.txt ++++ new.argumentsReferenceInConstructor1_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class A { ++ /** ++ * Constructor ++ * ++ * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(foo = {}) { ++ /** ++ * @type object ++ */ ++ this.arguments = foo; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.errors.txt.diff new file mode 100644 index 0000000000..fb97c19836 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.argumentsReferenceInConstructor2_Js.errors.txt ++++ new.argumentsReferenceInConstructor2_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class A { ++ /** ++ * Constructor ++ * ++ * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(foo = {}) { ++ /** ++ * @type object ++ */ ++ this["arguments"] = foo; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff new file mode 100644 index 0000000000..b54e8f4889 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.argumentsReferenceInConstructor3_Js.errors.txt ++++ new.argumentsReferenceInConstructor3_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(11,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class A { ++ get arguments() { ++ return { bar: {} }; ++ } ++ } ++ ++ class B extends A { ++ /** ++ * Constructor ++ * ++ * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(foo = {}) { ++ super(); ++ ++ /** ++ * @type object ++ */ ++ this.foo = foo; ++ ++ /** ++ * @type object ++ */ ++ this.bar = super.arguments.foo; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff new file mode 100644 index 0000000000..24fdf4fb4c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.argumentsReferenceInConstructor4_Js.errors.txt ++++ new.argumentsReferenceInConstructor4_Js.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. + /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 (1 errors) ==== ++==== /a.js (3 errors) ==== + class A { + /** + * Constructor + * + * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(foo = {}) { + const key = "bar"; +@@= skipped -17, +21 lines =@@ + + /** + * @type object ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const arguments = this.arguments; + ~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.errors.txt.diff new file mode 100644 index 0000000000..a1b7e4a866 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.errors.txt.diff @@ -0,0 +1,33 @@ +--- old.argumentsReferenceInConstructor5_Js.errors.txt ++++ new.argumentsReferenceInConstructor5_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ const bar = { ++ arguments: {} ++ } ++ ++ class A { ++ /** ++ * Constructor ++ * ++ * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(foo = {}) { ++ /** ++ * @type object ++ */ ++ this.foo = foo; ++ ++ /** ++ * @type object ++ */ ++ this.bar = bar.arguments; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.errors.txt.diff new file mode 100644 index 0000000000..8511d94fc8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.argumentsReferenceInMethod1_Js.errors.txt ++++ new.argumentsReferenceInMethod1_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class A { ++ /** ++ * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ m(foo = {}) { ++ /** ++ * @type object ++ */ ++ this.arguments = foo; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.errors.txt.diff new file mode 100644 index 0000000000..d9c725589d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.argumentsReferenceInMethod2_Js.errors.txt ++++ new.argumentsReferenceInMethod2_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class A { ++ /** ++ * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ m(foo = {}) { ++ /** ++ * @type object ++ */ ++ this["arguments"] = foo; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff new file mode 100644 index 0000000000..a3ad683ddd --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff @@ -0,0 +1,33 @@ +--- old.argumentsReferenceInMethod3_Js.errors.txt ++++ new.argumentsReferenceInMethod3_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class A { ++ get arguments() { ++ return { bar: {} }; ++ } ++ } ++ ++ class B extends A { ++ /** ++ * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ m(foo = {}) { ++ /** ++ * @type object ++ */ ++ this.x = foo; ++ ++ /** ++ * @type object ++ */ ++ this.y = super.arguments.bar; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff new file mode 100644 index 0000000000..2b5f4a26fc --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.argumentsReferenceInMethod4_Js.errors.txt ++++ new.argumentsReferenceInMethod4_Js.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. + /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 (1 errors) ==== ++==== /a.js (3 errors) ==== + class A { + /** + * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + m(foo = {}) { + const key = "bar"; +@@= skipped -15, +19 lines =@@ + + /** + * @type object ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const arguments = this.arguments; + ~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.errors.txt.diff new file mode 100644 index 0000000000..232dcba758 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.errors.txt.diff @@ -0,0 +1,31 @@ +--- old.argumentsReferenceInMethod5_Js.errors.txt ++++ new.argumentsReferenceInMethod5_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ const bar = { ++ arguments: {} ++ } ++ ++ class A { ++ /** ++ * @param {object} [foo={}] ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ m(foo = {}) { ++ /** ++ * @type object ++ */ ++ this.foo = foo; ++ ++ /** ++ * @type object ++ */ ++ this.bar = bar.arguments; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff index 4810a1e796..5a1d97f303 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff @@ -2,27 +2,61 @@ +++ new.arrowExpressionBodyJSDoc.errors.txt @@= skipped -0, +0 lines =@@ -mytest.js(6,44): error TS2322: Type 'string' is not assignable to type 'T'. -+mytest.js(6,45): error TS2322: Type 'string' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. +- 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -mytest.js(13,44): error TS2322: Type 'string' is not assignable to type 'T'. +- 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. +- +- +-==== mytest.js (2 errors) ==== ++mytest.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++mytest.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. ++mytest.js(6,13): error TS8004: Type parameter declarations can only be used in TypeScript files. ++mytest.js(6,34): error TS8016: Type assertion expressions can only be used in TypeScript files. ++mytest.js(6,45): error TS2322: Type 'string' is not assignable to type 'T'. ++ 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. ++mytest.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++mytest.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. ++mytest.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. ++mytest.js(13,34): error TS8016: Type assertion expressions can only be used in TypeScript files. +mytest.js(13,61): error TS2322: Type 'string' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. - - -@@= skipped -10, +10 lines =@@ ++ 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. ++ ++ ++==== mytest.js (10 errors) ==== + /** + * @template T + * @param {T|undefined} value value or not ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} result value ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo1 = value => /** @type {string} */({ ...value }); - ~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -@@= skipped -10, +10 lines =@@ + /** + * @template T + * @param {T|undefined} value value or not ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} result value ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff new file mode 100644 index 0000000000..75bdc9bdef --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.arrowExpressionJs.errors.txt ++++ new.arrowExpressionJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++mytest.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++mytest.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. ++mytest.js(6,24): error TS8004: Type parameter declarations can only be used in TypeScript files. ++mytest.js(6,45): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== mytest.js (4 errors) ==== ++ /** ++ * @template T ++ * @param {T|undefined} value value or not ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} result value ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const cloneObjectGood = value => /** @type {T} */({ ...value }); ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.errors.txt.diff new file mode 100644 index 0000000000..49612ac80d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.errors.txt.diff @@ -0,0 +1,31 @@ +--- old.arrowFunctionJSDocAnnotation.errors.txt ++++ new.arrowFunctionJSDocAnnotation.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(10,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(11,18): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (3 errors) ==== ++ /** ++ * @param {any} v ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function identity(v) { ++ return v; ++ } ++ ++ const x = identity( ++ /** ++ * @param {number} param ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {number=} ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ param => param ++ ); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt.diff new file mode 100644 index 0000000000..51da005600 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.checkJsObjectLiteralHasCheckedKeyof.errors.txt ++++ new.checkJsObjectLiteralHasCheckedKeyof.errors.txt +@@= skipped -0, +0 lines =@@ ++file.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. + file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. + + +-==== file.js (1 errors) ==== ++==== file.js (2 errors) ==== + // @ts-check + const obj = { + x: 1, +@@= skipped -9, +10 lines =@@ + + /** + * @type {keyof typeof obj} ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + let selected = "x"; + selected = "z"; // should fail \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff index af290d6fc7..556c1c9f23 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff @@ -2,7 +2,9 @@ +++ new.checkJsTypeDefNoUnusedLocalMarked.errors.txt @@= skipped -0, +0 lines =@@ - ++something.js(3,20): error TS8010: Type annotations can only be used in TypeScript files. +something.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++something.js(5,29): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== file.ts (0 errors) ==== @@ -15,11 +17,15 @@ + } + + export = Foo; -+==== something.js (1 errors) ==== ++==== something.js (3 errors) ==== + /** @typedef {typeof import("./file")} Foo */ + + /** @typedef {(foo: Foo) => string} FooFun */ ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + module.exports = /** @type {FooFun} */(void 0); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file ++!!! error TS2309: An export assignment cannot be used in a module with other exported elements. ++ ~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/constructorPropertyJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/constructorPropertyJs.errors.txt.diff new file mode 100644 index 0000000000..fc372dd974 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/constructorPropertyJs.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.constructorPropertyJs.errors.txt ++++ new.constructorPropertyJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class C { ++ /** ++ * @param {any} a ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ foo(a) { ++ this.constructor = a; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt.diff new file mode 100644 index 0000000000..4e58d4e5f8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt.diff @@ -0,0 +1,62 @@ +--- old.contextuallyTypedParametersOptionalInJSDoc.errors.txt ++++ new.contextuallyTypedParametersOptionalInJSDoc.errors.txt +@@= skipped -0, +0 lines =@@ ++index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(8,28): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(14,6): error TS8009: The '?' modifier can only be used in TypeScript files. + 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(22,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(25,6): error TS8009: The '?' modifier can only be used in TypeScript files. ++index.js(25,14): error TS8010: Type annotations can only be used in TypeScript files. + 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 (2 errors) ==== ++==== index.js (10 errors) ==== + /** + * + * @param {number} num ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function acceptNum(num) {} + + /** + * @typedef {(a: string, b: number) => void} Fn ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + /** @type {Fn} */ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const fn1 = + /** + * @param [b] ++ ~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + */ + function self(a, b) { + acceptNum(b); // error +@@= skipped -29, +47 lines =@@ + }; + + /** @type {Fn} */ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const fn2 = + /** + * @param {number} [b] ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function self(a, b) { + acceptNum(b); // error \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff index 24a1d9bbd3..e04771cf80 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff @@ -2,44 +2,79 @@ +++ new.contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt @@= skipped -0, +0 lines =@@ - ++index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(2,28): error TS2304: Cannot find name 'B'. ++index.js(2,41): error TS8010: Type annotations can only be used in TypeScript files. +index.js(2,42): error TS2304: Cannot find name 'A'. ++index.js(2,47): error TS8010: Type annotations can only be used in TypeScript files. +index.js(2,48): error TS2304: Cannot find name 'B'. +index.js(2,67): error TS2304: Cannot find name 'B'. +index.js(10,12): error TS2315: Type 'Funcs' is not generic. ++index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(14,21): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(20,19): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (5 errors) ==== ++==== index.js (12 errors) ==== + /** ++ ~~~ + * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS2304: Cannot find name 'B'. ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2304: Cannot find name 'A'. ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2304: Cannot find name 'B'. + ~ +!!! error TS2304: Cannot find name 'B'. + * @template A ++ ~~~~~~~~~~~~~~ + * @template {Record} B ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ ++ ~~~ ++ + + /** ++ ~~~ + * @template A ++ ~~~~~~~~~~~~~~ + * @template {Record} B ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {Funcs} fns ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~ +!!! error TS2315: Type 'Funcs' is not generic. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {[A, B]} ++ ~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function foo(fns) { ++ ~~~~~~~~~~~~~~~~~~~ + return /** @type {any} */ (null); ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + const result = foo({ + bar: { + fn: + /** @param {string} a */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + (a) => {}, + thing: "asd", + }, diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff new file mode 100644 index 0000000000..cde4ad76e0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff @@ -0,0 +1,69 @@ +--- old.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt ++++ new.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(7,21): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(12,6): error TS8009: The '?' modifier can only be used in TypeScript files. ++index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(19,6): error TS8009: The '?' modifier can only be used in TypeScript files. ++index.js(19,14): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(20,6): error TS8009: The '?' modifier can only be used in TypeScript files. ++index.js(20,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (10 errors) ==== ++ /** ++ ~~~ ++ * @template T ++ ~~~~~~~~~~~~~~ ++ * @param {(value: T, index: number) => boolean} predicate ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~ ++ function filter(predicate) { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ return /** @type {any} */ (null); ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ const a = filter( ++ /** ++ * @param {number} [pose] ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ (pose) => true ++ ); ++ ++ const b = filter( ++ /** ++ * @param {number} [pose] ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} [_] ++ ~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ (pose, _) => true ++ ); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff index fecec633bc..e738d43017 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff @@ -2,6 +2,7 @@ +++ new.controlFlowInstanceof.errors.txt @@= skipped -0, +0 lines =@@ - ++uglify.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +uglify.js(6,7): error TS2339: Property 'val' does not exist on type '{}'. + + @@ -114,10 +115,12 @@ + } + + // Repro from #27550 (based on uglify code) -+==== uglify.js (1 errors) ==== ++==== uglify.js (2 errors) ==== + /** @constructor */ + function AtTop(val) { this.val = val } + /** @type {*} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var v = 1; + if (v instanceof AtTop) { + v.val 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 new file mode 100644 index 0000000000..c17c27d755 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt.diff @@ -0,0 +1,101 @@ +--- old.declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt ++++ new.declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt +@@= skipped -0, +0 lines =@@ +- ++input.js(5,30): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(7,30): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(8,34): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(10,35): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(13,59): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(16,24): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(17,44): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++input.js(18,43): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(19,27): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(21,46): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(23,40): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(25,33): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(29,27): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(37,70): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== input.js (19 errors) ==== ++ /** ++ * @typedef {{ } & { name?: string }} P ++ */ ++ ++ const something = /** @type {*} */(null); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ export let vLet = /** @type {P} */(something); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ export const vConst = /** @type {P} */(something); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ export function fn(p = /** @type {P} */(something)) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ /** @param {number} req */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ export class C { ++ field = /** @type {P} */(something); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ /** @optional */ optField = /** @type {P} */(something); // not a thing ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ /** @readonly */ roFiled = /** @type {P} */(something); ++ ~~~~~~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ method(p = /** @type {P} */(something)) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ /** @param {number} req */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ methodWithRequiredDefault(p = /** @type {P} */(something), req) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ constructor(ctorField = /** @type {P} */(something)) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ get x() { return /** @type {P} */(something) } ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ set x(v) { } ++ } ++ ++ export default /** @type {P} */(something); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ // allows `undefined` on the input side, thanks to the initializer ++ /** ++ * ++ * @param {P} x ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} b ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file 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 new file mode 100644 index 0000000000..04ec488f90 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt.diff @@ -0,0 +1,101 @@ +--- old.declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt ++++ new.declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt +@@= skipped -0, +0 lines =@@ +- ++input.js(5,30): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(7,30): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(8,34): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(10,35): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(13,59): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(16,24): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(17,44): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++input.js(18,43): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(19,27): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(21,46): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(23,40): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(25,33): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(29,27): error TS8016: Type assertion expressions can only be used in TypeScript files. ++input.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(37,70): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== input.js (19 errors) ==== ++ /** ++ * @typedef {{ } & { name?: string }} P ++ */ ++ ++ const something = /** @type {*} */(null); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ export let vLet = /** @type {P} */(something); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ export const vConst = /** @type {P} */(something); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ export function fn(p = /** @type {P} */(something)) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ /** @param {number} req */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ export class C { ++ field = /** @type {P} */(something); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ /** @optional */ optField = /** @type {P} */(something); // not a thing ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ /** @readonly */ roFiled = /** @type {P} */(something); ++ ~~~~~~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ method(p = /** @type {P} */(something)) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ /** @param {number} req */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ methodWithRequiredDefault(p = /** @type {P} */(something), req) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ constructor(ctorField = /** @type {P} */(something)) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ get x() { return /** @type {P} */(something) } ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ set x(v) { } ++ } ++ ++ export default /** @type {P} */(something); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ // allows `undefined` on the input side, thanks to the initializer ++ /** ++ * ++ * @param {P} x ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} b ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.errors.txt.diff new file mode 100644 index 0000000000..888b51d69d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.declarationEmitClassAccessorsJs1.errors.txt ++++ new.declarationEmitClassAccessorsJs1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (2 errors) ==== ++ // https://github.com/microsoft/TypeScript/issues/58167 ++ ++ export class VFile { ++ /** ++ * @returns {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ get path() { ++ return '' ++ } ++ ++ /** ++ * @param {URL | string} path ++ ~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set path(path) { ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt.diff new file mode 100644 index 0000000000..e1269a7a0c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.declarationEmitClassSetAccessorParamNameInJs.errors.txt ++++ new.declarationEmitClassSetAccessorParamNameInJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++foo.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (1 errors) ==== ++ // https://github.com/microsoft/TypeScript/issues/55391 ++ ++ export class Foo { ++ /** ++ * Bar. ++ * ++ * @param {string} baz Baz. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set bar(baz) {} ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt.diff new file mode 100644 index 0000000000..5383769db8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.declarationEmitClassSetAccessorParamNameInJs2.errors.txt ++++ new.declarationEmitClassSetAccessorParamNameInJs2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++foo.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (1 errors) ==== ++ export class Foo { ++ /** ++ * Bar. ++ * ++ * @param {{ prop: string }} baz Baz. ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set bar({}) {} ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt.diff new file mode 100644 index 0000000000..e5437ace1b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.declarationEmitClassSetAccessorParamNameInJs3.errors.txt ++++ new.declarationEmitClassSetAccessorParamNameInJs3.errors.txt +@@= skipped -0, +0 lines =@@ +- ++foo.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (1 errors) ==== ++ export class Foo { ++ /** ++ * Bar. ++ * ++ * @param {{ prop: string | undefined }} baz Baz. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set bar({ prop = 'foo' }) {} ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.errors.txt.diff new file mode 100644 index 0000000000..e47fcba5c4 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.declarationEmitLateBoundJSAssignments.errors.txt ++++ new.declarationEmitLateBoundJSAssignments.errors.txt +@@= skipped -0, +0 lines =@@ +- ++file.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== file.js (4 errors) ==== ++ export function foo() {} ++ foo.bar = 12; ++ const _private = Symbol(); ++ foo[_private] = "ok"; ++ const strMem = "strMemName"; ++ foo[strMem] = "ok"; ++ const dashStrMem = "dashed-str-mem"; ++ foo[dashStrMem] = "ok"; ++ const numMem = 42; ++ foo[numMem] = "ok"; ++ ++ /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const x = foo[_private]; ++ /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const y = foo[strMem]; ++ /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const z = foo[numMem]; ++ /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const a = foo[dashStrMem]; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt.diff new file mode 100644 index 0000000000..0e5940f9ef --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt.diff @@ -0,0 +1,75 @@ +--- old.declarationEmitObjectLiteralAccessorsJs1.errors.txt ++++ new.declarationEmitObjectLiteralAccessorsJs1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(21,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(28,14): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(36,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(46,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (6 errors) ==== ++ // same type accessors ++ export const obj1 = { ++ /** ++ * my awesome getter (first in source order) ++ * @returns {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ get x() { ++ return ""; ++ }, ++ /** ++ * my awesome setter (second in source order) ++ * @param {string} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set x(a) {}, ++ }; ++ ++ // divergent accessors ++ export const obj2 = { ++ /** ++ * my awesome getter ++ * @returns {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ get x() { ++ return ""; ++ }, ++ /** ++ * my awesome setter ++ * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set x(a) {}, ++ }; ++ ++ export const obj3 = { ++ /** ++ * my awesome getter ++ * @returns {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ get x() { ++ return ""; ++ }, ++ }; ++ ++ export const obj4 = { ++ /** ++ * my awesome setter ++ * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set x(a) {}, ++ }; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile.errors.txt.diff index 01b25dd180..a594e37091 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile.errors.txt.diff @@ -2,15 +2,15 @@ +++ new.decoratorInJsFile.errors.txt @@= skipped -0, +0 lines =@@ -a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -- -- --==== a.js (1 errors) ==== -- @SomeDecorator -- class SomeClass { -- foo(x: number) { ++a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== a.js (1 errors) ==== + @SomeDecorator + class SomeClass { + foo(x: number) { - ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- -- } -- } -+ \ No newline at end of file ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile1.errors.txt.diff index 349ad2c6c6..92f8e9b3d3 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile1.errors.txt.diff @@ -2,15 +2,15 @@ +++ new.decoratorInJsFile1.errors.txt @@= skipped -0, +0 lines =@@ -a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -- -- --==== a.js (1 errors) ==== -- @SomeDecorator -- class SomeClass { -- foo(x: number) { ++a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== a.js (1 errors) ==== + @SomeDecorator + class SomeClass { + foo(x: number) { - ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- -- } -- } -+ \ No newline at end of file ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff index 6569dcf3a6..28064adf35 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff @@ -2,10 +2,13 @@ +++ new.expandoFunctionContextualTypesJs.errors.txt @@= skipped -0, +0 lines =@@ - ++input.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. ++input.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. +input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== input.js (1 errors) ==== ++==== input.js (4 errors) ==== + /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ + + /** @@ -14,6 +17,8 @@ + + /** + * @type {StatelessComponent} ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const MyComponent = () => /* @type {any} */(null); + @@ -32,12 +37,16 @@ + + /** + * @type {StatelessComponent} ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const check = MyComponent2; + + /** + * + * @param {{ props: MyComponentProps }} p ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function expectLiteral(p) {} + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.errors.txt.diff new file mode 100644 index 0000000000..828eec824e --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.errors.txt.diff @@ -0,0 +1,28 @@ +--- old.expandoFunctionSymbolPropertyJs.errors.txt ++++ new.expandoFunctionSymbolPropertyJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /types.ts (0 errors) ==== ++ export const symb = Symbol(); ++ ++ export interface TestSymb { ++ (): void; ++ readonly [symb]: boolean; ++ } ++ ++==== /a.js (1 errors) ==== ++ import { symb } from "./types"; ++ ++ /** ++ * @returns {import("./types").TestSymb} ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function test() { ++ function inner() {} ++ inner[symb] = true; ++ return inner; ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.errors.txt.diff new file mode 100644 index 0000000000..0b5fc0d559 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.exportDefaultWithJSDoc2.errors.txt ++++ new.exportDefaultWithJSDoc2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(6,27): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== a.js (1 errors) ==== ++ /** ++ * A number, or a string containing a number. ++ * @typedef {(number|string)} NumberLike ++ */ ++ ++ export default /** @type {NumberLike[]} */([ ]); ++ ~~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++==== b.ts (0 errors) ==== ++ import A from './a' ++ A[0] \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt.diff new file mode 100644 index 0000000000..7863bc90bd --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.extendedUnicodePlaneIdentifiersJSDoc.errors.txt ++++ new.extendedUnicodePlaneIdentifiersJSDoc.errors.txt +@@= skipped -0, +0 lines =@@ +- ++file.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== file.js (2 errors) ==== ++ /** ++ * Adds ++ * @param {number} 𝑚 ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} 𝑀 ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function foo(𝑚, 𝑀) { ++ console.log(𝑀 + 𝑚); ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff index 4c2ce91c3f..577da8f609 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff @@ -2,47 +2,59 @@ +++ new.fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@= skipped -0, +0 lines =@@ -BaseB.js(2,24): error TS8004: Type parameter declarations can only be used in TypeScript files. ++BaseB.js(1,29): error TS8004: Type parameter declarations can only be used in TypeScript files. BaseB.js(2,25): error TS1005: ',' expected. ++BaseB.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(3,14): error TS2304: Cannot find name 'Class'. -BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. ++BaseB.js(4,24): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(4,25): error TS2304: Cannot find name 'Class'. -BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. -SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files. ++SubB.js(3,34): error TS8011: Type arguments can only be used in TypeScript files. ==== BaseA.js (0 errors) ==== -@@= skipped -13, +9 lines =@@ - import BaseA from './BaseA'; - export default class SubA extends BaseA { +@@= skipped -15, +15 lines =@@ } --==== BaseB.js (6 errors) ==== -+==== BaseB.js (3 errors) ==== + ==== BaseB.js (6 errors) ==== import BaseA from './BaseA'; ++ export default class B { - ~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS1005: ',' expected. _AClass: Class; ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2304: Cannot find name 'Class'. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor(AClass: Class) { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2304: Cannot find name 'Class'. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. this._AClass = AClass; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ++ ~~~~~ } --==== SubB.js (1 errors) ==== -+==== SubB.js (0 errors) ==== ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ==== SubB.js (1 errors) ==== import SubA from './SubA'; import BaseB from './BaseB'; export default class SubB extends BaseB { - ~~~~ --!!! error TS8011: Type arguments can only be used in TypeScript files. ++ ~~~~~~~~~~~~ + !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { - super(SubA); - } \ No newline at end of file + super(SubA); \ No newline at end of file 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..29aa38a8f2 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.importTypeResolutionJSDocEOF.errors.txt ++++ new.importTypeResolutionJSDocEOF.errors.txt +@@= skipped -0, +0 lines =@@ +- ++usage.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== interfaces.d.ts (0 errors) ==== ++ export interface Bar { ++ prop: string ++ } ++ ++==== usage.js (1 errors) ==== ++ /** @type {Bar} */ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ export let bar; ++ ++ /** @typedef {import('./interfaces').Bar} Bar */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt.diff new file mode 100644 index 0000000000..c2b419eda0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.jsDeclarationEmitDoesNotRenameImport.errors.txt ++++ new.jsDeclarationEmitDoesNotRenameImport.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(10,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== test/Test.js (0 errors) ==== ++ /** @module test/Test */ ++ class Test {} ++ export default Test; ++==== Test.js (0 errors) ==== ++ /** @module Test */ ++ class Test {} ++ export default Test; ++==== index.js (1 errors) ==== ++ import Test from './test/Test.js' ++ ++ /** ++ * @typedef {Object} Options ++ * @property {typeof import("./Test.js").default} [test] ++ */ ++ ++ class X extends Test { ++ /** ++ * @param {Options} options ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(options) { ++ super(); ++ if (options.test) { ++ this.test = new options.test(); ++ } ++ } ++ } ++ ++ export default X; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff new file mode 100644 index 0000000000..92d08d3c0b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff @@ -0,0 +1,47 @@ +--- old.jsDeclarationsInheritedTypes.errors.txt ++++ new.jsDeclarationsInheritedTypes.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(20,15): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(27,15): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (3 errors) ==== ++ /** ++ * @typedef A ++ * @property {string} a ++ */ ++ ++ /** ++ * @typedef B ++ * @property {number} b ++ */ ++ ++ class C1 { ++ /** ++ * @type {A} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ value; ++ } ++ ++ class C2 extends C1 { ++ /** ++ * @type {A} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ value; ++ } ++ ++ class C3 extends C1 { ++ /** ++ * @type {A & B} ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ value; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt.diff new file mode 100644 index 0000000000..944994c296 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt.diff @@ -0,0 +1,55 @@ +--- old.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt ++++ new.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(7,8): error TS8009: The '?' modifier can only be used in TypeScript files. ++index.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== 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 (2 errors) ==== ++ /** ++ * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit ++ */ ++ ++ export class NewAjax { ++ /** ++ * @param {LionRequestInit} [init] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ case5_unexpectedlyResolvesPathToNodeModules(init) {} ++ } ++ ++ /** ++ * @type {(init?: LionRequestInit) => void} ++ */ ++ // @ts-expect-error ++ NewAjax.prototype.case6_unexpectedlyResolvesPathToNodeModules; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff index aa131e44ee..4f2298a1c7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff @@ -3,10 +3,13 @@ @@= skipped -0, +0 lines =@@ - +enumDef.js(16,18): error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. ++index.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. +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(13,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(18,11): error TS2503: Cannot find namespace 'Host'. ++index.js(18,11): error TS8010: Type annotations can only be used in TypeScript files. + + +==== enumDef.js (1 errors) ==== @@ -30,11 +33,13 @@ +!!! error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. + x: 12 + } -+==== index.js (4 errors) ==== ++==== index.js (7 errors) ==== + var Other = {}; + Other.Cls = class { + /** + * @param {!Host.UserMetrics.Action} p ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ +!!! error TS2503: Cannot find namespace 'Host'. + */ @@ -50,6 +55,8 @@ + * @type {Host.UserMetrics.Bargh} + ~~~~ +!!! error TS2503: Cannot find namespace 'Host'. ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var x = "ok"; + @@ -57,6 +64,8 @@ + * @type {Host.UserMetrics.Blah} + ~~~~ +!!! error TS2503: Cannot find namespace 'Host'. ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var y = "ok"; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff index 708fd18a67..bb1a86e259 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff @@ -3,10 +3,13 @@ @@= skipped -0, +0 lines =@@ - +index.js(10,12): error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? ++index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(17,16): error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? ++usage.js(12,16): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== usage.js (0 errors) ==== ++==== usage.js (1 errors) ==== + const { Thing, useThing, cbThing } = require("./index"); + + useThing(Thing.a); @@ -19,13 +22,15 @@ + + cbThing(type => { + /** @type {LogEntry} */ ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const logEntry = { + time: Date.now(), + type, + }; + }); + -+==== index.js (2 errors) ==== ++==== index.js (4 errors) ==== + /** @enum {string} */ + const Thing = Object.freeze({ + a: "thing", @@ -38,6 +43,8 @@ + * @param {Thing} x + ~~~~~ +!!! error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function useThing(x) {} + @@ -45,6 +52,8 @@ + + /** + * @param {(x: Thing) => void} x ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~ +!!! error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? + */ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff index 4f27d9dc88..c468258a2b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff @@ -2,13 +2,24 @@ +++ new.jsExportMemberMergedWithModuleAugmentation.errors.txt @@= skipped -0, +0 lines =@@ -/index.ts(11,7): error TS2741: Property 'x' is missing in type '{ b: string; }' but required in type 'Abcde'. +- +- +-==== /test.js (0 errors) ==== +/index.ts(1,23): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. +/index.ts(3,16): error TS2671: Cannot augment module './test' because it resolves to a non-module entity. +/index.ts(11,10): error TS2749: 'Abcde' refers to a value, but is being used as a type here. Did you mean 'typeof Abcde'? - - - ==== /test.js (0 errors) ==== -@@= skipped -10, +12 lines =@@ ++/test.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /test.js (1 errors) ==== + class Abcde { + /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + x; + } + +@@= skipped -10, +15 lines =@@ Abcde }; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff index 135c21c283..ee041c4019 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff @@ -5,11 +5,18 @@ -/b.js(4,15): error TS2314: Generic type 'A' requires 1 type argument(s). -/b.js(8,15): error TS2314: Generic type 'A' requires 1 type argument(s). +/b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ++/b.js(9,16): error TS8011: Type arguments can only be used in TypeScript files. +/b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== /a.d.ts (0 errors) ==== -@@= skipped -12, +12 lines =@@ + declare class A { x: T; } + +-==== /b.js (3 errors) ==== ++==== /b.js (4 errors) ==== + class B extends A {} + ~ + !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new B().x; /** @augments A */ @@ -24,6 +31,8 @@ - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2314: Generic type 'A' requires 1 type argument(s). class D extends A {} ++ ~~ ++!!! error TS8011: Type arguments can only be used in TypeScript files. + ~ +!!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new D().x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt.diff new file mode 100644 index 0000000000..b1e51af630 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt.diff @@ -0,0 +1,71 @@ +--- old.jsFileAlternativeUseOfOverloadTag.errors.txt ++++ new.jsFileAlternativeUseOfOverloadTag.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsFileAlternativeUseOfOverloadTag.js(7,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileAlternativeUseOfOverloadTag.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileAlternativeUseOfOverloadTag.js(25,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileAlternativeUseOfOverloadTag.js(38,7): error TS8017: Signature declarations can only be used in TypeScript files. ++ ++ ++==== jsFileAlternativeUseOfOverloadTag.js (4 errors) ==== ++ // These are a few examples of existing alternative uses of @overload tag. ++ // They will not work as expected with our implementation, but we are ++ // trying to make sure that our changes do not result in any crashes here. ++ ++ const example1 = { ++ /** ++ * @overload Example1(value) ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * Creates Example1 ++ * @param value [String] ++ */ ++ constructor: function Example1(value, options) {}, ++ }; ++ ++ const example2 = { ++ /** ++ * Example 2 ++ * ++ * @overload Example2(value) ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * Creates Example2 ++ * @param value [String] ++ * @param secretAccessKey [String] ++ * @param sessionToken [String] ++ * @example Creates with string value ++ * const example = new Example(''); ++ * @overload Example2(options) ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * Creates Example2 ++ * @option options value [String] ++ * @example Creates with options object ++ * const example = new Example2({ ++ * value: '', ++ * }); ++ */ ++ constructor: function Example2() {}, ++ }; ++ ++ const example3 = { ++ /** ++ * @overload evaluate(options = {}, [callback]) ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * Evaluate something ++ * @note Something interesting ++ * @param options [map] ++ * @return [string] returns evaluation result ++ * @return [null] returns nothing if callback provided ++ * @callback callback function (error, result) ++ * If callback is provided it will be called with evaluation result ++ * @param error [Error] ++ * @param result [String] ++ * @see callback ++ */ ++ evaluate: function evaluate(options, callback) {}, ++ }; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff index ca83426250..c6d4d1e58e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff @@ -10,11 +10,16 @@ -!!! error TS5055: Cannot write file 'a.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. -==== a.js (2 errors) ==== -- abstract class c { ++a.js(1,19): error TS8009: The 'abstract' modifier can only be used in TypeScript files. ++ ++ ++==== a.js (1 errors) ==== + abstract class c { - ~~~~~~~~ -!!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. -- abstract x; ++ + abstract x; - ~~~~~~~~ --!!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. -- } -+ \ No newline at end of file ++ ~~~~~~~~~~~~ + !!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt.diff index 057a42bafe..d042e35af5 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt.diff @@ -3,13 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,1): error TS8009: The 'declare' modifier can only be used in TypeScript files. -- -- + a.js(1,1): error TS8009: The 'declare' modifier can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- declare var v; -- ~~~~~~~ --!!! error TS8009: The 'declare' modifier can only be used in TypeScript files. -+ \ No newline at end of file + ==== a.js (1 errors) ==== + declare var v; + ~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff index 6c10af799b..8d651c1cb1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff @@ -2,13 +2,15 @@ +++ new.jsFileCompilationConstructorOverloadSyntax.errors.txt @@= skipped -0, +0 lines =@@ -a.js(2,3): error TS8017: Signature declarations can only be used in TypeScript files. -- -- --==== a.js (1 errors) ==== -- class A { -- constructor(); ++a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. + + + ==== a.js (1 errors) ==== + class A { ++ + constructor(); - ~~~~~~~~~~~ --!!! error TS8017: Signature declarations can only be used in TypeScript files. -- } -- -+ \ No newline at end of file ++ ~~~~~~~~~~~~~~~~ + !!! error TS8017: Signature declarations can only be used in TypeScript files. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationEnumSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationEnumSyntax.errors.txt.diff index ae4611c2a0..e80e3cf99b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationEnumSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationEnumSyntax.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- enum E { } ++a.js(1,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + enum E { } - ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~~~~ + !!! error TS8006: 'enum' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt.diff index 60680cb98b..eecb0edc89 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt.diff @@ -3,13 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,1): error TS8003: 'export =' can only be used in TypeScript files. -- -- + a.js(1,1): error TS8003: 'export =' can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- export = b; -- ~~~~~~~~~~~ --!!! error TS8003: 'export =' can only be used in TypeScript files. -+ \ No newline at end of file + ==== a.js (1 errors) ==== + export = b; + ~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff index 0251a5ce1e..cdef364579 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff @@ -2,11 +2,12 @@ +++ new.jsFileCompilationFunctionOverloadSyntax.errors.txt @@= skipped -0, +0 lines =@@ -a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. -- -- --==== a.js (1 errors) ==== -- function foo(); ++a.js(1,1): error TS8017: Signature declarations can only be used in TypeScript files. + + + ==== a.js (1 errors) ==== + function foo(); - ~~~ --!!! error TS8017: Signature declarations can only be used in TypeScript files. -- -+ \ No newline at end of file ++ ~~~~~~~~~~~~~~~ + !!! error TS8017: Signature declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff index 05d36ec8a4..3f7a5f4ef8 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- class C implements D { } ++a.js(1,8): error TS8005: 'implements' clauses can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + class C implements D { } - ~~~~~~~~~~~~ --!!! error TS8005: 'implements' clauses can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~~~~~~~ + !!! error TS8005: 'implements' clauses can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationImportEqualsSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationImportEqualsSyntax.errors.txt.diff index 00077eac3c..d4a6f42276 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationImportEqualsSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationImportEqualsSyntax.errors.txt.diff @@ -3,13 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -- -- + a.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- import a = b; -- ~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ \ No newline at end of file + ==== a.js (1 errors) ==== + import a = b; + ~~~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff index 3b84fccbba..f854e7ee44 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- interface I { } ++a.js(1,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + interface I { } - ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~~~~~~~~~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff index f7e96404d2..62ea645dd7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff @@ -2,13 +2,15 @@ +++ new.jsFileCompilationMethodOverloadSyntax.errors.txt @@= skipped -0, +0 lines =@@ -a.js(2,3): error TS8017: Signature declarations can only be used in TypeScript files. -- -- --==== a.js (1 errors) ==== -- class A { -- foo(); ++a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. + + + ==== a.js (1 errors) ==== + class A { ++ + foo(); - ~~~ --!!! error TS8017: Signature declarations can only be used in TypeScript files. -- } -- -+ \ No newline at end of file ++ ~~~~~~~~ + !!! error TS8017: Signature declarations can only be used in TypeScript files. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationModuleSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationModuleSyntax.errors.txt.diff index c322194367..18ab189b20 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationModuleSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationModuleSyntax.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- module M { } ++a.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + module M { } - ~ --!!! error TS8006: 'module' declarations can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~~~~~~ + !!! error TS8006: 'module' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationNonNullAssertion.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationNonNullAssertion.errors.txt.diff deleted file mode 100644 index 49f06fda71..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationNonNullAssertion.errors.txt.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.jsFileCompilationNonNullAssertion.errors.txt -+++ new.jsFileCompilationNonNullAssertion.errors.txt -@@= skipped -0, +0 lines =@@ --/src/a.js(1,1): error TS8013: Non-null assertions can only be used in TypeScript files. -- -- --==== /src/a.js (1 errors) ==== -- 0! -- ~~ --!!! error TS8013: Non-null assertions can only be used in TypeScript files. -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalParameter.errors.txt.diff index f17694a5b4..e215a6941d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalParameter.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalParameter.errors.txt.diff @@ -3,13 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,13): error TS8009: The '?' modifier can only be used in TypeScript files. -- -- + a.js(1,13): error TS8009: The '?' modifier can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- function F(p?) { } -- ~ --!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ \ No newline at end of file + ==== a.js (1 errors) ==== + function F(p?) { } + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicParameterModifier.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicParameterModifier.errors.txt.diff index e09006c18e..b8b7d1b64d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicParameterModifier.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicParameterModifier.errors.txt.diff @@ -3,13 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,23): error TS8012: Parameter modifiers can only be used in TypeScript files. -- -- + a.js(1,23): error TS8012: Parameter modifiers can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- class C { constructor(public x) { }} -- ~~~~~~ --!!! error TS8012: Parameter modifiers can only be used in TypeScript files. -+ \ No newline at end of file + ==== a.js (1 errors) ==== + class C { constructor(public x) { }} + ~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff index 5e500bbd82..855fe20fb2 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- function F(): number { } ++a.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + function F(): number { } - ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.errors.txt.diff index 4ab5110bb2..cb5ca61282 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.errors.txt.diff @@ -8,10 +8,14 @@ -!!! error TS5055: Cannot write file 'a.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. -==== a.js (0 errors) ==== -- /** -- * @type {number} -- * @type {string} -- */ -- var v; -- -+ \ No newline at end of file ++a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (1 errors) ==== + /** + * @type {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @type {string} + */ + var v; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff index 9de5cd2c94..c164e98564 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- type a = b; ++a.js(1,1): error TS8008: Type aliases can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + type a = b; - ~ --!!! error TS8008: Type aliases can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~~~~~ + !!! error TS8008: Type aliases can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.types.diff deleted file mode 100644 index 920ee806f9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.types.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.jsFileCompilationTypeAliasSyntax.types -+++ new.jsFileCompilationTypeAliasSyntax.types -@@= skipped -1, +1 lines =@@ - - === a.js === - type a = b; -->a : b -+>a : error diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff index c5c94d57ca..bea94a7714 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff @@ -2,15 +2,15 @@ +++ new.jsFileCompilationTypeAssertions.errors.txt @@= skipped -0, +0 lines =@@ -/src/a.js(1,6): error TS8016: Type assertion expressions can only be used in TypeScript files. ++/src/a.js(1,5): error TS8016: Type assertion expressions can only be used in TypeScript files. /src/a.js(2,10): error TS17008: JSX element 'string' has no corresponding closing tag. /src/a.js(3,1): error TS1005: 'undefined; - ~~~~~~ - !!! error TS17008: JSX element 'string' has no corresponding closing tag. \ No newline at end of file + ~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeOfParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeOfParameter.errors.txt.diff index 5fd61d1e56..ba1b0a8d7f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeOfParameter.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeOfParameter.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- function F(a: number) { } ++a.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + function F(a: number) { } - ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff index d62372836f..3645a6d4bb 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- class C { } ++a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + class C { } - ~ --!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~~~~~~~~ + !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff index eeb9c0f857..126257198f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff @@ -2,11 +2,12 @@ +++ new.jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt @@= skipped -0, +0 lines =@@ -a.js(1,19): error TS8004: Type parameter declarations can only be used in TypeScript files. -- -- --==== a.js (1 errors) ==== -- const Bar = class {}; ++a.js(1,12): error TS8004: Type parameter declarations can only be used in TypeScript files. + + + ==== a.js (1 errors) ==== + const Bar = class {}; - ~ --!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -- -+ \ No newline at end of file ++ ~~~~~~~~~~~~ + !!! error TS8004: Type parameter declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff index 284305e5be..9638d0c1cf 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- function F() { } ++a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + function F() { } - ~ --!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~~~~~~~~~~~~~ + !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff index a1b6e6c83c..92f042dd59 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff @@ -8,8 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -- var v: () => number; ++a.js(1,7): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ + ==== a.js (1 errors) ==== + var v: () => number; - ~~~~~~~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -+ \ No newline at end of file ++ ~~~~~~~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff new file mode 100644 index 0000000000..903db52451 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff @@ -0,0 +1,110 @@ +--- old.jsFileFunctionOverloads.errors.txt ++++ new.jsFileFunctionOverloads.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsFileFunctionOverloads.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(12,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(27,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(29,17): error TS8004: Type parameter declarations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(34,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(41,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(48,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(51,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads.js(54,31): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== jsFileFunctionOverloads.js (15 errors) ==== ++ /** ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {number} x ++ * @returns {'number'} ++ */ ++ /** ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {string} x ++ * @returns {'string'} ++ */ ++ /** ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {boolean} x ++ * @returns {'boolean'} ++ */ ++ /** ++ * @param {unknown} x ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function getTypeName(x) { ++ return typeof x; ++ } ++ ++ /** ++ * @template T ++ * @param {T} x ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const identity = x => x; ++ ~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ /** ++ * @template T ++ * @template U ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {T[]} array ++ * @param {(x: T) => U[]} iterable ++ * @returns {U[]} ++ */ ++ /** ++ * @template T ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {T[][]} array ++ * @returns {T[]} ++ */ ++ /** ++ * @param {unknown[]} array ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {(x: unknown) => unknown} iterable ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {unknown[]} ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function flatMap(array, iterable = identity) { ++ /** @type {unknown[]} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const result = []; ++ for (let i = 0; i < array.length; i += 1) { ++ result.push(.../** @type {unknown[]} */(iterable(array[i]))); ++ ~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ } ++ return result; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff new file mode 100644 index 0000000000..5f9c151273 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff @@ -0,0 +1,105 @@ +--- old.jsFileFunctionOverloads2.errors.txt ++++ new.jsFileFunctionOverloads2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsFileFunctionOverloads2.js(3,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(11,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(25,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(27,17): error TS8004: Type parameter declarations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(32,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(37,5): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(41,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(42,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(43,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(46,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileFunctionOverloads2.js(49,31): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== jsFileFunctionOverloads2.js (15 errors) ==== ++ // Also works if all @overload tags are combined in one comment. ++ /** ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {number} x ++ * @returns {'number'} ++ * ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {string} x ++ * @returns {'string'} ++ * ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {boolean} x ++ * @returns {'boolean'} ++ * ++ * @param {unknown} x ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function getTypeName(x) { ++ return typeof x; ++ } ++ ++ /** ++ * @template T ++ * @param {T} x ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const identity = x => x; ++ ~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ /** ++ * @template T ++ * @template U ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {T[]} array ++ * @param {(x: T) => U[]} iterable ++ * @returns {U[]} ++ * ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {T[][]} array ++ * @returns {T[]} ++ * ++ * @param {unknown[]} array ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {(x: unknown) => unknown} iterable ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {unknown[]} ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function flatMap(array, iterable = identity) { ++ /** @type {unknown[]} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const result = []; ++ for (let i = 0; i < array.length; i += 1) { ++ result.push(.../** @type {unknown[]} */(iterable(array[i]))); ++ ~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ } ++ return result; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff new file mode 100644 index 0000000000..f092f3e52e --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.jsFileImportPreservedWhenUsed.errors.txt ++++ new.jsFileImportPreservedWhenUsed.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(6,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== dash.d.ts (0 errors) ==== ++ type ObjectIterator = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; ++ ++ interface LoDashStatic { ++ mapValues(obj: T | null | undefined, callback: ObjectIterator): { [P in keyof T]: TResult }; ++ } ++ declare const _: LoDashStatic; ++ export = _; ++==== Consts.ts (0 errors) ==== ++ export const INDEX_FIELD = '__INDEX'; ++==== index.js (2 errors) ==== ++ import * as _ from './dash'; ++ import { INDEX_FIELD } from './Consts'; ++ ++ export class Test { ++ /** ++ * @param {object} obj ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {object} vm ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ test(obj, vm) { ++ let index = 0; ++ vm.objects = _.mapValues( ++ obj, ++ object => ({ ...object, [INDEX_FIELD]: index++ }), ++ ); ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff new file mode 100644 index 0000000000..6cac563c55 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff @@ -0,0 +1,130 @@ +--- old.jsFileMethodOverloads.errors.txt ++++ new.jsFileMethodOverloads.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsFileMethodOverloads.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++jsFileMethodOverloads.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileMethodOverloads.js(13,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileMethodOverloads.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileMethodOverloads.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileMethodOverloads.js(31,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileMethodOverloads.js(36,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileMethodOverloads.js(40,6): error TS8009: The '?' modifier can only be used in TypeScript files. ++jsFileMethodOverloads.js(40,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== jsFileMethodOverloads.js (10 errors) ==== ++ /** ++ ~~~ ++ * @template T ++ ~~~~~~~~~~~~~~ ++ */ ++ ~~~ ++ class Example { ++ ~~~~~~~~~~~~~~~~ ++ /** ++ ~~~~~ ++ * @param {T} value ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~ ++ constructor(value) { ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ this.value = value; ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~ ++ ++ ++ /** ++ ~~~~~ ++ * @overload ++ ~~~~~~~~~~~~~~ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {Example} this ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ * @returns {'number'} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ */ ++ ~~~~~ ++ /** ++ ~~~~~ ++ * @overload ++ ~~~~~~~~~~~~~~ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {Example} this ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ * @returns {'string'} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ */ ++ ~~~~~ ++ /** ++ ~~~~~ ++ * @returns {string} ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~ ++ getTypeName() { ++ ~~~~~~~~~~~~~~~~~ ++ return typeof this.value; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~ ++ ++ ++ /** ++ ~~~~~ ++ * @template U ++ ~~~~~~~~~~~~~~~~ ++ * @overload ++ ~~~~~~~~~~~~~~ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {(y: T) => U} fn ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ * @returns {U} ++ ~~~~~~~~~~~~~~~~~ ++ */ ++ ~~~~~ ++ /** ++ ~~~~~ ++ * @overload ++ ~~~~~~~~~~~~~~ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @returns {T} ++ ~~~~~~~~~~~~~~~~~ ++ */ ++ ~~~~~ ++ /** ++ ~~~~~ ++ * @param {(y: T) => unknown} [fn] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {unknown} ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~ ++ transform(fn) { ++ ~~~~~~~~~~~~~~~~~ ++ return fn ? fn(this.value) : this.value; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff new file mode 100644 index 0000000000..41f2b1c550 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff @@ -0,0 +1,124 @@ +--- old.jsFileMethodOverloads2.errors.txt ++++ new.jsFileMethodOverloads2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsFileMethodOverloads2.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++jsFileMethodOverloads2.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileMethodOverloads2.js(14,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileMethodOverloads2.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileMethodOverloads2.js(22,16): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileMethodOverloads2.js(30,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileMethodOverloads2.js(34,7): error TS8017: Signature declarations can only be used in TypeScript files. ++jsFileMethodOverloads2.js(37,6): error TS8009: The '?' modifier can only be used in TypeScript files. ++jsFileMethodOverloads2.js(37,14): error TS8010: Type annotations can only be used in TypeScript files. ++jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== jsFileMethodOverloads2.js (10 errors) ==== ++ // Also works if all @overload tags are combined in one comment. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ /** ++ ~~~ ++ * @template T ++ ~~~~~~~~~~~~~~ ++ */ ++ ~~~ ++ class Example { ++ ~~~~~~~~~~~~~~~~ ++ /** ++ ~~~~~ ++ * @param {T} value ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~ ++ constructor(value) { ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ this.value = value; ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~ ++ ++ ++ /** ++ ~~~~~ ++ * @overload ++ ~~~~~~~~~~~~~~ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {Example} this ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ * @returns {'number'} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ * ++ ~~~~ ++ * @overload ++ ~~~~~~~~~~~~~~ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {Example} this ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ * @returns {'string'} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ * ++ ~~~~ ++ * @returns {string} ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~ ++ getTypeName() { ++ ~~~~~~~~~~~~~~~~~ ++ return typeof this.value; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~ ++ ++ ++ /** ++ ~~~~~ ++ * @template U ++ ~~~~~~~~~~~~~~~~ ++ * @overload ++ ~~~~~~~~~~~~~~ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {(y: T) => U} fn ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ * @returns {U} ++ ~~~~~~~~~~~~~~~~~ ++ * ++ ~~~~ ++ * @overload ++ ~~~~~~~~~~~~~~ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @returns {T} ++ ~~~~~~~~~~~~~~~~~ ++ * ++ ~~~~ ++ * @param {(y: T) => unknown} [fn] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {unknown} ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~ ++ transform(fn) { ++ ~~~~~~~~~~~~~~~~~ ++ return fn ? fn(this.value) : this.value; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff new file mode 100644 index 0000000000..3b6cb739f2 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff @@ -0,0 +1,43 @@ +--- old.jsFileMethodOverloads3.errors.txt ++++ new.jsFileMethodOverloads3.errors.txt +@@= skipped -0, +0 lines =@@ + /a.js(2,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. ++/a.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. + /a.js(7,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. +- +- +-==== /a.js (2 errors) ==== ++/a.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. ++/a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (6 errors) ==== + /** + * @overload + ~~~~~~~~ + !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {number} x + */ + +@@= skipped -13, +19 lines =@@ + * @overload + ~~~~~~~~ + !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {string} x + */ + + /** + * @param {string | number} x ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string | number} ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function id(x) { + return x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.errors.txt.diff new file mode 100644 index 0000000000..b245659244 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.errors.txt.diff @@ -0,0 +1,41 @@ +--- old.jsFileMethodOverloads5.errors.txt ++++ new.jsFileMethodOverloads5.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. ++/a.js(8,5): error TS8017: Signature declarations can only be used in TypeScript files. ++/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(16,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++/a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (5 errors) ==== ++ /** ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {string} a ++ * @return {void} ++ */ ++ ++ /** ++ * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ * @param {number} a ++ * @param {number} [b] ++ * @return {void} ++ */ ++ ++ /** ++ * @param {string | number} a ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} [b] ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export const foo = function (a, b) { } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.errors.txt.diff new file mode 100644 index 0000000000..bed5e16aaa --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.jsdocAccessEnumType.errors.txt ++++ new.jsdocAccessEnumType.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/b.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.ts (0 errors) ==== ++ export enum E { A } ++ ++==== /b.js (1 errors) ==== ++ import { E } from "./a"; ++ /** @type {E} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const e = E.A; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff index 7281d6f678..cc3246ab33 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff @@ -2,40 +2,70 @@ +++ new.jsdocArrayObjectPromiseImplicitAny.errors.txt @@= skipped -0, +0 lines =@@ - ++jsdocArrayObjectPromiseImplicitAny.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(23,13): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. +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(32,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseImplicitAny.js(37,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocArrayObjectPromiseImplicitAny.js (2 errors) ==== ++==== jsdocArrayObjectPromiseImplicitAny.js (14 errors) ==== + /** @type {Array} */ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var anyArray = [5]; + + /** @type {Array} */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var numberArray = [5]; + + /** + * @param {Array} arr ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {Array} ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function returnAnyArray(arr) { + return arr; + } + + /** @type {Promise} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var anyPromise = Promise.resolve(5); + + /** @type {Promise} */ ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var numberPromise = Promise.resolve(5); + + /** + * @param {Promise} pr ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {Promise} ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function returnAnyPromise(pr) { + return pr; + } + + /** @type {Object} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var anyObject = {valueOf: 1}; // not an error since assigning to any. + ~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type '() => Object'. @@ -43,11 +73,17 @@ + /** @type {Object} */ + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var paramedObject = {valueOf: 1}; + + /** + * @param {Object} obj ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {Object} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function returnAnyObject(obj) { + return obj; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff index 9f407cd4d4..25720fb184 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff @@ -1,25 +1,108 @@ --- old.jsdocArrayObjectPromiseNoImplicitAny.errors.txt +++ new.jsdocArrayObjectPromiseNoImplicitAny.errors.txt -@@= skipped -4, +4 lines =@@ +@@= skipped -0, +0 lines =@@ + jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS2314: Generic type 'Array' requires 1 type argument(s). ++jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseNoImplicitAny.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS2314: Generic type 'Array' requires 1 type argument(s). ++jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. + jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS2314: Generic type 'Array' requires 1 type argument(s). ++jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. + jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseNoImplicitAny.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseNoImplicitAny.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(30,21): error TS2322: Type 'number' is not assignable to type '() => Object'. - - -==== jsdocArrayObjectPromiseNoImplicitAny.js (7 errors) ==== +jsdocArrayObjectPromiseNoImplicitAny.js(32,12): error TS2315: Type 'Object' is not generic. ++jsdocArrayObjectPromiseNoImplicitAny.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseNoImplicitAny.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocArrayObjectPromiseNoImplicitAny.js(37,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocArrayObjectPromiseNoImplicitAny.js (8 errors) ==== ++==== jsdocArrayObjectPromiseNoImplicitAny.js (20 errors) ==== /** @type {Array} */ ~~~~~ !!! error TS2314: Generic type 'Array' requires 1 type argument(s). -@@= skipped -49, +50 lines =@@ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var notAnyArray = [5]; + + /** @type {Array} */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var numberArray = [5]; + + /** + * @param {Array} arr + ~~~~~ + !!! error TS2314: Generic type 'Array' requires 1 type argument(s). ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {Array} + ~~~~~ + !!! error TS2314: Generic type 'Array' requires 1 type argument(s). ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function returnNotAnyArray(arr) { + return arr; +@@= skipped -30, +51 lines =@@ + /** @type {Promise} */ + ~~~~~~~ + !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var notAnyPromise = Promise.resolve(5); + + /** @type {Promise} */ ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var numberPromise = Promise.resolve(5); + + /** + * @param {Promise} pr + ~~~~~~~ + !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {Promise} + ~~~~~~~ + !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function returnNotAnyPromise(pr) { + return pr; + } + + /** @type {Object} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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. ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var paramedObject = {valueOf: 1}; - /** \ No newline at end of file + /** + * @param {Object} obj ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {Object} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function returnNotAnyObject(obj) { + return obj; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff index 7c77099eea..1aa2da75f1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff @@ -3,10 +3,13 @@ @@= skipped -0, +0 lines =@@ -index.js(3,3): error TS2322: Type 'number' is not assignable to type 'string'. +index.js(12,14): error TS7006: Parameter 'arg' implicitly has an 'any' type. ++index.js(16,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(20,16): error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. -@@= skipped -5, +5 lines =@@ +-==== index.js (2 errors) ==== ++==== index.js (4 errors) ==== /** @type () => string */ function fn1() { return 42; @@ -15,7 +18,7 @@ } /** @type () => string */ -@@= skipped -11, +9 lines =@@ +@@= skipped -16, +16 lines =@@ /** @type (arg: string) => string */ function fn3(arg) { @@ -23,4 +26,15 @@ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. return arg; } - \ No newline at end of file + + /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const obj1 = { type: "foo", prop: 10 }; + + /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const obj2 = { type: "other", prop: 10 }; + ~~~~ + !!! error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff new file mode 100644 index 0000000000..0a96713e61 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.jsdocCallbackAndType.errors.txt ++++ new.jsdocCallbackAndType.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. + /a.js(8,3): error TS2554: Expected 0 arguments, but got 1. + + +-==== /a.js (1 errors) ==== ++==== /a.js (2 errors) ==== + /** + * @template T + * @callback B + */ + /** @type {B} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + let b; + b(); + b(1); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff new file mode 100644 index 0000000000..8ea24d9039 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.jsdocClassMissingTypeArguments.errors.txt ++++ new.jsdocClassMissingTypeArguments.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. + /a.js(4,13): error TS2314: Generic type 'C' requires 1 type argument(s). +- +- +-==== /a.js (1 errors) ==== ++/a.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (3 errors) ==== + /** @template T */ ++ ~~~~~~~~~~~~~~~~~~ + class C {} ++ ~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** @param {C} p */ + ~ + !!! error TS2314: Generic type 'C' requires 1 type argument(s). ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(p) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff index 829a61d7f4..7d066588a5 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff @@ -2,16 +2,22 @@ +++ new.jsdocFunctionClassPropertiesDeclaration.errors.txt @@= skipped -0, +0 lines =@@ - ++/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +/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 (4 errors) ==== ++==== /a.js (6 errors) ==== + /** + * @param {number | undefined} x ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number | undefined} y ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function Foo(x, y) { + if (!(this instanceof Foo)) { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff index 240506dd0b..2d137dc837 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff @@ -1,15 +1,15 @@ --- old.jsdocFunctionTypeFalsePositive.errors.txt +++ new.jsdocFunctionTypeFalsePositive.errors.txt @@= skipped -0, +0 lines =@@ ++/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. /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) ==== -+ -+ -+==== /a.js (1 errors) ==== + + + ==== /a.js (2 errors) ==== /** @param {<} x */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ~~ !!! error TS1098: Type parameter list cannot be empty. - ~ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff index 546850ee3c..ff0d004b6e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff @@ -2,15 +2,33 @@ +++ new.jsdocIllegalTags.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(2,19): error TS1092: Type parameters cannot appear on a constructor declaration. ++/a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. +/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) ==== +- +- +-==== /a.js (2 errors) ==== ++/a.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (4 errors) ==== class C { ++ /** @template T */ - ~ ++ ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~ !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor() { } - } \ No newline at end of file ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + } + class D { + /** @return {number} */ + ~~~~~~ + !!! error TS1093: Type annotation cannot appear on a constructor declaration. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff index 81bb094f22..7969e691dd 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff @@ -2,16 +2,22 @@ +++ new.jsdocImportTypeNodeNamespace.errors.txt @@= 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. ++Main.js(2,21): error TS8016: Type assertion expressions can only be used in TypeScript files. +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) ==== +@@= skipped -6, +7 lines =@@ + } + export default _default; + +-==== Main.js (1 errors) ==== ++==== Main.js (2 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. ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~ +!!! error TS2694: Namespace '"GeometryType"' has no exported member 'default'. } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.errors.txt.diff new file mode 100644 index 0000000000..b31360f39c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.jsdocImportTypeResolution.errors.txt ++++ new.jsdocImportTypeResolution.errors.txt +@@= skipped -0, +0 lines =@@ +- ++usage.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== module.js (0 errors) ==== ++ export class MyClass { ++ } ++ ++==== usage.js (1 errors) ==== ++ /** ++ * @typedef {Object} options ++ * @property {import("./module").MyClass} option ++ */ ++ /** @type {options} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ let v; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.errors.txt.diff new file mode 100644 index 0000000000..a0a3e3422b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.errors.txt.diff @@ -0,0 +1,15 @@ +--- old.jsdocParamTagOnPropertyInitializer.errors.txt ++++ new.jsdocParamTagOnPropertyInitializer.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class Foo { ++ /**@param {string} x */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ m = x => x.toLowerCase(); ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff index d1fab64b56..eed51b4985 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff @@ -8,9 +8,10 @@ - -==== example.js (3 errors) ==== +example.js(3,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++example.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== example.js (1 errors) ==== ++==== example.js (2 errors) ==== // @ts-check /** * @type {function(@foo)} @@ -23,5 +24,7 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ let x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff new file mode 100644 index 0000000000..e68cbd5c34 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.jsdocPropertyTagInvalid.errors.txt ++++ new.jsdocPropertyTagInvalid.errors.txt +@@= skipped -0, +0 lines =@@ + /a.js(3,15): error TS2552: Cannot find name 'sting'. Did you mean 'string'? +- +- +-==== /a.js (1 errors) ==== ++/a.js(6,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (2 errors) ==== + /** + * @typedef MyType + * @property {sting} [x] +@@= skipped -9, +10 lines =@@ + */ + + /** @param {MyType} p */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export function f(p) { } + + ==== /b.js (0 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt.diff new file mode 100644 index 0000000000..a3b9726c6f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.jsdocReferenceGlobalTypeInCommonJs.errors.txt ++++ new.jsdocReferenceGlobalTypeInCommonJs.errors.txt +@@= skipped -0, +0 lines =@@ ++a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + a.js(4,1): error TS2686: 'Puppeteer' refers to a UMD global, but the current file is a module. Consider adding an import instead. + + +-==== a.js (1 errors) ==== ++==== a.js (2 errors) ==== + const other = require('./other'); + /** @type {Puppeteer.Keyboard} */ ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var ppk; + Puppeteer.connect; + ~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff new file mode 100644 index 0000000000..be237bb963 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.jsdocResolveNameFailureInTypedef.errors.txt ++++ new.jsdocResolveNameFailureInTypedef.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + /a.js(7,14): error TS2304: Cannot find name 'CantResolveThis'. + + +-==== /a.js (1 errors) ==== ++==== /a.js (2 errors) ==== + /** + * @param {Ty} x ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(x) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff index 92e18b3433..ffde564d76 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff @@ -3,12 +3,21 @@ @@= 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 errors) ==== ++/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. +/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) ==== -@@= skipped -9, +9 lines =@@ ++ ++ ++==== /a.js (3 errors) ==== + /** @param {...number} a */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(a) { + a; // number | undefined + // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. arguments[0]; } f([1, 2]); // Error diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff new file mode 100644 index 0000000000..4f7a90eab8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff @@ -0,0 +1,15 @@ +--- old.jsdocRestParameter_es6.errors.txt ++++ new.jsdocRestParameter_es6.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ /** @param {...number} a */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ function f(...a) { ++ a; // number[] ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.errors.txt.diff new file mode 100644 index 0000000000..4e5cb4164b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.errors.txt.diff @@ -0,0 +1,47 @@ +--- old.jsdocTypeCast.errors.txt ++++ new.jsdocTypeCast.errors.txt +@@= skipped -0, +0 lines =@@ ++jsdocTypeCast.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocTypeCast.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. + jsdocTypeCast.js(6,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. ++jsdocTypeCast.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. + jsdocTypeCast.js(10,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. +- +- +-==== jsdocTypeCast.js (2 errors) ==== ++jsdocTypeCast.js(13,16): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocTypeCast.js(14,24): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== jsdocTypeCast.js (7 errors) ==== + /** + * @param {string} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(x) { + /** @type {'a' | 'b'} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + let a = (x); // Error + ~ + !!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. + a; + + /** @type {'a' | 'b'} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + let b = (((x))); // Error + ~ + !!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. + b; + + /** @type {'a' | 'b'} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + let c = /** @type {'a' | 'b'} */ (x); // Ok ++ ~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + c; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt.diff new file mode 100644 index 0000000000..0b72457a71 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.jsdocTypeGenericInstantiationAttempt.errors.txt ++++ new.jsdocTypeGenericInstantiationAttempt.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (1 errors) ==== ++ /** ++ * @param {Array<*>} list ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function thing(list) { ++ return list; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff index 2122f5ce56..afb3e4561a 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff @@ -1,53 +1,134 @@ --- old.jsdocTypeNongenericInstantiationAttempt.errors.txt +++ new.jsdocTypeNongenericInstantiationAttempt.errors.txt @@= skipped -0, +0 lines =@@ ++index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. 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. ++index2.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +index2.js(2,19): error TS2304: Cannot find name 'Void'. ++index3.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +index3.js(2,19): error TS2304: Cannot find name 'Undefined'. ++index4.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index4.js(2,19): error TS2315: Type 'Function' is not generic. ++index5.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index5.js(2,19): error TS2315: Type 'String' is not generic. ++index6.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index6.js(2,19): error TS2315: Type 'Number' is not generic. ++index7.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index7.js(2,19): error TS2315: Type 'Object' is not generic. +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,12): error TS8010: Type annotations can only be used in TypeScript files. index8.js(4,15): error TS2304: Cannot find name 'T'. -@@= skipped -20, +21 lines =@@ - ==== index2.js (1 errors) ==== +-==== index.js (1 errors) ==== ++==== index.js (2 errors) ==== + /** + * @param {(m: Boolean) => string} somebody ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~ + !!! error TS2315: Type 'Boolean' is not generic. + */ +@@= skipped -17, +28 lines =@@ + return 'Hello ' + somebody; + } + +-==== index2.js (1 errors) ==== ++==== index2.js (2 errors) ==== /** * @param {(m: Void) => string} somebody - ~~~~~~~ -!!! error TS2315: Type 'Void' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ +!!! error TS2304: Cannot find name 'Void'. */ function sayHello2(somebody) { return 'Hello ' + somebody; -@@= skipped -11, +11 lines =@@ - ==== index3.js (1 errors) ==== + } + + +-==== index3.js (1 errors) ==== ++==== index3.js (2 errors) ==== /** * @param {(m: Undefined) => string} somebody - ~~~~~~~~~~~~ -!!! error TS2315: Type 'Undefined' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'Undefined'. */ function sayHello3(somebody) { return 'Hello ' + somebody; -@@= skipped -51, +51 lines =@@ + } + + +-==== index4.js (1 errors) ==== ++==== index4.js (2 errors) ==== + /** + * @param {(m: Function) => string} somebody ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~ + !!! error TS2315: Type 'Function' is not generic. + */ +@@= skipped -33, +39 lines =@@ + } + + +-==== index5.js (1 errors) ==== ++==== index5.js (2 errors) ==== + /** + * @param {(m: String) => string} somebody ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~ + !!! error TS2315: Type 'String' is not generic. + */ +@@= skipped -11, +13 lines =@@ + } + + +-==== index6.js (1 errors) ==== ++==== index6.js (2 errors) ==== + /** + * @param {(m: Number) => string} somebody ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~ + !!! error TS2315: Type 'Number' is not generic. + */ +@@= skipped -11, +13 lines =@@ + } + + +-==== index7.js (1 errors) ==== ++==== index7.js (2 errors) ==== + /** + * @param {(m: Object) => string} somebody ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~ + !!! error TS2315: Type 'Object' is not generic. + */ +@@= skipped -10, +12 lines =@@ return 'Hello ' + somebody; } -==== index8.js (1 errors) ==== -+==== index8.js (2 errors) ==== ++==== index8.js (3 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 TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'T'. */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt.diff new file mode 100644 index 0000000000..da45ed1622 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.jsdocTypedefBeforeParenthesizedExpression.errors.txt ++++ new.jsdocTypedefBeforeParenthesizedExpression.errors.txt +@@= skipped -0, +0 lines =@@ +- ++test.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. ++test.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== test.js (2 errors) ==== ++ // @ts-check ++ /** @typedef {number} NotADuplicateIdentifier */ ++ ++ (2 * 2); ++ ++ /** @typedef {number} AlsoNotADuplicate */ ++ ++ (2 * 2) + 1; ++ ++ ++ /** ++ * ++ * @param a {NotADuplicateIdentifier} ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param b {AlsoNotADuplicate} ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function makeSureTypedefsAreStillRecognized(a, b) {} ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff index 9f75443651..e50cba3fb0 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff @@ -2,23 +2,22 @@ +++ new.jsdocTypedefMissingType.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(2,14): error TS8021: JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags. -- -- --==== /a.js (1 errors) ==== -- // Bad: missing a type -- /** @typedef T */ ++/a.js(12,11): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== /a.js (1 errors) ==== + // Bad: missing a type + /** @typedef T */ - ~ -!!! error TS8021: JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags. -- -- const t = 0; -- -- // OK: missing a type, but have property tags. -- /** -- * @typedef Person -- * @property {string} name -- */ -- -- /** @type Person */ -- const person = { name: "" }; -- -+ \ No newline at end of file + + const t = 0; + +@@= skipped -15, +13 lines =@@ + */ + + /** @type Person */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const person = { name: "" }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff index 4d78ec0273..78dd8fda10 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff @@ -7,16 +7,20 @@ - - -==== export.js (3 errors) ==== -- export type foo = 5; ++export.js(1,1): error TS8008: Type aliases can only be used in TypeScript files. ++ ++ ++==== export.js (1 errors) ==== + export type foo = 5; - ~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'foo'. - ~~~ --!!! error TS8008: Type aliases can only be used in TypeScript files. -- /** -- * @typedef {{ -- * }} -- */ -- export const foo = 5; ++ ~~~~~~~~~~~~~~~~~~~~ + !!! error TS8008: Type aliases can only be used in TypeScript files. + /** + * @typedef {{ + * }} + */ + export const foo = 5; - ~~~ --!!! error TS2451: Cannot redeclare block-scoped variable 'foo'. -+ \ No newline at end of file +-!!! error TS2451: Cannot redeclare block-scoped variable 'foo'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.errors.txt.diff new file mode 100644 index 0000000000..dd18112fc8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.jsdocTypedef_propertyWithNoType.errors.txt ++++ new.jsdocTypedef_propertyWithNoType.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ /** ++ * @typedef Foo ++ * @property foo ++ */ ++ ++ /** @type {Foo} */ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const x = { foo: 0 }; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/modulePreserve4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/modulePreserve4.errors.txt.diff index 85fd403b08..d419c08d61 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/modulePreserve4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/modulePreserve4.errors.txt.diff @@ -16,10 +16,11 @@ -/main3.cjs(1,13): error TS2305: Module '"./a"' has no exported member 'y'. -/main3.cjs(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +/main3.cjs(1,13): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. ++/main3.cjs(1,28): error TS8002: 'import ... =' can only be used in TypeScript files. /main3.cjs(5,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(8,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(10,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. -@@= skipped -18, +15 lines =@@ +@@= skipped -18, +16 lines =@@ /main3.cjs(17,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. @@ -58,21 +59,13 @@ import a1 = require("./a"); // { x: 0 } a1.x; a1.default.x; // Arguably should exist but doesn't -@@= skipped -33, +33 lines =@@ - import g1 from "./g"; // { default: 0 } - import g2 = require("./g"); // { default: 0 } - --==== /main3.cjs (9 errors) ==== -+==== /main3.cjs (8 errors) ==== - import { x, y } from "./a"; // No y +@@= skipped -38, +38 lines =@@ ~ !!! error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. ~ -!!! error TS2305: Module '"./a"' has no exported member 'y'. +!!! error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. ++ ~~~~~~~~ import a1 = require("./a"); // Error in JS -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - const a2 = require("./a"); // { x: 0 } - - import b1 from "./b"; // 0 \ No newline at end of file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt.diff new file mode 100644 index 0000000000..a5654f94dc --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt.diff @@ -0,0 +1,32 @@ +--- old.parenthesizedJSDocCastAtReturnStatement.errors.txt ++++ new.parenthesizedJSDocCastAtReturnStatement.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(10,23): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== index.js (4 errors) ==== ++ /** @type {Map>} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const cache = new Map() ++ ++ /** ++ * @param {string} key ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {() => string} ++ ~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const getStringGetter = (key) => { ++ return () => { ++ return /** @type {string} */ (cache.get(key)) ++ ~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt.diff new file mode 100644 index 0000000000..98af6fab20 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.parenthesizedJSDocCastDoesNotNarrow.errors.txt ++++ new.parenthesizedJSDocCastDoesNotNarrow.errors.txt +@@= skipped -0, +0 lines =@@ ++index.js(3,20): error TS8016: Type assertion expressions can only be used in TypeScript files. + index.js(12,8): error TS2678: Type '"invalid"' is not comparable to type '"bar" | "foo"'. + + +-==== index.js (1 errors) ==== ++==== index.js (2 errors) ==== + let value = ""; + + switch (/** @type {"foo" | "bar"} */ (value)) { ++ ~~~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + case "bar": + value; + break; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.errors.txt.diff new file mode 100644 index 0000000000..1ea0cfbc8b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.errors.txt.diff @@ -0,0 +1,33 @@ +--- old.requireOfJsonFileInJsFile.errors.txt ++++ new.requireOfJsonFileInJsFile.errors.txt +@@= skipped -0, +0 lines =@@ + /user.js(2,7): error TS2339: Property 'b' does not exist on type '{ a: number; }'. ++/user.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + /user.js(5,7): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. + /user.js(9,7): error TS2339: Property 'b' does not exist on type '{ a: number; }'. ++/user.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. + /user.js(12,7): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. + + +-==== /user.js (4 errors) ==== ++==== /user.js (6 errors) ==== + const json0 = require("./json.json"); + json0.b; // Error (good) + ~ + !!! error TS2339: Property 'b' does not exist on type '{ a: number; }'. + + /** @type {{ b: number }} */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const json1 = require("./json.json"); // No error (bad) + ~~~~~ + !!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. +@@= skipped -22, +26 lines =@@ + !!! error TS2339: Property 'b' does not exist on type '{ a: number; }'. + + /** @type {{ b: number }} */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const js1 = require("./js.js"); // Error (good) + ~~~ + !!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.errors.txt.diff new file mode 100644 index 0000000000..9dc164b446 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.returnConditionalExpressionJSDocCast.errors.txt ++++ new.returnConditionalExpressionJSDocCast.errors.txt +@@= skipped -0, +0 lines =@@ +- ++file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(10,23): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== file.js (4 errors) ==== ++ // Don't peek into conditional return expression if it's wrapped in a cast ++ /** @type {Map} */ ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const sources = new Map(); ++ /** ++ ++ * @param {string=} type the type of source that should be generated ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {String} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function source(type = "javascript") { ++ return /** @type {String} */ ( ++ ~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ type ++ ? sources.get(type) ++ : sources.get("some other thing") ++ ); ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff new file mode 100644 index 0000000000..c9e9bf5ab3 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff @@ -0,0 +1,35 @@ +--- old.strictOptionalProperties3.errors.txt ++++ new.strictOptionalProperties3.errors.txt +@@= skipped -0, +0 lines =@@ ++a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. + 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(13,12): error TS8010: Type annotations can only be used in TypeScript files. + a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. + Types of property 'value' are incompatible. + Type 'undefined' is not assignable to type 'number'. + + +-==== a.js (2 errors) ==== ++==== a.js (4 errors) ==== + /** + * @typedef {object} A + * @property {number} [value] + */ + + /** @type {A} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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. +@@= skipped -23, +27 lines =@@ + */ + + /** @type {B} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.errors.txt.diff new file mode 100644 index 0000000000..25a463580c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.strictOptionalProperties4.errors.txt ++++ new.strictOptionalProperties4.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(6,22): error TS8016: Type assertion expressions can only be used in TypeScript files. ++a.js(9,22): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== a.js (2 errors) ==== ++ /** ++ * @typedef Foo ++ * @property {number} [foo] ++ */ ++ ++ const x = /** @type {Foo} */ ({}); ++ ~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ x.foo; // number | undefined ++ ++ const y = /** @type {Required} */ ({}); ++ ~~~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ y.foo; // number ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.errors.txt.diff new file mode 100644 index 0000000000..4f58a67ca3 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.subclassThisTypeAssignable01.errors.txt ++++ new.subclassThisTypeAssignable01.errors.txt +@@= skipped -0, +0 lines =@@ ++file1.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. + 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'. +@@= skipped -57, +58 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 (2 errors) ==== + /** @type {ClassComponent} */ ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const test9 = new C(); + ~~~~~ + !!! error TS2322: Type 'C' is not assignable to type 'ClassComponent'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.errors.txt.diff new file mode 100644 index 0000000000..8ddee870c9 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.errors.txt.diff @@ -0,0 +1,42 @@ +--- old.subclassThisTypeAssignable02.errors.txt ++++ new.subclassThisTypeAssignable02.errors.txt +@@= skipped -0, +0 lines =@@ +- ++file1.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== tile1.ts (0 errors) ==== ++ interface Lifecycle> { ++ oninit?(vnode: Vnode): number; ++ [_: number]: any; ++ } ++ ++ interface Vnode> { ++ tag: Component; ++ } ++ ++ interface Component> { ++ view(this: State, vnode: Vnode): number; ++ } ++ ++ interface ClassComponent extends Lifecycle> { ++ oninit?(vnode: Vnode): number; ++ view(vnode: Vnode): number; ++ } ++ ++ interface MyAttrs { id: number } ++ class C implements ClassComponent { ++ view(v: Vnode) { return 0; } ++ ++ // Must declare a compatible-ish index signature or else ++ // we won't correctly implement ClassComponent. ++ [_: number]: unknown; ++ } ++ ++ const test8: ClassComponent = new C(); ++==== file1.js (1 errors) ==== ++ /** @type {ClassComponent} */ ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const test9 = new C(); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff index 4989352fd0..ad4992268d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff @@ -2,26 +2,36 @@ +++ new.thisAssignmentInNamespaceDeclaration1.errors.txt @@= skipped -0, +0 lines =@@ -a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. ++a.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. a.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. -b.js(1,11): error TS8006: 'namespace' declarations can only be used in TypeScript files. ++b.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. b.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. --==== a.js (2 errors) ==== -+==== a.js (1 errors) ==== + ==== a.js (2 errors) ==== module foo { - ~~~ -!!! error TS8006: 'module' declarations can only be used in TypeScript files. ++ ~~~~~~~~~~~~ this.bar = 4; ++ ~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2331: 'this' cannot be referenced in a module or namespace body. } ++ ~ ++!!! error TS8006: 'module' declarations can only be used in TypeScript files. --==== b.js (2 errors) ==== -+==== b.js (1 errors) ==== + ==== b.js (2 errors) ==== namespace blah { - ~~~~ -!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~ this.prop = 42; ++ ~~~~~~~~~~~~~~~~~~~ ~~~~ - !!! error TS2331: 'this' cannot be referenced in a module or namespace body. \ No newline at end of file + !!! error TS2331: 'this' cannot be referenced in a module or namespace body. + } ++ ~ ++!!! error TS8006: 'module' declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff new file mode 100644 index 0000000000..67f53ae10f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.thisInFunctionCallJs.errors.txt ++++ new.thisInFunctionCallJs.errors.txt +@@= skipped -0, +0 lines =@@ + /a.js(9,26): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + /a.js(15,31): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +- +- +-==== /a.js (2 errors) ==== ++/a.js(21,20): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(29,20): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (4 errors) ==== + class Test { + constructor() { + /** @type {number[]} */ +@@= skipped -29, +31 lines =@@ + forEacher() { + this.data.forEach( + /** @this {Test} */ ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function (d) { + console.log(d === this.data.length) + }, this) +@@= skipped -8, +10 lines =@@ + finder() { + this.data.find( + /** @this {Test} */ ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function (d) { + return d === this.data.length + }, this) \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.errors.txt.diff new file mode 100644 index 0000000000..f3c6207bd6 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.errors.txt.diff @@ -0,0 +1,51 @@ +--- old.topLevelBlockExpando.errors.txt ++++ new.topLevelBlockExpando.errors.txt +@@= skipped -0, +0 lines =@@ +- ++check.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== check.ts (0 errors) ==== ++ // https://github.com/microsoft/TypeScript/issues/31972 ++ interface Person { ++ first: string; ++ last: string; ++ } ++ ++ { ++ const dice = () => Math.floor(Math.random() * 6); ++ dice.first = 'Rando'; ++ dice.last = 'Calrissian'; ++ const diceP: Person = dice; ++ } ++ ++==== check.js (1 errors) ==== ++ // Creates a type { first:string, last: string } ++ /** ++ * @typedef {Object} Human - creates a new type named 'SpecialType' ++ * @property {string} first - a string property of SpecialType ++ * @property {string} last - a number property of SpecialType ++ */ ++ ++ /** ++ * @param {Human} param used as a validation tool ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function doHumanThings(param) {} ++ ++ const dice1 = () => Math.floor(Math.random() * 6); ++ // dice1.first = 'Rando'; ++ dice1.last = 'Calrissian'; ++ ++ // doHumanThings(dice) ++ ++ // but inside a block... you can't call a human ++ { ++ const dice2 = () => Math.floor(Math.random() * 6); ++ dice2.first = 'Rando'; ++ dice2.last = 'Calrissian'; ++ ++ doHumanThings(dice2) ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.errors.txt.diff new file mode 100644 index 0000000000..05df9bfb8d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.errors.txt.diff @@ -0,0 +1,35 @@ +--- old.unicodeEscapesInJSDoc.errors.txt ++++ new.unicodeEscapesInJSDoc.errors.txt +@@= skipped -0, +0 lines =@@ +- ++file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== file.js (4 errors) ==== ++ /** ++ * @param {number} \u0061 ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} a\u0061 ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function foo(a, aa) { ++ console.log(a + aa); ++ } ++ ++ /** ++ * @param {number} \u{0061} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} a\u{0061} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function bar(a, aa) { ++ console.log(a + aa); ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/uniqueSymbolJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/uniqueSymbolJs.errors.txt.diff index e97c2ce80f..ca6385bfcb 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/uniqueSymbolJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/uniqueSymbolJs.errors.txt.diff @@ -3,12 +3,21 @@ @@= skipped -0, +0 lines =@@ -a.js(5,18): error TS1337: An index signature parameter type cannot be a literal type or generic type. Consider using a mapped object type instead. -a.js(5,28): error TS1005: ';' expected. +- +- +-==== a.js (2 errors) ==== ++a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(5,18): error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type. ++a.js(5,22): error TS8010: Type annotations can only be used in TypeScript files. +a.js(5,23): error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? - - - ==== a.js (2 errors) ==== -@@= skipped -8, +8 lines =@@ ++ ++ ++==== a.js (4 errors) ==== + /** @type {unique symbol} */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const foo = Symbol(); + /** @typedef {{ [foo]: boolean }} A */ /** @typedef {{ [key: foo] boolean }} B */ ~~~ @@ -16,6 +25,8 @@ - ~~~~~~~ -!!! error TS1005: ';' expected. +!!! error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? \ No newline at end of file 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 d468294256..43bec4ecda 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.errors.txt.diff @@ -2,14 +2,21 @@ +++ new.unusedTypeParameters_templateTag.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(1,5): error TS6133: 'T' is declared but its value is never read. +- +- +-==== /a.js (1 errors) ==== ++/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +/a.js(1,15): error TS6196: 'T' is declared but never used. - - - ==== /a.js (1 errors) ==== ++ ++ ++==== /a.js (2 errors) ==== /** @template T */ - ~~~~~~~~~~~~ -!!! error TS6133: 'T' is declared but its value is never read. ++ ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS6196: 'T' is declared but never used. function f() {} ++ ~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file 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 d46e56aaf4..63757e8c80 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.errors.txt.diff @@ -8,61 +8,96 @@ - - -==== /a.js (4 errors) ==== ++/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +/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(10,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +/a.js(13,3): error TS6205: All type parameters are unused. ++/a.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +/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 (5 errors) ==== ++==== /a.js (8 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 TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ /** ++ ~~~ * @template T,V - ~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ */ - ~ ++ ~~~ + ~~ !!! error TS6205: All type parameters are unused. class C2 { ++ ~~~~~~~~~~ constructor() { } -@@= skipped -30, +34 lines =@@ ++ ~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ /** ++ ~~~ * @template T,V,X - ~ -!!! 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'. } - } \ No newline at end of file ++ ~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt.diff new file mode 100644 index 0000000000..1ebe130021 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.annotatedThisPropertyInitializerDoesntNarrow.errors.txt ++++ new.annotatedThisPropertyInitializerDoesntNarrow.errors.txt +@@= skipped -0, +0 lines =@@ +- ++Compilation.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. ++Compilation.js(7,33): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== Compilation.js (2 errors) ==== ++ // from webpack/lib/Compilation.js and filed at #26427 ++ /** @param {{ [s: string]: number }} map */ ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ function mappy(map) {} ++ ++ export class C { ++ constructor() { ++ /** @type {{ [assetName: string]: number}} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ this.assets = {}; ++ } ++ m() { ++ mappy(this.assets) ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff index dc36288ada..6c89461c88 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff @@ -2,10 +2,14 @@ +++ new.assertionTypePredicates2.errors.txt @@= skipped -0, +0 lines =@@ - ++assertionTypePredicates2.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++assertionTypePredicates2.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. ++assertionTypePredicates2.js(14,20): error TS8016: Type assertion expressions can only be used in TypeScript files. ++assertionTypePredicates2.js(19,16): error TS8010: Type annotations can only be used in TypeScript files. +assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. + + -+==== assertionTypePredicates2.js (1 errors) ==== ++==== assertionTypePredicates2.js (5 errors) ==== + /** + * @typedef {{ x: number }} A + */ @@ -16,15 +20,23 @@ + + /** + * @param {A} a ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns { asserts a is B } ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const foo = (a) => { + if (/** @type { B } */ (a).y !== 0) throw TypeError(); ++ ~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + return undefined; + }; + + export const main = () => { + /** @type { A } */ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const a = { x: 1 }; + foo(a); + ~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.errors.txt.diff new file mode 100644 index 0000000000..634f66cde6 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.errors.txt.diff @@ -0,0 +1,65 @@ +--- old.assertionsAndNonReturningFunctions.errors.txt ++++ new.assertionsAndNonReturningFunctions.errors.txt +@@= skipped -0, +0 lines =@@ ++assertionsAndNonReturningFunctions.js(1,22): error TS8010: Type annotations can only be used in TypeScript files. ++assertionsAndNonReturningFunctions.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++assertionsAndNonReturningFunctions.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. ++assertionsAndNonReturningFunctions.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. ++assertionsAndNonReturningFunctions.js(22,14): error TS8010: Type annotations can only be used in TypeScript files. ++assertionsAndNonReturningFunctions.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. + assertionsAndNonReturningFunctions.js(46,9): error TS7027: Unreachable code detected. ++assertionsAndNonReturningFunctions.js(51,12): error TS8010: Type annotations can only be used in TypeScript files. + assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code detected. + + +-==== assertionsAndNonReturningFunctions.js (2 errors) ==== ++==== assertionsAndNonReturningFunctions.js (9 errors) ==== + /** @typedef {(check: boolean) => asserts check} AssertFunc */ ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + /** @type {AssertFunc} */ ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const assert = check => { + if (!check) throw new Error(); + } +@@= skipped -16, +27 lines =@@ + + /** + * @param {boolean} check ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {asserts check} ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function assert2(check) { + if (!check) throw new Error(); +@@= skipped -8, +12 lines =@@ + + /** + * @returns {never} ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function fail() { + throw new Error(); +@@= skipped -7, +9 lines =@@ + + /** + * @param {*} x ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f1(x) { + if (!!true) { +@@= skipped -24, +26 lines =@@ + + /** + * @param {boolean} b ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f2(b) { + switch (b) { \ No newline at end of file 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 ec3ffa5a3a..edb5c095a2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.errors.txt.diff @@ -13,18 +13,25 @@ - -==== file.js (7 errors) ==== +file.js(2,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(6,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++file.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++file.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== file.js (5 errors) ==== ++==== file.js (10 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const a = () => 0 - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -36,6 +43,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const b = async () => 0 - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -47,6 +56,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const c = async () => { return 0 - ~~~~~~ @@ -60,6 +71,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const d = async () => { return "" } @@ -68,6 +81,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (p) => {} // Error (good) 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 5a82cdee21..474de3f39c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff @@ -8,34 +8,70 @@ - 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'. ++/a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. +/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(21,14): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(28,7): error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. + Type 'Promise' is not assignable to type 'string'. ++/a.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(34,14): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.d.ts (0 errors) ==== declare class Thenable { then(): void; } -==== /a.js (3 errors) ==== -+==== /a.js (2 errors) ==== ++==== /a.js (12 errors) ==== /** * @callback T1 * @param {string} str -@@= skipped -32, +28 lines =@@ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string} + */ + + /** + * @callback T2 + * @param {string} str ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {Promise} + */ + + /** + * @callback T3 + * @param {string} str ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {Thenable} + */ + + /** * @param {string} str ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @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. +!!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ const f1 = async str => { return str; - } +@@= skipped -40, +56 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. ++!!! error TS8010: Type annotations can only be used in TypeScript files. const f2 = async str => { + ~~ +!!! error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. @@ -43,16 +79,33 @@ return str; } -@@= skipped -28, +28 lines =@@ + /** + * @param {string} str ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {Promise} ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const f3 = async str => { + return str; + } + + /** @type {T2} */ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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'. ++!!! error TS8010: Type annotations can only be used in TypeScript files. const f5 = async str => { return str; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff index b3e507b55d..c099b6df53 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff @@ -2,13 +2,17 @@ +++ new.callbackCrossModule.errors.txt @@= skipped -0, +0 lines =@@ - ++mod1.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++use.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. +use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. + + -+==== mod1.js (1 errors) ==== ++==== mod1.js (2 errors) ==== + /** @callback Con - some kind of continuation + * @param {object | undefined} error ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {any} I don't even know what this should return + */ + module.exports = C @@ -18,8 +22,10 @@ + this.p = 1 + } + -+==== use.js (1 errors) ==== ++==== use.js (2 errors) ==== + /** @param {import('./mod1').Con} k */ ++ ~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace 'C' has no exported member 'Con'. + function f(k) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff index e019fdce7f..cbf709a09b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff @@ -2,15 +2,19 @@ +++ new.callbackOnConstructor.errors.txt @@= skipped -0, +0 lines =@@ - ++callbackOnConstructor.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. +callbackOnConstructor.js(12,12): error TS2304: Cannot find name 'ValueGetter_2'. ++callbackOnConstructor.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== callbackOnConstructor.js (1 errors) ==== ++==== callbackOnConstructor.js (3 errors) ==== + export class Preferences { + assignability = "no" + /** + * @callback ValueGetter_2 + * @param {string} name ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {boolean|number|string|undefined} + */ + constructor() {} @@ -20,5 +24,7 @@ + /** @type {ValueGetter_2} */ + ~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'ValueGetter_2'. ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var ooscope2 = s => s.length > 0 + \ No newline at end of file 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..98ca8b6b1c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.callbackTag1.errors.txt ++++ new.callbackTag1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++cb.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== cb.js (4 errors) ==== ++ /** @callback Sid ++ * @param {string} s ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {string} What were you expecting ++ */ ++ var x = 1 ++ ++ /** @type {Sid} smallId */ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ var sid = s => s + "!"; ++ ++ ++ /** @type {NoReturn} */ ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ var noreturn = obj => void obj.title ++ ++ /** ++ * @callback NoReturn ++ * @param {{ e: number, m: number, title: string }} s - Knee deep, shores, etc ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff index 9d44d496ef..cbfd600916 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff @@ -2,11 +2,42 @@ +++ new.callbackTag2.errors.txt @@= skipped -0, +0 lines =@@ -cb.js(18,29): error TS2304: Cannot find name 'S'. +- +- +-==== cb.js (1 errors) ==== ++cb.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. - - - ==== cb.js (1 errors) ==== -@@= skipped -19, +19 lines =@@ ++cb.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== cb.js (9 errors) ==== + /** @template T + * @callback Id + * @param {T} t ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} Maybe just return 120 and cast it? + */ + var x = 1 + + /** @type {Id} I actually wanted to write `const "120"` */ ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var one_twenty = s => "120"; + + /** @template S + * @callback SharedId + * @param {S} ego ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {S} + */ class SharedClass { constructor() { /** @type {SharedId} */ @@ -17,4 +48,28 @@ +!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. } } - /** @type {SharedId} */ \ No newline at end of file + /** @type {SharedId} */ ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var outside = n => n + 1; + + /** @type {Final<{ fantasy }, { heroes }>} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var noreturn = (barts, tidus, noctis) => "cecil" + + /** + * @template V,X + * @callback Final + * @param {V} barts - "Barts" ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {X} tidus - Titus ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {X & V} noctis - "Prince Noctis Lucius Caelum" ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {"cecil" | "zidane"} + */ + \ No newline at end of file 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..3791574a14 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.callbackTag3.errors.txt ++++ new.callbackTag3.errors.txt +@@= skipped -0, +0 lines =@@ +- ++cb.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== cb.js (1 errors) ==== ++ /** @callback Miracle ++ * @returns {string} What were you expecting ++ */ ++ /** @type {Miracle} smallId */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ var sid = () => "!"; ++ ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff new file mode 100644 index 0000000000..e6babd3e5c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff @@ -0,0 +1,33 @@ +--- old.callbackTag4.errors.txt ++++ new.callbackTag4.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (4 errors) ==== ++ /** ++ * @callback C ++ * @this {{ a: string, b: number }} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {string} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} b ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {boolean} ++ */ ++ ++ /** @type {C} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const cb = function (a, b) { ++ this ++ return true ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNamespace.errors.txt.diff new file mode 100644 index 0000000000..1d73615ec9 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNamespace.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.callbackTagNamespace.errors.txt ++++ new.callbackTagNamespace.errors.txt +@@= skipped -0, +0 lines =@@ +- ++namespaced.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++namespaced.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== namespaced.js (2 errors) ==== ++ /** ++ * @callback NS.Nested.Inner ++ * @param {Object} space - spaaaaaaaaace ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {Object} peace - peaaaaaaaaace ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @return {string | number} ++ */ ++ var x = 1; ++ /** @type {NS.Nested.Inner} */ ++ function f(space, peace) { ++ return '1' ++ } ++ \ No newline at end of file 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..198167dc08 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff @@ -0,0 +1,35 @@ +--- old.callbackTagNestedParameter.errors.txt ++++ new.callbackTagNestedParameter.errors.txt +@@= skipped -0, +0 lines =@@ +- ++cb_nested.js(4,4): error TS8010: Type annotations can only be used in TypeScript files. ++cb_nested.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++cb_nested.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== cb_nested.js (3 errors) ==== ++ /** ++ * @callback WorksWithPeopleCallback ++ * @param {Object} person ++ * @param {string} person.name ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ * @param {number} [person.age] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ * @returns {void} ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * For each person, calls your callback. ++ * @param {WorksWithPeopleCallback} callback ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {void} ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function eachPerson(callback) { ++ callback({ name: "Empty" }); ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff index 20cd34bc46..6c52576c61 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff @@ -2,17 +2,23 @@ +++ new.callbackTagVariadicType.errors.txt @@= skipped -0, +0 lines =@@ - ++callbackTagVariadicType.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++callbackTagVariadicType.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +callbackTagVariadicType.js(9,18): error TS2554: Expected 1 arguments, but got 2. + + -+==== callbackTagVariadicType.js (1 errors) ==== ++==== callbackTagVariadicType.js (3 errors) ==== + /** + * @callback Foo + * @param {...string} args ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number} + */ + + /** @type {Foo} */ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const x = () => 1 + var res = x('a', 'b') + ~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/chainedPrototypeAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/chainedPrototypeAssignment.errors.txt.diff index a22e977b2c..757dde1c6f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/chainedPrototypeAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/chainedPrototypeAssignment.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +0 lines =@@ -use.js(5,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -use.js(6,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. ++mod.js(11,17): error TS8010: Type annotations can only be used in TypeScript files. +use.js(3,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. +use.js(4,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. @@ -24,4 +25,19 @@ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. ==== types.d.ts (0 errors) ==== - declare function require(name: string): any; \ No newline at end of file + declare function require(name: string): any; + declare var exports: any; +-==== mod.js (0 errors) ==== ++==== mod.js (1 errors) ==== + /// + var A = function A() { + this.a = 1 +@@= skipped -28, +29 lines =@@ + exports.B = B + A.prototype = B.prototype = { + /** @param {number} n */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + m(n) { + return n + 1 + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignProperty.errors.txt.diff index 4d70a6774c..37c12f34b9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignProperty.errors.txt.diff @@ -14,18 +14,22 @@ - - -==== validator.ts (10 errors) ==== ++index.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(4,19): error TS2306: File 'mod1.js' is not a module. ++index.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(9,19): error TS2306: File 'mod2.js' is not a module. +mod1.js(1,23): error TS2304: Cannot find name 'exports'. +mod1.js(2,23): error TS2304: Cannot find name 'exports'. +mod1.js(3,23): error TS2304: Cannot find name 'exports'. +mod1.js(4,23): error TS2304: Cannot find name 'exports'. +mod1.js(5,23): error TS2304: Cannot find name 'exports'. ++mod1.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. +mod2.js(1,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +mod2.js(2,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +mod2.js(3,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +mod2.js(4,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +mod2.js(5,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++mod2.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. +validator.ts(3,21): error TS2306: File 'mod1.js' is not a module. +validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. + @@ -39,7 +43,7 @@ m1.thing; m1.readonlyProp; -@@= skipped -27, +33 lines =@@ +@@= skipped -27, +37 lines =@@ // disallowed assignments m1.readonlyProp = "name"; @@ -84,7 +88,7 @@ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -==== mod1.js (0 errors) ==== -+==== mod1.js (5 errors) ==== ++==== mod1.js (6 errors) ==== Object.defineProperty(exports, "thing", { value: 42, writable: true }); + ~~~~~~~ +!!! error TS2304: Cannot find name 'exports'. @@ -101,13 +105,15 @@ + ~~~~~~~ +!!! error TS2304: Cannot find name 'exports'. /** @param {string} str */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } }); -==== mod2.js (0 errors) ==== -+==== mod2.js (5 errors) ==== ++==== mod2.js (6 errors) ==== Object.defineProperty(module.exports, "thing", { value: "yes", writable: true }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -124,15 +130,19 @@ + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @param {string} str */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } }); -==== index.js (0 errors) ==== -+==== index.js (2 errors) ==== ++==== index.js (4 errors) ==== /** * @type {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ const q = require("./mod1").thing; + ~~~~~~~~ @@ -140,6 +150,8 @@ /** * @type {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ const u = require("./mod2").thing; + ~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt.diff index e79888a53e..5e23b33612 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt.diff @@ -9,7 +9,9 @@ - - -==== validator.ts (5 errors) ==== ++mod1.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +mod1.js(6,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. ++mod1.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. +validator.ts(5,12): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. + + @@ -24,7 +26,7 @@ m1.thing; m1.readonlyProp; -@@= skipped -24, +23 lines =@@ +@@= skipped -24, +25 lines =@@ // disallowed assignments m1.readonlyProp = "name"; @@ -47,10 +49,12 @@ -==== mod1.js (0 errors) ==== + + -+==== mod1.js (1 errors) ==== ++==== mod1.js (3 errors) ==== /** * @constructor * @param {string} name ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Person(name) { this.name = name; @@ -58,4 +62,13 @@ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. } Person.prototype.describe = function () { - return "Person called " + this.name; \ No newline at end of file + return "Person called " + this.name; +@@= skipped -33, +27 lines =@@ + Object.defineProperty(Person.prototype, "readonlyAccessor", { get() { return 21.75 } }); + Object.defineProperty(Person.prototype, "setonlyAccessor", { + /** @param {string} str */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set(str) { + this.rwAccessors = Number(str) + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.errors.txt.diff new file mode 100644 index 0000000000..4427020e7e --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.checkJsdocOptionalParamOrder.errors.txt ++++ new.checkJsdocOptionalParamOrder.errors.txt +@@= skipped -0, +0 lines =@@ ++0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. + 0.js(7,20): error TS1016: A required parameter cannot follow an optional parameter. + + +-==== 0.js (1 errors) ==== ++==== 0.js (5 errors) ==== + // @ts-check + /** + * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} [b] ++ ~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} c ++ ~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo(a, b, c) {} + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt.diff index ff12ecfbcb..55ed41719b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt.diff @@ -5,23 +5,38 @@ - - -==== 0.js (1 errors) ==== -- // @ts-check -- /** -- * @param {number=} n -- * @param {string} [s] -- */ -- var x = function foo(n, s) {} -- var y; -- /** -- * @param {boolean!} b -- */ -- y = function bar(b) {} -- -- /** -- * @param {string} s ++0.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== 0.js (5 errors) ==== + // @ts-check + /** + * @param {number=} n ++ ~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} [s] ++ ~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var x = function foo(n, s) {} + var y; +@@= skipped -15, +28 lines =@@ + + /** + * @param {string} s - ~ -!!! error TS8024: JSDoc '@param' tag has name 's', but there is no parameter with that name. -- */ -- var one = function (s) { }, two = function (untyped) { }; -- -+ \ No newline at end of file ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var one = function (s) { }, two = function (untyped) { }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.errors.txt.diff new file mode 100644 index 0000000000..a923bbcb6e --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.checkJsdocParamTag1.errors.txt ++++ new.checkJsdocParamTag1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++0.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== 0.js (4 errors) ==== ++ // @ts-check ++ /** ++ * @param {number=} n ++ ~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {string} [s] ++ ~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function foo(n, s) {} ++ ++ foo(); ++ foo(1); ++ foo(1, "hi"); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.errors.txt.diff new file mode 100644 index 0000000000..a95dc40e2d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.checkJsdocReturnTag1.errors.txt ++++ new.checkJsdocReturnTag1.errors.txt +@@= skipped -0, +0 lines =@@ ++returns.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. ++returns.js(10,14): error TS8010: Type annotations can only be used in TypeScript files. ++returns.js(17,14): error TS8010: Type annotations can only be used in TypeScript files. + returns.js(20,12): error TS2872: This kind of expression is always truthy. + + +-==== returns.js (1 errors) ==== ++==== returns.js (4 errors) ==== + // @ts-check + /** + * @returns {string} This comment is not currently exposed ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f() { + return "hello"; +@@= skipped -11, +16 lines =@@ + + /** + * @returns {string=} This comment is not currently exposed ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f1() { + return "hello world"; +@@= skipped -7, +9 lines =@@ + + /** + * @returns {string|number} This comment is not currently exposed ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f2() { + return 5 || "hello"; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.errors.txt.diff new file mode 100644 index 0000000000..0b664b3a2c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.checkJsdocReturnTag2.errors.txt ++++ new.checkJsdocReturnTag2.errors.txt +@@= skipped -0, +0 lines =@@ ++returns.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. + returns.js(6,5): error TS2322: Type 'number' is not assignable to type 'string'. ++returns.js(10,14): error TS8010: Type annotations can only be used in TypeScript files. + 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 (5 errors) ==== + // @ts-check + /** + * @returns {string} This comment is not currently exposed ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f() { + return 5; +@@= skipped -16, +20 lines =@@ + + /** + * @returns {string | number} This comment is not currently exposed ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f1() { + return 5 || true; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff index ade10090ef..7f95c17eac 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff @@ -1,14 +1,47 @@ --- old.checkJsdocSatisfiesTag1.errors.txt +++ new.checkJsdocSatisfiesTag1.errors.txt @@= skipped -0, +0 lines =@@ ++/a.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(20,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++/a.js(21,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(21,44): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. -/a.js(22,17): error TS1360: Type '{}' does not satisfy the expected type 'T1'. - Property 'a' is missing in type '{}' but required in type 'T1'. ++/a.js(22,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/a.js(22,38): error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. ++/a.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(25,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++/a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(28,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++/a.js(29,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++/a.js(30,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++/a.js(31,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(31,49): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. -@@= skipped -28, +27 lines =@@ +-==== /a.js (3 errors) ==== ++==== /a.js (14 errors) ==== + /** + * @typedef {Object} T1 + * @property {number} a +@@= skipped -16, +26 lines =@@ + + /** + * @typedef {(x: string) => string} T3 ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + /** +@@= skipped -8, +10 lines =@@ + */ + + const t1 = /** @satisfies {T1} */ ({ a: 1 }); ++ ~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); ++ ~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ~ !!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. const t3 = /** @satisfies {T1} */ ({}); @@ -16,9 +49,34 @@ -!!! error TS1360: Type '{}' does not satisfy the expected type 'T1'. -!!! error TS1360: Property 'a' is missing in type '{}' but required in type 'T1'. -!!! related TS2728 /a.js:3:4: 'a' is declared here. ++ ~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + ~ +!!! error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. +!!! related TS2728 /a.js:3:23: 'a' is declared here. /** @type {T2} */ - const t4 = /** @satisfies {T2} */ ({ a: "a" }); \ No newline at end of file ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const t4 = /** @satisfies {T2} */ ({ a: "a" }); ++ ~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + /** @type {(m: string) => string} */ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const t5 = /** @satisfies {T3} */((m) => m.substring(0)); ++ ~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + const t6 = /** @satisfies {[number, number]} */ ([1, 2]); ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + const t7 = /** @satisfies {T4} */ ({ a: 'test' }); ++ ~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); ++ ~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + ~ + !!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff new file mode 100644 index 0000000000..552bbff342 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.checkJsdocSatisfiesTag10.errors.txt ++++ new.checkJsdocSatisfiesTag10.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + /a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. + /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. + + +-==== /a.js (2 errors) ==== ++==== /a.js (3 errors) ==== + /** @typedef {"a" | "b" | "c" | "d"} Keys */ + + const p = /** @satisfies {Partial>} */ ({ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + a: 0, + b: "hello", + x: 8 // Should error, 'x' isn't in 'Keys' \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.errors.txt.diff index 4d4c0fe983..437e623ed0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.errors.txt.diff @@ -6,29 +6,28 @@ - - -==== /a.js (2 errors) ==== -- /** -- * @typedef {Object} T1 -- * @property {number} a -- */ -- -- /** -- * @typedef {Object} T2 -- * @property {number} a -- */ -- -- /** -- * @satisfies {T1} -- * @satisfies {T2} ++/a.js(20,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== + /** + * @typedef {Object} T1 + * @property {number} a +@@= skipped -15, +14 lines =@@ + /** + * @satisfies {T1} + * @satisfies {T2} - ~~~~~~~~~ -!!! error TS1223: 'satisfies' tag already specified. -- */ -- const t1 = { a: 1 }; -- -- /** -- * @satisfies {number} + */ + const t1 = { a: 1 }; + + /** + * @satisfies {number} - ~~~~~~~~~ -!!! error TS1223: 'satisfies' tag already specified. -- */ -- const t2 = /** @satisfies {number} */ (1); -- -+ \ No newline at end of file + */ + const t2 = /** @satisfies {number} */ (1); ++ ~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.errors.txt.diff index 85c8c13099..a72f22e5e8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.errors.txt.diff @@ -8,23 +8,27 @@ - - -==== /a.js (4 errors) ==== -- /** -- * @typedef {Object} T1 -- * @property {number} a -- */ -- -- /** -- * @satisfies T1 ++/a.js(10,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== + /** + * @typedef {Object} T1 + * @property {number} a +@@= skipped -11, +8 lines =@@ + + /** + * @satisfies T1 - ~~ -!!! error TS1005: '{' expected. -- */ + */ - -!!! error TS1005: '}' expected. -- const t1 = { a: 1 }; -- const t2 = /** @satisfies T1 */ ({ a: 1 }); -- ~~ + const t1 = { a: 1 }; + const t2 = /** @satisfies T1 */ ({ a: 1 }); + ~~ -!!! error TS1005: '{' expected. - -!!! error TS1005: '}' expected. -- -+ \ No newline at end of file ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff index 2c074193e1..4246c5e64a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff @@ -4,16 +4,22 @@ - +/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,34): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + -+==== /a.js (2 errors) ==== ++==== /a.js (4 errors) ==== + /** @typedef {Object. boolean>} Predicates */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + const p = /** @satisfies {Predicates} */ ({ ++ ~~~~~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + 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 new file mode 100644 index 0000000000..54be4714bc --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.checkJsdocSatisfiesTag3.errors.txt ++++ new.checkJsdocSatisfiesTag3.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(2,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + /a.js(3,7): error TS7006: Parameter 's' implicitly has an 'any' type. +- +- +-==== /a.js (1 errors) ==== ++/a.js(8,17): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++ ++ ++==== /a.js (4 errors) ==== + /** @type {{ f(s: string): void } & Record }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + f(s) { }, // "incorrect" implicit any on 's' + ~ + !!! error TS7006: Parameter 's' implicitly has an 'any' type. +@@= skipped -11, +18 lines =@@ + + // This needs to not crash (outer node is not expression) + /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff index 50185c3ada..4a61a052be 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff @@ -3,11 +3,17 @@ @@= skipped -0, +0 lines =@@ -/a.js(5,21): error TS1360: Type '{}' does not satisfy the expected type 'Foo'. - Property 'a' is missing in type '{}' but required in type 'Foo'. +- +- +-==== /a.js (1 errors) ==== ++/a.js(5,32): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/a.js(5,43): error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. - - - ==== /a.js (1 errors) ==== -@@= skipped -7, +6 lines =@@ ++/b.js(6,32): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++ ++ ++==== /a.js (2 errors) ==== + /** + * @typedef {Object} Foo * @property {number} a */ export default /** @satisfies {Foo} */ ({}); @@ -15,9 +21,19 @@ -!!! error TS1360: Type '{}' does not satisfy the expected type 'Foo'. -!!! error TS1360: Property 'a' is missing in type '{}' but required in type 'Foo'. -!!! related TS2728 /a.js:3:4: 'a' is declared here. ++ ~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + ~ +!!! error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. +!!! related TS2728 /a.js:3:23: 'a' is declared here. - ==== /b.js (0 errors) ==== - /** \ No newline at end of file +-==== /b.js (0 errors) ==== ++==== /b.js (1 errors) ==== + /** + * @typedef {Object} Foo + * @property {number} a + */ + + export default /** @satisfies {Foo} */ ({ a: 1 }); ++ ~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.errors.txt.diff new file mode 100644 index 0000000000..ea1d84e592 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.checkJsdocSatisfiesTag5.errors.txt ++++ new.checkJsdocSatisfiesTag5.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(1,31): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(3,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++ ++ ++==== /a.js (2 errors) ==== ++ /** @typedef {{ move(distance: number): void }} Movable */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ++ const car = /** @satisfies {Movable & Record} */ ({ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ++ start() { }, ++ move(d) { ++ // d should be number ++ }, ++ stop() { } ++ }) ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.errors.txt.diff new file mode 100644 index 0000000000..2134c5aaed --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.checkJsdocSatisfiesTag6.errors.txt ++++ new.checkJsdocSatisfiesTag6.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(8,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + /a.js(14,11): error TS2339: Property 'y' does not exist on type '{ x: number; }'. + + +-==== /a.js (1 errors) ==== ++==== /a.js (2 errors) ==== + /** + * @typedef {Object} Point2d + * @property {number} x +@@= skipped -9, +10 lines =@@ + + // Undesirable behavior today with type annotation + const a = /** @satisfies {Partial} */ ({ x: 10 }); ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + // Should OK + console.log(a.x.toFixed()); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff new file mode 100644 index 0000000000..dce7c70e7a --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.checkJsdocSatisfiesTag7.errors.txt ++++ new.checkJsdocSatisfiesTag7.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + /a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. + /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. + + +-==== /a.js (2 errors) ==== ++==== /a.js (3 errors) ==== + /** @typedef {"a" | "b" | "c" | "d"} Keys */ + + const p = /** @satisfies {Record} */ ({ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + a: 0, + b: "hello", + x: 8 // Should error, 'x' isn't in 'Keys' \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff index f18376a34a..19e89d0d8f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff @@ -7,9 +7,10 @@ -==== /a.js (1 errors) ==== +/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(4,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + -+==== /a.js (2 errors) ==== ++==== /a.js (3 errors) ==== /** @typedef {Object.} Facts */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. @@ -18,6 +19,8 @@ // Should be able to detect a failure here const x = /** @satisfies {Facts} */ ({ ++ ~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. m: true, s: "false" - ~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff new file mode 100644 index 0000000000..fec2ac3ee2 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.checkJsdocSatisfiesTag9.errors.txt ++++ new.checkJsdocSatisfiesTag9.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(9,40): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + /a.js(11,26): error TS2353: Object literal may only specify known properties, and 'd' does not exist in type 'Color'. + + +-==== /a.js (1 errors) ==== ++==== /a.js (2 errors) ==== + /** + * @typedef {Object} Color + * @property {number} r +@@= skipped -10, +11 lines =@@ + + // All of these should be Colors, but I only use some of them here. + export const Palette = /** @satisfies {Record} */ ({ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + white: { r: 255, g: 255, b: 255 }, + black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff index 886d602488..44250ba884 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff @@ -5,23 +5,58 @@ - - -==== 0.js (1 errors) ==== ++0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(20,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(24,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(28,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(33,11): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(38,11): error TS8010: Type annotations can only be used in TypeScript files. +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 (4 errors) ==== ++==== 0.js (14 errors) ==== // @ts-check /** @type {String} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var S = "hello world"; -@@= skipped -21, +24 lines =@@ + + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = 10; + + /** @type {*} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var anyT = 2; + anyT = "hello"; + + /** @type {?} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var anyT1 = 2; + anyT1 = "hi"; + + /** @type {Function} */ ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const y = (a) => a + 1; y(1); @@ -31,6 +66,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const x1 = (a) => a + 1; x1(0); @@ -38,11 +75,22 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const x2 = (a) => a + 1; x2(0); -@@= skipped -22, +29 lines =@@ + /** + * @type {object} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var props = {}; + + /** * @type {Object} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ var props = {}; + ~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff index 6b72170b6d..a1d9902555 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff @@ -2,7 +2,9 @@ +++ new.checkJsdocTypeTag2.errors.txt @@= skipped -0, +0 lines =@@ -0.js(3,5): error TS2322: Type 'boolean' is not assignable to type 'string'. ++0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(3,5): error TS2322: Type 'boolean' is not assignable to type 'String'. ++0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -13,22 +15,31 @@ - -==== 0.js (7 errors) ==== +0.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(12,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(23,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++0.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== 0.js (6 errors) ==== ++==== 0.js (13 errors) ==== // @ts-check /** @type {String} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var S = true; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. +!!! error TS2322: Type 'boolean' is not assignable to type 'String'. /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var n = "hello"; -@@= skipped -19, +18 lines =@@ + ~ !!! error TS2322: Type 'string' is not assignable to type 'number'. /** @type {function (number)} */ @@ -37,6 +48,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const x1 = (a) => a + 1; x1("string"); - ~~~~~~~~ @@ -46,9 +59,13 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const x2 = (a) => a + 1; /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var a; a = x2(0); - ~ @@ -58,6 +75,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const x3 = (a) => a.concat("hi"); - ~~~~~~ -!!! error TS2339: Property 'concat' does not exist on type 'number'. @@ -67,6 +86,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const x4 = (a) => a + 1; - ~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.errors.txt.diff new file mode 100644 index 0000000000..f9ebd17be1 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.errors.txt.diff @@ -0,0 +1,13 @@ +--- old.checkJsdocTypeTag3.errors.txt ++++ new.checkJsdocTypeTag3.errors.txt +@@= skipped -0, +0 lines =@@ +- ++test.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== test.js (1 errors) ==== ++ /** @type {Array} */ ++ ~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ var nns; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff new file mode 100644 index 0000000000..34487090d5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.checkJsdocTypeTag4.errors.txt ++++ new.checkJsdocTypeTag4.errors.txt +@@= skipped -0, +0 lines =@@ ++test.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. + test.js(5,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. ++test.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. + 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 (2 errors) ==== ++==== test.js (4 errors) ==== + /** Also should error for jsdoc typedefs + * @template {string} U + * @typedef {{ b: U }} B + */ + /** @type {A} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ + !!! error TS2344: Type 'number' does not satisfy the constraint 'string'. + var a; + /** @type {B} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ + !!! error TS2344: Type 'number' does not satisfy the constraint 'string'. + var b; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff index c6f159b314..fddb797705 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff @@ -2,34 +2,47 @@ +++ new.checkJsdocTypeTag5.errors.txt @@= skipped -0, +0 lines =@@ -test.js(3,17): error TS2322: Type 'number' is not assignable to type 'string'. ++test.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. 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(6,12): error TS8010: Type annotations can only be used in TypeScript files. +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(11,12): error TS8010: Type annotations can only be used in TypeScript files. 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(13,12): error TS8010: Type annotations can only be used in TypeScript files. +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(17,18): error TS8010: Type annotations can only be used in TypeScript files. ++test.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. +test.js(24,5): error TS2322: Type 'number' is not assignable to type '0 | 1 | 2'. ++test.js(26,19): error TS8010: Type annotations can only be used in TypeScript files. ++test.js(26,39): error TS8010: Type annotations can only be used in TypeScript files. ++test.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. 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) ==== -+==== test.js (6 errors) ==== ++==== test.js (15 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} */ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. 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} */ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var g = function (x) { return x } - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -42,11 +55,15 @@ - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. /** @type {{ (x: number): string }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. 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 }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var k = function (x) { return x } - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -56,18 +73,36 @@ /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ -@@= skipped -45, +45 lines =@@ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Argle} */ + function blargle(s) { + return 0; + } /** @type {0 | 1 | 2} - assignment should not error */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. 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 */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. /** @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; - } \ No newline at end of file + } + + /** @type {2 | 3} - overloads are not supported, so there will be an error */ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var twothree = monaLisa(false); + ~~~~~~~~ + !!! error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff index 91b9e0af5b..363b590590 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff @@ -2,11 +2,14 @@ +++ new.checkJsdocTypeTag6.errors.txt @@= skipped -0, +0 lines =@@ -test.js(1,12): error TS8030: The type of a function declaration must match the function's signature. ++test.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. 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(26,12): error TS8010: Type annotations can only be used in TypeScript files. 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(29,12): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -16,14 +19,20 @@ -==== test.js (7 errors) ==== + + -+==== test.js (3 errors) ==== ++==== test.js (6 errors) ==== /** @type {number} */ - ~~~~~~ -!!! error TS8030: The type of a function declaration must match the function's signature. function f() { return 1 } -@@= skipped -24, +17 lines =@@ + + /** @type {{ prop: string }} */ ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var g = function (prop) { + ~ + !!! error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. } /** @type {(a: number) => number} */ @@ -32,7 +41,7 @@ function add1(a, b) { return a + b; } /** @type {(a: number, b: number) => number} */ -@@= skipped -15, +13 lines =@@ +@@= skipped -39, +35 lines =@@ // They can't have more parameters than the type/context. /** @type {() => void} */ @@ -41,7 +50,20 @@ function funcWithMoreParameters(more) {} // error /** @type {() => void} */ -@@= skipped -19, +17 lines =@@ ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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} */ ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const arrowWithMoreParameters = (more) => {}; // error + ~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. +@@= skipped -19, +21 lines =@@ ({ /** @type {() => void} */ methodWithMoreParameters(more) {}, // error diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag7.errors.txt.diff new file mode 100644 index 0000000000..eccb6bff5b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag7.errors.txt.diff @@ -0,0 +1,25 @@ +--- old.checkJsdocTypeTag7.errors.txt ++++ new.checkJsdocTypeTag7.errors.txt +@@= skipped -0, +0 lines =@@ +- ++test.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. ++test.js(2,28): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== test.js (2 errors) ==== ++ /** ++ * @typedef {(a: string, b: number) => void} Foo ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ++ class C { ++ /** @type {Foo} */ ++ foo(a, b) {} ++ ++ /** @type {(optional?) => void} */ ++ methodWithOptionalParameters() {} ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag8.errors.txt.diff index 0a81a4d39f..b1d84581d6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag8.errors.txt.diff @@ -2,14 +2,17 @@ +++ new.checkJsdocTypeTag8.errors.txt @@= skipped -0, +0 lines =@@ - ++index.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. +index.js(4,20): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. + + -+==== index.js (1 errors) ==== ++==== index.js (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/57953 + + /** + * @param {Number|BigInt} n ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff index b398e62b86..6c1cd30b36 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff @@ -14,13 +14,15 @@ -==== 0.js (8 errors) ==== +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(18,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== 0.js (3 errors) ==== ++==== 0.js (5 errors) ==== // @ts-check var lol; const obj = { -@@= skipped -18, +13 lines =@@ +@@= skipped -18, +15 lines =@@ /** @type {function(number): number} */ method1(n1) { return "42"; @@ -48,11 +50,15 @@ } lol = "string" /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var s = obj.method1(0); - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var s1 = obj.method2("0"); - ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. 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..a6506e9c14 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff @@ -0,0 +1,59 @@ +--- old.checkJsdocTypedefInParamTag1.errors.txt ++++ new.checkJsdocTypedefInParamTag1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++0.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== 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 ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function foo(opts) { ++ opts.x; ++ } ++ ++ foo({x: 'abc'}); ++ ++ /** ++ * @typedef {Object} AnotherOpts ++ * @property anotherX {string} ++ * @property anotherY {string=} ++ * ++ * @param {AnotherOpts} opts ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function foo1(opts) { ++ opts.anotherX; ++ } ++ ++ foo1({anotherX: "world"}); ++ ++ /** ++ * @typedef {object} Opts1 ++ * @property {string} x ++ * @property {string=} y ++ * @property {string} [z] ++ * @property {string} [w="hi"] ++ * ++ * @param {Opts1} opts ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function foo2(opts) { ++ opts.x; ++ } ++ foo2({x: 'abc'}); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff index cfb3d23d1b..fb4ab1bd6d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff @@ -8,9 +8,10 @@ +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(10,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== 0.js (3 errors) ==== ++==== 0.js (4 errors) ==== // @ts-check var exports = {}; @@ -29,5 +30,7 @@ -!!! error TS2694: Namespace 'exports' has no exported member 'SomeName'. + ~~~~~~~ +!!! error TS2503: Cannot find namespace 'exports'. ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const myString = 'str'; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkObjectDefineProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkObjectDefineProperty.errors.txt.diff index a3a773a7c6..55ae05059c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkObjectDefineProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkObjectDefineProperty.errors.txt.diff @@ -8,9 +8,16 @@ - - -==== validate.ts (4 errors) ==== ++index.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,10): error TS2741: Property 'name' is missing in type '{}' but required in type '{ name: string; }'. ++index.js(21,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(23,11): error TS2339: Property 'zip' does not exist on type '{}'. ++index.js(26,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(28,11): error TS2339: Property 'houseNumber' does not exist on type '{}'. ++index.js(33,29): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(38,12): error TS8010: Type annotations can only be used in TypeScript files. +validate.ts(3,3): error TS2339: Property 'name' does not exist on type '{}'. +validate.ts(4,3): error TS2339: Property 'middleInit' does not exist on type '{}'. +validate.ts(5,3): error TS2339: Property 'lastName' does not exist on type '{}'. @@ -77,11 +84,26 @@ +!!! error TS2339: Property 'middleInit' does not exist on type '{}'. -==== index.js (0 errors) ==== -+==== index.js (3 errors) ==== ++==== index.js (10 errors) ==== const x = {}; Object.defineProperty(x, "name", { value: "Charles", writable: true }); Object.defineProperty(x, "middleInit", { value: "H" }); -@@= skipped -50, +80 lines =@@ +@@= skipped -39, +76 lines =@@ + Object.defineProperty(x, "houseNumber", { get() { return 21.75 } }); + Object.defineProperty(x, "zipStr", { + /** @param {string} str */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set(str) { + this.zip = Number(str) + } +@@= skipped -7, +9 lines =@@ + + /** + * @param {{name: string}} named ++ ~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ function takeName(named) { return named.name; } takeName(x); @@ -90,6 +112,8 @@ +!!! related TS2728 index.js:15:13: 'name' is declared here. /** * @type {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ var a = x.zip; + ~~~ @@ -97,10 +121,28 @@ /** * @type {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ var b = x.houseNumber; + ~~~~~~~~~~~ +!!! error TS2339: Property 'houseNumber' does not exist on type '{}'. const returnExemplar = () => x; - const needsExemplar = (_ = x) => void 0; \ No newline at end of file + const needsExemplar = (_ = x) => void 0; + + const expected = /** @type {{name: string, readonly middleInit: string, readonly lastName: string, zip: number, readonly houseNumber: number, zipStr: string}} */(/** @type {*} */(null)); ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** + * + * @param {typeof returnExemplar} a ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {typeof needsExemplar} b ++ ~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function match(a, b) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkOtherObjectAssignProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkOtherObjectAssignProperty.errors.txt.diff index 2ef436de9d..c18a09dde5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkOtherObjectAssignProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkOtherObjectAssignProperty.errors.txt.diff @@ -13,6 +13,8 @@ -==== importer.js (7 errors) ==== +importer.js(1,21): error TS2306: File 'mod1.js' is not a module. +mod1.js(2,23): error TS2304: Cannot find name 'exports'. ++mod1.js(5,11): error TS8010: Type annotations can only be used in TypeScript files. ++mod1.js(7,22): error TS8016: Type assertion expressions can only be used in TypeScript files. +mod1.js(8,23): error TS2304: Cannot find name 'exports'. +mod1.js(11,23): error TS2304: Cannot find name 'exports'. +mod1.js(14,23): error TS2304: Cannot find name 'exports'. @@ -34,7 +36,7 @@ mod.bad1; mod.bad2; mod.bad3; -@@= skipped -22, +20 lines =@@ +@@= skipped -22, +22 lines =@@ mod.thing = 0; mod.other = 0; @@ -54,7 +56,7 @@ -!!! error TS2540: Cannot assign to 'bad3' because it is a read-only property. -==== mod1.js (0 errors) ==== -+==== mod1.js (6 errors) ==== ++==== mod1.js (8 errors) ==== const obj = { value: 42, writable: true }; Object.defineProperty(exports, "thing", obj); + ~~~~~~~ @@ -62,8 +64,12 @@ /** * @type {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ let str = /** @type {string} */("other"); ++ ~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. Object.defineProperty(exports, str, { value: 42, writable: true }); + ~~~~~~~ +!!! error TS2304: Cannot find name 'exports'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff new file mode 100644 index 0000000000..1173d12361 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.checkSpecialPropertyAssignments.errors.txt ++++ new.checkSpecialPropertyAssignments.errors.txt +@@= skipped -0, +0 lines =@@ ++bug24252.js(4,20): error TS8010: Type annotations can only be used in TypeScript files. ++bug24252.js(6,20): error TS8010: Type annotations can only be used in TypeScript files. + 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 (3 errors) ==== + var A = {}; + A.B = class { + m() { + /** @type {string[]} */ ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x = []; + /** @type {number[]} */ ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var y; + y = x; + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff index 2b89283198..9d647489a4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff @@ -5,12 +5,18 @@ -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(3,12): error TS8010: Type annotations can only be used in TypeScript files. +first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. ++first.js(27,16): error TS8010: Type annotations can only be used in TypeScript files. +first.js(27,21): error TS8020: JSDoc types can only be used inside documentation comments. ++first.js(28,16): error TS8010: Type annotations can only be used in TypeScript files. +first.js(44,4): error TS2339: Property 'numberOxen' 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(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++generic.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++generic.js(9,22): error TS8011: Type arguments can only be used in TypeScript files. +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. @@ -31,11 +37,16 @@ +second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. + + -+==== first.js (4 errors) ==== ++==== first.js (7 errors) ==== /** * @constructor * @param {number} numberOxen -@@= skipped -36, +33 lines =@@ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function Wagon(numberOxen) { + this.numberOxen = numberOxen +@@= skipped -36, +41 lines =@@ } // ok class Sql extends Wagon { @@ -50,9 +61,13 @@ } /** * @param {Array.} files ++ ~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. * @param {"csv" | "json" | "xmlolololol"} format ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * This is not assignable, so should have a type error */ load(files, format) { @@ -63,7 +78,7 @@ if (format === "xmlolololol") { throw new Error("please do not use XML. It was a joke."); } -@@= skipped -30, +27 lines =@@ +@@= skipped -30, +31 lines =@@ } var db = new Sql(); db.numberOxen = db.foonly @@ -102,14 +117,28 @@ +!!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (2 errors) ==== -+==== generic.js (5 errors) ==== ++==== generic.js (8 errors) ==== /** ++ ~~~ * @template T ++ ~~~~~~~~~~~~~~ * @param {T} flavour -@@= skipped -11, +13 lines =@@ ++ ~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function Soup(flavour) { ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + this.flavour = flavour ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { ++ ~~~~~ ++!!! error TS8011: Type arguments can only be used in TypeScript files. + ~~~~ +!!! error TS2507: Type '(flavour: T) => void' is not a constructor function type. log() { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.errors.txt.diff index 18e8e7a09d..94269d68a6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.errors.txt.diff @@ -3,15 +3,18 @@ @@= skipped -0, +0 lines =@@ - +bug43713.js(1,9): error TS2305: Module '"./commonJSAliasedExport"' has no exported member 'funky'. ++bug43713.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +commonJSAliasedExport.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +commonJSAliasedExport.js(7,16): error TS2339: Property 'funky' does not exist on type '(ast: any) => any'. + + -+==== bug43713.js (1 errors) ==== ++==== bug43713.js (2 errors) ==== + const { funky } = require('./commonJSAliasedExport'); + ~~~~~ +!!! error TS2305: Module '"./commonJSAliasedExport"' has no exported member 'funky'. + /** @type {boolean} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var diddy + var diddy = funky(1) + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff index 579c812e95..6939ecfe0e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff @@ -3,13 +3,16 @@ @@= skipped -0, +0 lines =@@ - +main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? ++main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== main.js (1 errors) ==== ++==== main.js (2 errors) ==== + const { K } = require("./mod1"); + /** @param {K} k */ + ~ +!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(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 0dd6edc42f..33ec25a45e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.errors.txt.diff @@ -3,13 +3,16 @@ @@= skipped -0, +0 lines =@@ - +main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? ++main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== main.js (1 errors) ==== ++==== main.js (2 errors) ==== + const { K } = require("./mod1"); + /** @param {K} k */ + ~ +!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(k) { + k.values() + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff index ab343dc0e8..4bd4ec8085 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff @@ -3,13 +3,16 @@ @@= skipped -0, +0 lines =@@ - +main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? ++main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== main.js (1 errors) ==== ++==== main.js (2 errors) ==== + const { K } = require("./mod1"); + /** @param {K} k */ + ~ +!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(k) { + k.values() + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff index 0ba61e4376..ddb5570264 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff @@ -2,18 +2,34 @@ +++ new.constructorFunctionMethodTypeParameters.errors.txt @@= skipped -0, +0 lines =@@ - ++constructorFunctionMethodTypeParameters.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++constructorFunctionMethodTypeParameters.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++constructorFunctionMethodTypeParameters.js(19,30): error TS8004: Type parameter declarations can only be used in TypeScript files. +constructorFunctionMethodTypeParameters.js(22,16): error TS2304: Cannot find name 'T'. ++constructorFunctionMethodTypeParameters.js(22,16): error TS8010: Type annotations can only be used in TypeScript files. ++constructorFunctionMethodTypeParameters.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. +constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find name 'T'. ++constructorFunctionMethodTypeParameters.js(24,17): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== constructorFunctionMethodTypeParameters.js (2 errors) ==== ++==== constructorFunctionMethodTypeParameters.js (8 errors) ==== + /** ++ ~~~ + * @template {string} T ++ ~~~~~~~~~~~~~~~~~~~~~~~ + * @param {T} t ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function Cls(t) { ++ ~~~~~~~~~~~~~~~~~ + this.t = t; ++ ~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + * @template {string} V @@ -26,19 +42,36 @@ + }; + + Cls.prototype.nestedComment = ++ + /** ++ ~~~~~~~ + * @template {string} U ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {T} t ++ ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS2304: Cannot find name 'T'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} u ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T} ++ ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS2304: Cannot find name 'T'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~~~~~ + function (t, u) { ++ ~~~~~~~~~~~~~~~~~~~~~ + return t ++ ~~~~~~~~~~~~~~~~ + }; ++ ~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + var c = new Cls('a'); + const s = c.topLevelComment('a', 'b'); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.errors.txt.diff index 3f9c9593a1..ee329c830c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.errors.txt.diff @@ -11,11 +11,12 @@ +index.js(23,15): error TS2350: Only a void function can be called with the 'new' keyword. +index.js(27,39): error TS2350: Only a void function can be called with the 'new' keyword. +index.js(31,15): error TS2350: Only a void function can be called with the 'new' keyword. ++index.js(51,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(55,13): error TS2554: Expected 1 arguments, but got 0. -==== index.js (3 errors) ==== -+==== index.js (9 errors) ==== ++==== index.js (10 errors) ==== function C1() { if (!(this instanceof C1)) return new C1(); + ~~~~~~~~ @@ -69,4 +70,13 @@ +!!! error TS2350: Only a void function can be called with the 'new' keyword. var c5_v1; - c5_v1 = function f() { }; \ No newline at end of file + c5_v1 = function f() { }; +@@= skipped -58, +77 lines =@@ + /** + * @constructor + * @param {number} num ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function C7(num) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff index 866e73f31c..d0c6be8cc6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff @@ -5,16 +5,21 @@ - - -==== a.js (1 errors) ==== ++a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. +a.js(8,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. ++a.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. +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 (3 errors) ==== ++==== a.js (5 errors) ==== /** @param {number} x */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. function C(x) { this.x = x -@@= skipped -9, +11 lines =@@ + } +@@= skipped -9, +15 lines =@@ this.y = 12 } var c = new C(1) @@ -26,6 +31,8 @@ c.y = undefined // ok /** @param {number} x */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. function A(x) { if (!(this instanceof A)) { return new A(x) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.errors.txt.diff new file mode 100644 index 0000000000..826803ecdd --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.constructorTagWithThisTag.errors.txt ++++ new.constructorTagWithThisTag.errors.txt +@@= skipped -0, +0 lines =@@ +- ++classthisboth.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== classthisboth.js (1 errors) ==== ++ /** ++ * @class ++ * @this {{ e: number, m: number }} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * this-tag should win, both 'e' and 'm' should be defined. ++ */ ++ function C() { ++ this.e = this.m + 1 ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.errors.txt.diff new file mode 100644 index 0000000000..ba9a0eaf4a --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.errors.txt.diff @@ -0,0 +1,40 @@ +--- old.contextualTypeFromJSDoc.errors.txt ++++ new.contextualTypeFromJSDoc.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (3 errors) ==== ++ /** @type {Array<[string, {x?:number, y?:number}]>} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const arr = [ ++ ['a', { x: 1 }], ++ ['b', { y: 2 }] ++ ]; ++ ++ /** @return {Array<[string, {x?:number, y?:number}]>} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ function f() { ++ return [ ++ ['a', { x: 1 }], ++ ['b', { y: 2 }] ++ ]; ++ } ++ ++ class C { ++ /** @param {Array<[string, {x?:number, y?:number}]>} value */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ set x(value) { } ++ get x() { ++ return [ ++ ['a', { x: 1 }], ++ ['b', { y: 2 }] ++ ]; ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff index 8ba6639782..75149ecf86 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff @@ -2,16 +2,20 @@ +++ new.contextualTypedSpecialAssignment.errors.txt @@= skipped -0, +0 lines =@@ - ++mod.js(2,34): error TS8010: Type annotations can only be used in TypeScript files. ++test.js(3,9): error TS8010: Type annotations can only be used in TypeScript files. +test.js(15,5): error TS2322: Type 'string' is not assignable to type '"done"'. +test.js(16,7): error TS7006: Parameter 'n' implicitly has an 'any' type. +test.js(57,17): error TS2339: Property 'x' does not exist on type 'Thing'. +test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. + + -+==== test.js (4 errors) ==== ++==== test.js (5 errors) ==== + /** @typedef {{ + status: 'done' + m(n: number): void ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + }} DoneStatus */ + + // property assignment @@ -89,9 +93,11 @@ + m(n) { } + } + -+==== mod.js (0 errors) ==== ++==== mod.js (1 errors) ==== + // module.exports assignment + /** @type {{ status: 'done', m(n: number): void }} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + module.exports = { + status: "done", + m(n) { } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).errors.txt.diff new file mode 100644 index 0000000000..9faf9dc7fb --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).errors.txt.diff @@ -0,0 +1,64 @@ +--- old.destructuringParameterDeclaration9(strict=false).errors.txt ++++ new.destructuringParameterDeclaration9(strict=false).errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(3,4): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (4 errors) ==== ++ /** ++ * @param {Object} [config] ++ * @param {Partial>} [config.additionalFiles] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function prepareConfig({ ++ additionalFiles: { ++ json = [] ++ } = {} ++ } = {}) { ++ json // string[] ++ } ++ ++ export function prepareConfigWithoutAnnotation({ ++ additionalFiles: { ++ json = [] ++ } = {} ++ } = {}) { ++ json ++ } ++ ++ /** @type {(param: { ++ ~~~~~~~~~ ++ additionalFiles?: Partial>; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ }) => void} */ ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ export const prepareConfigWithContextualSignature = ({ ++ additionalFiles: { ++ json = [] ++ } = {} ++ } = {})=> { ++ json // string[] ++ } ++ ++ // Additional repros from https://github.com/microsoft/TypeScript/issues/59936 ++ ++ /** ++ * @param {{ a?: { json?: string[] }}} [config] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f1({ a: { json = [] } = {} } = {}) { return json } ++ ++ /** ++ * @param {[[string[]?]?]} [x] ++ ~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f2([[json = []] = []] = []) { return json } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).errors.txt.diff new file mode 100644 index 0000000000..75da44d63c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).errors.txt.diff @@ -0,0 +1,51 @@ +--- old.destructuringParameterDeclaration9(strict=true).errors.txt ++++ new.destructuringParameterDeclaration9(strict=true).errors.txt +@@= skipped -0, +0 lines =@@ ++index.js(3,4): error TS8010: Type annotations can only be used in TypeScript files. + index.js(15,9): error TS7031: Binding element 'json' implicitly has an 'any[]' type. +- +- +-==== index.js (1 errors) ==== ++index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (5 errors) ==== + /** + * @param {Object} [config] + * @param {Partial>} [config.additionalFiles] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function prepareConfig({ + additionalFiles: { +@@= skipped -24, +30 lines =@@ + } + + /** @type {(param: { ++ ~~~~~~~~~ + additionalFiles?: Partial>; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }) => void} */ ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const prepareConfigWithContextualSignature = ({ + additionalFiles: { + json = [] +@@= skipped -14, +18 lines =@@ + + /** + * @param {{ a?: { json?: string[] }}} [config] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f1({ a: { json = [] } = {} } = {}) { return json } + + /** + * @param {[[string[]?]?]} [x] ++ ~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f2([[json = []] = []] = []) { return json } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff index 4b31a93b36..e3f7fbf4c4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff @@ -4,14 +4,24 @@ -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(24,13): error TS8010: Type annotations can only be used in TypeScript files. +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(25,12): error TS8010: Type annotations can only be used in TypeScript files. +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(26,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(29,16): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(31,16): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(33,16): error TS8010: Type annotations can only be used in TypeScript files. +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(35,16): error TS8010: Type annotations can only be used in TypeScript files. 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 (5 errors) ==== ++a.js(41,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (13 errors) ==== /** @enum {string} */ const Target = { START: "start", @@ -31,27 +41,52 @@ OK: 1, /** @type {number} */ FINE: 2, -@@= skipped -31, +29 lines =@@ +@@= skipped -31, +37 lines =@@ } /** @param {Target} t + ~~~~~~ +!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Second} s + ~~~~~~ +!!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Fs} f + ~~ +!!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ function consume(t,s,f) { /** @type {string} */ -@@= skipped -11, +17 lines =@@ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var str = t + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var num = s /** @type {(n: number) => number} */ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var v = Target.START v = Target.UNKNOWN // error, can't find 'UNKNOWN' - ~~~~~~~ \ No newline at end of file + ~~~~~~~ +@@= skipped -19, +41 lines =@@ + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums + } + /** @param {string} s */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function ff(s) { + // element access with arbitrary string is an error only with noImplicitAny + if (!Target[s]) { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff index cd516c8a20..0e114ebf91 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff @@ -3,26 +3,35 @@ @@= skipped -0, +0 lines =@@ - +type.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. ++type.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++type.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +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'? ++value.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== type.js (2 errors) ==== ++==== type.js (4 errors) ==== + /** @typedef {import("./mod1").TestEnum} TE */ + ~~~~~~~~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. + /** @type {TE} */ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const test = 'add' + /** @type {import("./mod1").TestEnum} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. + const tost = 'remove' + -+==== value.js (1 errors) ==== ++==== value.js (2 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'? ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const tist = TestEnum.ADD + + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff index 69e6638c6f..9909a63130 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff @@ -3,9 +3,10 @@ @@= skipped -0, +0 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(7,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== bug27134.js (1 errors) ==== ++==== bug27134.js (2 errors) ==== + /** + * @enum {number} + */ @@ -15,6 +16,8 @@ + * @type {foo} + ~~~ +!!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var s; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff index edfe5ae50a..9153e54284 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff @@ -14,17 +14,19 @@ - - -==== foo.js (10 errors) ==== ++foo.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(21,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. + Type 'void' is not assignable to type 'Promise'. ++foo.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. + Type 'void' is not assignable to type 'never'. + + -+==== foo.js (2 errors) ==== ++==== foo.js (4 errors) ==== /** * @callback FunctionReturningPromise * @returns {Promise} -@@= skipped -17, +11 lines =@@ +@@= skipped -17, +13 lines =@@ /** @type {FunctionReturningPromise} */ function testPromise1() { @@ -49,6 +51,8 @@ } /** @type {FunctionReturningPromise} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var testPromise4 = function() { - ~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. @@ -58,7 +62,7 @@ console.log("test") } -@@= skipped -34, +27 lines =@@ +@@= skipped -34, +29 lines =@@ /** @type {FunctionReturningNever} */ function testNever1() { @@ -84,6 +88,8 @@ } /** @type {FunctionReturningNever} */ ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var testNever4 = function() { - ~~~~~~~~ -!!! error TS2534: A function returning 'never' cannot have a reachable end point. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/esDecorators-classDeclaration-exportModifier.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/esDecorators-classDeclaration-exportModifier.errors.txt.diff index 611a6b4b71..4e0f4b1adf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/esDecorators-classDeclaration-exportModifier.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/esDecorators-classDeclaration-exportModifier.errors.txt.diff @@ -7,43 +7,46 @@ - - -==== global.js (0 errors) ==== -- /** @type {*} */ -- var dec; -- --==== file1.js (0 errors) ==== -- // ok -- @dec export class C1 { } -- --==== file2.js (0 errors) ==== -- // ok -- @dec export default class C2 {} -- ++global.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== global.js (1 errors) ==== + /** @type {*} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var dec; + + ==== file1.js (0 errors) ==== +@@= skipped -14, +14 lines =@@ + // ok + @dec export default class C2 {} + -==== file3.js (1 errors) ==== -- // error -- export @dec default class C3 {} ++==== file3.js (0 errors) ==== + // error + export @dec default class C3 {} - ~~~~ -!!! error TS1206: Decorators are not valid here. -- --==== file4.js (0 errors) ==== -- // ok -- export @dec class C4 {} -- --==== file5.js (0 errors) ==== -- // ok -- export default @dec class C5 {} -- + + ==== file4.js (0 errors) ==== + // ok +@@= skipped -14, +12 lines =@@ + // ok + export default @dec class C5 {} + -==== file6.js (1 errors) ==== -- // error -- @dec export @dec class C6 {} ++==== file6.js (0 errors) ==== + // error + @dec export @dec class C6 {} - ~~~~ -!!! error TS8038: Decorators may not appear after 'export' or 'export default' if they also appear before 'export'. -!!! related TS1486 file6.js:2:1: Decorator used before 'export' here. -- + -==== file7.js (1 errors) ==== -- // error -- @dec export default @dec class C7 {} ++==== file7.js (0 errors) ==== + // error + @dec export default @dec class C7 {} - ~~~~ -!!! error TS8038: Decorators may not appear after 'export' or 'export default' if they also appear before 'export'. -!!! related TS1486 file7.js:2:1: Decorator used before 'export' here. -- -+ \ No newline at end of file + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportNamespace_js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportNamespace_js.errors.txt.diff deleted file mode 100644 index db304cbfa3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportNamespace_js.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.exportNamespace_js.errors.txt -+++ new.exportNamespace_js.errors.txt -@@= skipped -0, +0 lines =@@ --b.js(1,1): error TS8006: 'export type' declarations can only be used in TypeScript files. - c.js(2,1): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'. - - - ==== a.js (0 errors) ==== - export class A {} - --==== b.js (1 errors) ==== -+==== b.js (0 errors) ==== - export type * from './a'; -- ~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8006: 'export type' declarations can only be used in TypeScript files. - - ==== c.js (1 errors) ==== - import { A } from './b'; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff index a86c615df7..0a657910bc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff @@ -4,8 +4,10 @@ - +mod.js(2,11): error TS2339: Property 'K' does not exist on type '{}'. +use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. ++use.js(8,13): error TS8010: Type annotations can only be used in TypeScript files. +use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. +use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? ++use.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== mod.js (1 errors) ==== @@ -21,7 +23,7 @@ + } + } + -+==== use.js (3 errors) ==== ++==== use.js (5 errors) ==== + import * as s from './mod' + + var k = new s.n.K() @@ -32,11 +34,15 @@ + + + /** @param {s.n.K} c ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2694: Namespace '"mod"' has no exported member 'n'. + @param {s.Classic} classic */ + ~~~~~~~~~ +!!! error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(c, classic) { + c.x + classic.p diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff index 51f38d66e6..6c92e750c4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff @@ -2,12 +2,13 @@ +++ new.exportSpecifiers_js.errors.txt @@= skipped -0, +0 lines =@@ -a.js(2,10): error TS8006: 'export...type' declarations can only be used in TypeScript files. -- -- --==== a.js (1 errors) ==== -- const foo = 0; -- export { type foo }; ++a.js(2,9): error TS8006: 'export...type' declarations can only be used in TypeScript files. + + + ==== a.js (1 errors) ==== + const foo = 0; + export { type foo }; - ~~~~~~~~ --!!! error TS8006: 'export...type' declarations can only be used in TypeScript files. -- -+ \ No newline at end of file ++ ~~~~~~~~~ + !!! error TS8006: 'export...type' declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff index f71a29aa27..34d9724e5b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +0 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'? ++use.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== def.js (0 errors) ==== @@ -13,11 +14,13 @@ + }; + export default MyEnum; + -+==== use.js (1 errors) ==== ++==== use.js (2 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'? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const v = MyEnum.b; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff new file mode 100644 index 0000000000..d631e8a152 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.extendsTag1.errors.txt ++++ new.extendsTag1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++bug25101.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++bug25101.js(5,17): error TS8011: Type arguments can only be used in TypeScript files. ++ ++ ++==== bug25101.js (2 errors) ==== ++ /** ++ ~~~ ++ * @template T ++ ~~~~~~~~~~~~~~ ++ * @extends {Set} Should prefer this Set, not the Set in the heritage clause ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ */ ++ ~~~ ++ class My extends Set {} ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ~~~~ ++!!! error TS8011: Type arguments can only be used in TypeScript files. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff new file mode 100644 index 0000000000..85d5474d0b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff @@ -0,0 +1,95 @@ +--- old.extendsTag5.errors.txt ++++ new.extendsTag5.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++/a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(26,16): error TS8011: Type arguments can only be used in TypeScript files. + /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(34,16): error TS8011: Type arguments can only be used in TypeScript files. ++/a.js(39,16): error TS8011: Type arguments can only be used in TypeScript files. + /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 (2 errors) ==== ++/a.js(44,16): error TS8011: Type arguments can only be used in TypeScript files. ++ ++ ++==== /a.js (8 errors) ==== + /** ++ ~~~ + * @typedef {{ ++ ~~~~~~~~~~~~~~ + * a: number | string; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ + * b: boolean | string[]; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * }} Foo ++ ~~~~~~~~ + */ ++ ~~ ++ + + /** ++ ~~~ + * @template {Foo} T ++ ~~~~~~~~~~~~~~~~~~~ + */ ++ ~~ + class A { ++ ~~~~~~~~~ + /** ++ ~~~~~~ + * @param {T} a ++ ~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~~~~ + constructor(a) { ++ ~~~~~~~~~~~~~~~~~~~ + return a ++ ~~~~~~~~~~~~~~~ + } ++ ~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + * @extends {A<{ +@@= skipped -32, +59 lines =@@ + * }>} + */ + class B extends A {} ++ ~~ ++!!! error TS8011: Type arguments can only be used in TypeScript files. + + /** + * @extends {A<{ +@@= skipped -15, +17 lines =@@ + !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. + */ + class C extends A {} ++ ~~ ++!!! error TS8011: Type arguments can only be used in TypeScript files. + + /** + * @extends {A<{a: string, b: string[]}>} + */ + class D extends A {} ++ ~~ ++!!! error TS8011: Type arguments can only be used in TypeScript files. + + /** + * @extends {A<{a: string, b: string}>} +@@= skipped -14, +18 lines =@@ + !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. + */ + class E extends A {} ++ ~~ ++!!! error TS8011: Type arguments can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff new file mode 100644 index 0000000000..49b0d90f81 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff @@ -0,0 +1,55 @@ +--- old.genericSetterInClassTypeJsDoc.errors.txt ++++ new.genericSetterInClassTypeJsDoc.errors.txt +@@= skipped -0, +0 lines =@@ +- ++genericSetterInClassTypeJsDoc.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++genericSetterInClassTypeJsDoc.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== genericSetterInClassTypeJsDoc.js (2 errors) ==== ++ /** ++ ~~~ ++ * @template T ++ ~~~~~~~~~~~~~~ ++ */ ++ ~~~ ++ class Box { ++ ~~~~~~~~~~~~ ++ #value; ++ ~~~~~~~~~~~ ++ ++ ++ /** @param {T} initialValue */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor(initialValue) { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ this.#value = initialValue; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~~~ ++ ++ ~~~~ ++ /** @type {T} */ ++ ~~~~~~~~~~~~~~~~~~~~ ++ get value() { ++ ~~~~~~~~~~~~~~~~~ ++ return this.#value; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~~~ ++ ++ ++ set value(value) { ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ this.#value = value; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ new Box(3).value = 3; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff index 9da266ec89..47e158ae7f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff @@ -4,8 +4,9 @@ -error TS5055: Cannot write file '/a.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. -error TS5056: Cannot write file '/a.js' because it would be overwritten by multiple input files. --/a.js(1,1): error TS8006: 'import type' declarations can only be used in TypeScript files. + /a.js(1,1): error TS8006: 'import type' declarations can only be used in TypeScript files. -/a.js(2,1): error TS8006: 'export type' declarations can only be used in TypeScript files. ++/a.js(1,26): error TS8006: 'export type' declarations can only be used in TypeScript files. /b.ts(1,8): error TS1363: A type-only import can specify a default import or named bindings, but not both. /c.ts(4,1): error TS1392: An import alias cannot use 'import type' @@ -16,18 +17,11 @@ ==== /a.ts (0 errors) ==== export default class A {} export class B {} -@@= skipped -19, +11 lines =@@ - ~~~~~~~~~~~~~~~~ - !!! error TS1363: A type-only import can specify a default import or named bindings, but not both. - --==== /a.js (2 errors) ==== -+==== /a.js (0 errors) ==== +@@= skipped -23, +17 lines =@@ import type A from './a'; -- ~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ export type { A }; -- ~~~~~~~~~~~~~~~~~~ --!!! error TS8006: 'export type' declarations can only be used in TypeScript files. - - ==== /c.ts (1 errors) ==== - namespace ns { \ No newline at end of file + ~~~~~~~~~~~~~~~~~~ + !!! error TS8006: 'export type' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importSpecifiers_js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importSpecifiers_js.errors.txt.diff index 13191d59af..4056302609 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importSpecifiers_js.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importSpecifiers_js.errors.txt.diff @@ -2,14 +2,15 @@ +++ new.importSpecifiers_js.errors.txt @@= skipped -0, +0 lines =@@ -a.js(1,10): error TS8006: 'import...type' declarations can only be used in TypeScript files. -- -- --==== a.ts (0 errors) ==== -- export interface A {} -- --==== a.js (1 errors) ==== -- import { type A } from "./a"; ++a.js(1,9): error TS8006: 'import...type' declarations can only be used in TypeScript files. + + + ==== a.ts (0 errors) ==== +@@= skipped -5, +5 lines =@@ + + ==== a.js (1 errors) ==== + import { type A } from "./a"; - ~~~~~~ --!!! error TS8006: 'import...type' declarations can only be used in TypeScript files. -- -+ \ No newline at end of file ++ ~~~~~~~ + !!! error TS8006: 'import...type' declarations can only be used in TypeScript files. + \ No newline at end of file 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..1412b2d2a6 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.importTag1.errors.txt ++++ new.importTag1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface Foo { ++ a: number; ++ } ++ ++==== /foo.js (2 errors) ==== ++ /** ++ * @import { Foo } from "./types" ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param { Foo } foo ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(foo) {} ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag11.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag11.errors.txt.diff index 1d60c189e9..66f92671e2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag11.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag11.errors.txt.diff @@ -6,12 +6,17 @@ - - -==== /foo.js (2 errors) ==== -- /** -- * @import foo ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++ ++ ++==== /foo.js (1 errors) ==== + /** + * @import foo - -!!! error TS1109: Expression expected. -- */ ++ ~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ - -!!! error TS1005: 'from' expected. -- -+ \ No newline at end of file + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag12.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag12.errors.txt.diff index 3bcbbcf079..b8ebdf34bc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag12.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag12.errors.txt.diff @@ -2,13 +2,15 @@ +++ new.importTag12.errors.txt @@= skipped -0, +0 lines =@@ -/foo.js(2,20): error TS1109: Expression expected. -- -- --==== /foo.js (1 errors) ==== -- /** -- * @import foo from ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. + + + ==== /foo.js (1 errors) ==== + /** + * @import foo from - -!!! error TS1109: Expression expected. -- */ -- -+ \ No newline at end of file ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag13.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag13.errors.txt.diff index a55a49f933..71c3450d7e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag13.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag13.errors.txt.diff @@ -2,13 +2,19 @@ +++ new.importTag13.errors.txt @@= skipped -0, +0 lines =@@ -/foo.js(1,15): error TS1005: 'from' expected. +- +- +-==== /foo.js (1 errors) ==== ++/foo.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(1,15): error TS1141: String literal expected. - - - ==== /foo.js (1 errors) ==== ++ ++ ++==== /foo.js (2 errors) ==== /** @import x = require("types") */ - ~ -!!! error TS1005: 'from' expected. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~ +!!! error TS1141: String literal expected. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag14.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag14.errors.txt.diff index 689b431d29..57f9ecee38 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag14.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag14.errors.txt.diff @@ -1,14 +1,20 @@ --- old.importTag14.errors.txt +++ new.importTag14.errors.txt @@= skipped -0, +0 lines =@@ ++/foo.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(1,25): error TS2306: File '/foo.js' is not a module. /foo.js(1,33): error TS1464: Type import attributes should have exactly one key - 'resolution-mode' - with value 'import' or 'require'. /foo.js(1,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. -/foo.js(1,38): error TS1005: '{' expected. - - - ==== /foo.js (3 errors) ==== +- +- +-==== /foo.js (3 errors) ==== ++ ++ ++==== /foo.js (4 errors) ==== /** @import * as f from "./foo" with */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~ +!!! error TS2306: File '/foo.js' is not a module. ~~~~ 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 new file mode 100644 index 0000000000..a9a776ef2d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).errors.txt.diff @@ -0,0 +1,31 @@ +--- old.importTag15(module=es2015).errors.txt ++++ new.importTag15(module=es2015).errors.txt +@@= skipped -0, +0 lines =@@ ++1.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. + 1.js(1,30): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. ++1.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. + 1.js(2,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. ++1.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== 0.ts (0 errors) ==== + export interface I { } + +-==== 1.js (2 errors) ==== ++==== 1.js (5 errors) ==== + /** @import { I } from './0' with { type: "json" } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. + /** @import * as foo from './0' with { type: "json" } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. + + /** @param {I} a */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(a) {} + \ No newline at end of file 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 new file mode 100644 index 0000000000..d81eee3ea8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).errors.txt.diff @@ -0,0 +1,31 @@ +--- old.importTag15(module=esnext).errors.txt ++++ new.importTag15(module=esnext).errors.txt +@@= skipped -0, +0 lines =@@ ++1.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. + 1.js(1,30): error TS2857: Import attributes cannot be used with type-only imports or exports. ++1.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. + 1.js(2,33): error TS2857: Import attributes cannot be used with type-only imports or exports. ++1.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== 0.ts (0 errors) ==== + export interface I { } + +-==== 1.js (2 errors) ==== ++==== 1.js (5 errors) ==== + /** @import { I } from './0' with { type: "json" } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2857: Import attributes cannot be used with type-only imports or exports. + /** @import * as foo from './0' with { type: "json" } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2857: Import attributes cannot be used with type-only imports or exports. + + /** @param {I} a */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(a) {} + \ No newline at end of file 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..08f0e2153f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.errors.txt.diff @@ -0,0 +1,28 @@ +--- old.importTag16.errors.txt ++++ new.importTag16.errors.txt +@@= skipped -0, +0 lines =@@ +- ++b.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. ++b.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++b.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.ts (0 errors) ==== ++ export default interface Foo {} ++ export interface I {} ++ ++==== b.js (3 errors) ==== ++ /** @import Foo, { I } from "./a" */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ ++ /** ++ * @param {Foo} a ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {I} b ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function foo(a, b) {} ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff index 1c6f910b5b..e00e290a77 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff @@ -3,15 +3,32 @@ @@= 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"'. ++/a.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/a.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/a.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(5,15): error TS2749: 'Import' refers to a value, but is being used as a type here. Did you mean 'typeof Import'? ++/a.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(12,15): error TS2749: 'Require' refers to a value, but is being used as a type here. Did you mean 'typeof Require'? ==== /node_modules/@types/foo/package.json (0 errors) ==== -@@= skipped -25, +25 lines =@@ +@@= skipped -19, +23 lines =@@ + ==== /node_modules/@types/foo/index.d.cts (0 errors) ==== + export declare const Require: "script"; + +-==== /a.js (2 errors) ==== ++==== /a.js (6 errors) ==== + /** @import { Import } from 'foo' with { 'resolution-mode': 'import' } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + /** @import { Require } from 'foo' with { 'resolution-mode': 'require' } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. /** * @returns { Import } ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2749: 'Import' refers to a value, but is being used as a type here. Did you mean 'typeof Import'? */ @@ -23,6 +40,8 @@ /** * @returns { Require } ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~ +!!! error TS2749: 'Require' refers to a value, but is being used as a type here. Did you mean 'typeof Require'? */ 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..d9a8e02666 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.importTag18.errors.txt ++++ new.importTag18.errors.txt +@@= skipped -0, +0 lines =@@ +- ++b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++b.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.ts (0 errors) ==== ++ export interface Foo {} ++ ++==== b.js (2 errors) ==== ++ /** ++ * @import { ++ ~~~~~~~~~ ++ * Foo ++ ~~~~~~~~~ ++ * } from "./a" ++ ~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param {Foo} a ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function foo(a) {} ++ \ No newline at end of file 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..5788185cac --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.importTag19.errors.txt ++++ new.importTag19.errors.txt +@@= skipped -0, +0 lines =@@ +- ++b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++b.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.ts (0 errors) ==== ++ export interface Foo {} ++ ++==== b.js (2 errors) ==== ++ /** ++ * @import { Foo } ++ ~~~~~~~~~~~~~~~ ++ * from "./a" ++ ~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param {Foo} a ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function foo(a) {} ++ \ No newline at end of file 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..fceb1047fe --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.importTag2.errors.txt ++++ new.importTag2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface Foo { ++ a: number; ++ } ++ ++==== /foo.js (2 errors) ==== ++ /** ++ * @import * as types from "./types" ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param { types.Foo } foo ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function f(foo) {} ++ \ No newline at end of file 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..5eecda83df --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.importTag20.errors.txt ++++ new.importTag20.errors.txt +@@= skipped -0, +0 lines =@@ +- ++b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++b.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.ts (0 errors) ==== ++ export interface Foo {} ++ ++==== b.js (2 errors) ==== ++ /** ++ * @import ++ ~~~~~~~ ++ * { Foo ++ ~~~~~~~~ ++ * } from './a' ++ ~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param {Foo} a ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function foo(a) {} ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag21.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag21.errors.txt.diff new file mode 100644 index 0000000000..51591f8d08 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag21.errors.txt.diff @@ -0,0 +1,41 @@ +--- old.importTag21.errors.txt ++++ new.importTag21.errors.txt +@@= skipped -0, +0 lines =@@ +- ++test.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. ++ ++ ++==== node_modules/tslib/package.json (0 errors) ==== ++ { ++ "name": "tslib", ++ "exports": { ++ ".": { ++ "module": { ++ "types": "./modules/index.d.ts", ++ "default": "./tslib.es6.mjs" ++ }, ++ "import": { ++ "node": "./modules/index.js", ++ "default": { ++ "types": "./modules/index.d.ts", ++ "default": "./tslib.es6.mjs" ++ } ++ }, ++ "default": "./tslib.js" ++ }, ++ "./*": "./*", ++ "./": "./" ++ } ++ } ++ ++==== node_modules/tslib/modules/index.d.ts (0 errors) ==== ++ export {}; ++ ++==== node_modules/tslib/tslib.d.ts (0 errors) ==== ++ export {}; ++ ++==== test.js (1 errors) ==== ++ /** @import * as tslib from "tslib" */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ /** @type {typeof tslib} T */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff new file mode 100644 index 0000000000..4cc94555c2 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff @@ -0,0 +1,26 @@ +--- old.importTag23.errors.txt ++++ new.importTag23.errors.txt +@@= skipped -0, +0 lines =@@ ++/b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/b.js(5,18): error TS8005: 'implements' clauses can only be used in TypeScript files. + /b.js(6,14): error TS2420: Class 'C' incorrectly implements interface 'I'. + Property 'foo' is missing in type 'C' but required in type 'I'. + +@@= skipped -6, +8 lines =@@ + foo(): void; + } + +-==== /b.js (1 errors) ==== ++==== /b.js (3 errors) ==== + /** + * @import * as NS from './a' ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + */ + + /** @implements {NS.I} */ ++ ~~~~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + export class C {} + ~ + !!! error TS2420: Class 'C' incorrectly implements interface 'I'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff new file mode 100644 index 0000000000..9245a6672b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.importTag3.errors.txt ++++ new.importTag3.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /types.ts (0 errors) ==== ++ export default interface Foo { ++ a: number; ++ } ++ ++==== /foo.js (2 errors) ==== ++ /** ++ * @import Foo from "./types" ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param { Foo } foo ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function f(foo) {} ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff new file mode 100644 index 0000000000..8bcf42a98a --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff @@ -0,0 +1,40 @@ +--- old.importTag4.errors.txt ++++ new.importTag4.errors.txt +@@= skipped -0, +0 lines =@@ ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. + /foo.js(2,14): error TS2300: Duplicate identifier 'Foo'. ++/foo.js(6,4): error TS8006: 'import type' declarations can only be used in TypeScript files. + /foo.js(6,14): error TS2300: Duplicate identifier 'Foo'. ++/foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== /types.ts (0 errors) ==== +@@= skipped -6, +9 lines =@@ + a: number; + } + +-==== /foo.js (2 errors) ==== ++==== /foo.js (5 errors) ==== + /** + * @import { Foo } from "./types" ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~ + !!! error TS2300: Duplicate identifier 'Foo'. + */ + + /** + * @import { Foo } from "./types" ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~ + !!! error TS2300: Duplicate identifier 'Foo'. + */ + + /** + * @param { Foo } foo ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(foo) {} + \ No newline at end of file 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..90833dc98c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.importTag5.errors.txt ++++ new.importTag5.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface Foo { ++ a: number; ++ } ++ ++==== /foo.js (2 errors) ==== ++ /** ++ * @import { Foo } from "./types" ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param { Foo } foo ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(foo) {} ++ \ No newline at end of file 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..62cb42a496 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.errors.txt.diff @@ -0,0 +1,40 @@ +--- old.importTag6.errors.txt ++++ new.importTag6.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++/foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface A { ++ a: number; ++ } ++ export interface B { ++ a: number; ++ } ++ ++==== /foo.js (3 errors) ==== ++ /** ++ * @import { ++ ~~~~~~~~~ ++ * A, ++ ~~~~~~~~~ ++ * B, ++ ~~~~~~~~~ ++ * } from "./types" ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param { A } a ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param { B } b ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(a, b) {} ++ \ No newline at end of file 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..933900508c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.importTag7.errors.txt ++++ new.importTag7.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface A { ++ a: number; ++ } ++ export interface B { ++ a: number; ++ } ++ ++==== /foo.js (3 errors) ==== ++ /** ++ * @import { ++ ~~~~~~~~~ ++ * A, ++ ~~~~~ ++ * B } from "./types" ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param { A } a ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param { B } b ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(a, b) {} ++ \ No newline at end of file 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..cca70041fa --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.importTag8.errors.txt ++++ new.importTag8.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface A { ++ a: number; ++ } ++ export interface B { ++ a: number; ++ } ++ ++==== /foo.js (3 errors) ==== ++ /** ++ * @import ++ ~~~~~~~ ++ * { A, B } ++ ~~~~~~~~~~~ ++ * from "./types" ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param { A } a ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param { B } b ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(a, b) {} ++ \ No newline at end of file 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..0ccc93cd39 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.importTag9.errors.txt ++++ new.importTag9.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. ++/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /types.ts (0 errors) ==== ++ export interface A { ++ a: number; ++ } ++ export interface B { ++ a: number; ++ } ++ ++==== /foo.js (3 errors) ==== ++ /** ++ * @import ++ ~~~~~~~ ++ * * as types ++ ~~~~~~~~~~~~~ ++ * from "./types" ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ++ */ ++ ++ /** ++ * @param { types.A } a ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param { types.B } b ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(a, b) {} ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.errors.txt.diff new file mode 100644 index 0000000000..8dadc95f72 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.errors.txt.diff @@ -0,0 +1,40 @@ +--- old.importTypeInJSDoc.errors.txt ++++ new.importTypeInJSDoc.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(5,20): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(7,22): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(8,22): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== externs.d.ts (0 errors) ==== ++ declare namespace MyClass { ++ export interface Bar { ++ doer: (x: string) => void; ++ } ++ } ++ declare class MyClass { ++ field: string; ++ static Bar: (x: string, y?: number) => void; ++ constructor(x: MyClass.Bar); ++ } ++ declare global { ++ const Foo: typeof MyClass; ++ } ++ export = MyClass; ++==== index.js (3 errors) ==== ++ /** ++ * @typedef {import("./externs")} Foo ++ */ ++ ++ let a = /** @type {Foo} */(/** @type {*} */(undefined)); ++ ~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ a = new Foo({doer: Foo.Bar}); ++ const q = /** @type {import("./externs").Bar} */({ doer: q => q }); ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ const r = /** @type {typeof import("./externs").Bar} */(r => r); ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ \ No newline at end of file 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..3973b36381 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff @@ -0,0 +1,69 @@ +--- old.inferThis.errors.txt ++++ new.inferThis.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(1,17): error TS8004: Type parameter declarations can only be used in TypeScript files. ++/a.js(4,15): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(9,6): error TS8004: Type parameter declarations can only be used in TypeScript files. ++/a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(14,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (6 errors) ==== ++ export class C { ++ ++ /** ++ ~~~~~~~ ++ * @template T ++ ~~~~~~~~~~~~~~~~~~ ++ * @this {T} ++ ~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @return {T} ++ ~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ static a() { ++ ~~~~~~~~~~~~~~~~ ++ return this; ++ ~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ ++ ++ /** ++ ~~~~~~~ ++ * @template T ++ ~~~~~~~~~~~~~~~~~~ ++ * @this {T} ++ ~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @return {T} ++ ~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ b() { ++ ~~~~~~~~~ ++ return this; ++ ~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ } ++ ++ 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/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff new file mode 100644 index 0000000000..1e319bc4c2 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff @@ -0,0 +1,32 @@ +--- old.instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt ++++ new.instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt +@@= skipped -0, +0 lines =@@ +- ++instantiateTemplateTagTypeParameterOnVariableStatement.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++instantiateTemplateTagTypeParameterOnVariableStatement.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. ++instantiateTemplateTagTypeParameterOnVariableStatement.js(6,12): error TS8004: Type parameter declarations can only be used in TypeScript files. ++instantiateTemplateTagTypeParameterOnVariableStatement.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== instantiateTemplateTagTypeParameterOnVariableStatement.js (4 errors) ==== ++ /** ++ * @template T ++ * @param {T} a ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {(b: T) => T} ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const seq = a => b => b; ++ ~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ const text1 = "hello"; ++ const text2 = "world"; ++ ++ /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ var text3 = seq(text1)(text2); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff new file mode 100644 index 0000000000..33ae5e5251 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff @@ -0,0 +1,48 @@ +--- old.jsDeclarationsClassAccessor.errors.txt ++++ new.jsDeclarationsClassAccessor.errors.txt +@@= skipped -0, +0 lines =@@ +- ++argument.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. ++argument.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== supplement.d.ts (0 errors) ==== ++ export { }; ++ declare module "./argument.js" { ++ interface Argument { ++ idlType: any; ++ default: null; ++ } ++ } ++==== base.js (0 errors) ==== ++ export class Base { ++ constructor() { } ++ ++ toJSON() { ++ const json = { type: undefined, name: undefined, inheritance: undefined }; ++ return json; ++ } ++ } ++==== argument.js (2 errors) ==== ++ import { Base } from "./base.js"; ++ export class Argument extends Base { ++ /** ++ * @param {*} tokeniser ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ static parse(tokeniser) { ++ return; ++ } ++ ++ get type() { ++ return "argument"; ++ } ++ ++ /** ++ * @param {*} defs ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ *validate(defs) { } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff new file mode 100644 index 0000000000..b155cdd10d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff @@ -0,0 +1,49 @@ +--- old.jsDeclarationsClassImplementsGenericsSerialization.errors.txt ++++ new.jsDeclarationsClassImplementsGenericsSerialization.errors.txt +@@= skipped -0, +0 lines =@@ +- ++lib.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++lib.js(3,17): error TS8005: 'implements' clauses can only be used in TypeScript files. ++lib.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== interface.ts (0 errors) ==== ++ export interface Encoder { ++ encode(value: T): Uint8Array ++ } ++==== lib.js (3 errors) ==== ++ /** ++ ~~~ ++ * @template T ++ ~~~~~~~~~~~~~~ ++ * @implements {IEncoder} ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. ++ */ ++ ~~~ ++ export class Encoder { ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ /** ++ ~~~~~~~ ++ * @param {T} value ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ encode(value) { ++ ~~~~~~~~~~~~~~~~~~~ ++ return new Uint8Array(0) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ ++ /** ++ * @template T ++ * @typedef {import('./interface').Encoder} IEncoder ++ */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff index 47035117e1..31ea574ff0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff @@ -8,6 +8,9 @@ +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(36,16): error TS8010: Type annotations can only be used in TypeScript files. ++jsDeclarationsClassMethod.js(37,16): error TS8010: Type annotations can only be used in TypeScript files. ++jsDeclarationsClassMethod.js(38,18): error TS8010: Type annotations can only be used in TypeScript files. +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. @@ -15,7 +18,7 @@ +jsDeclarationsClassMethod.js(61,30): error TS7006: Parameter 'y' implicitly has an 'any' type. + + -+==== jsDeclarationsClassMethod.js (11 errors) ==== ++==== jsDeclarationsClassMethod.js (14 errors) ==== + function C1() { + /** + * A comment prop @@ -64,8 +67,14 @@ + /** + * A comment method1 + * @param {number} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} y ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + method1(x, y) { + return x + y; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff new file mode 100644 index 0000000000..8ffd9670c5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff @@ -0,0 +1,442 @@ +--- old.jsDeclarationsClasses.errors.txt ++++ new.jsDeclarationsClasses.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(13,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(24,15): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(30,15): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(31,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++index.js(38,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(40,34): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(43,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(48,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(50,34): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(53,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(58,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(59,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(65,15): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(71,15): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(72,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++index.js(79,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(84,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(89,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(94,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(97,2): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(104,15): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(108,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(109,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(111,25): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(115,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(116,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(153,2): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(161,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(167,2): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(173,23): error TS8011: Type arguments can only be used in TypeScript files. ++index.js(175,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(183,20): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== index.js (34 errors) ==== ++ export class A {} ++ ++ export class B { ++ static cat = "cat"; ++ } ++ ++ export class C { ++ static Cls = class {} ++ } ++ ++ export class D { ++ /** ++ * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} b ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(a, b) {} ++ } ++ ++ ++ ++ /** ++ ~~~ ++ * @template T,U ++ ~~~~~~~~~~~~~~~~ ++ */ ++ ~~~ ++ export class E { ++ ~~~~~~~~~~~~~~~~ ++ /** ++ ~~~~~~~ ++ * @type {T & U} ++ ~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ field; ++ ~~~~~~~~~~ ++ ++ ++ // @readonly is currently unsupported, it seems - included here just in case that changes ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ /** ++ ~~~~~~~ ++ * @type {T & U} ++ ~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @readonly ++ ~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~ ++ */ ++ ~~~~~~~ ++ ~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++ readonlyField; ++ ~~~~~~~~~~~~~~~~~~ ++ ++ ++ initializedField = 12; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ /** ++ ~~~~~~~ ++ * @return {U} ++ ~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ get f1() { return /** @type {*} */(null); } ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++ /** ++ ~~~~~~~ ++ * @param {U} _p ++ ~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ set f1(_p) {} ++ ~~~~~~~~~~~~~~~~~ ++ ++ ++ /** ++ ~~~~~~~ ++ * @return {U} ++ ~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ get f2() { return /** @type {*} */(null); } ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++ /** ++ ~~~~~~~ ++ * @param {U} _p ++ ~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ set f3(_p) {} ++ ~~~~~~~~~~~~~~~~~ ++ ++ ++ /** ++ ~~~~~~~ ++ * @param {T} a ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {U} b ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ constructor(a, b) {} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ ++ ++ /** ++ ~~~~~~~ ++ * @type {string} ++ ~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ static staticField; ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ // @readonly is currently unsupported, it seems - included here just in case that changes ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ /** ++ ~~~~~~~ ++ * @type {string} ++ ~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @readonly ++ ~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~ ++ */ ++ ~~~~~~~ ++ ~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++ static staticReadonlyField; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ static staticInitializedField = 12; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ /** ++ ~~~~~~~ ++ * @return {string} ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ static get s1() { return ""; } ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ /** ++ ~~~~~~~ ++ * @param {string} _p ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ static set s1(_p) {} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ /** ++ ~~~~~~~ ++ * @return {string} ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ static get s2() { return ""; } ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ /** ++ ~~~~~~~ ++ * @param {string} _p ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ static set s3(_p) {} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ ++ ++ /** ++ ~~~ ++ * @template T,U ++ ~~~~~~~~~~~~~~~~ ++ */ ++ ~~~ ++ export class F { ++ ~~~~~~~~~~~~~~~~ ++ /** ++ ~~~~~~~ ++ * @type {T & U} ++ ~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ field; ++ ~~~~~~~~~~ ++ /** ++ ~~~~~~~ ++ * @param {T} a ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {U} b ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ constructor(a, b) {} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ ++ ++ /** ++ ~~~~~~~ ++ ~~~~~~~ ++ * @template A,B ++ ~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~~ ++ * @param {A} a ++ ~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {B} b ++ ~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ ~~~~~~~ ++ static create(a, b) { return new F(a, b); } ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ class G {} ++ ++ export { G }; ++ ++ class HH {} ++ ++ export { HH as H }; ++ ++ export class I {} ++ export { I as II }; ++ ++ export { J as JJ }; ++ export class J {} ++ ++ ++ export class K { ++ constructor() { ++ this.p1 = 12; ++ this.p2 = "ok"; ++ } ++ ++ method() { ++ return this.p1; ++ } ++ } ++ ++ export class L extends K {} ++ ++ export class M extends null { ++ constructor() { ++ this.prop = 12; ++ } ++ } ++ ++ ++ ++ ++ ++ /** ++ ~~~ ++ * @template T ++ ~~~~~~~~~~~~~~ ++ */ ++ ~~~ ++ export class N extends L { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ /** ++ ~~~~~~~ ++ * @param {T} param ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ constructor(param) { ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ super(); ++ ~~~~~~~~~~~~~~~~ ++ this.another = param; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ ++ ++ /** ++ ~~~ ++ * @template U ++ ~~~~~~~~~~~~~~ ++ * @extends {N} ++ ~~~~~~~~~~~~~~~~~~ ++ */ ++ ~~~ ++ export class O extends N { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~ ++!!! error TS8011: Type arguments can only be used in TypeScript files. ++ /** ++ ~~~~~~~ ++ * @param {U} param ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ constructor(param) { ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ super(param); ++ ~~~~~~~~~~~~~~~~~~~~~ ++ this.another2 = param; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ } ++ ~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ var x = /** @type {*} */(null); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ export class VariableBase extends x {} ++ ++ export class HasStatics { ++ static staticMethod() {} ++ } ++ ++ export class ExtendsStatics extends HasStatics { ++ static also() {} ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff index 9ae89ec417..dd75f32e84 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff @@ -22,119 +22,170 @@ -index.js(63,11): error TS8010: Type annotations can only be used in TypeScript files. -index.js(67,11): error TS8010: Type annotations can only be used in TypeScript files. -index.js(68,11): error TS8010: Type annotations can only be used in TypeScript files. -- -- --==== index.js (21 errors) ==== -- // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), -- // but we should be able to synthesize declarations from the symbols regardless -- -- export class M { ++index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(5,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(6,2): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(8,26): error TS8011: Type arguments can only be used in TypeScript files. ++index.js(9,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(13,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(19,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(23,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(27,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(28,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(32,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(39,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(43,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(47,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(48,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(52,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(53,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(59,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(63,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(67,10): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(68,10): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== index.js (21 errors) ==== + // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // but we should be able to synthesize declarations from the symbols regardless ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ + + export class M { - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -- field: T; ++ ~~~~~~~~~~~~~~~~~~~ + field: T; - ~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class N extends M { ++ ~~~~~~~~~~~~~ ++ ~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ + + export class N extends M { - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~ --!!! error TS8011: Type arguments can only be used in TypeScript files. -- other: U; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ + !!! error TS8011: Type arguments can only be used in TypeScript files. + other: U; - ~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class O { -- [idx: string]: string; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class P extends O {} -- -- export class Q extends O { -- [idx: string]: "ok"; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class R extends O { -- [idx: number]: "ok"; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class S extends O { -- [idx: string]: "ok"; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- [idx: number]: never; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class T { -- [idx: number]: string; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class U extends T {} -- -- -- export class V extends T { -- [idx: string]: string; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class W extends T { -- [idx: number]: "ok"; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class X extends T { -- [idx: string]: string; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- [idx: number]: "ok"; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class Y { -- [idx: string]: {x: number}; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- [idx: number]: {x: number, y: number}; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class Z extends Y {} -- -- export class AA extends Y { -- [idx: string]: {x: number, y: number}; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class BB extends Y { -- [idx: number]: {x: 0, y: 0}; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class CC extends Y { -- [idx: string]: {x: number, y: number}; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- [idx: number]: {x: 0, y: 0}; -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -+ \ No newline at end of file ++ ~~~~~~~~~~~~~ ++ ~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + export class O { + [idx: string]: string; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + +@@= skipped -52, +61 lines =@@ + + export class Q extends O { + [idx: string]: "ok"; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class R extends O { + [idx: number]: "ok"; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class S extends O { + [idx: string]: "ok"; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: never; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class T { + [idx: number]: string; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + +@@= skipped -30, +30 lines =@@ + + export class V extends T { + [idx: string]: string; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class W extends T { + [idx: number]: "ok"; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class X extends T { + [idx: string]: string; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: "ok"; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class Y { + [idx: string]: {x: number}; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: {x: number, y: number}; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + +@@= skipped -32, +32 lines =@@ + + export class AA extends Y { + [idx: string]: {x: number, y: number}; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class BB extends Y { + [idx: number]: {x: 0, y: 0}; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class CC extends Y { + [idx: string]: {x: number, y: number}; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: {x: 0, y: 0}; +- ~~~~~~ ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.errors.txt.diff new file mode 100644 index 0000000000..fe09bb76cb --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.errors.txt.diff @@ -0,0 +1,36 @@ +--- old.jsDeclarationsComputedNames.errors.txt ++++ new.jsDeclarationsComputedNames.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index2.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (0 errors) ==== ++ const TopLevelSym = Symbol(); ++ const InnerSym = Symbol(); ++ module.exports = { ++ [TopLevelSym](x = 12) { ++ return x; ++ }, ++ items: { ++ [InnerSym]: (arg = {x: 12}) => arg.x ++ } ++ } ++ ++==== index2.js (1 errors) ==== ++ const TopLevelSym = Symbol(); ++ const InnerSym = Symbol(); ++ ++ export class MyClass { ++ static [TopLevelSym] = 12; ++ [InnerSym] = "ok"; ++ /** ++ * @param {typeof TopLevelSym | typeof InnerSym} _p ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(_p = InnerSym) { ++ // switch on _p ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff new file mode 100644 index 0000000000..3187c4a675 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff @@ -0,0 +1,50 @@ +--- old.jsDeclarationsDefault.errors.txt ++++ new.jsDeclarationsDefault.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index3.js(2,20): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index4.js(3,20): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== index1.js (0 errors) ==== ++ export default 12; ++ ++==== index2.js (0 errors) ==== ++ export default function foo() { ++ return foo; ++ } ++ export const x = foo; ++ export { foo as bar }; ++ ++==== index3.js (1 errors) ==== ++ export default class Foo { ++ a = /** @type {Foo} */(null); ++ ~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ }; ++ export const X = Foo; ++ export { Foo as Bar }; ++ ++==== index4.js (1 errors) ==== ++ import Fab from "./index3"; ++ class Bar extends Fab { ++ x = /** @type {Bar} */(null); ++ ~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ } ++ export default Bar; ++ ++==== index5.js (0 errors) ==== ++ // merge type alias and const (OK) ++ export default 12; ++ /** ++ * @typedef {string | number} default ++ */ ++ ++==== index6.js (0 errors) ==== ++ // merge type alias and function (OK) ++ export default function func() {}; ++ /** ++ * @typedef {string | number} default ++ */ ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff index 665d647959..b454400a7d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff @@ -3,12 +3,20 @@ @@= skipped -0, +0 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(23,12): error TS8010: Type annotations can only be used in TypeScript files. +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(24,12): error TS8010: Type annotations can only be used in TypeScript files. +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(25,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(28,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(30,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(32,16): error TS8010: Type annotations can only be used in TypeScript files. +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(34,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(38,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (4 errors) ==== ++==== index.js (12 errors) ==== + /** @enum {string} */ + export const Target = { + START: "start", @@ -34,27 +42,43 @@ + * @param {Target} t + ~~~~~~ +!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {Second} s + ~~~~~~ +!!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {Fs} f + ~~ +!!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function consume(t,s,f) { + /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var str = t + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var num = s + /** @type {(n: number) => number} */ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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'? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var v = Target.START + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums + } + /** @param {string} s */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export function ff(s) { + // element access with arbitrary string is an error only with noImplicitAny + if (!Target[s]) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff index e00f7c667e..951027bba3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff @@ -13,93 +13,176 @@ -index.js(41,19): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(47,13): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(55,19): error TS8006: 'enum' declarations can only be used in TypeScript files. -- -- --==== index.js (12 errors) ==== -- // Pretty much all of this should be an error, (since enums are forbidden in js), -- // but we should be able to synthesize declarations from the symbols regardless -- -- export enum A {} ++index.js(1,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(4,17): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(8,2): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(12,14): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(16,20): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(21,20): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(22,17): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(28,2): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(33,2): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(39,2): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(45,2): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript files. + + + ==== index.js (12 errors) ==== + // Pretty much all of this should be an error, (since enums are forbidden in js), ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // but we should be able to synthesize declarations from the symbols regardless ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ + + export enum A {} - ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- -- export enum B { ++ ~~~~~~~~~~~~~~~~ + !!! error TS8006: 'enum' declarations can only be used in TypeScript files. ++ ++ + + export enum B { - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- Member -- } -- -- enum C {} ++ ~~~~~~~~~~~~~~~ + Member ++ ~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'enum' declarations can only be used in TypeScript files. ++ ++ + + enum C {} - ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- -- export { C }; -- -- enum DD {} ++ ~~~~~~~~~ + !!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + export { C }; ++ ++ + + enum DD {} - ~~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- -- export { DD as D }; -- -- export enum E {} ++ ~~~~~~~~~~ + !!! error TS8006: 'enum' declarations can only be used in TypeScript files. + + export { DD as D }; ++ ++ + + export enum E {} - ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- export { E as EE }; -- -- export { F as FF }; -- export enum F {} ++ ~~~~~~~~~~~~~~~~ + !!! error TS8006: 'enum' declarations can only be used in TypeScript files. + export { E as EE }; + + export { F as FF }; ++ + export enum F {} - ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- -- export enum G { ++ ~~~~~~~~~~~~~~~~ + !!! error TS8006: 'enum' declarations can only be used in TypeScript files. ++ ++ + + export enum G { - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- A = 1, -- B, -- C -- } -- -- export enum H { ++ ~~~~~~~~~~~~~~~ + A = 1, ++ ~~~~~~~~~~ + B, ++ ~~~~~~ + C ++ ~~~~~ + } ++ ~ ++!!! error TS8006: 'enum' declarations can only be used in TypeScript files. ++ ++ + + export enum H { - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- A = "a", -- B = "b" -- } -- -- export enum I { ++ ~~~~~~~~~~~~~~~ + A = "a", ++ ~~~~~~~~~~~~ + B = "b" ++ ~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'enum' declarations can only be used in TypeScript files. ++ ++ + + export enum I { - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- A = "a", -- B = 0, -- C -- } -- -- export const enum J { ++ ~~~~~~~~~~~~~~~ + A = "a", ++ ~~~~~~~~~~~~ + B = 0, ++ ~~~~~~~~~~ + C ++ ~~~~~ + } ++ ~ ++!!! error TS8006: 'enum' declarations can only be used in TypeScript files. ++ ++ + + export const enum J { - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- A = 1, -- B, -- C -- } -- -- export enum K { ++ ~~~~~~~~~~~~~~~~~~~~~ + A = 1, ++ ~~~~~~~~~~ + B, ++ ~~~~~~ + C ++ ~~~~~ + } ++ ~ ++!!! error TS8006: 'enum' declarations can only be used in TypeScript files. ++ ++ + + export enum K { - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- None = 0, -- A = 1 << 0, -- B = 1 << 1, -- C = 1 << 2, -- Mask = A | B | C, -- } -- -- export const enum L { ++ ~~~~~~~~~~~~~~~ + None = 0, ++ ~~~~~~~~~~~~~~~ + A = 1 << 0, ++ ~~~~~~~~~~~~~~~ + B = 1 << 1, ++ ~~~~~~~~~~~~~~~ + C = 1 << 2, ++ ~~~~~~~~~~~~~~~ + Mask = A | B | C, ++ ~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'enum' declarations can only be used in TypeScript files. ++ ++ + + export const enum L { - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- None = 0, -- A = 1 << 0, -- B = 1 << 1, -- C = 1 << 2, -- Mask = A | B | C, -- } -- -+ \ No newline at end of file ++ ~~~~~~~~~~~~~~~~~~~~~ + None = 0, ++ ~~~~~~~~~~~~~~~ + A = 1 << 0, ++ ~~~~~~~~~~~~~~~ + B = 1 << 1, ++ ~~~~~~~~~~~~~~~ + C = 1 << 2, ++ ~~~~~~~~~~~~~~~ + Mask = A | B | C, ++ ~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt.diff new file mode 100644 index 0000000000..6d25a966f3 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.jsDeclarationsExportAssignedClassExpression.errors.txt ++++ new.jsDeclarationsExportAssignedClassExpression.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (1 errors) ==== ++ module.exports = class Thing { ++ /** ++ * @param {number} p ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(p) { ++ this.t = 12 + p; ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt.diff new file mode 100644 index 0000000000..016a56c4f7 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt ++++ new.jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (1 errors) ==== ++ module.exports = class { ++ /** ++ * @param {number} p ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(p) { ++ this.t = 12 + p; ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt.diff index b6ab682031..7ca978669d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt.diff @@ -3,16 +3,19 @@ @@= skipped -0, +0 lines =@@ - +index.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(9,16): error TS2339: Property 'Sub' does not exist on type 'typeof exports'. + + -+==== index.js (2 errors) ==== ++==== index.js (3 errors) ==== + module.exports = class { + ~~~~~~~~~~~~~~~~~~~~~~~~ + /** + ~~~~~~~ + * @param {number} p + ~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(p) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff index e09c802428..a73d15c21c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff @@ -5,13 +5,28 @@ +index.js(1,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(3,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(4,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(7,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(11,38): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(12,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(12,58): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(19,13): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(21,38): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(22,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(22,58): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. +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(35,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. +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(45,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. +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`. @@ -22,7 +37,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 (18 errors) ==== ++==== index.js (33 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`. @@ -36,33 +51,72 @@ + + /** + * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function d(a, b) { return /** @type {*} */(null); } ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + Object.defineProperty(module.exports, "d", { value: d }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++ ++ ++ + + + /** ++ ~~~ + * @template T,U ++ ~~~~~~~~~~~~~~~~ + * @param {T} a ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T & U} ++ ~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function e(a, b) { return /** @type {*} */(null); } ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + Object.defineProperty(module.exports, "e", { value: e }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++ ++ + + /** ++ ~~~ + * @template T ++ ~~~~~~~~~~~~~~ + * @param {T} a ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function f(a) { ++ ~~~~~~~~~~~~~~~ + return a; ++ ~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + Object.defineProperty(module.exports, "f", { value: f }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -74,7 +128,11 @@ + + /** + * @param {{x: string}} a ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof module.exports.b}} b ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ @@ -88,7 +146,11 @@ + + /** + * @param {{x: string}} a ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof module.exports.b}} b ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff index fad73826d0..ade0b751b8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff @@ -1,23 +1,21 @@ --- old.jsDeclarationsExportFormsErr.errors.txt +++ new.jsDeclarationsExportFormsErr.errors.txt @@= skipped -0, +0 lines =@@ --bar.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. + bar.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -bar.js(2,1): error TS8003: 'export =' can only be used in TypeScript files. -bin.js(2,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. ++bar.js(1,30): error TS8003: 'export =' can only be used in TypeScript files. globalNs.js(2,1): error TS1315: Global module exports may only appear in declaration files. - ==== cls.js (0 errors) ==== - export class Foo {} - --==== bar.js (2 errors) ==== -+==== bar.js (0 errors) ==== +@@= skipped -10, +9 lines =@@ import ns = require("./cls"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ export = ns; // TS Only -- ~~~~~~~~~~~~ --!!! error TS8003: 'export =' can only be used in TypeScript files. + ~~~~~~~~~~~~ + !!! error TS8003: 'export =' can only be used in TypeScript files. -==== bin.js (1 errors) ==== +==== bin.js (0 errors) ==== diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff index be95625d15..0db30bd19e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff @@ -5,28 +5,41 @@ +context.js(4,14): error TS1340: Module './timer' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./timer')'? +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(6,31): error TS2694: Namespace 'Hook' has no exported member 'HookHandler'. ++context.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. +context.js(34,14): error TS2350: Only a void function can be called with the 'new' keyword. ++context.js(40,16): error TS8010: Type annotations can only be used in TypeScript files. ++context.js(41,16): error TS8010: Type annotations can only be used in TypeScript files. ++context.js(42,18): error TS8010: Type annotations can only be used in TypeScript files. +context.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++hook.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. +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(5,12): error TS8010: Type annotations can only be used in TypeScript files. +hook.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++timer.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== timer.js (0 errors) ==== ++==== timer.js (1 errors) ==== + /** + * @param {number} timeout ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function Timer(timeout) { + this.timeout = timeout; + } + module.exports = Timer; -+==== hook.js (2 errors) ==== ++==== hook.js (4 errors) ==== + /** + * @typedef {(arg: import("./context")) => void} HookHandler ++ ~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~ +!!! 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 ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function Hook(handle) { + this.handle = handle; @@ -35,7 +48,7 @@ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== context.js (5 errors) ==== ++==== context.js (9 errors) ==== + /** + * Imports + * @@ -71,6 +84,8 @@ + * + * @class + * @param {Input} input ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + function Context(input) { @@ -84,8 +99,14 @@ + Context.prototype = { + /** + * @param {Input} input ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {HookHandler=} handle ++ ~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {State} ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + construct(input, handle = () => void 0) { + return input; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.errors.txt.diff new file mode 100644 index 0000000000..29658f0372 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.errors.txt.diff @@ -0,0 +1,57 @@ +--- old.jsDeclarationsFunctionJSDoc.errors.txt ++++ new.jsDeclarationsFunctionJSDoc.errors.txt +@@= skipped -0, +0 lines =@@ +- ++source.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++source.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++source.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. ++source.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. ++source.js(26,18): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== source.js (5 errors) ==== ++ /** ++ * Foos a bar together using an `a` and a `b` ++ * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {string} b ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function foo(a, b) {} ++ ++ /** ++ * Legacy - DO NOT USE ++ */ ++ export class Aleph { ++ /** ++ * Impossible to construct. ++ * @param {Aleph} a ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {null} b ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(a, b) { ++ /** ++ * Field is always null ++ */ ++ this.field = b; ++ } ++ ++ /** ++ * Doesn't actually do anything ++ * @returns {void} ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ doIt() {} ++ } ++ ++ /** ++ * Not the speed of light ++ */ ++ export const c = 12; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff index ab7bce91b9..6799e70522 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff @@ -3,13 +3,20 @@ @@= skipped -0, +0 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'? ++referencer.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++source.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++source.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +source.js(7,16): error TS2350: Only a void function can be called with the 'new' keyword. + + -+==== source.js (1 errors) ==== ++==== source.js (3 errors) ==== + /** + * @param {number} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} y ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function Point(x, y) { + if (!(this instanceof Point)) { @@ -21,13 +28,15 @@ + this.y = y; + } + -+==== referencer.js (1 errors) ==== ++==== referencer.js (2 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'? ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function magnitude(p) { + return Math.sqrt(p.x ** 2 + p.y ** 2); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff index 553f356860..12344ff2f7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff @@ -3,13 +3,21 @@ @@= skipped -0, +0 lines =@@ - +referencer.js(3,23): error TS2350: Only a void function can be called with the 'new' keyword. ++source.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +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(13,16): error TS8010: Type annotations can only be used in TypeScript files. ++source.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. ++source.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. +source.js(40,16): error TS2350: Only a void function can be called with the 'new' keyword. ++source.js(53,16): error TS8010: Type annotations can only be used in TypeScript files. ++source.js(62,16): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== source.js (2 errors) ==== ++==== source.js (8 errors) ==== + /** + * @param {number} len ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function Vec(len) { + /** @@ -23,6 +31,8 @@ + * @param {Vec} other + ~~~ +!!! error TS2749: 'Vec' refers to a value, but is being used as a type here. Did you mean 'typeof Vec'? ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + dot(other) { + if (other.storage.length !== this.storage.length) { @@ -45,7 +55,11 @@ + + /** + * @param {number} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} y ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function Point2D(x, y) { + if (!(this instanceof Point2D)) { @@ -65,6 +79,8 @@ + }, + /** + * @param {number} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set x(x) { + this.storage[0] = x; @@ -74,6 +90,8 @@ + }, + /** + * @param {number} y ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set y(y) { + this.storage[1] = y; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff index bf29d0665d..5862d1a7da 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff @@ -3,9 +3,10 @@ @@= skipped -0, +0 lines =@@ - +source.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++source.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== source.js (1 errors) ==== ++==== source.js (2 errors) ==== + module.exports = MyClass; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -20,4 +21,6 @@ + * + * @callback DoneCB + * @param {number} failures - Number of failures that occurred. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff index 303a737360..50cfcbec96 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff @@ -2,13 +2,28 @@ +++ new.jsDeclarationsFunctions.errors.txt @@= skipped -0, +0 lines =@@ - ++index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(14,45): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(14,59): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(20,13): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(22,45): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(22,59): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(38,21): error TS2349: This expression is not callable. + Type '{ y: any; }' has no call signatures. ++index.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(48,21): error TS2349: This expression is not callable. + Type '{ y: any; }' has no call signatures. + + -+==== index.js (2 errors) ==== ++==== index.js (17 errors) ==== + export function a() {} + + export function b() {} @@ -19,31 +34,73 @@ + + /** + * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {string} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function d(a, b) { return /** @type {*} */(null); } ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ + + /** ++ ~~~ + * @template T,U ++ ~~~~~~~~~~~~~~~~ + * @param {T} a ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T & U} ++ ~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + export function e(a, b) { return /** @type {*} */(null); } ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ + + /** ++ ~~~ + * @template T ++ ~~~~~~~~~~~~~~ + * @param {T} a ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + export function f(a) { ++ ~~~~~~~~~~~~~~~~~~~~~~ + return a; ++ ~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + f.self = f; + + /** + * @param {{x: string}} a ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof b}} b ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function g(a, b) { + return a.x && b.y(); @@ -56,7 +113,11 @@ + + /** + * @param {{x: string}} a ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof b}} b ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function hh(a, b) { + return a.x && b.y(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff index 4d291444a9..943c257cf6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff @@ -4,12 +4,18 @@ - +index.js(4,18): error TS2339: Property 'cat' does not exist on type '() => void'. +index.js(7,18): error TS2339: Property 'Cls' does not exist on type '() => void'. ++index.js(14,57): error TS8016: Type assertion expressions can only be used in TypeScript files. ++index.js(22,57): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(31,18): error TS2339: Property 'self' does not exist on type '(a: any) => any'. ++index.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. +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(44,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. +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 (5 errors) ==== ++==== index.js (11 errors) ==== + module.exports.a = function a() {} + + module.exports.b = function b() {} @@ -28,6 +34,8 @@ + * @return {string} + */ + module.exports.d = function d(a, b) { return /** @type {*} */(null); } ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** + * @template T,U @@ -36,6 +44,8 @@ + * @return {T & U} + */ + module.exports.e = function e(a, b) { return /** @type {*} */(null); } ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** + * @template T @@ -50,7 +60,11 @@ + + /** + * @param {{x: string}} a ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof module.exports.b}} b ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ @@ -62,7 +76,11 @@ + + /** + * @param {{x: string}} a ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof module.exports.b}} b ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff new file mode 100644 index 0000000000..7d2ac5d06e --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff @@ -0,0 +1,161 @@ +--- old.jsDeclarationsGetterSetter.errors.txt ++++ new.jsDeclarationsGetterSetter.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(33,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(44,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(52,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(66,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(72,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(81,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(85,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(94,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(98,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(107,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(111,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (12 errors) ==== ++ export class A { ++ get x() { ++ return 12; ++ } ++ } ++ ++ export class B { ++ /** ++ * @param {number} _arg ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set x(_arg) { ++ } ++ } ++ ++ export class C { ++ get x() { ++ return 12; ++ } ++ set x(_arg) { ++ } ++ } ++ ++ export class D {} ++ Object.defineProperty(D.prototype, "x", { ++ get() { ++ return 12; ++ } ++ }); ++ ++ export class E {} ++ Object.defineProperty(E.prototype, "x", { ++ /** ++ * @param {number} _arg ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set(_arg) {} ++ }); ++ ++ export class F {} ++ Object.defineProperty(F.prototype, "x", { ++ get() { ++ return 12; ++ }, ++ /** ++ * @param {number} _arg ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set(_arg) {} ++ }); ++ ++ export class G {} ++ Object.defineProperty(G.prototype, "x", { ++ /** ++ * @param {number[]} args ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set(...args) {} ++ }); ++ ++ export class H {} ++ Object.defineProperty(H.prototype, "x", { ++ set() {} ++ }); ++ ++ ++ export class I {} ++ Object.defineProperty(I.prototype, "x", { ++ /** ++ * @param {number} v ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ set: (v) => {} ++ }); ++ ++ /** ++ * @param {number} v ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const jSetter = (v) => {} ++ export class J {} ++ Object.defineProperty(J.prototype, "x", { ++ set: jSetter ++ }); ++ ++ /** ++ * @param {number} v ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const kSetter1 = (v) => {} ++ /** ++ * @param {number} v ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const kSetter2 = (v) => {} ++ export class K {} ++ Object.defineProperty(K.prototype, "x", { ++ set: Math.random() ? kSetter1 : kSetter2 ++ }); ++ ++ /** ++ * @param {number} v ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const lSetter1 = (v) => {} ++ /** ++ * @param {string} v ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const lSetter2 = (v) => {} ++ export class L {} ++ Object.defineProperty(L.prototype, "x", { ++ set: Math.random() ? lSetter1 : lSetter2 ++ }); ++ ++ /** ++ * @param {number | boolean} v ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const mSetter1 = (v) => {} ++ /** ++ * @param {string | boolean} v ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const mSetter2 = (v) => {} ++ export class M {} ++ Object.defineProperty(M.prototype, "x", { ++ set: Math.random() ? mSetter1 : mSetter2 ++ }); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff index 44269de68f..543d0da424 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff @@ -6,23 +6,29 @@ - -==== file.js (0 errors) ==== +file.js(4,11): error TS2315: Type 'Object' is not generic. ++file.js(4,11): error TS8010: Type annotations can only be used in TypeScript files. +file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. +file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. +file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +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(6,11): error TS8010: Type annotations can only be used in TypeScript files. +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. ++file2.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. ++file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== file.js (6 errors) ==== ++==== file.js (7 errors) ==== /** * @namespace myTypes * @global * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ const myTypes = { // SOME PROPS HERE @@ -50,7 +56,7 @@ export {myTypes}; -==== file2.js (1 errors) ==== -+==== file2.js (3 errors) ==== ++==== file2.js (6 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. @@ -61,6 +67,8 @@ * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ const testFnTypes = { // SOME PROPS HERE @@ -76,6 +84,11 @@ * @param {testFnTypes.input} input - Input. + ~~~~~~~~~~~ +!!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number|null} Result. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ - function testFn(input) { \ No newline at end of file + function testFn(input) { + if (typeof input === 'number') { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff index 516be88695..ef17a94160 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff @@ -3,18 +3,22 @@ @@= skipped -0, +0 lines =@@ - +file.js(4,11): error TS2315: Type 'Object' is not generic. ++file.js(4,11): error TS8010: Type annotations can only be used in TypeScript files. +file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. +file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. +file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +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(6,11): error TS8010: Type annotations can only be used in TypeScript files. +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. ++file2.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. ++file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. +file2.js(28,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== file2.js (4 errors) ==== ++==== file2.js (7 errors) ==== + const {myTypes} = require('./file.js'); + + /** @@ -23,6 +27,8 @@ + * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const testFnTypes = { + // SOME PROPS HERE @@ -38,7 +44,11 @@ + * @param {testFnTypes.input} input - Input. + ~~~~~~~~~~~ +!!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number|null} Result. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function testFn(input) { + if (typeof input === 'number') { @@ -51,13 +61,15 @@ + module.exports = {testFn, testFnTypes}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== file.js (6 errors) ==== ++==== file.js (7 errors) ==== + /** + * @namespace myTypes + * @global + * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const myTypes = { + // SOME PROPS HERE diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff index 3c6b8c3b2f..fc0ba03484 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff @@ -2,12 +2,15 @@ +++ new.jsDeclarationsImportNamespacedType.errors.txt @@= skipped -0, +0 lines =@@ - ++file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(2,29): error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. + + -+==== file.js (1 errors) ==== ++==== file.js (2 errors) ==== + import { dummy } from './mod1' + /** @type {import('./mod1').Dotted.Name} - should work */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. + var dot2 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff index 604789c684..e2da7af442 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff @@ -34,183 +34,365 @@ - - -==== index.js (30 errors) ==== -- // Pretty much all of this should be an error, (since interfaces are forbidden in js), -- // but we should be able to synthesize declarations from the symbols regardless -- -- export interface A {} -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- export interface B { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- cat: string; -- } -- -- export interface C { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- field: T & U; -- optionalField?: T; -- readonly readonlyField: T & U; -- readonly readonlyOptionalField?: U; -- (): number; -- (x: T): U; -- (x: Q): T & Q; -- -- new (): string; -- new (x: T): U; -- new (x: Q): T & Q; -- -- method(): number; -- method(a: T & Q): Q & number; -- method(a?: number): number; -- method(...args: any[]): number; -- -- optMethod?(): number; -- } -- -- interface G {} -- ~ ++index.js(1,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(4,22): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(8,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(29,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(33,14): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(37,20): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(42,20): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(43,22): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(47,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(51,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(55,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(59,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(63,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(65,32): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(69,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(73,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(78,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(82,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(84,32): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(89,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(93,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(98,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(103,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(105,32): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(109,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(113,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ ++==== index.js (26 errors) ==== + // Pretty much all of this should be an error, (since interfaces are forbidden in js), ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // but we should be able to synthesize declarations from the symbols regardless ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ + + export interface A {} +- ~ ++ ~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface B { +- ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- export { G }; ++ ~~~~~~~~~~~~~~~~~~~~ + cat: string; ++ ~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface C { +- ~ +-!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ + field: T & U; ++ ~~~~~~~~~~~~~~~~~ + optionalField?: T; ++ ~~~~~~~~~~~~~~~~~~~~~~ + readonly readonlyField: T & U; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + readonly readonlyOptionalField?: U; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + (): number; ++ ~~~~~~~~~~~~~~~ + (x: T): U; ++ ~~~~~~~~~~~~~~ + (x: Q): T & Q; ++ ~~~~~~~~~~~~~~~~~~~~~ ++ + + new (): string; ++ ~~~~~~~~~~~~~~~~~~~ + new (x: T): U; ++ ~~~~~~~~~~~~~~~~~~ + new (x: Q): T & Q; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++ + + method(): number; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + method(a: T & Q): Q & number; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + method(a?: number): number; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + method(...args: any[]): number; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ + + optMethod?(): number; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + interface G {} +- ~ ++ ~~~~~~~~~~~~~~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + export { G }; - ~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -- -- interface HH {} ++ ++ + + interface HH {} - ~~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- export { HH as H }; ++ ~~~~~~~~~~~~~~~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. + + export { HH as H }; - ~~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -- -- export interface I {} ++ ++ + + export interface I {} - ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- export { I as II }; ++ ~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. + export { I as II }; - ~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -- -- export { J as JJ }; + + export { J as JJ }; - ~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -- export interface J {} ++ + export interface J {} - ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- export interface K extends I,J { ++ ~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface K extends I,J { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- x: string; -- } -- -- export interface L extends K { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + x: string; ++ ~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface L extends K { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- y: string; -- } -- -- export interface M { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + y: string; ++ ~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface M { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- field: T; -- } -- -- export interface N extends M { ++ ~~~~~~~~~~~~~~~~~~~~~~~ + field: T; ++ ~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface N extends M { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- other: U; -- } -- -- export interface O { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + other: U; ++ ~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface O { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: string]: string; -- } -- -- export interface P extends O {} ++ ~~~~~~~~~~~~~~~~~~~~ + [idx: string]: string; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface P extends O {} - ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- export interface Q extends O { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface Q extends O { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: string]: "ok"; -- } -- -- export interface R extends O { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: "ok"; ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface R extends O { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: number]: "ok"; -- } -- -- export interface S extends O { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: "ok"; ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface S extends O { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: string]: "ok"; -- [idx: number]: never; -- } -- -- export interface T { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: "ok"; ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: never; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface T { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: number]: string; -- } -- -- export interface U extends T {} ++ ~~~~~~~~~~~~~~~~~~~~ + [idx: number]: string; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface U extends T {} - ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- -- export interface V extends T { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ ++ + + + export interface V extends T { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: string]: string; -- } -- -- export interface W extends T { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: string; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface W extends T { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: number]: "ok"; -- } -- -- export interface X extends T { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: "ok"; ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface X extends T { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: string]: string; -- [idx: number]: "ok"; -- } -- -- export interface Y { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: string; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: "ok"; ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface Y { - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: string]: {x: number}; -- [idx: number]: {x: number, y: number}; -- } -- -- export interface Z extends Y {} ++ ~~~~~~~~~~~~~~~~~~~~ + [idx: string]: {x: number}; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: {x: number, y: number}; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface Z extends Y {} - ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- export interface AA extends Y { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface AA extends Y { - ~~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: string]: {x: number, y: number}; -- } -- -- export interface BB extends Y { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: {x: number, y: number}; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface BB extends Y { - ~~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: number]: {x: 0, y: 0}; -- } -- -- export interface CC extends Y { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: {x: 0, y: 0}; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. ++ ++ + + export interface CC extends Y { - ~~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: string]: {x: number, y: number}; -- [idx: number]: {x: 0, y: 0}; -- } -- -+ \ No newline at end of file ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: string]: {x: number, y: number}; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [idx: number]: {x: 0, y: 0}; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff index d983ccd590..5bc136d0c9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff @@ -2,63 +2,114 @@ +++ new.jsDeclarationsJSDocRedirectedLookups.errors.txt @@= skipped -0, +0 lines =@@ - ++index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(5,12): error TS2304: Cannot find name 'Void'. ++index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(6,12): error TS2304: Cannot find name 'Undefined'. ++index.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(7,12): error TS2304: Cannot find name 'Null'. ++index.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(11,12): error TS2552: Cannot find name 'array'. Did you mean 'Array'? ++index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(12,12): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? ++index.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(13,12): error TS2315: Type 'Object' is not generic. ++index.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. +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(30,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (8 errors) ==== ++==== index.js (25 errors) ==== + // these are recognized as TS concepts by the checker + /** @type {String} */const a = ""; ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Number} */const b = 0; ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Boolean} */const c = true; ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Void} */const d = undefined; + ~~~~ +!!! error TS2304: Cannot find name 'Void'. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Undefined} */const e = undefined; + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'Undefined'. ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Null} */const f = null; + ~~~~ +!!! error TS2304: Cannot find name 'Null'. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + /** @type {Function} */const g = () => void 0; ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {array} */const i = []; + ~~~~~ +!!! error TS2552: Cannot find name 'array'. Did you mean 'Array'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Array' is declared here. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @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. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Object} */const k = {x: "x"}; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + + // 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; ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + // @ts-ignore + /** @type {bool} */const m = true; ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + // @ts-ignore + /** @type {int} */const n = true; ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + // @ts-ignore + /** @type {float} */const o = true; ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + // @ts-ignore + /** @type {integer} */const p = true; ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + // 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 ++!!! error TS2749: 'event' refers to a value, but is being used as a type here. Did you mean 'typeof event'? ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file 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..64df139f01 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingGenerics.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.jsDeclarationsMissingGenerics.errors.txt ++++ new.jsDeclarationsMissingGenerics.errors.txt +@@= skipped -0, +0 lines =@@ +- ++file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== file.js (2 errors) ==== ++ /** ++ * @param {Array} x ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function x(x) {} ++ /** ++ * @param {Promise} x ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function y(x) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff index 4740647901..7f1aaeea10 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff @@ -2,14 +2,23 @@ +++ new.jsDeclarationsMissingTypeParameters.errors.txt @@= skipped -0, +0 lines =@@ - ++file.js(2,5): error TS8009: The '?' modifier can only be used in TypeScript files. ++file.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. +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,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== file.js (2 errors) ==== ++==== file.js (6 errors) ==== + /** + * @param {Array=} y desc ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + function x(y) { } + + // @ts-ignore @@ -19,6 +28,8 @@ + + /** + * @return {(Array.<> | null)} list of devices ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + ~~ @@ -29,5 +40,7 @@ + /** + * + * @return {?Promise} A promise ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function w() { return null; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff index 6344763693..98a58766b9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff @@ -3,9 +3,10 @@ @@= skipped -0, +0 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(9,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (1 errors) ==== ++==== index.js (2 errors) ==== + /** + * @module A + */ @@ -17,6 +18,8 @@ + * @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`. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export let el = null; + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff index 8ffe7e8556..fec041d231 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff @@ -2,18 +2,28 @@ +++ new.jsDeclarationsNestedParams.errors.txt @@= skipped -0, +0 lines =@@ - ++file.js(5,9): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(7,19): error TS8010: Type annotations can only be used in TypeScript files. +file.js(7,26): error TS8020: JSDoc types can only be used inside documentation comments. ++file.js(16,9): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(20,19): error TS8010: Type annotations can only be used in TypeScript files. +file.js(20,26): error TS8020: JSDoc types can only be used inside documentation comments. + + -+==== file.js (2 errors) ==== ++==== file.js (6 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 TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + */ @@ -25,10 +35,18 @@ + * 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 TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt.diff new file mode 100644 index 0000000000..cffe859faa --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.jsDeclarationsOptionalTypeLiteralProps1.errors.txt ++++ new.jsDeclarationsOptionalTypeLiteralProps1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++foo.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (1 errors) ==== ++ /** ++ * foo ++ * ++ * @public ++ * @param {object} opts ++ * @param {number} opts.a ++ * @param {number} [opts.b] ++ * @param {number} [opts.c] ++ * @returns {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function foo({ a, b, c }) { ++ return a + b + c; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt.diff index 985ac34538..f97b9b3ebe 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt.diff @@ -2,12 +2,13 @@ +++ new.jsDeclarationsOptionalTypeLiteralProps2.errors.txt @@= skipped -0, +0 lines =@@ - ++foo.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(11,16): error TS7031: Binding element 'a' implicitly has an 'any' type. +foo.js(11,19): error TS7031: Binding element 'b' implicitly has an 'any' type. +foo.js(11,22): error TS7031: Binding element 'c' implicitly has an 'any' type. + + -+==== foo.js (3 errors) ==== ++==== foo.js (4 errors) ==== + /** + * foo + * @@ -17,6 +18,8 @@ + * @param {number} [opts.b] + * @param {number} [opts.c] + * @returns {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo({ a, b, c }) { + ~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff index b2112d421b..a6dd054bd3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff @@ -5,6 +5,9 @@ +base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +file.js(1,15): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? +file.js(4,12): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? ++file.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== base.js (1 errors) ==== @@ -22,7 +25,7 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + -+==== file.js (2 errors) ==== ++==== file.js (5 errors) ==== + /** @typedef {import('./base')} BaseFactory */ + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? @@ -31,6 +34,8 @@ + * @param {import('./base')} factory + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + /** @enum {import('./base')} */ + const couldntThinkOfAny = {} @@ -38,7 +43,11 @@ + /** + * + * @param {InstanceType} base ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {InstanceType} ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const test = (base) => { + return base; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff index b007854e6e..fef5b188fb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff @@ -3,6 +3,8 @@ @@= skipped -0, +0 lines =@@ - +base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ++file.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== base.js (1 errors) ==== @@ -20,13 +22,17 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + -+==== file.js (0 errors) ==== ++==== file.js (2 errors) ==== + /** @typedef {typeof import('./base')} BaseFactory */ + + /** + * + * @param {InstanceType} base ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {InstanceType} ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const test = (base) => { + return base; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsPrivateFields01.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsPrivateFields01.errors.txt.diff new file mode 100644 index 0000000000..94bb89dc58 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsPrivateFields01.errors.txt.diff @@ -0,0 +1,31 @@ +--- old.jsDeclarationsPrivateFields01.errors.txt ++++ new.jsDeclarationsPrivateFields01.errors.txt +@@= skipped -0, +0 lines =@@ +- ++file.js(12,23): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== file.js (1 errors) ==== ++ export class C { ++ #hello = "hello"; ++ #world = 100; ++ ++ #calcHello() { ++ return this.#hello; ++ } ++ ++ get #screamingHello() { ++ return this.#hello.toUpperCase(); ++ } ++ /** @param value {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ set #screamingHello(value) { ++ throw "NO"; ++ } ++ ++ getWorld() { ++ return this.#world; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.errors.txt.diff new file mode 100644 index 0000000000..5af197c8e5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.errors.txt.diff @@ -0,0 +1,106 @@ +--- old.jsDeclarationsReactComponents.errors.txt ++++ new.jsDeclarationsReactComponents.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsDeclarationsReactComponents2.jsx(3,11): error TS8010: Type annotations can only be used in TypeScript files. ++jsDeclarationsReactComponents3.jsx(3,11): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== jsDeclarationsReactComponents1.jsx (0 errors) ==== ++ /// ++ import React from "react"; ++ import PropTypes from "prop-types" ++ ++ const TabbedShowLayout = ({ ++ }) => { ++ return ( ++
++ ); ++ }; ++ ++ TabbedShowLayout.propTypes = { ++ version: PropTypes.number, ++ ++ }; ++ ++ TabbedShowLayout.defaultProps = { ++ tabs: undefined ++ }; ++ ++ export default TabbedShowLayout; ++ ++==== jsDeclarationsReactComponents2.jsx (1 errors) ==== ++ import React from "react"; ++ /** ++ * @type {React.SFC} ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const TabbedShowLayout = () => { ++ return ( ++
++ ok ++
++ ); ++ }; ++ ++ TabbedShowLayout.defaultProps = { ++ tabs: "default value" ++ }; ++ ++ export default TabbedShowLayout; ++ ++==== jsDeclarationsReactComponents3.jsx (1 errors) ==== ++ import React from "react"; ++ /** ++ * @type {{defaultProps: {tabs: string}} & ((props?: {elem: string}) => JSX.Element)} ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const TabbedShowLayout = () => { ++ return ( ++
++ ok ++
++ ); ++ }; ++ ++ TabbedShowLayout.defaultProps = { ++ tabs: "default value" ++ }; ++ ++ export default TabbedShowLayout; ++ ++==== jsDeclarationsReactComponents4.jsx (0 errors) ==== ++ import React from "react"; ++ const TabbedShowLayout = (/** @type {{className: string}}*/prop) => { ++ return ( ++
++ ok ++
++ ); ++ }; ++ ++ TabbedShowLayout.defaultProps = { ++ tabs: "default value" ++ }; ++ ++ export default TabbedShowLayout; ++==== jsDeclarationsReactComponents5.jsx (0 errors) ==== ++ import React from 'react'; ++ import PropTypes from 'prop-types'; ++ ++ function Tree({ allowDropOnRoot }) { ++ return
++ } ++ ++ Tree.propTypes = { ++ classes: PropTypes.object, ++ }; ++ ++ Tree.defaultProps = { ++ classes: {}, ++ parentSource: 'parent_id', ++ }; ++ ++ export default Tree; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReexportedCjsAlias.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReexportedCjsAlias.errors.txt.diff new file mode 100644 index 0000000000..0587995303 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReexportedCjsAlias.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.jsDeclarationsReexportedCjsAlias.errors.txt ++++ new.jsDeclarationsReexportedCjsAlias.errors.txt +@@= skipped -0, +0 lines =@@ +- ++lib.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== main.js (0 errors) ==== ++ const { SomeClass, SomeClass: Another } = require('./lib'); ++ ++ module.exports = { ++ SomeClass, ++ Another ++ } ++==== lib.js (1 errors) ==== ++ /** ++ * @param {string} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function bar(a) { ++ return a + a; ++ } ++ ++ class SomeClass { ++ a() { ++ return 1; ++ } ++ } ++ ++ module.exports = { ++ bar, ++ SomeClass ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt.diff index a4400a9598..99ec32649f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt.diff @@ -4,6 +4,7 @@ - +index.js(7,19): error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? +index.js(14,18): error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? ++index.js(14,18): error TS8010: Type annotations can only be used in TypeScript files. + + +==== test.js (0 errors) ==== @@ -20,7 +21,7 @@ + } + + module.exports = { Rectangle }; -+==== index.js (2 errors) ==== ++==== index.js (3 errors) ==== + const {Rectangle} = require('./rectangle'); + + class Render { @@ -39,6 +40,8 @@ + * @returns {Rectangle} the rect + ~~~~~~~~~ +!!! error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + addRectangle() { + const obj = new Rectangle(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff index 84a007210a..e9f2ce081f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff @@ -2,43 +2,67 @@ +++ new.jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt @@= skipped -0, +0 lines =@@ - ++index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++index.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(22,12): error TS2315: Type 'Object' is not generic. ++index.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(22,18): error TS8020: JSDoc types can only be used inside documentation comments. + + -+==== index.js (4 errors) ==== ++==== index.js (12 errors) ==== + /** @type {?} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const a = null; + + /** @type {*} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const b = null; + + /** @type {string?} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const c = null; + + /** @type {string=} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const d = null; + + /** @type {string!} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const g = null; + + /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + 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 28c1441a5e..b97965ebc9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt.diff @@ -2,22 +2,44 @@ +++ new.jsDeclarationsReusesExistingTypeAnnotations.errors.txt @@= skipped -0, +0 lines =@@ - ++index.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(11,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(44,9): error TS1051: A 'set' accessor cannot have an optional parameter. ++index.js(44,9): error TS8009: The '?' modifier can only be used in TypeScript files. ++index.js(44,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(54,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(64,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(74,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(82,9): error TS1051: A 'set' accessor cannot have an optional parameter. ++index.js(82,9): error TS8009: The '?' modifier can only be used in TypeScript files. ++index.js(82,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(87,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(92,17): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(97,17): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (2 errors) ==== ++==== index.js (16 errors) ==== + class С1 { + /** @type {string=} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + p1 = undefined; + + /** @type {string | undefined} */ ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + p2 = undefined; + + /** @type {?string} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + p3 = null; + + /** @type {string | null} */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + p4 = null; + } + @@ -53,6 +75,10 @@ + /** @param {string=} value */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1051: A 'set' accessor cannot have an optional parameter. ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set p1(value) { + this.p1 = value; + } @@ -63,6 +89,8 @@ + } + + /** @param {string | undefined} value */ ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set p2(value) { + this.p2 = value; + } @@ -73,6 +101,8 @@ + } + + /** @param {?string} value */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set p3(value) { + this.p3 = value; + } @@ -83,6 +113,8 @@ + } + + /** @param {string | null} value */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set p4(value) { + this.p4 = value; + } @@ -93,21 +125,31 @@ + /** @param {string=} value */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1051: A 'set' accessor cannot have an optional parameter. ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set p1(value) { + this.p1 = value; + } + + /** @param {string | undefined} value */ ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set p2(value) { + this.p2 = value; + } + + /** @param {?string} value */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set p3(value) { + this.p3 = value; + } + + /** @param {string | null} value */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + set p4(value) { + this.p4 = value; + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff new file mode 100644 index 0000000000..6a672cfc91 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff @@ -0,0 +1,26 @@ +--- old.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt ++++ new.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (2 errors) ==== ++ export class Super { ++ /** ++ * @param {string} firstArg ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {string} secondArg ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ constructor(firstArg, secondArg) { } ++ } ++ ++ export class Sub extends Super { ++ constructor() { ++ super('first', 'second'); ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff new file mode 100644 index 0000000000..cd400cd8ef --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.jsDeclarationsThisTypes.errors.txt ++++ new.jsDeclarationsThisTypes.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (1 errors) ==== ++ export class A { ++ /** @returns {this} */ ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ method() { ++ return this; ++ } ++ } ++ export default class Base extends A { ++ // This method is required to reproduce #35932 ++ verify() { } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff index 87be54e949..a2e90f9e10 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff @@ -2,10 +2,14 @@ +++ new.jsDeclarationsTypeAliases.errors.txt @@= skipped -0, +0 lines =@@ - ++index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. ++mixed.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++mixed.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. +mixed.js(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== index.js (0 errors) ==== ++==== index.js (2 errors) ==== + export {}; // flag file as module + /** + * @typedef {string | number | symbol} PropName @@ -16,6 +20,8 @@ + * + * @callback NumberToStringCb + * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string} + */ + @@ -30,16 +36,22 @@ + * @template T + * @callback Identity + * @param {T} x ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + */ + -+==== mixed.js (1 errors) ==== ++==== mixed.js (3 errors) ==== + /** + * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType + */ + /** + * @param {number} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {SomeType} ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function doTheThing(x) { + return {x: ""+x}; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt.diff new file mode 100644 index 0000000000..b680283829 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.jsDeclarationsTypeReassignmentFromDeclaration.errors.txt ++++ new.jsDeclarationsTypeReassignmentFromDeclaration.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /some-mod.d.ts (0 errors) ==== ++ interface Item { ++ x: string; ++ } ++ declare const items: Item[]; ++ export = items; ++==== index.js (1 errors) ==== ++ /** @type {typeof import("/some-mod")} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const items = []; ++ module.exports = items; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff index a75e868ac2..08ad6aed22 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff @@ -2,26 +2,36 @@ +++ new.jsDeclarationsTypeReferences4.errors.txt @@= skipped -0, +0 lines =@@ -index.js(4,18): error TS8006: 'namespace' declarations can only be used in TypeScript files. -- -- --==== index.js (1 errors) ==== -- /// -- export const Something = 2; // to show conflict that can occur -- // @ts-ignore -- export namespace A { ++index.js(2,28): error TS8006: 'module' declarations can only be used in TypeScript files. + + + ==== index.js (1 errors) ==== + /// + export const Something = 2; // to show conflict that can occur ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // @ts-ignore ++ ~~~~~~~~~~~~~ + export namespace A { - ~ -!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. -- // @ts-ignore -- export namespace B { -- const Something = require("fs").Something; -- const thing = new Something(); -- // @ts-ignore -- export { thing }; -- } -- } -- --==== node_modules/@types/node/index.d.ts (0 errors) ==== -- declare module "fs" { -- export class Something {} -- } -+ \ No newline at end of file ++ ~~~~~~~~~~~~~~~~~~~~ + // @ts-ignore ++ ~~~~~~~~~~~~~~~~~ + export namespace B { ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + const Something = require("fs").Something; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const thing = new Something(); ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // @ts-ignore ++ ~~~~~~~~~~~~~~~~~~~~~ + export { thing }; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~~~~~ + } ++ ~ ++!!! error TS8006: 'module' declarations can only be used in TypeScript files. + + ==== node_modules/@types/node/index.d.ts (0 errors) ==== + declare module "fs" { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff index 63315a780b..7f1e67e057 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +0 lines =@@ - +conn.js(11,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++usage.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. +usage.js(11,37): error TS2694: Namespace 'Conn' has no exported member 'Whatever'. +usage.js(16,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + @@ -22,7 +23,7 @@ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== usage.js (2 errors) ==== ++==== usage.js (3 errors) ==== + /** + * @typedef {import("./conn")} Conn + */ @@ -30,6 +31,8 @@ + class Wrap { + /** + * @param {Conn} c ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(c) { + this.connItem = c.item; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff index cbea1dc733..1e7e95b275 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff @@ -2,18 +2,22 @@ +++ new.jsDeclarationsTypedefAndLatebound.errors.txt @@= skipped -0, +0 lines =@@ - ++LazySet.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. +LazySet.js(13,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (0 errors) ==== ++==== index.js (1 errors) ==== + const LazySet = require("./LazySet"); + + /** @type {LazySet} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const stringSet = undefined; + stringSet.addAll(stringSet); + + -+==== LazySet.js (1 errors) ==== ++==== LazySet.js (2 errors) ==== + // Comment out this JSDoc, and note that the errors index.js go away. + /** + * @typedef {Object} SomeObject @@ -21,6 +25,8 @@ + class LazySet { + /** + * @param {LazySet} iterable ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + addAll(iterable) {} + [Symbol.iterator]() {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.errors.txt.diff new file mode 100644 index 0000000000..c936fbdd96 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.errors.txt.diff @@ -0,0 +1,31 @@ +--- old.jsDeclarationsTypedefFunction.errors.txt ++++ new.jsDeclarationsTypedefFunction.errors.txt +@@= skipped -0, +0 lines =@@ +- ++foo.js(3,10): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (3 errors) ==== ++ /** ++ * @typedef {{ ++ * [id: string]: [Function, Function]; ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * }} ResolveRejectMap ++ */ ++ ++ let id = 0 ++ ++ /** ++ * @param {ResolveRejectMap} handlers ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {Promise} ++ ~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const send = handlers => new Promise((resolve, reject) => { ++ handlers[++id] = [resolve, reject] ++ }) \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff index a95ad05e93..22947afeb7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff @@ -3,12 +3,16 @@ @@= skipped -0, +0 lines =@@ - +index.js(3,37): error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. ++index.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(16,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(21,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++module.js(11,11): error TS8010: Type annotations can only be used in TypeScript files. +module.js(24,12): error TS2315: Type 'Object' is not generic. ++module.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. +module.js(27,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== index.js (2 errors) ==== ++==== index.js (4 errors) ==== + const {taskGroups, taskNameToGroup} = require('./module.js'); + + /** @typedef {import('./module.js').TaskGroup} TaskGroup */ @@ -26,7 +30,11 @@ + class MainThreadTasks { + /** + * @param {TaskGroup} x ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {TaskNode} y ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(x, y){} + } @@ -34,7 +42,7 @@ + module.exports = MainThreadTasks; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== module.js (2 errors) ==== ++==== module.js (4 errors) ==== + /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ + + /** @@ -46,6 +54,8 @@ + + /** + * @type {{[P in TaskGroupIds]: {id: P, label: string}}} ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const taskGroups = { + parseHTML: { @@ -61,6 +71,8 @@ + /** @type {Object} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const taskNameToGroup = {}; + + module.exports = { 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..82e983d6fc --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.jsDeclarationsUniqueSymbolUsage.errors.txt ++++ new.jsDeclarationsUniqueSymbolUsage.errors.txt +@@= skipped -0, +0 lines =@@ +- ++b.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. ++b.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (0 errors) ==== ++ export const kSymbol = Symbol("my-symbol"); ++ ++ /** ++ * @typedef {{[kSymbol]: true}} WithSymbol ++ */ ++==== b.js (2 errors) ==== ++ /** ++ * @returns {import('./a').WithSymbol} ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {import('./a').WithSymbol} value ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function b(value) { ++ return value; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff new file mode 100644 index 0000000000..f0c93aa0b0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff @@ -0,0 +1,45 @@ +--- old.jsdocAccessibilityTags.errors.txt ++++ new.jsdocAccessibilityTags.errors.txt +@@= skipped -0, +0 lines =@@ ++jsdocAccessibilityTag.js(5,8): error TS8009: The 'private' modifier can only be used in TypeScript files. ++jsdocAccessibilityTag.js(11,8): error TS8009: The 'protected' modifier can only be used in TypeScript files. ++jsdocAccessibilityTag.js(17,8): error TS8009: The 'public' modifier can only be used in TypeScript files. + jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. + jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. + jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. +@@= skipped -9, +12 lines =@@ + jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. + + +-==== jsdocAccessibilityTag.js (10 errors) ==== ++==== jsdocAccessibilityTag.js (13 errors) ==== + class A { + /** + * Ap docs + * + * @private ++ ~~~~~~~~ + */ ++ ~~~~~ ++!!! error TS8009: The 'private' modifier can only be used in TypeScript files. + priv = 4; + /** + * Aq docs + * + * @protected ++ ~~~~~~~~~~ + */ ++ ~~~~~ ++!!! error TS8009: The 'protected' modifier can only be used in TypeScript files. + prot = 5; + /** + * Ar docs + * + * @public ++ ~~~~~~~ + */ ++ ~~~~~ ++!!! error TS8009: The 'public' modifier can only be used in TypeScript files. + pub = 6; + /** @public */ + get ack() { return this.priv } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff new file mode 100644 index 0000000000..b23b773c08 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.jsdocAugments_withTypeParameter.errors.txt ++++ new.jsdocAugments_withTypeParameter.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/b.js(2,16): error TS8011: Type arguments can only be used in TypeScript files. ++ ++ ++==== /a.d.ts (0 errors) ==== ++ declare class A { x: T } ++ ++==== /b.js (1 errors) ==== ++ /** @augments A */ ++ class B extends A { ++ ~~ ++!!! error TS8011: Type arguments can only be used in TypeScript files. ++ m() { ++ return this.x; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.errors.txt.diff new file mode 100644 index 0000000000..0a0b39828d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.jsdocBindingInUnreachableCode.errors.txt ++++ new.jsdocBindingInUnreachableCode.errors.txt +@@= skipped -0, +0 lines =@@ +- ++bug27341.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== bug27341.js (1 errors) ==== ++ if (false) { ++ /** ++ * @param {string} s ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ const x = function (s) { ++ }; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt.diff new file mode 100644 index 0000000000..61f9e009ba --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt.diff @@ -0,0 +1,146 @@ +--- old.jsdocCatchClauseWithTypeAnnotation.errors.txt ++++ new.jsdocCatchClauseWithTypeAnnotation.errors.txt +@@= skipped -0, +0 lines =@@ ++foo.js(11,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(12,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(13,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(14,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(16,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(17,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(18,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(19,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(20,31): error TS8010: Type annotations can only be used in TypeScript files. + foo.js(20,54): error TS2339: Property 'foo' does not exist on type 'unknown'. ++foo.js(21,31): error TS8010: Type annotations can only be used in TypeScript files. + 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(22,31): error TS8010: Type annotations can only be used in TypeScript files. + foo.js(23,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. ++foo.js(23,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(27,23): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(34,14): error TS8010: Type annotations can only be used in TypeScript files. + foo.js(35,7): error TS2492: Cannot redeclare identifier 'err' in catch clause. ++foo.js(39,14): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(44,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(45,31): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(46,31): error TS8010: Type annotations can only be used in TypeScript files. + foo.js(46,45): error TS2339: Property 'x' does not exist on type '{}'. ++foo.js(47,31): error TS8010: Type annotations can only be used in TypeScript files. + 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(48,31): error TS8010: Type annotations can only be used in TypeScript files. + foo.js(49,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. +- +- +-==== foo.js (9 errors) ==== ++foo.js(49,31): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (30 errors) ==== + /** + * @typedef {any} Any + */ +@@= skipped -20, +41 lines =@@ + function fn() { + try { } catch (x) { } // should be OK + try { } catch (/** @type {any} */ err) { } // should be OK ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {Any} */ err) { } // should be OK ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {unknown} */ err) { } // should be OK ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {Unknown} */ err) { } // should be OK ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (err) { err.foo; } // should be OK + try { } catch (/** @type {any} */ err) { err.foo; } // should be OK ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {Any} */ err) { err.foo; } // should be OK ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {unknown} */ err) { console.log(err); } // should be OK ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {Unknown} */ err) { console.log(err); } // should be OK ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {unknown} */ err) { err.foo; } // error in the body ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ + !!! error TS2339: Property 'foo' does not exist on type 'unknown'. + try { } catch (/** @type {Unknown} */ err) { err.foo; } // error in the body ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ + !!! 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. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {object} */ err) { } // error in the type + ~~~~~~ + !!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + try { console.log(); } + // @ts-ignore + catch (/** @type {number} */ err) { // e should not be a `number` ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + console.log(err.toLowerCase()); + } + +@@= skipped -31, +57 lines =@@ + try { } + catch (err) { + /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + let err; + ~~~ + !!! error TS2492: Cannot redeclare identifier 'err' in catch clause. +@@= skipped -7, +9 lines =@@ + try { } + catch (err) { + /** @type {boolean} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var err; + } + + try { } catch ({ x }) { } // should be OK + try { } catch (/** @type {any} */ { x }) { x.foo; } // should be OK ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {Any} */ { x }) { x.foo;} // should be OK ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {unknown} */ { x }) { console.log(x); } // error in the destructure ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ + !!! error TS2339: Property 'x' does not exist on type '{}'. + try { } catch (/** @type {Unknown} */ { x }) { console.log(x); } // error in the destructure ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ + !!! 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. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + try { } catch (/** @type {object} */ { x }) { } // error in the type + ~~~~~~ + !!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff index 1dd3554bc8..1542802ffa 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff @@ -3,9 +3,10 @@ @@= skipped -0, +0 lines =@@ - +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(8,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocConstructorFunctionTypeReference.js (1 errors) ==== ++==== jsdocConstructorFunctionTypeReference.js (2 errors) ==== + var Validator = function VFunc() { + this.flags = "gim" + }; @@ -16,6 +17,8 @@ + * @param {Validator} state + ~~~~~~~~~ +!!! error TS2749: 'Validator' refers to a value, but is being used as a type here. Did you mean 'typeof Validator'? ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var validateRegExpFlags = function(state) { + return state.flags diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff index 6b6ecc5911..5e7e98203f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff @@ -7,25 +7,34 @@ - -==== functions.js (1 errors) ==== +functions.js(3,13): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++functions.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +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(13,13): error TS8010: Type annotations can only be used in TypeScript files. +functions.js(15,14): error TS7006: Parameter 'c' implicitly has an 'any' type. ++functions.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. +functions.js(30,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++functions.js(30,12): error TS8010: Type annotations can only be used in TypeScript files. +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(36,12): error TS8010: Type annotations can only be used in TypeScript files. +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(49,13): error TS8010: Type annotations can only be used in TypeScript files. +functions.js(51,26): error TS7006: Parameter 'dref' implicitly has an 'any' type. ++functions.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. +functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. + + -+==== functions.js (11 errors) ==== ++==== functions.js (18 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id1(c) { + ~ @@ -43,6 +52,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id2(c) { + ~ @@ -50,13 +61,22 @@ return c } -@@= skipped -32, +53 lines =@@ + class C { + /** @param {number} n */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor(n) { + this.length = n; + } +@@= skipped -32, +66 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var f = function (ab, onetwo) { return ab === "a" ? 3 : 4; } + ~~ +!!! error TS7006: Parameter 'ab' implicitly has an 'any' type. @@ -65,12 +85,21 @@ /** -@@= skipped -19, +26 lines =@@ + * @constructor + * @param {number} n ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function D(n) { + this.length = n; +@@= skipped -19, +30 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'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ var construct = function(dref) { return new dref(33); } + ~~~~ @@ -78,7 +107,16 @@ var z3 = construct(D); z3.length; -@@= skipped -16, +20 lines =@@ +@@= skipped -9, +15 lines =@@ + /** + * @constructor + * @param {number} n ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var E = function(n) { + this.not_length_on_purpose = n; +@@= skipped -7, +9 lines =@@ var y3 = id2(E); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplementsTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplementsTag.errors.txt.diff new file mode 100644 index 0000000000..d2b7121db0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplementsTag.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.jsdocImplementsTag.errors.txt ++++ new.jsdocImplementsTag.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(6,17): error TS8005: 'implements' clauses can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ /** ++ * @typedef { { foo: string } } A ++ */ ++ ++ /** ++ * @implements { A } ++ ~~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. ++ */ ++ class B { ++ foo = '' ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.errors.txt.diff new file mode 100644 index 0000000000..36de9321b4 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.errors.txt.diff @@ -0,0 +1,49 @@ +--- old.jsdocImplements_class.errors.txt ++++ new.jsdocImplements_class.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(2,18): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(5,18): error TS8005: 'implements' clauses can only be used in TypeScript files. ++/a.js(10,17): error TS8005: 'implements' clauses can only be used in TypeScript files. ++/a.js(12,18): error TS8010: Type annotations can only be used in TypeScript files. + /a.js(13,5): error TS2416: Property 'method' in type 'B2' is not assignable to the same property in base type 'A'. + Type '() => string' is not assignable to type '() => number'. + Type 'string' is not assignable to type 'number'. ++/a.js(16,18): error TS8005: 'implements' clauses can only be used in TypeScript files. + /a.js(17,7): error TS2720: Class 'B3' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? + Property 'method' is missing in type 'B3' but required in type 'A'. + + +-==== /a.js (2 errors) ==== ++==== /a.js (7 errors) ==== + class A { + /** @return {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + method() { throw new Error(); } + } + /** @implements {A} */ ++ ~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B { + method() { return 0 } + } + + /** @implements A */ ++ ~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B2 { + /** @return {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + method() { return "" } + ~~~~~~ + !!! error TS2416: Property 'method' in type 'B2' is not assignable to the same property in base type 'A'. +@@= skipped -25, +38 lines =@@ + } + + /** @implements {A} */ ++ ~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B3 { + ~~ + !!! error TS2720: Class 'B3' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface.errors.txt.diff new file mode 100644 index 0000000000..b185b93244 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface.errors.txt.diff @@ -0,0 +1,41 @@ +--- old.jsdocImplements_interface.errors.txt ++++ new.jsdocImplements_interface.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(1,17): error TS8005: 'implements' clauses can only be used in TypeScript files. ++/a.js(7,18): error TS8005: 'implements' clauses can only be used in TypeScript files. + /a.js(9,5): error TS2416: Property 'mNumber' in type 'B2' is not assignable to the same property in base type 'A'. + Type '() => string' is not assignable to type '() => number'. + Type 'string' is not assignable to type 'number'. ++/a.js(13,17): error TS8005: 'implements' clauses can only be used in TypeScript files. + /a.js(14,7): error TS2420: Class 'B3' incorrectly implements interface 'A'. + Property 'mNumber' is missing in type 'B3' but required in type 'A'. + +@@= skipped -8, +11 lines =@@ + interface A { + mNumber(): number; + } +-==== /a.js (2 errors) ==== ++==== /a.js (5 errors) ==== + /** @implements A */ ++ ~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B { + mNumber() { + return 0; + } + } + /** @implements {A} */ ++ ~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B2 { + mNumber() { + ~~~~~~~ +@@= skipped -18, +22 lines =@@ + } + } + /** @implements A */ ++ ~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B3 { + ~~ + !!! error TS2420: Class 'B3' incorrectly implements interface 'A'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface_multiple.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface_multiple.errors.txt.diff new file mode 100644 index 0000000000..bddb4ec339 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface_multiple.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.jsdocImplements_interface_multiple.errors.txt ++++ new.jsdocImplements_interface_multiple.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(2,17): error TS8005: 'implements' clauses can only be used in TypeScript files. ++/a.js(14,16): error TS8005: 'implements' clauses can only be used in TypeScript files. + /a.js(17,7): error TS2420: Class 'BadSquare' incorrectly implements interface 'Drawable'. + Property 'draw' is missing in type 'BadSquare' but required in type 'Drawable'. + +@@= skipped -8, +10 lines =@@ + interface Sizable { + size(): number; + } +-==== /a.js (1 errors) ==== ++==== /a.js (3 errors) ==== + /** + * @implements {Drawable} ++ ~~~~~~~~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + * @implements Sizable + **/ + class Square { +@@= skipped -15, +17 lines =@@ + } + /** + * @implements Drawable ++ ~~~~~~~~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + * @implements {Sizable} + **/ + class BadSquare { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_missingType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_missingType.errors.txt.diff index 7a27f9d761..3d11cbb353 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_missingType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_missingType.errors.txt.diff @@ -2,14 +2,15 @@ +++ new.jsdocImplements_missingType.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(2,16): error TS1003: Identifier expected. -- -- --==== /a.js (1 errors) ==== -- class A { constructor() { this.x = 0; } } -- /** @implements */ -- ++/a.js(2,16): error TS8005: 'implements' clauses can only be used in TypeScript files. + + + ==== /a.js (1 errors) ==== + class A { constructor() { this.x = 0; } } + /** @implements */ + -!!! error TS1003: Identifier expected. -- class B { -- } -- -+ \ No newline at end of file ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B { + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_namespacedInterface.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_namespacedInterface.errors.txt.diff new file mode 100644 index 0000000000..3f0c5d1f6b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_namespacedInterface.errors.txt.diff @@ -0,0 +1,35 @@ +--- old.jsdocImplements_namespacedInterface.errors.txt ++++ new.jsdocImplements_namespacedInterface.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(1,17): error TS8005: 'implements' clauses can only be used in TypeScript files. ++/a.js(7,18): error TS8005: 'implements' clauses can only be used in TypeScript files. ++ ++ ++==== /defs.d.ts (0 errors) ==== ++ declare namespace N { ++ interface A { ++ mNumber(): number; ++ } ++ interface AT { ++ gen(): T; ++ } ++ } ++==== /a.js (2 errors) ==== ++ /** @implements N.A */ ++ ~~~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. ++ class B { ++ mNumber() { ++ return 0; ++ } ++ } ++ /** @implements {N.AT} */ ++ ~~~~~~~~~~~~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. ++ class BAT { ++ gen() { ++ return ""; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_properties.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_properties.errors.txt.diff new file mode 100644 index 0000000000..6f53e5c0c0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_properties.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.jsdocImplements_properties.errors.txt ++++ new.jsdocImplements_properties.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(2,17): error TS8005: 'implements' clauses can only be used in TypeScript files. + /a.js(3,7): error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? + Property 'x' is missing in type 'B' but required in type 'A'. +- +- +-==== /a.js (1 errors) ==== ++/a.js(5,17): error TS8005: 'implements' clauses can only be used in TypeScript files. ++/a.js(10,18): error TS8005: 'implements' clauses can only be used in TypeScript files. ++ ++ ++==== /a.js (4 errors) ==== + class A { constructor() { this.x = 0; } } + /** @implements A*/ ++ ~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B {} + ~ + !!! error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? +@@= skipped -11, +16 lines =@@ + !!! related TS2728 /a.js:1:27: 'x' is declared here. + + /** @implements A*/ ++ ~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B2 { + x = 10 + } + + /** @implements {A}*/ ++ ~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B3 { + constructor() { this.x = 10 } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_signatures.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_signatures.errors.txt.diff new file mode 100644 index 0000000000..41a0bf7220 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_signatures.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.jsdocImplements_signatures.errors.txt ++++ new.jsdocImplements_signatures.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(1,18): error TS8005: 'implements' clauses can only be used in TypeScript files. + /a.js(2,7): error TS2420: Class 'B' incorrectly implements interface 'Sig'. + Index signature for type 'string' is missing in type 'B'. + +@@= skipped -5, +6 lines =@@ + interface Sig { + [index: string]: string + } +-==== /a.js (1 errors) ==== ++==== /a.js (2 errors) ==== + /** @implements {Sig} */ ++ ~~~ ++!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + class B { + ~ + !!! error TS2420: Class 'B' incorrectly implements interface 'Sig'. \ No newline at end of file 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..bfea2f6c4d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.jsdocImportType.errors.txt ++++ new.jsdocImportType.errors.txt +@@= skipped -0, +0 lines =@@ +- ++use.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. ++use.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== use.js (2 errors) ==== ++ /// ++ /** @typedef {import("./mod1")} C ++ * @type {C} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ var c; ++ c.chunk; ++ ++ const D = require("./mod1"); ++ /** @type {D} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ 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/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff new file mode 100644 index 0000000000..4123c62a2a --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff @@ -0,0 +1,36 @@ +--- old.jsdocImportType2.errors.txt ++++ new.jsdocImportType2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++use.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. ++use.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== use.js (2 errors) ==== ++ /// ++ /** @typedef {import("./mod1")} C ++ * @type {C} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ var c; ++ c.chunk; ++ ++ const D = require("./mod1"); ++ /** @type {D} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ 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/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff index 475e063877..d26a351f65 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +0 lines =@@ - +test.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'C'. ++test.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== mod1.js (0 errors) ==== @@ -11,11 +12,13 @@ + } + module.exports.C = C + -+==== test.js (1 errors) ==== ++==== test.js (2 errors) ==== + /** @typedef {import('./mod1').C} X */ + ~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'C'. + /** @param {X} c */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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 index 22c4d013c0..c640d056d1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +0 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')'? ++test.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== ex.d.ts (0 errors) ==== @@ -11,10 +12,12 @@ + } + export = config; + -+==== test.js (1 errors) ==== ++==== test.js (2 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')'? ++ ~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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 index 8f62d8a48b..cb091d9735 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToESModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToESModule.errors.txt.diff @@ -3,15 +3,18 @@ @@= skipped -0, +0 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')'? ++test.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== ex.d.ts (0 errors) ==== + export var config: {} + -+==== test.js (1 errors) ==== ++==== test.js (2 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')'? ++ ~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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 index 2443dbe9b5..ef9721d179 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt.diff @@ -2,14 +2,17 @@ +++ new.jsdocImportTypeReferenceToStringLiteral.errors.txt @@= skipped -0, +0 lines =@@ - ++a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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) ==== ++==== a.js (2 errors) ==== + /** @type {import('./b').FOO} */ ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! 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 50285f14a6..073c878fec 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocIndexSignature.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocIndexSignature.errors.txt.diff @@ -6,37 +6,49 @@ - -==== indices.js (1 errors) ==== +indices.js(1,12): error TS2315: Type 'Object' is not generic. ++indices.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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,12): error TS8010: Type annotations can only be used in TypeScript files. +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,12): error TS8010: Type annotations can only be used in TypeScript files. +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,13): error TS8010: Type annotations can only be used in TypeScript files. +indices.js(7,19): error TS8020: JSDoc types can only be used inside documentation comments. + + -+==== indices.js (8 errors) ==== ++==== indices.js (12 errors) ==== /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. var o1; /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. var o2; /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. var o3; /** @param {Object.} o */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. function f(o) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.errors.txt.diff new file mode 100644 index 0000000000..d7a0750eb3 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.errors.txt.diff @@ -0,0 +1,33 @@ +--- old.jsdocLiteral.errors.txt ++++ new.jsdocLiteral.errors.txt +@@= skipped -0, +0 lines =@@ +- ++in.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++in.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++in.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++in.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++in.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== in.js (5 errors) ==== ++ /** ++ * @param {'literal'} p1 ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {"literal"} p2 ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {'literal' | 'other'} p3 ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {'literal' | number} p4 ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {12 | true | 'str'} p5 ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(p1, p2, p3, p4, p5) { ++ return p1 + p2 + p3 + p4 + p5 + '.'; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.errors.txt.diff new file mode 100644 index 0000000000..b76bf336f4 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.errors.txt.diff @@ -0,0 +1,28 @@ +--- old.jsdocNeverUndefinedNull.errors.txt ++++ new.jsdocNeverUndefinedNull.errors.txt +@@= skipped -0, +0 lines =@@ +- ++in.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++in.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++in.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++in.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== in.js (4 errors) ==== ++ /** ++ * @param {never} p1 ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {undefined} p2 ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {null} p3 ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {void} nothing ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(p1, p2, p3) { ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff index dcc2f56e2b..85b9ef4d5f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff @@ -6,16 +6,19 @@ 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(1,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (4 errors) ==== -+==== jsdocOuterTypeParameters1.js (2 errors) ==== ++==== jsdocOuterTypeParameters1.js (3 errors) ==== /** @return {T} */ ~ !!! error TS2304: Cannot find name 'T'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const dedupingMixin = function(mixin) {}; /** @template {T} */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff index da32259324..e6c2813b41 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff @@ -5,16 +5,20 @@ - 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(1,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (2 errors) ==== ++==== jsdocOuterTypeParameters1.js (3 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'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const dedupingMixin = function(mixin) {}; /** @template T */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff new file mode 100644 index 0000000000..68db191e5d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.jsdocOverrideTag1.errors.txt ++++ new.jsdocOverrideTag1.errors.txt +@@= skipped -0, +0 lines =@@ ++0.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(20,16): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(21,18): error TS8010: Type annotations can only be used in TypeScript files. + 0.js(27,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'A'. + 0.js(32,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. + 0.js(40,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. + + +-==== 0.js (3 errors) ==== ++==== 0.js (7 errors) ==== + class A { + + /** + * @method + * @param {string | number} a ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {boolean} ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + foo (a) { + return typeof a === 'string' +@@= skipped -23, +31 lines =@@ + * @override + * @method + * @param {string | number} a ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {boolean} ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + foo (a) { + return super.foo(a) \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.errors.txt.diff index 04a0106ed7..b4afeb938f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.errors.txt.diff @@ -3,16 +3,141 @@ @@= skipped -0, +0 lines =@@ -0.js(68,19): error TS2339: Property 'a' does not exist on type 'String'. -0.js(68,22): error TS2339: Property 'b' does not exist on type 'String'. ++0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(26,4): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(33,4): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(36,4): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(41,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(43,4): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(50,4): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(56,12): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(66,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(70,20): error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name. - - +- +- -==== 0.js (3 errors) ==== -+==== 0.js (1 errors) ==== ++0.js(71,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== 0.js (20 errors) ==== // Object literal syntax /** * @param {{a: string, b: string}} obj -@@= skipped -71, +69 lines =@@ ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function good1({a, b}, x) {} + /** + * @param {{a: string, b: string}} obj ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{c: number, d: number}} OBJECTION ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function good2({a, b}, {c, d}) {} + /** + * @param {number} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{a: string, b: string}} obj ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} y ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function good3(x, {a, b}, y) {} + /** + * @param {{a: string, b: string}} obj ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function good4({a, b}) {} + +@@= skipped -29, +62 lines =@@ + /** + * @param {Object} obj + * @param {string} obj.a - this is like the saddest way to specify a type ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {string} obj.b - but it sure does allow a lot of documentation ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {string} x ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function good5({a, b}, x) {} + /** + * @param {Object} obj + * @param {string} obj.a ++ ~~~~~~~~~~~~~~~~~~~~~ + * @param {string} obj.b - but it sure does allow a lot of documentation ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {Object} OBJECTION - documentation here too ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} OBJECTION.c ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {string} OBJECTION.d - meh ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function good6({a, b}, {c, d}) {} + /** + * @param {number} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {Object} obj + * @param {string} obj.a ++ ~~~~~~~~~~~~~~~~~~~~~ + * @param {string} obj.b ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {string} y ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function good7(x, {a, b}, y) {} + /** + * @param {Object} obj + * @param {string} obj.a ++ ~~~~~~~~~~~~~~~~~~~~~ + * @param {string} obj.b ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function good8({a, b}) {} + + /** + * @param {{ a: string }} argument ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function good9({ a }) { + console.log(arguments, a); +@@= skipped -40, +68 lines =@@ + * @param {string} obj.a + * @param {string} obj.b - and x's type gets used for both parameters + * @param {string} x ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ function bad1(x, {a, b}) {} - ~ @@ -21,4 +146,11 @@ -!!! error TS2339: Property 'b' does not exist on type 'String'. /** * @param {string} y - here, y's type gets ignored but obj's is fine - ~ \ No newline at end of file + ~ + !!! error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name. + * @param {{a: string, b: string}} obj ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function bad2(x, {a, b}) {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff new file mode 100644 index 0000000000..94064170f3 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff @@ -0,0 +1,102 @@ +--- old.jsdocParamTagTypeLiteral.errors.txt ++++ new.jsdocParamTagTypeLiteral.errors.txt +@@= skipped -0, +0 lines =@@ ++0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + 0.js(3,20): error TS8024: JSDoc '@param' tag has name 'unrelated', but there is no parameter with that name. +- +- +-==== 0.js (1 errors) ==== ++0.js(12,4): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(25,4): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(36,4): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(45,4): error TS8010: Type annotations can only be used in TypeScript files. ++0.js(58,4): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== 0.js (7 errors) ==== + /** + * @param {Object} notSpecial ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @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. +@@= skipped -15, +23 lines =@@ + /** + * @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 ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function foo1(opts1) { + opts1.x; + } +@@= skipped -13, +19 lines =@@ + /** + * @param {Object[]} opts2 + * @param {string} opts2[].anotherX ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {string=} opts2[].anotherY ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function foo2(/** @param opts2 bad idea theatre! */opts2) { + opts2[0].anotherX; + } +@@= skipped -11, +15 lines =@@ + /** + * @param {object} opts3 + * @param {string} opts3.x ++ ~~~~~~~~~~~~~~~~~~~~~~~ + */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function foo3(opts3) { + opts3.x; + } +@@= skipped -9, +12 lines =@@ + /** + * @param {object[]} opts4 + * @param {string} opts4[].x ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {string=} opts4[].y ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {string} [opts4[].z] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {string} [opts4[].w="hi"] ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo4(opts4) { + opts4[0].x; +@@= skipped -13, +18 lines =@@ + /** + * @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. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function foo5(opts5) { + opts5[0].what.bad[0].idea; + opts5[0].unnest; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.errors.txt.diff new file mode 100644 index 0000000000..65e4562e4b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.jsdocParseBackquotedParamName.errors.txt ++++ new.jsdocParseBackquotedParamName.errors.txt +@@= skipped -0, +0 lines =@@ ++a.js(2,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(3,20): error TS8010: Type annotations can only be used in TypeScript files. + a.js(5,18): error TS1016: A required parameter cannot follow an optional parameter. + + +-==== a.js (1 errors) ==== ++==== a.js (4 errors) ==== + /** + * @param {string=} `args` ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param `bwarg` {?number?} ++ ~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(args, bwarg) { + ~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff index 0bed525624..c0c5a4a7f3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff @@ -6,10 +6,11 @@ - -==== a.js (1 errors) ==== +a.js(3,12): error TS7006: Parameter 'callback' implicitly has an 'any' type. ++a.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + -+==== a.js (2 errors) ==== ++==== a.js (3 errors) ==== // from bcryptjs /** @param {function(...[*])} callback */ - ~~~~~~~~~~~~~~~~ @@ -22,6 +23,8 @@ /** * @type {!function(...number):string} ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff index 0b43e0d1a6..68c129cf48 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff @@ -3,15 +3,18 @@ @@= skipped -0, +0 lines =@@ - +paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++paren.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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 (3 errors) ==== ++==== paren.js (4 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x = (s, id) => id(s) + ~ +!!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.errors.txt.diff new file mode 100644 index 0000000000..c6956778ae --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.errors.txt.diff @@ -0,0 +1,40 @@ +--- old.jsdocParseMatchingBackticks.errors.txt ++++ new.jsdocParseMatchingBackticks.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsdocParseMatchingBackticks.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocParseMatchingBackticks.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocParseMatchingBackticks.js(7,19): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocParseMatchingBackticks.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocParseMatchingBackticks.js(9,24): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocParseMatchingBackticks.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== jsdocParseMatchingBackticks.js (6 errors) ==== ++ /** ++ * `@param` initial at-param is OK in title comment ++ * @param {string} x hi there `@param` ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {string} y hi there `@ * param ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * this is the margin ++ * so we'll drop everything before it ++ `@param` @param {string} z hello??? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * `@param` @param {string} alpha hello??? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * `@ * param` @param {string} beta hello??? ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {string} gamma ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ export function f(x, y, z, alpha, beta, gamma) { ++ return x + y + z + alpha + beta + gamma ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff index a6dd8192ea..a024c91ec4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff @@ -3,14 +3,17 @@ @@= skipped -0, +0 lines =@@ - +paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++paren.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +paren.js(2,9): error TS7006: Parameter 's' implicitly has an 'any' type. + + -+==== paren.js (2 errors) ==== ++==== paren.js (3 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x = s => s.toString() + ~ +!!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff index 76fc71ede2..320d6fc7e8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff @@ -3,16 +3,27 @@ @@= skipped -0, +0 lines =@@ - +a.js(1,5): error TS1047: A rest parameter cannot be optional. ++a.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. ++a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(3,12): error TS2370: A rest parameter must be of an array type. ++a.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(12,14): error TS7006: Parameter 'f' implicitly has an 'any' type. + + -+==== a.js (3 errors) ==== ++==== a.js (7 errors) ==== + /** @param {...*=} args + ~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + @return {*=} */ + ~~~~ +!!! error TS1047: A rest parameter cannot be optional. ++ ~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(...args) { + ~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. @@ -20,6 +31,8 @@ + } + + /** @type *= */ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x; + + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff new file mode 100644 index 0000000000..fcbd69c979 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.jsdocPostfixEqualsAddsOptionality.errors.txt ++++ new.jsdocPostfixEqualsAddsOptionality.errors.txt +@@= skipped -0, +0 lines =@@ ++a.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. ++a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. + 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 errors) ==== ++a.js(12,5): error TS8009: The '?' modifier can only be used in TypeScript files. ++a.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (6 errors) ==== + /** @param {number=} a */ ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(a) { + a = 1 + a = null // should not be allowed +@@= skipped -18, +26 lines =@@ + f(1) + + /** @param {???!?number?=} a */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function g(a) { + a = 1 + a = null \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff index cd4ecc1839..9940ca857b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff @@ -12,49 +12,82 @@ -prefixPostfix.js(13,12): error TS1014: A rest parameter must be last in a parameter list. -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(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. ++prefixPostfix.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. prefixPostfix.js(18,21): error TS7006: Parameter 'a' implicitly has an 'any' type. prefixPostfix.js(18,39): error TS7006: Parameter 'h' implicitly has an 'any' type. prefixPostfix.js(18,48): error TS7006: Parameter 'k' implicitly has an 'any' type. -==== prefixPostfix.js (14 errors) ==== -+==== prefixPostfix.js (3 errors) ==== ++==== prefixPostfix.js (15 errors) ==== /** * @param {number![]} x - number[] ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {!number[]} y - number[] ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(number[])!} z - number[] ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number?[]} a - parse error without parentheses - -!!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. - ~ -!!! error TS1005: '}' expected. * @param {?number[]} b - number[] | null ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(number[])?} c - number[] | null ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...?number} e - (number | null)[] -- ~~~~~~~~~~ + ~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?} f - number[] | null -- ~~~~~~~~~~ + ~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number!?} g - number[] | null -- ~~~~~~~~~~~ + ~~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?!} h - parse error without parentheses (also nonsensical) - -!!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. - ~ -!!! error TS1005: '}' expected. * @param {...number[]} i - number[][] -- ~~~~~~~~~~~ + ~~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number![]?} j - number[][] | null -- ~~~~~~~~~~~~~ + ~~~~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?[]!} k - parse error without parentheses - -!!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. - ~ -!!! error TS1005: '}' expected. * @param {number extends number ? true : false} l - conditional types work ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {[number, number?]} m - [number, (number | undefined)?] - */ \ No newline at end of file ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f(x, y, z, a, b, c, e, f, g, h, i, j, k, l, m) { + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.errors.txt.diff new file mode 100644 index 0000000000..85496209ae --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.jsdocPrivateName1.errors.txt ++++ new.jsdocPrivateName1.errors.txt +@@= skipped -0, +0 lines =@@ ++jsdocPrivateName1.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. + jsdocPrivateName1.js(3,5): error TS2322: Type 'number' is not assignable to type 'boolean'. + + +-==== jsdocPrivateName1.js (1 errors) ==== ++==== jsdocPrivateName1.js (2 errors) ==== + class A { + /** @type {boolean} some number value */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + #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/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff new file mode 100644 index 0000000000..aef7312b3f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.jsdocReadonly.errors.txt ++++ new.jsdocReadonly.errors.txt +@@= skipped -0, +0 lines =@@ ++jsdocReadonly.js(3,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++jsdocReadonly.js(4,8): error TS8009: The 'private' modifier can only be used in TypeScript files. ++jsdocReadonly.js(5,15): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocReadonly.js(9,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++jsdocReadonly.js(11,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. + jsdocReadonly.js(23,3): error TS2540: Cannot assign to 'y' because it is a read-only property. + + +-==== jsdocReadonly.js (1 errors) ==== ++==== jsdocReadonly.js (6 errors) ==== + class LOL { + /** + * @readonly ++ ~~~~~~~~~ + * @private ++ ~~~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++ ~~~~~~~~ + * @type {number} ++ ~~~~~~~ ++!!! error TS8009: The 'private' modifier can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * Order rules do not apply to JSDoc + */ + x = 1 + /** @readonly */ ++ ~~~~~~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + y = 2 + /** @readonly Definitely not here */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + static z = 3 + /** @readonly This is OK too */ + constructor() { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.errors.txt.diff index 6c46f1071b..de84cbc0c6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.errors.txt.diff @@ -2,12 +2,15 @@ +++ new.jsdocReadonlyDeclarations.errors.txt @@= skipped -0, +0 lines =@@ - ++jsdocReadonlyDeclarations.js(2,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +jsdocReadonlyDeclarations.js(14,1): error TS2554: Expected 1 arguments, but got 0. + + -+==== jsdocReadonlyDeclarations.js (1 errors) ==== ++==== jsdocReadonlyDeclarations.js (2 errors) ==== + class C { + /** @readonly */ ++ ~~~~~~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + x = 6 + /** @readonly */ + constructor(n) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff new file mode 100644 index 0000000000..b0915af652 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.jsdocReturnTag1.errors.txt ++++ new.jsdocReturnTag1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++returns.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. ++returns.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. ++returns.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== returns.js (3 errors) ==== ++ /** ++ * @returns {string} This comment is not currently exposed ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f() { ++ return 5; ++ } ++ ++ /** ++ * @returns {string=} This comment is not currently exposed ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f1() { ++ return 5; ++ } ++ ++ /** ++ * @returns {string|number} This comment is not currently exposed ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f2() { ++ return 5 || "hello"; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.errors.txt.diff new file mode 100644 index 0000000000..790bc717d8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.errors.txt.diff @@ -0,0 +1,67 @@ +--- old.jsdocSignatureOnReturnedFunction.errors.txt ++++ new.jsdocSignatureOnReturnedFunction.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsdocSignatureOnReturnedFunction.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocSignatureOnReturnedFunction.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocSignatureOnReturnedFunction.js(5,18): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocSignatureOnReturnedFunction.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocSignatureOnReturnedFunction.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocSignatureOnReturnedFunction.js(16,18): error TS8010: Type annotations can only be used in TypeScript files. ++jsdocSignatureOnReturnedFunction.js(24,16): error TS8016: Type assertion expressions can only be used in TypeScript files. ++jsdocSignatureOnReturnedFunction.js(31,16): error TS8016: Type assertion expressions can only be used in TypeScript files. ++ ++ ++==== jsdocSignatureOnReturnedFunction.js (8 errors) ==== ++ function f1() { ++ /** ++ * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} b ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ return (a, b) => { ++ return a + b; ++ } ++ } ++ ++ function f2() { ++ /** ++ * @param {number} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} b ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ return function (a, b){ ++ return a + b; ++ } ++ } ++ ++ function f3() { ++ /** @type {(a: number, b: number) => number} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ return (a, b) => { ++ return a + b; ++ } ++ } ++ ++ function f4() { ++ /** @type {(a: number, b: number) => number} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ++ return function (a, b){ ++ return a + b; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff new file mode 100644 index 0000000000..2301ab4028 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff @@ -0,0 +1,78 @@ +--- old.jsdocTemplateClass.errors.txt ++++ new.jsdocTemplateClass.errors.txt +@@= skipped -0, +0 lines =@@ ++templateTagOnClasses.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++templateTagOnClasses.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. ++templateTagOnClasses.js(7,22): error TS8010: Type annotations can only be used in TypeScript files. ++templateTagOnClasses.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. ++templateTagOnClasses.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. ++templateTagOnClasses.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. ++templateTagOnClasses.js(16,16): error TS8010: Type annotations can only be used in TypeScript files. ++templateTagOnClasses.js(17,17): error TS8010: Type annotations can only be used in TypeScript files. + templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to type 'number'. + + +-==== templateTagOnClasses.js (1 errors) ==== ++==== templateTagOnClasses.js (9 errors) ==== + /** ++ ~~~ + * @template T ++ ~~~~~~~~~~~~~~ + * @typedef {(t: T) => T} Id ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + /** @template T */ ++ ~~~~~~~~~~~~~~~~~~ + class Foo { ++ ~~~~~~~~~~~ + /** @typedef {(t: T) => T} Id2 */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @param {T} x */ ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor (x) { ++ ~~~~~~~~~~~~~~~~~~~~~ + this.a = x ++ ~~~~~~~~~~~~~~~~~~ + } ++ ~~~~~ + /** ++ ~~~~~~~ + * ++ ~~~~~~~ + * @param {T} x ++ ~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {Id} y ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {Id2} alpha ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T} ++ ~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~~~~~ + foo(x, y, alpha) { ++ ~~~~~~~~~~~~~~~~~~~~~~ + return alpha(y(x)) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + var f = new Foo(1) + var g = new Foo(false) + f.a = g.a \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff index fd8c906846..705a131408 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff @@ -5,31 +5,50 @@ - - -==== templateTagOnConstructorFunctions.js (1 errors) ==== -- /** -- * @template U -- * @typedef {(u: U) => U} Id -- */ -- /** -- * @param {T} t -- * @template T -- */ -- function Zet(t) { -- /** @type {T} */ -- this.u -- this.t = t -- } -- /** -- * @param {T} v -- * @param {Id} id -- */ -- Zet.prototype.add = function(v, id) { -- this.u = v || this.t -- return id(this.u) -- } -- var z = new Zet(1) -- z.t = 2 -- z.u = false ++templateTagOnConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++templateTagOnConstructorFunctions.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. ++templateTagOnConstructorFunctions.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== templateTagOnConstructorFunctions.js (3 errors) ==== + /** ++ ~~~ + * @template U ++ ~~~~~~~~~~~~~~ + * @typedef {(u: U) => U} Id ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + /** ++ ~~~ + * @param {T} t ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @template T ++ ~~~~~~~~~~~~~~ + */ ++ ~~~ + function Zet(t) { ++ ~~~~~~~~~~~~~~~~~ + /** @type {T} */ ++ ~~~~~~~~~~~~~~~~~~~~ + this.u ++ ~~~~~~~~~~ + this.t = t ++ ~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + /** + * @param {T} v + * @param {Id} id +@@= skipped -25, +45 lines =@@ + var z = new Zet(1) + z.t = 2 + z.u = false - ~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. -- -+ \ No newline at end of file + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff index 1de308f13e..d521b8b3c9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff @@ -2,20 +2,58 @@ +++ new.jsdocTemplateConstructorFunction2.errors.txt @@= skipped -0, +0 lines =@@ -templateTagWithNestedTypeLiteral.js(21,1): error TS2322: Type 'boolean' is not assignable to type 'number'. ++templateTagWithNestedTypeLiteral.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++templateTagWithNestedTypeLiteral.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++templateTagWithNestedTypeLiteral.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. - - +- +- -==== templateTagWithNestedTypeLiteral.js (2 errors) ==== -+==== templateTagWithNestedTypeLiteral.js (1 errors) ==== ++templateTagWithNestedTypeLiteral.js(30,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== templateTagWithNestedTypeLiteral.js (5 errors) ==== /** ++ ~~~ * @param {T} t ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T -@@= skipped -23, +22 lines =@@ ++ ~~~~~~~~~~~~~~ + */ ++ ~~~ + function Zet(t) { ++ ~~~~~~~~~~~~~~~~~ + /** @type {T} */ ++ ~~~~~~~~~~~~~~~~~~~~ + this.u ++ ~~~~~~~~~~ + this.t = t ++ ~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + /** + * @param {T} v + * @param {object} o +@@= skipped -23, +38 lines =@@ var z = new Zet(1) z.t = 2 z.u = false - ~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. let answer = z.add(3, { nested: 4 }) + + // lookup in typedef should not crash the compiler, even when the type is unknown +@@= skipped -13, +13 lines =@@ + !!! error TS2304: Cannot find name 'T'. + */ + /** @type {A} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const options = { value: null }; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff index 716047469c..3e80aa4b69 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff @@ -2,27 +2,67 @@ +++ 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(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++forgot.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++forgot.js(8,15): error TS8004: Type parameter declarations can only be used in TypeScript files. ++forgot.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +forgot.js(13,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++forgot.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. +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) ==== ++==== forgot.js (7 errors) ==== /** ++ ~~~ * @param {T} a ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T -@@= skipped -15, +16 lines =@@ ++ ~~~~~~~~~~~~~~ + */ ++ ~~~ + function f(a) { ++ ~~~~~~~~~~~~~~~ + return () => a ++ ~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + let n = f(1)() ++ ++ + + /** ++ ~~~ * @param {T} a ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ ++ ~~~ function g(a) { ++ ~~~~~~~~~~~~~~~ return () => a -@@= skipped -11, +14 lines =@@ ++ ~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + let s = g('hi')() + + /** +@@= skipped -26, +60 lines =@@ */ Element.prototype.animate = function(keyframes) {}; ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff new file mode 100644 index 0000000000..4a71c6ddd1 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.jsdocTemplateTag2.errors.txt ++++ new.jsdocTemplateTag2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++github17339.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. ++github17339.js(5,15): error TS8010: Type annotations can only be used in TypeScript files. ++github17339.js(7,4): error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ ++==== github17339.js (3 errors) ==== ++ var obj = { ++ /** ++ * @template T ++ * @param {T} a ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ x: function (a) { ++ ~~~~~~~~~~~~~~~ ++ return a; ++ ~~~~~~~~~~~ ++ }, ++ ~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ }; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff index a30dd9f14c..5b21303c23 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff @@ -1,6 +1,13 @@ --- old.jsdocTemplateTag3.errors.txt +++ new.jsdocTemplateTag3.errors.txt @@= skipped -0, +0 lines =@@ ++a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(11,13): error TS8010: Type annotations can only be used in TypeScript files. 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; }'. @@ -11,13 +18,65 @@ - -==== a.js (5 errors) ==== +a.js(21,3): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. ++a.js(21,50): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (3 errors) ==== ++==== a.js (12 errors) ==== /** ++ ~~~ * @template {{ a: number, b: string }} T,U A Comment ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @template {{ c: boolean }} V uh ... are comments even supported?? -@@= skipped -32, +29 lines =@@ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @template W ++ ~~~~~~~~~~~~~~ + * @template X That last one had no comment ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {T} t ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} u ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {V} v ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {W} w ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {X} x ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {W | X} ++ ~~~~~~~~~~~~~~~~~~ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + 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; ++ ~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); f({ a: 12 }, undefined, undefined, 101, 'nope'); ~~~~~~~~~~ @@ -25,14 +84,27 @@ -!!! error TS2345: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: 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. ++ ++ /** ++ ~~~ * @template {NoLongerAllowed} - ~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'NoLongerAllowed'. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @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 ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ - function g(x) { } \ No newline at end of file ++ ~~~ + function g(x) { } ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff index 0f87797d38..401888dde3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff @@ -2,9 +2,11 @@ +++ new.jsdocTemplateTag4.errors.txt @@= skipped -0, +0 lines =@@ - ++a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(8,16): error TS2315: Type 'Object' is not generic. +a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +a.js(16,36): error TS7006: Parameter 'key' implicitly has an 'any' type. ++a.js(26,16): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(27,16): error TS2315: Type 'Object' is not generic. +a.js(28,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +a.js(35,37): error TS7006: Parameter 'key' implicitly has an 'any' type. @@ -13,21 +15,32 @@ +a.js(55,40): error TS7006: Parameter 'key' implicitly has an 'any' type. + + -+==== a.js (9 errors) ==== ++==== a.js (11 errors) ==== + /** ++ ~~~ + * Should work for function declarations ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @constructor ++ ~~~~~~~~~~~~~~~ + * @template {string} K ++ ~~~~~~~~~~~~~~~~~~~~~~~ + * @template V ++ ~~~~~~~~~~~~~~ + */ ++ ~~~ + function Multimap() { ++ ~~~~~~~~~~~~~~~~~~~~~ + /** @type {Object} TODO: Remove the prototype from the fresh object */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + this._map = {}; ++ ~~~~~~~~~~~~~~~~~~~ + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }; ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + * @param {K} key the key ok @@ -46,13 +59,18 @@ + * @template V + */ + var Multimap2 = function() { ++ ~~~~~~~~~~~~~ + /** @type {Object} TODO: Remove the prototype from the fresh object */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + this._map = {}; ++ ~~~~~~~~~~~~~~~~~~~ + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }; ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + * @param {K} key the key ok diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff index 4b8b9d6040..972801c289 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff @@ -2,47 +2,70 @@ +++ new.jsdocTemplateTag5.errors.txt @@= skipped -0, +0 lines =@@ - ++a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(8,16): error TS2315: Type 'Object' is not generic. +a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +a.js(14,16): error TS2304: Cannot find name 'K'. ++a.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(15,18): error TS2304: Cannot find name 'V'. ++a.js(15,18): error TS8010: Type annotations can only be used in TypeScript files. +a.js(18,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. ++a.js(28,16): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(29,16): error TS2315: Type 'Object' is not generic. +a.js(30,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +a.js(35,16): error TS2304: Cannot find name 'K'. ++a.js(35,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(36,18): error TS2304: Cannot find name 'V'. ++a.js(36,18): error TS8010: Type annotations can only be used in TypeScript files. +a.js(39,21): error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. +a.js(51,16): error TS2315: Type 'Object' is not generic. +a.js(52,10): error TS2339: Property '_map' does not exist on type '{ Multimap3: { (): void; prototype: { get(key: K): V; }; }; }'. +a.js(57,16): error TS2304: Cannot find name 'K'. ++a.js(57,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(58,18): error TS2304: Cannot find name 'V'. ++a.js(58,18): error TS8010: Type annotations can only be used in TypeScript files. +a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. + + -+==== a.js (15 errors) ==== ++==== a.js (23 errors) ==== + /** ++ ~~~ + * Should work for function declarations ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @constructor ++ ~~~~~~~~~~~~~~~ + * @template {string} K ++ ~~~~~~~~~~~~~~~~~~~~~~~ + * @template V ++ ~~~~~~~~~~~~~~ + */ ++ ~~~ + function Multimap() { ++ ~~~~~~~~~~~~~~~~~~~~~ + /** @type {Object} TODO: Remove the prototype from the fresh object */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + this._map = {}; ++ ~~~~~~~~~~~~~~~~~~~ + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }; ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + Multimap.prototype = { + /** + * @param {K} key the key ok + ~ +!!! error TS2304: Cannot find name 'K'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {V} the value ok + ~ +!!! error TS2304: Cannot find name 'V'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get(key) { + return this._map[key + '']; @@ -58,22 +81,31 @@ + * @template V + */ + var Multimap2 = function() { ++ ~~~~~~~~~~~~~ + /** @type {Object} TODO: Remove the prototype from the fresh object */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + this._map = {}; ++ ~~~~~~~~~~~~~~~~~~~ + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }; ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + Multimap2.prototype = { + /** + * @param {K} key the key ok + ~ +!!! error TS2304: Cannot find name 'K'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {V} the value ok + ~ +!!! error TS2304: Cannot find name 'V'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get: function(key) { + return this._map[key + '']; @@ -103,9 +135,13 @@ + * @param {K} key the key ok + ~ +!!! error TS2304: Cannot find name 'K'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {V} the value ok + ~ +!!! error TS2304: Cannot find name 'V'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get(key) { + return this._map[key + '']; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff new file mode 100644 index 0000000000..6ff53831f5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff @@ -0,0 +1,239 @@ +--- old.jsdocTemplateTag6.errors.txt ++++ new.jsdocTemplateTag6.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(11,64): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(23,64): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(28,14): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(34,24): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(38,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(39,14): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(45,54): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(50,14): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(56,62): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(63,16): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(65,22): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(69,16): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(77,40): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(81,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (22 errors) ==== ++ /** ++ ~~~ ++ * @template const T ++ ~~~~~~~~~~~~~~~~~~~~ ++ * @param {T} x ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~ ++ function f1(x) { ++ ~~~~~~~~~~~~~~~~ ++ return x; ++ ~~~~~~~~~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ 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 ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~ ++ function f2(x) { ++ ~~~~~~~~~~~~~~~~ ++ return x; ++ ~~~~~~~~~~~~~ ++ }; ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ 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 ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T[]} ++ ~~~~~~~~~~~~~~~~~ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~ ++ function f3(x) { ++ ~~~~~~~~~~~~~~~~ ++ return [x]; ++ ~~~~~~~~~~~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ const t7 = f3("hello"); ++ const t8 = f3("hello"); ++ ++ ++ ++ /** ++ ~~~ ++ * @template const T ++ ~~~~~~~~~~~~~~~~~~~~ ++ * @param {[T, T]} x ++ ~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~ ++ function f4(x) { ++ ~~~~~~~~~~~~~~~~ ++ return x[0]; ++ ~~~~~~~~~~~~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ 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 ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~ ++ function f5(obj) { ++ ~~~~~~~~~~~~~~~~~~ ++ return obj.x; ++ ~~~~~~~~~~~~~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ 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 ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ constructor(x) {} ++ ~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ ++ ++ /** ++ ~~~~~~~ ++ ~~~~~~~ ++ * @template const U ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~~~~~~ ++ * @param {U} x ++ ~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ ~~~~~~~ ++ foo(x) { ++ ~~~~~~~~~~~~ ++ ~~~~~~~~~~~~ ++ return x; ++ ~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~ ++ } ++ ~~~~~ ++ ~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ 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 ++ ~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {T} ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~ ++ function f6(...args) { ++ ~~~~~~~~~~~~~~~~~~~~~~ ++ return args; ++ ~~~~~~~~~~~~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ const t15 = f6(1, 'b', { a: 1, b: 'x' }); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff new file mode 100644 index 0000000000..694d8980df --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff @@ -0,0 +1,63 @@ +--- old.jsdocTemplateTag7.errors.txt ++++ new.jsdocTemplateTag7.errors.txt +@@= skipped -0, +0 lines =@@ ++a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. + a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++a.js(9,12): error TS8004: Type parameter declarations can only be used in TypeScript files. + a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter +- +- +-==== a.js (2 errors) ==== ++a.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (6 errors) ==== + /** ++ ~~~ + * @template const T ++ ~~~~~~~~~~~~~~~~~~~~ + ~~~~~ + !!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + * @typedef {[T]} X ++ ~~~~~~~~~~~~~~~~~~~ + */ ++ ~~~ ++ + + /** ++ ~~~ + * @template const T ++ ~~~~~~~~~~~~~~~~~~~~ + */ ++ ~~~ + class C { } ++ ~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ + + /** ++ ~~~ + * @template private T ++ ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ + !!! error TS1273: 'private' modifier cannot appear on a type parameter + * @param {T} x ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function f(x) { ++ ~~~~~~~~~~~~~~~ + return x; ++ ~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff index 8b2d7d7f0b..4ed49a0454 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff @@ -2,21 +2,36 @@ +++ new.jsdocTemplateTag8.errors.txt @@= skipped -0, +0 lines =@@ +a.js(2,14): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias ++a.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. 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(23,18): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. 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(42,18): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(46,11): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(51,11): error TS8010: Type annotations can only be used in TypeScript files. 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'. -@@= skipped -12, +15 lines =@@ +@@= skipped -9, +20 lines =@@ + 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(56,33): error TS8004: Type parameter declarations can only be used in TypeScript files. 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(60,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (18 errors) ==== /** * @template out T + ~~~ @@ -24,7 +39,22 @@ * @typedef {Object} Covariant * @property {T} x */ -@@= skipped -25, +27 lines =@@ + + /** + * @type {Covariant} ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + let super_covariant = { x: 1 }; + + /** + * @type {Covariant} ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + let sub_covariant = { x: '' }; + +@@= skipped -28, +36 lines =@@ /** * @template in T @@ -32,8 +62,25 @@ +!!! 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 ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + /** + * @type {Contravariant} ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + let super_contravariant = { f: (x) => {} }; + + /** + * @type {Contravariant} ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ -@@= skipped -22, +24 lines =@@ + let sub_contravariant = { f: (x) => {} }; + +@@= skipped -22, +30 lines =@@ /** * @template in out T @@ -41,4 +88,44 @@ +!!! 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 - */ \ No newline at end of file ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + /** + * @type {Invariant} ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + let super_invariant = { f: (x) => {} }; + + /** + * @type {Invariant} ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + let sub_invariant = { f: (x) => { return "" } }; + +@@= skipped -26, +34 lines =@@ + !!! 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'. ++ ~~~~~~~~~~ ++ + + /** ++ ~~~ + * @template in T ++ ~~~~~~~~~~~~~~~~~ + ~~ + !!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias + * @param {T} x ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function f(x) {} ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff index 31ea3f1da6..b9dd315d22 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff @@ -1,33 +1,187 @@ --- old.jsdocTemplateTagDefault.errors.txt +++ new.jsdocTemplateTagDefault.errors.txt @@= skipped -0, +0 lines =@@ ++file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. 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(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(13,21): error TS8004: Type parameter declarations can only be used in TypeScript files. 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(46,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(49,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. ++file.js(54,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(57,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. - - +- +- -==== file.js (7 errors) ==== -+==== file.js (5 errors) ==== ++file.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. ++file.js(63,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== file.js (18 errors) ==== /** * @template {string | number} [T=string] - ok: defaults are permitted * @typedef {[T]} A -@@= skipped -31, +29 lines =@@ + */ + + /** @type {A} */ // ok, default for `T` in `A` is `string` ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const aDefault1 = [""]; + /** @type {A} */ // error: `number` is not assignable to string` ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const aDefault2 = [0]; + ~ + !!! error TS2322: Type 'number' is not assignable to type 'string'. + /** @type {A} */ // ok, `T` is provided for `A` ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const aString = [""]; + /** @type {A} */ // ok, `T` is provided for `A` ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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` - ~ -!!! error TS1005: '=' expected. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @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. ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ + !!! 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 ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function f1(a, b) {} ++ ~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ + + /** ++ ~~~~ + * @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 ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function f2(a, b) {} ++ ~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ + + /** ++ ~~~ + * @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 ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ ++ ~~~ + function f3(a, b) {} ++ ~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff new file mode 100644 index 0000000000..8b1954bf29 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.jsdocTemplateTagNameResolution.errors.txt ++++ new.jsdocTemplateTagNameResolution.errors.txt +@@= skipped -0, +0 lines =@@ ++file.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + file.js(10,7): error TS2322: Type 'string' is not assignable to type 'number'. + + +-==== file.js (1 errors) ==== ++==== file.js (2 errors) ==== + /** + * @template T + * @template {keyof T} K +@@= skipped -10, +11 lines =@@ + const x = { a: 1 }; + + /** @type {Foo} */ ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const y = "a"; + ~ + !!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff index 2475a703b5..0a319d5089 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff @@ -1,26 +1,29 @@ --- old.jsdocThisType.errors.txt +++ new.jsdocThisType.errors.txt @@= skipped -0, +0 lines =@@ ++/a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. /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(11,12): error TS8010: Type annotations can only be used in TypeScript files. /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'. +/a.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++/a.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.d.ts (0 errors) ==== -@@= skipped -12, +9 lines =@@ +@@= skipped -14, +14 lines =@@ - export type M = (this: Foo) => void; - --==== /a.js (6 errors) ==== -+==== /a.js (3 errors) ==== + ==== /a.js (6 errors) ==== /** @type {import('./types').M} */ ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. export const f1 = function() { this.test(); -@@= skipped -11, +11 lines =@@ + ~~~~ +@@= skipped -9, +11 lines =@@ /** @type {import('./types').M} */ export function f2() { this.test(); @@ -29,7 +32,12 @@ } /** @type {(this: import('./types').Foo) => void} */ -@@= skipped -14, +12 lines =@@ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const f3 = function() { + this.test(); + ~~~~ +@@= skipped -14, +14 lines =@@ /** @type {(this: import('./types').Foo) => void} */ export function f4() { this.test(); @@ -41,6 +49,8 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. export const f5 = function() { this.test(); - ~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff index 54ee845a3b..83aecc8706 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff @@ -2,20 +2,29 @@ +++ new.jsdocTypeDefAtStartOfFile.errors.txt @@= skipped -0, +0 lines =@@ - ++dtsEquivalent.js(1,19): error TS8010: Type annotations can only be used in TypeScript files. +index.js(1,12): error TS2304: Cannot find name 'AnyEffect'. ++index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(3,12): error TS2304: Cannot find name 'Third'. ++index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== dtsEquivalent.js (0 errors) ==== ++==== dtsEquivalent.js (1 errors) ==== + /** @typedef {{[k: string]: any}} AnyEffect */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @typedef {number} Third */ -+==== index.js (2 errors) ==== ++==== index.js (4 errors) ==== + /** @type {AnyEffect} */ + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'AnyEffect'. ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + let b; + /** @type {Third} */ + ~~~~~ +!!! error TS2304: Cannot find name 'Third'. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + let c; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff index ae65230ca2..b550d37076 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff @@ -3,14 +3,17 @@ @@= skipped -0, +0 lines =@@ - +bug27342.js(3,11): error TS2709: Cannot use namespace 'exports' as a type. ++bug27342.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== bug27342.js (1 errors) ==== ++==== bug27342.js (2 errors) ==== + module.exports = {} + /** + * @type {exports} + ~~~~~~~ +!!! error TS2709: Cannot use namespace 'exports' as a type. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var x + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff index f6aa14b029..baf11528d5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff @@ -3,15 +3,19 @@ @@= skipped -0, +0 lines =@@ - +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(3,12): error TS8010: Type annotations can only be used in TypeScript files. +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(8,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocTypeReferenceToImport.js (2 errors) ==== ++==== jsdocTypeReferenceToImport.js (4 errors) ==== + const C = require('./ex').C; + const D = require('./ex')?.C; + /** @type {C} c */ + ~ +!!! error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var c = new C() + c.start + c.end @@ -19,6 +23,8 @@ + /** @type {D} c */ + ~ +!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var d = new D() + d.start + d.end diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff index 9e66ced279..de02308829 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +0 lines =@@ - +MC.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++MW.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. +MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + @@ -23,12 +24,14 @@ + ~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== MW.js (1 errors) ==== ++==== MW.js (2 errors) ==== + /** @typedef {import("./MC")} MC */ + + class MW { + /** + * @param {MC} compiler the compiler ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(compiler) { + this.compiler = compiler; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff index b9969a5cd3..1651a75fde 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff @@ -3,11 +3,13 @@ @@= skipped -0, +0 lines =@@ - +MC.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++MC.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. +MW.js(1,15): error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? ++MW.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. +MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== MC.js (1 errors) ==== ++==== MC.js (2 errors) ==== + const MW = require("./MW"); + + /** @typedef {number} Meyerhauser */ @@ -17,6 +19,8 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** @type {any} */ + ~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x = {} + ~~~~~~~~~~~~~~ + return new MW(x); @@ -25,7 +29,7 @@ + ~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== MW.js (2 errors) ==== ++==== MW.js (3 errors) ==== + /** @typedef {import("./MC")} MC */ + ~~~~~~~~~~~~~~ +!!! error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? @@ -33,6 +37,8 @@ + class MW { + /** + * @param {MC} compiler the compiler ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(compiler) { + this.compiler = compiler; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff index 6d5f9a870c..87d9ab3922 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, +0 lines =@@ - +jsdocTypeReferenceToMergedClass.js(2,12): error TS2503: Cannot find namespace 'Workspace'. ++jsdocTypeReferenceToMergedClass.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocTypeReferenceToMergedClass.js (1 errors) ==== ++==== jsdocTypeReferenceToMergedClass.js (2 errors) ==== + var Workspace = {} + /** @type {Workspace.Project} */ + ~~~~~~~~~ +!!! error TS2503: Cannot find namespace 'Workspace'. ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var p; + p.isServiceProject() + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff index b83f68328b..6c7b6895c1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff @@ -3,12 +3,15 @@ @@= skipped -0, +0 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,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== foo.js (1 errors) ==== ++==== foo.js (2 errors) ==== + /** @param {Image} image */ + ~~~~~ +!!! error TS2749: 'Image' refers to a value, but is being used as a type here. Did you mean 'typeof Image'? ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function process(image) { + return new image(1, 1) + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt.diff new file mode 100644 index 0000000000..48d969fcd7 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt.diff @@ -0,0 +1,15 @@ +--- old.jsdocTypeReferenceUseBeforeDef.errors.txt ++++ new.jsdocTypeReferenceUseBeforeDef.errors.txt +@@= skipped -0, +0 lines =@@ +- ++bug25097.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== bug25097.js (1 errors) ==== ++ /** @type {C | null} */ ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const c = null ++ class C { ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff index d9f1f96033..5d66ad9d9e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff @@ -2,6 +2,30 @@ +++ new.jsdocTypeTag.errors.txt @@= skipped -0, +0 lines =@@ - ++a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(52,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(61,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(67,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(70,12): error TS8010: Type annotations can only be used in TypeScript files. +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'. @@ -10,77 +34,125 @@ +b.ts(21,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 (24 errors) ==== + /** @type {String} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var S; + + /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var s; + + /** @type {Number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var N; + + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n; + + /** @type {BigInt} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var BI; + + /** @type {bigint} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var bi; + + /** @type {Boolean} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var B; + + /** @type {boolean} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var b; + + /** @type {Void} */ ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var V; + + /** @type {void} */ ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var v; + + /** @type {Undefined} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var U; + + /** @type {undefined} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var u; + + /** @type {Null} */ ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var Nl; + + /** @type {null} */ ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var nl; + + /** @type {Array} */ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var A; + + /** @type {array} */ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var a; + + /** @type {Promise} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var P; + + /** @type {promise} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var p; + + /** @type {?number} */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var nullable; + + /** @type {Object} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var Obj; + + /** @type {object} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var obj; + + /** @type {Function} */ ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var Func; + + /** @type {(s: string) => number} */ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var f; + + /** @type {new (s: string) => { s: string }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var ctor; + +==== b.ts (6 errors) ==== diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff index cb553f8687..4d0fa62b91 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff @@ -14,66 +14,127 @@ - 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(2,20): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(4,20): error TS8016: Type assertion expressions can only be used in TypeScript files. +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(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++b.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++b.js(12,20): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(13,25): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(43,23): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(44,23): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(45,23): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. ++b.js(47,26): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(48,26): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(49,26): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x ++b.js(51,24): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. ++b.js(52,24): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(52,38): error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. ++b.js(53,24): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(59,23): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. ++b.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. ++b.js(66,15): error TS8016: Type assertion expressions can only be used in TypeScript files. 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, +12 lines =@@ + Type 'number' is not assignable to type 'string'. + b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. ++b.js(71,27): error TS8016: Type assertion expressions can only be used in TypeScript files. ++b.js(72,27): error TS8016: Type assertion expressions can only be used in TypeScript files. + + ==== a.ts (0 errors) ==== var W: string; -==== b.js (10 errors) ==== -+==== b.js (9 errors) ==== ++==== b.js (30 errors) ==== // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); ++ ~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. var W = /** @type {string} */(4); // Error -- ~~~~~~ + ~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~ !!! 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 {*} */ -@@= skipped -48, +48 lines =@@ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var a; + + /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var s; + + var a = /** @type {*} */("" + 4); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + var s = "" + /** @type {*} */(4); ++ ~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + class SomeBase { + constructor() { +@@= skipped -66, +91 lines =@@ + var someFakeClass = new SomeFakeClass(); + someBase = /** @type {SomeBase} */(someDerived); ++ ~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someBase = /** @type {SomeBase} */(someBase); ++ ~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someBase = /** @type {SomeBase} */(someOther); // Error -- ~~~~~~~~ + ~~~~~~~~ -!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. !!! related TS2728 b.js:17:9: 'p' is declared here. someDerived = /** @type {SomeDerived} */(someDerived); ++ ~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someDerived = /** @type {SomeDerived} */(someBase); ++ ~~~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someDerived = /** @type {SomeDerived} */(someOther); // Error -- ~~~~~~~~~~~ + ~~~~~~~~~~~ -!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x someOther = /** @type {SomeOther} */(someDerived); // Error -- ~~~~~~~~~ + ~~~~~~~~~ -!!! error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~~~ +!!! error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someBase); // Error -- ~~~~~~~~~ + ~~~~~~~~~ -!!! error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~ +!!! error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someOther); ++ ~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -@@= skipped -28, +24 lines =@@ + someFakeClass = someBase; someFakeClass = someDerived; someBase = someFakeClass; // Error @@ -83,5 +144,34 @@ -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. someBase = /** @type {SomeBase} */(someFakeClass); ++ ~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + // Type assertion cannot be a type-predicate type + /** @type {number | string} */ ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var numOrStr; + /** @type {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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 TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~ + !!! error TS2454: Variable 'numOrStr' is used before being assigned. + str = numOrStr; // Error, no narrowing occurred +@@= skipped -57, +74 lines =@@ + - // Type assertion cannot be a type-predicate type \ No newline at end of file + var asConst1 = /** @type {const} */(1); ++ ~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + var asConst2 = /** @type {const} */({ ++ ~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + x: 1 + }); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff index 0136365e68..5925d243ed 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff @@ -7,15 +7,18 @@ - -==== a.js (2 errors) ==== +a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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 (3 errors) ==== ++==== a.js (4 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (value) => { + ~~~~~ +!!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff index 28a1528267..97f3dbed9e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff @@ -3,6 +3,7 @@ @@= 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(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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. @@ -11,11 +12,13 @@ -==== a.js (3 errors) ==== -+==== a.js (6 errors) ==== ++==== a.js (7 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (value) => { + ~~~~~ +!!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt.diff new file mode 100644 index 0000000000..8bd9d8b177 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.jsdocVariableDeclarationWithTypeAnnotation.errors.txt ++++ new.jsdocVariableDeclarationWithTypeAnnotation.errors.txt +@@= skipped -0, +0 lines =@@ +- ++foo.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (2 errors) ==== ++ /** @type {boolean} */ ++ var /** @type {string} */ x, ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ /** @type {number} */ y; ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff index a79f41e4ea..a0193041d4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff @@ -3,14 +3,17 @@ @@= skipped -0, +0 lines =@@ - +a.js(2,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? ++a.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (1 errors) ==== ++==== a.js (2 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. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const foo = function (a, b, ...r) { }; + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.errors.txt.diff new file mode 100644 index 0000000000..48b5ee2f9a --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.errors.txt.diff @@ -0,0 +1,35 @@ +--- old.linkTagEmit1.errors.txt ++++ new.linkTagEmit1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++linkTagEmit1.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== declarations.d.ts (0 errors) ==== ++ declare namespace NS { ++ type R = number ++ } ++==== linkTagEmit1.js (1 errors) ==== ++ /** @typedef {number} N */ ++ /** ++ * @typedef {Object} D1 ++ * @property {1} e Just link to {@link NS.R} this time ++ * @property {1} m Wyatt Earp loved {@link N integers} I bet. ++ */ ++ ++ /** @typedef {number} Z @see N {@link N} */ ++ ++ /** ++ * @param {number} integer {@link Z} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function computeCommonSourceDirectoryOfFilenames(integer) { ++ return integer + 1 // pls pls pls ++ } ++ ++ /** {@link https://hvad} */ ++ var see3 = true ++ ++ /** @typedef {number} Attempt {@link https://wat} {@linkcode I think lingcod is better} {@linkplain or lutefisk}*/ ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.errors.txt.diff new file mode 100644 index 0000000000..a0e197fef1 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.malformedTags.errors.txt ++++ new.malformedTags.errors.txt +@@= skipped -0, +0 lines =@@ +- ++myFile02.js(4,10): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== myFile02.js (1 errors) ==== ++ /** ++ * Checks if `value` is classified as an `Array` object. ++ * ++ * @type Function ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ var isArray = Array.isArray; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment.errors.txt.diff index 9b02b363c3..d3fe5e1316 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment.errors.txt.diff @@ -2,6 +2,7 @@ +++ new.moduleExportAssignment.errors.txt @@= skipped -0, +0 lines =@@ - ++npmlog.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. +npmlog.js(5,14): error TS2741: Property 'y' is missing in type 'EE' but required in type 'typeof import("npmlog")'. +npmlog.js(8,16): error TS2339: Property 'on' does not exist on type 'typeof import("npmlog")'. +npmlog.js(10,8): error TS2339: Property 'x' does not exist on type 'EE'. @@ -20,9 +21,11 @@ + ~~ +!!! error TS2339: Property 'on' does not exist on type 'typeof import("npmlog")'. + -+==== npmlog.js (5 errors) ==== ++==== npmlog.js (6 errors) ==== + class EE { + /** @param {string} s */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + on(s) { } + } + var npmlog = module.exports = new EE() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.errors.txt.diff new file mode 100644 index 0000000000..49d3b73dfb --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.moduleExportAssignment6.errors.txt ++++ new.moduleExportAssignment6.errors.txt +@@= skipped -0, +0 lines =@@ +- ++webpackLibNormalModule.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. ++webpackLibNormalModule.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== webpackLibNormalModule.js (2 errors) ==== ++ class C { ++ /** @param {number} x */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor(x) { ++ this.x = x ++ this.exports = [x] ++ } ++ /** @param {number} y */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ m(y) { ++ return this.x + y ++ } ++ } ++ function exec() { ++ const module = new C(12); ++ return module.exports; // should be fine because `module` is defined locally ++ } ++ ++ function tricky() { ++ // (a trickier variant of what webpack does) ++ const module = new C(12); ++ return () => { ++ return module.exports; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff index db60a68388..304edb0ae4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff @@ -7,17 +7,31 @@ +index.ts(7,24): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. 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(2,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(2,28): error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. ++main.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(3,28): error TS2694: Namespace '"mod".export=' has no exported member 'AnotherThing'. ++main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(4,28): error TS2694: Namespace '"mod".export=' has no exported member 'foo'. ++main.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(5,28): error TS2694: Namespace '"mod".export=' has no exported member 'qux'. ++main.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(6,28): error TS2694: Namespace '"mod".export=' has no exported member 'baz'. ++main.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(7,28): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. ++main.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(8,28): error TS2694: Namespace '"mod".export=' has no exported member 'literal'. ++main.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(20,35): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. - - -==== mod.js (0 errors) ==== ++main.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. +mod.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + @@ -45,33 +59,74 @@ -==== main.js (1 errors) ==== + ~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== main.js (8 errors) ==== ++==== main.js (22 errors) ==== /** * @param {import("./mod").Thing} a ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. * @param {import("./mod").AnotherThing} b ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'AnotherThing'. * @param {import("./mod").foo} c ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'foo'. * @param {import("./mod").qux} d ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'qux'. * @param {import("./mod").baz} e ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. * @param {import("./mod").buz} f ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. * @param {import("./mod").literal} g ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~ +!!! error TS2694: Namespace '"mod".export=' 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 -48, +80 lines =@@ +@@= skipped -35, +95 lines =@@ + + /** + * @param {typeof import("./mod").Thing} a ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {typeof import("./mod").AnotherThing} b ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {typeof import("./mod").foo} c ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {typeof import("./mod").qux} d ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {typeof import("./mod").baz} e ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {typeof import("./mod").buz} f ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ + !!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. + * @param {typeof import("./mod").literal} g ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function jsvalues(a, b, c, d, e, f, g) { return a.length + b.length + c() + d() + e() + f() + g.length } @@ -80,7 +135,7 @@ function types( a: import('./mod').Thing, ~~~~~ -@@= skipped -18, +18 lines =@@ +@@= skipped -31, +45 lines =@@ ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. f: import('./mod').buz, diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff index de6a3161fb..b0df2029c1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff @@ -4,8 +4,10 @@ - +mod.js(2,18): error TS2339: Property 'K' does not exist on type '{}'. +use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. ++use.js(8,13): error TS8010: Type annotations can only be used in TypeScript files. +use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. +use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? ++use.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== mod.js (1 errors) ==== @@ -21,7 +23,7 @@ + } + } + -+==== use.js (3 errors) ==== ++==== use.js (5 errors) ==== + import * as s from './mod' + + var k = new s.n.K() @@ -32,11 +34,15 @@ + + + /** @param {s.n.K} c ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2694: Namespace '"mod"' has no exported member 'n'. + @param {s.Classic} classic */ + ~~~~~~~~~ +!!! error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(c, classic) { + c.x + classic.p diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment2.errors.txt.diff new file mode 100644 index 0000000000..77233abf4b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment2.errors.txt.diff @@ -0,0 +1,33 @@ +--- old.moduleExportsElementAccessAssignment2.errors.txt ++++ new.moduleExportsElementAccessAssignment2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++file1.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++file1.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++file1.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== file1.js (3 errors) ==== ++ // this file _should_ be a global file ++ var GlobalThing = { x: 12 }; ++ ++ /** ++ * @param {*} type ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {*} ctor ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {*} exports ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(type, ctor, exports) { ++ 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/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff index e443064e79..4fc98269cf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff @@ -5,8 +5,10 @@ index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. -index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -15,20 +17,31 @@ -index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -38, +27 lines =@@ +@@= skipped -38, +38 lines =@@ index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -37,20 +50,31 @@ -index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -38, +27 lines =@@ +@@= skipped -38, +38 lines =@@ index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -59,178 +83,199 @@ -index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -65, +54 lines =@@ - // esm format file - const x = 1; - export {x}; --==== index.js (38 errors) ==== -+==== index.js (27 errors) ==== - import * as m1 from "./index.js"; - import * as m2 from "./index.mjs"; - import * as m3 from "./index.cjs"; -@@= skipped -73, +73 lines =@@ +@@= skipped -135, +135 lines =@@ + void m21; + void m22; + void m23; ++ ++ // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m25 = require("./index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m26 = require("./subfolder"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m27 = require("./subfolder/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m28 = require("./subfolder/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m29 = require("./subfolder2"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m30 = require("./subfolder2/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m31 = require("./subfolder2/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m32 = require("./subfolder2/another"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m33 = require("./subfolder2/another/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m34 = require("./subfolder2/another/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - void m24; -@@= skipped -91, +69 lines =@@ - // esm format file - const x = 1; - export {x}; --==== index.cjs (38 errors) ==== -+==== index.cjs (27 errors) ==== - // ESM-format imports below should issue errors - import * as m1 from "./index.js"; - ~~~~~~~~~~~~ -@@= skipped -74, +74 lines =@@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -165, +178 lines =@@ + void m21; + void m22; + void m23; ++ ++ // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m25 = require("./index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m26 = require("./subfolder"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m27 = require("./subfolder/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m28 = require("./subfolder/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m29 = require("./subfolder2"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m30 = require("./subfolder2/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m31 = require("./subfolder2/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m32 = require("./subfolder2/another"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m33 = require("./subfolder2/another/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m34 = require("./subfolder2/another/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - void m24; -@@= skipped -91, +69 lines =@@ - // cjs format file - const x = 1; - export {x}; --==== index.mjs (38 errors) ==== -+==== index.mjs (27 errors) ==== - import * as m1 from "./index.js"; - import * as m2 from "./index.mjs"; - import * as m3 from "./index.cjs"; -@@= skipped -73, +73 lines =@@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -164, +177 lines =@@ + void m21; + void m22; + void m23; ++ ++ // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m25 = require("./index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m26 = require("./subfolder"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m27 = require("./subfolder/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m28 = require("./subfolder/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m29 = require("./subfolder2"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m30 = require("./subfolder2/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m31 = require("./subfolder2/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m32 = require("./subfolder2/another"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m33 = require("./subfolder2/another/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m34 = require("./subfolder2/another/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - void m24; \ No newline at end of file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node18).errors.txt.diff index aff003ddc2..c815b6d7ee 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node18).errors.txt.diff @@ -5,8 +5,10 @@ index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. -index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -15,20 +17,31 @@ -index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -38, +27 lines =@@ +@@= skipped -38, +38 lines =@@ index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -37,20 +50,31 @@ -index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -38, +27 lines =@@ +@@= skipped -38, +38 lines =@@ index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -59,178 +83,199 @@ -index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -65, +54 lines =@@ - // esm format file - const x = 1; - export {x}; --==== index.js (38 errors) ==== -+==== index.js (27 errors) ==== - import * as m1 from "./index.js"; - import * as m2 from "./index.mjs"; - import * as m3 from "./index.cjs"; -@@= skipped -73, +73 lines =@@ +@@= skipped -135, +135 lines =@@ + void m21; + void m22; + void m23; ++ ++ // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m25 = require("./index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m26 = require("./subfolder"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m27 = require("./subfolder/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m28 = require("./subfolder/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m29 = require("./subfolder2"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m30 = require("./subfolder2/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m31 = require("./subfolder2/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m32 = require("./subfolder2/another"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m33 = require("./subfolder2/another/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m34 = require("./subfolder2/another/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - void m24; -@@= skipped -91, +69 lines =@@ - // esm format file - const x = 1; - export {x}; --==== index.cjs (38 errors) ==== -+==== index.cjs (27 errors) ==== - // ESM-format imports below should issue errors - import * as m1 from "./index.js"; - ~~~~~~~~~~~~ -@@= skipped -74, +74 lines =@@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -165, +178 lines =@@ + void m21; + void m22; + void m23; ++ ++ // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m25 = require("./index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m26 = require("./subfolder"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m27 = require("./subfolder/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m28 = require("./subfolder/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m29 = require("./subfolder2"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m30 = require("./subfolder2/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m31 = require("./subfolder2/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m32 = require("./subfolder2/another"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m33 = require("./subfolder2/another/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m34 = require("./subfolder2/another/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - void m24; -@@= skipped -91, +69 lines =@@ - // cjs format file - const x = 1; - export {x}; --==== index.mjs (38 errors) ==== -+==== index.mjs (27 errors) ==== - import * as m1 from "./index.js"; - import * as m2 from "./index.mjs"; - import * as m3 from "./index.cjs"; -@@= skipped -73, +73 lines =@@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -164, +177 lines =@@ + void m21; + void m22; + void m23; ++ ++ // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m25 = require("./index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m26 = require("./subfolder"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m27 = require("./subfolder/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m28 = require("./subfolder/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m29 = require("./subfolder2"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m30 = require("./subfolder2/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m31 = require("./subfolder2/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m32 = require("./subfolder2/another"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m33 = require("./subfolder2/another/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ++ import m34 = require("./subfolder2/another/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - void m24; \ No newline at end of file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt.diff index f3b05ae21c..48a55067da 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt.diff @@ -12,10 +12,21 @@ -index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? index.cjs(77,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. -@@= skipped -30, +19 lines =@@ +@@= skipped -30, +30 lines =@@ index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? @@ -30,10 +41,21 @@ -index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? index.js(76,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. -@@= skipped -33, +22 lines =@@ +@@= skipped -33, +33 lines =@@ index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? @@ -48,150 +70,173 @@ -index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? index.mjs(76,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. -@@= skipped -60, +49 lines =@@ - // esm format file - const x = 1; - export {x}; --==== index.js (33 errors) ==== -+==== index.js (22 errors) ==== - import * as m1 from "./index.js"; - import * as m2 from "./index.mjs"; - import * as m3 from "./index.cjs"; -@@= skipped -73, +73 lines =@@ +@@= skipped -130, +130 lines =@@ + void m21; + void m22; + void m23; ++ ++ // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m25 = require("./index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m26 = require("./subfolder"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m27 = require("./subfolder/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m28 = require("./subfolder/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m29 = require("./subfolder2"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m30 = require("./subfolder2/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m31 = require("./subfolder2/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m32 = require("./subfolder2/another"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m33 = require("./subfolder2/another/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m34 = require("./subfolder2/another/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - void m24; - void m25; - void m26; -@@= skipped -81, +59 lines =@@ - // esm format file - const x = 1; - export {x}; --==== index.cjs (22 errors) ==== -+==== index.cjs (11 errors) ==== - // ESM-format imports below should issue errors - import * as m1 from "./index.js"; - import * as m2 from "./index.mjs"; -@@= skipped -52, +52 lines =@@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -133, +146 lines =@@ + void m21; + void m22; + void m23; ++ ++ // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m25 = require("./index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m26 = require("./subfolder"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m27 = require("./subfolder/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m28 = require("./subfolder/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m29 = require("./subfolder2"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m30 = require("./subfolder2/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m31 = require("./subfolder2/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m32 = require("./subfolder2/another"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m33 = require("./subfolder2/another/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m34 = require("./subfolder2/another/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - void m24; - void m25; - void m26; -@@= skipped -81, +59 lines =@@ - // cjs format file - const x = 1; - export {x}; --==== index.mjs (33 errors) ==== -+==== index.mjs (22 errors) ==== - import * as m1 from "./index.js"; - import * as m2 from "./index.mjs"; - import * as m3 from "./index.cjs"; -@@= skipped -73, +73 lines =@@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -154, +167 lines =@@ + void m21; + void m22; + void m23; ++ ++ // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m25 = require("./index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m26 = require("./subfolder"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m27 = require("./subfolder/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m28 = require("./subfolder/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m29 = require("./subfolder2"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m30 = require("./subfolder2/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m31 = require("./subfolder2/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m32 = require("./subfolder2/another"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m33 = require("./subfolder2/another/"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ++ import m34 = require("./subfolder2/another/index"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - void m24; - void m25; - void m26; \ No newline at end of file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt.diff index f1ab5818bb..4b9751cb65 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt.diff @@ -3,33 +3,32 @@ @@= skipped -0, +0 lines =@@ -file.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`. +file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ++index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. -subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. -- -- --==== subfolder/index.js (1 errors) ==== -+ -+ -+==== subfolder/index.js (0 errors) ==== ++subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. + + + ==== subfolder/index.js (1 errors) ==== // cjs format file const a = {}; ++ export = a; -- ~~~~~~~~~~~ --!!! error TS8003: 'export =' can only be used in TypeScript files. - ==== subfolder/file.js (0 errors) ==== - // cjs format file - const a = {}; - module.exports = a; --==== index.js (2 errors) ==== -+==== index.js (1 errors) ==== + ~~~~~~~~~~~ + !!! error TS8003: 'export =' can only be used in TypeScript files. +@@= skipped -16, +17 lines =@@ + ==== index.js (2 errors) ==== // esm format file const a = {}; ++ export = a; ~~~~~~~~~~~ - !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +-!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - ~~~~~~~~~~~ --!!! error TS8003: 'export =' can only be used in TypeScript files. + !!! error TS8003: 'export =' can only be used in TypeScript files. ++ ~~~~~~~~~~~ ++!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== file.js (1 errors) ==== // esm format file import "fs"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt.diff index b1a763b122..22a9f447f2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt.diff @@ -3,33 +3,32 @@ @@= skipped -0, +0 lines =@@ -file.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`. +file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ++index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. -subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. -- -- --==== subfolder/index.js (1 errors) ==== -+ -+ -+==== subfolder/index.js (0 errors) ==== ++subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. + + + ==== subfolder/index.js (1 errors) ==== // cjs format file const a = {}; ++ export = a; -- ~~~~~~~~~~~ --!!! error TS8003: 'export =' can only be used in TypeScript files. - ==== subfolder/file.js (0 errors) ==== - // cjs format file - const a = {}; - module.exports = a; --==== index.js (2 errors) ==== -+==== index.js (1 errors) ==== + ~~~~~~~~~~~ + !!! error TS8003: 'export =' can only be used in TypeScript files. +@@= skipped -16, +17 lines =@@ + ==== index.js (2 errors) ==== // esm format file const a = {}; ++ export = a; ~~~~~~~~~~~ - !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +-!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - ~~~~~~~~~~~ --!!! error TS8003: 'export =' can only be used in TypeScript files. + !!! error TS8003: 'export =' can only be used in TypeScript files. ++ ~~~~~~~~~~~ ++!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== file.js (1 errors) ==== // esm format file import "fs"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt.diff index 29f6faa7d2..d62f9f2874 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt.diff @@ -3,33 +3,32 @@ @@= skipped -0, +0 lines =@@ -file.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`. +file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ++index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. -subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. -- -- --==== subfolder/index.js (1 errors) ==== -+ -+ -+==== subfolder/index.js (0 errors) ==== ++subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. + + + ==== subfolder/index.js (1 errors) ==== // cjs format file const a = {}; ++ export = a; -- ~~~~~~~~~~~ --!!! error TS8003: 'export =' can only be used in TypeScript files. - ==== subfolder/file.js (0 errors) ==== - // cjs format file - const a = {}; - module.exports = a; --==== index.js (2 errors) ==== -+==== index.js (1 errors) ==== + ~~~~~~~~~~~ + !!! error TS8003: 'export =' can only be used in TypeScript files. +@@= skipped -16, +17 lines =@@ + ==== index.js (2 errors) ==== // esm format file const a = {}; ++ export = a; ~~~~~~~~~~~ - !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +-!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - ~~~~~~~~~~~ --!!! error TS8003: 'export =' can only be used in TypeScript files. + !!! error TS8003: 'export =' can only be used in TypeScript files. ++ ~~~~~~~~~~~ ++!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== file.js (1 errors) ==== // esm format file import "fs"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt.diff index fe0f2883f0..69b17f91b8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt.diff @@ -7,47 +7,46 @@ -index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. -- -- --==== subfolder/index.js (2 errors) ==== -- // cjs format file -- import fs = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- fs.readFile; -- export import fs2 = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. --==== index.js (2 errors) ==== -- // esm format file -- import fs = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- fs.readFile; -- export import fs2 = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. --==== file.js (2 errors) ==== -- // esm format file -- const __require = null; -- const _createRequire = null; -- import fs = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- fs.readFile; -- export import fs2 = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module" -- } --==== subfolder/package.json (0 errors) ==== -- { -- "type": "commonjs" -- } --==== types.d.ts (0 errors) ==== -- declare module "fs"; -+ \ No newline at end of file ++file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. ++file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. + + + ==== subfolder/index.js (2 errors) ==== + // cjs format file ++ ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; ++ + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + ==== index.js (2 errors) ==== + // esm format file ++ ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; ++ + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -27, +31 lines =@@ + // esm format file + const __require = null; + const _createRequire = null; ++ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; ++ + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt.diff index aa38396f6b..b95116bf28 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt.diff @@ -7,47 +7,46 @@ -index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. -- -- --==== subfolder/index.js (2 errors) ==== -- // cjs format file -- import fs = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- fs.readFile; -- export import fs2 = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. --==== index.js (2 errors) ==== -- // esm format file -- import fs = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- fs.readFile; -- export import fs2 = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. --==== file.js (2 errors) ==== -- // esm format file -- const __require = null; -- const _createRequire = null; -- import fs = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- fs.readFile; -- export import fs2 = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module" -- } --==== subfolder/package.json (0 errors) ==== -- { -- "type": "commonjs" -- } --==== types.d.ts (0 errors) ==== -- declare module "fs"; -+ \ No newline at end of file ++file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. ++file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. + + + ==== subfolder/index.js (2 errors) ==== + // cjs format file ++ ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; ++ + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + ==== index.js (2 errors) ==== + // esm format file ++ ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; ++ + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -27, +31 lines =@@ + // esm format file + const __require = null; + const _createRequire = null; ++ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; ++ + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt.diff index 6e1f15e324..c2c9867961 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt.diff @@ -7,47 +7,46 @@ -index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. -- -- --==== subfolder/index.js (2 errors) ==== -- // cjs format file -- import fs = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- fs.readFile; -- export import fs2 = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. --==== index.js (2 errors) ==== -- // esm format file -- import fs = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- fs.readFile; -- export import fs2 = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. --==== file.js (2 errors) ==== -- // esm format file -- const __require = null; -- const _createRequire = null; -- import fs = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- fs.readFile; -- export import fs2 = require("fs"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module" -- } --==== subfolder/package.json (0 errors) ==== -- { -- "type": "commonjs" -- } --==== types.d.ts (0 errors) ==== -- declare module "fs"; -+ \ No newline at end of file ++file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. ++file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. + + + ==== subfolder/index.js (2 errors) ==== + // cjs format file ++ ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; ++ + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + ==== index.js (2 errors) ==== + // esm format file ++ ~~~~~~~~~~~~~~~~~~ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; ++ + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -27, +31 lines =@@ + // esm format file + const __require = null; + const _createRequire = null; ++ + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; ++ + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt.diff index 31b8fd889e..483f70af3b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt.diff @@ -2,51 +2,47 @@ +++ new.nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt @@= skipped -0, +0 lines =@@ -index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. -subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -- -- --==== subfolder/index.js (4 errors) ==== -+ -+ -+==== subfolder/index.js (2 errors) ==== - // cjs format file - import {h} from "../index.js"; ++subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. + + + ==== subfolder/index.js (4 errors) ==== +@@= skipped -13, +13 lines =@@ ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. !!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. ++ import mod = require("../index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; ++ import mod2 = require("./index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - export async function f() { - const mod3 = await import ("../index.js"); - const mod4 = await import ("./index.js"); - h(); - } --==== index.js (3 errors) ==== -+==== index.js (1 errors) ==== + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -17, +19 lines =@@ + ==== index.js (3 errors) ==== // esm format file import {h as _h} from "./index.js"; ++ import mod = require("./index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; ++ import mod2 = require("./subfolder/index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - export async function h() { - const mod3 = await import ("./index.js"); - const mod4 = await import ("./subfolder/index.js"); \ No newline at end of file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt.diff index 8ab98c1b2e..681fc86565 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt.diff @@ -2,51 +2,47 @@ +++ new.nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt @@= skipped -0, +0 lines =@@ -index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. -subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -- -- --==== subfolder/index.js (4 errors) ==== -+ -+ -+==== subfolder/index.js (2 errors) ==== - // cjs format file - import {h} from "../index.js"; ++subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. + + + ==== subfolder/index.js (4 errors) ==== +@@= skipped -13, +13 lines =@@ ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. !!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. ++ import mod = require("../index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; ++ import mod2 = require("./index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - export async function f() { - const mod3 = await import ("../index.js"); - const mod4 = await import ("./index.js"); - h(); - } --==== index.js (3 errors) ==== -+==== index.js (1 errors) ==== + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -17, +19 lines =@@ + ==== index.js (3 errors) ==== // esm format file import {h as _h} from "./index.js"; ++ import mod = require("./index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; ++ import mod2 = require("./subfolder/index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. - export async function h() { - const mod3 = await import ("./index.js"); - const mod4 = await import ("./subfolder/index.js"); \ No newline at end of file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt.diff index 4c5b8ad1b8..fd82370825 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt.diff @@ -5,46 +5,34 @@ -index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -- -- --==== subfolder/index.js (2 errors) ==== -- // cjs format file -- import {h} from "../index.js"; -- import mod = require("../index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- import {f as _f} from "./index.js"; -- import mod2 = require("./index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- export async function f() { -- const mod3 = await import ("../index.js"); -- const mod4 = await import ("./index.js"); -- h(); -- } --==== index.js (2 errors) ==== -- // esm format file -- import {h as _h} from "./index.js"; -- import mod = require("./index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- import {f} from "./subfolder/index.js"; -- import mod2 = require("./subfolder/index.js"); -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS8002: 'import ... =' can only be used in TypeScript files. -- export async function h() { -- const mod3 = await import ("./index.js"); -- const mod4 = await import ("./subfolder/index.js"); -- f(); -- } --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module" -- } --==== subfolder/package.json (0 errors) ==== -- { -- "type": "commonjs" -- } -+ \ No newline at end of file ++index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. ++index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. ++subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. + + + ==== subfolder/index.js (2 errors) ==== + // cjs format file + import {h} from "../index.js"; ++ + import mod = require("../index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + import {f as _f} from "./index.js"; ++ + import mod2 = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. +@@= skipped -21, +23 lines =@@ + ==== index.js (2 errors) ==== + // esm format file + import {h as _h} from "./index.js"; ++ + import mod = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. + import {f} from "./subfolder/index.js"; ++ + import mod2 = require("./subfolder/index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff new file mode 100644 index 0000000000..2f1796e4d9 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.optionalBindingParameters3.errors.txt ++++ new.optionalBindingParameters3.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(7,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++/a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. + /a.js(9,12): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. + + +-==== /a.js (1 errors) ==== ++==== /a.js (3 errors) ==== + /** + * @typedef Foo + * @property {string} a +@@= skipped -8, +10 lines =@@ + + /** + * @param {Foo} [options] ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function f({ a = "a" }) {} + ~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff new file mode 100644 index 0000000000..95029e087e --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.optionalBindingParameters4.errors.txt ++++ new.optionalBindingParameters4.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ /** ++ * @param {{ cause?: string }} [options] ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function foo({ cause } = {}) { ++ return cause; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff index 7a4ff7dab6..a870d1e433 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff @@ -15,24 +15,47 @@ - - -==== overloadTag1.js (3 errors) ==== ++overloadTag1.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. ++overloadTag1.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. ++overloadTag1.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++overloadTag1.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. ++overloadTag1.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. +overloadTag1.js(26,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. ++overloadTag1.js(29,5): error TS8017: Signature declarations can only be used in TypeScript files. ++overloadTag1.js(34,5): error TS8017: Signature declarations can only be used in TypeScript files. + + -+==== overloadTag1.js (1 errors) ==== ++==== overloadTag1.js (8 errors) ==== /** * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} a -@@= skipped -18, +8 lines =@@ + * @param {number} b * @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. ++!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a * @param {boolean} b * @returns {string} -@@= skipped -21, +18 lines =@@ + * + * @param {string | number} a ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string | number} b ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string | number} ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function overloaded(a,b) { + if (typeof a === "string" && typeof b === "string") { +@@= skipped -39, +43 lines =@@ } var o1 = overloaded(1,2) var o2 = overloaded("zero", "one") @@ -48,7 +71,19 @@ /** * @overload -@@= skipped -24, +20 lines =@@ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {number} a + * @param {number} b + * @returns {number} + * + * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {string} a + * @param {boolean} b + * @returns {string} +@@= skipped -24, +24 lines =@@ } uncheckedInternally(1,2) uncheckedInternally("zero", "one") diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff new file mode 100644 index 0000000000..53079f6ad4 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff @@ -0,0 +1,48 @@ +--- old.overloadTag2.errors.txt ++++ new.overloadTag2.errors.txt +@@= skipped -0, +0 lines =@@ ++overloadTag2.js(8,9): error TS8017: Signature declarations can only be used in TypeScript files. + overloadTag2.js(14,9): error TS2394: This overload signature is not compatible with its implementation signature. ++overloadTag2.js(14,9): error TS8017: Signature declarations can only be used in TypeScript files. ++overloadTag2.js(19,9): error TS8017: Signature declarations can only be used in TypeScript files. ++overloadTag2.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. + 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 (3 errors) ==== ++==== overloadTag2.js (7 errors) ==== + export class Foo { + #a = true ? 1 : "1" + #b +@@= skipped -11, +15 lines =@@ + * Should not have an implicit any error, because constructor's return type is always implicit + * @constructor + * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {string} a + * @param {number} b + */ +@@= skipped -9, +11 lines =@@ + ~~~~~~~~ + !!! error TS2394: This overload signature is not compatible with its implementation signature. + !!! related TS2750 overloadTag2.js:25:5: The implementation signature is declared here. ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {number} a + */ + /** + * @constructor + * @overload ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {string} a + *//** + * @constructor + * @param {number | string} a ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(a, b) { + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff new file mode 100644 index 0000000000..84401b5745 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff @@ -0,0 +1,53 @@ +--- old.overloadTag3.errors.txt ++++ new.overloadTag3.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++/a.js(7,9): error TS8017: Signature declarations can only be used in TypeScript files. ++/a.js(12,16): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (4 errors) ==== ++ /** ++ ~~~ ++ * @template T ++ ~~~~~~~~~~~~~~ ++ */ ++ ~~~ ++ export class Foo { ++ ~~~~~~~~~~~~~~~~~~ ++ /** ++ ~~~~~~~ ++ * @constructor ++ ~~~~~~~~~~~~~~~~~~~ ++ * @overload ++ ~~~~~~~~~~~~~~~~ ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ constructor() { } ++ ~~~~~~~~~~~~~~~~~~~~~ ++ ++ ++ /** ++ ~~~~~~~ ++ * @param {T} value ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~~~~~ ++ bar(value) { } ++ ~~~~~~~~~~~~~~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ /** @type {Foo} */ ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ let foo; ++ foo = new Foo(); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.errors.txt.diff new file mode 100644 index 0000000000..fdce0d5294 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.errors.txt.diff @@ -0,0 +1,43 @@ +--- old.paramTagBracketsAddOptionalUndefined.errors.txt ++++ new.paramTagBracketsAddOptionalUndefined.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(2,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. ++a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (6 errors) ==== ++ /** ++ * @param {number} [p] ++ ~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number=} q ++ ~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {number} [r=101] ++ ~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(p, q, r) { ++ 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() ++ f(undefined, undefined, undefined) ++ f(1, 2, 3) ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff index 920c07865c..fb05cc949f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff @@ -1,6 +1,7 @@ --- old.paramTagNestedWithoutTopLevelObject3.errors.txt +++ new.paramTagNestedWithoutTopLevelObject3.errors.txt @@= skipped -0, +0 lines =@@ ++paramTagNestedWithoutTopLevelObject3.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. paramTagNestedWithoutTopLevelObject3.js(3,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. - - @@ -8,11 +9,14 @@ +paramTagNestedWithoutTopLevelObject3.js(6,16): error TS2339: Property 'bar' does not exist on type 'object'. + + -+==== paramTagNestedWithoutTopLevelObject3.js (2 errors) ==== ++==== paramTagNestedWithoutTopLevelObject3.js (3 errors) ==== /** * @param {object} xyz ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} xyz.bar.p -@@= skipped -9, +10 lines =@@ + ~~~~~~~~~ + !!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. */ function g(xyz) { return xyz.bar.p; 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..f69ec7ac68 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff @@ -0,0 +1,32 @@ +--- old.paramTagTypeResolution2.errors.txt ++++ new.paramTagTypeResolution2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++38572.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++38572.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++38572.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== 38572.js (3 errors) ==== ++ /** ++ ~~~ ++ * @template T ++ ~~~~~~~~~~~~~~ ++ * @param {T} a ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {{[K in keyof T]: (value: T[K]) => void }} b ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ~~~ ++ function f(a, b) { ++ ~~~~~~~~~~~~~~~~~~ ++ } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ++ f({ x: 42 }, { x(param) { param.toFixed() } }); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff index c7b1b74daa..24d1bc187c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff @@ -9,7 +9,31 @@ 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. -@@= skipped -22, +17 lines =@@ +- +- +-==== good.js (0 errors) ==== ++good.js(3,5): error TS8010: Type annotations can only be used in TypeScript files. ++good.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++good.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== good.js (3 errors) ==== + /** + * @param + * {number} x Arg x. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * y Arg y. + * @param {number} z ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * Arg z. + */ + function good(x, y, z) { +@@= skipped -22, +26 lines =@@ good(1, 2, 3) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff index d76c5a0954..8e72301611 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff @@ -2,24 +2,23 @@ +++ new.parserArrowFunctionExpression10.errors.txt @@= skipped -0, +0 lines =@@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. ++fileJs.js(1,10): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,11): error TS2304: Cannot find name 'c'. -fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,17): error TS2304: Cannot find name 'd'. fileJs.js(1,27): error TS2304: Cannot find name 'f'. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. -@@= skipped -8, +7 lines =@@ - fileTs.ts(1,27): error TS2304: Cannot find name 'f'. - - --==== fileJs.js (5 errors) ==== -+==== fileJs.js (4 errors) ==== +@@= skipped -12, +12 lines =@@ a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon ~ !!! error TS2304: Cannot find name 'a'. - ~ - !!! error TS2304: Cannot find name 'c'. - ~ --!!! error TS8010: Type annotations can only be used in TypeScript files. +-!!! error TS2304: Cannot find name 'c'. +- ~ ++ ~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~ ++!!! error TS2304: Cannot find name 'c'. ~ !!! error TS2304: Cannot find name 'd'. ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff index b4e708c936..6acd8ac0b6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff @@ -4,19 +4,16 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. fileJs.js(1,11): error TS2304: Cannot find name 'a'. -fileJs.js(1,21): error TS8010: Type annotations can only be used in TypeScript files. ++fileJs.js(1,20): error TS8010: Type annotations can only be used in TypeScript files. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. fileTs.ts(1,11): error TS2304: Cannot find name 'a'. - --==== fileJs.js (3 errors) ==== -+==== fileJs.js (2 errors) ==== - a ? () => a() : (): any => null; // Not legal JS; "Unexpected token ')'" at last paren - ~ +@@= skipped -10, +10 lines =@@ !!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'a'. - ~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. - ==== fileTs.ts (2 errors) ==== - a ? () => a() : (): any => null; \ No newline at end of file + ==== fileTs.ts (2 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff index c4705940d8..43ae273bdb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff @@ -3,29 +3,29 @@ @@= skipped -0, +0 lines =@@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. -fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. --fileJs.js(1,20): error TS8009: The '?' modifier can only be used in TypeScript files. ++fileJs.js(1,10): error TS8010: Type annotations can only be used in TypeScript files. + fileJs.js(1,20): error TS8009: The '?' modifier can only be used in TypeScript files. -fileJs.js(1,23): error TS8010: Type annotations can only be used in TypeScript files. -fileJs.js(1,32): error TS8010: Type annotations can only be used in TypeScript files. ++fileJs.js(1,22): error TS8010: Type annotations can only be used in TypeScript files. ++fileJs.js(1,31): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,40): error TS2304: Cannot find name 'd'. fileJs.js(1,46): error TS2304: Cannot find name 'e'. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. -@@= skipped -9, +5 lines =@@ - fileTs.ts(1,46): error TS2304: Cannot find name 'e'. - - --==== fileJs.js (7 errors) ==== -+==== fileJs.js (3 errors) ==== +@@= skipped -13, +13 lines =@@ a() ? (b: number, c?: string): void => d() : e; // Not legal JS; "Unexpected token ':'" at first colon ~ !!! error TS2304: Cannot find name 'a'. - ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- ~ --!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + ~ + !!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ~ - !!! error TS2304: Cannot find name 'd'. - ~ \ No newline at end of file + !!! error TS2304: Cannot find name 'd'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff index 7b1e6d7782..3b110331f0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff @@ -2,14 +2,13 @@ +++ new.parserArrowFunctionExpression15.errors.txt @@= skipped -0, +0 lines =@@ -fileJs.js(1,18): error TS8010: Type annotations can only be used in TypeScript files. -- -- --==== fileJs.js (1 errors) ==== -- false ? (param): string => param : null // Not legal JS; "Unexpected token ':'" at last colon ++fileJs.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== fileJs.js (1 errors) ==== + false ? (param): string => param : null // Not legal JS; "Unexpected token ':'" at last colon - ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- --==== fileTs.ts (0 errors) ==== -- false ? (param): string => param : null -- -+ \ No newline at end of file ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + + ==== fileTs.ts (0 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff index da8b37a944..a99495fd1a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff @@ -2,14 +2,13 @@ +++ new.parserArrowFunctionExpression16.errors.txt @@= skipped -0, +0 lines =@@ -fileJs.js(1,25): error TS8010: Type annotations can only be used in TypeScript files. -- -- --==== fileJs.js (1 errors) ==== -- true ? false ? (param): string => param : null : null // Not legal JS; "Unexpected token ':'" at last colon ++fileJs.js(1,24): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== fileJs.js (1 errors) ==== + true ? false ? (param): string => param : null : null // Not legal JS; "Unexpected token ':'" at last colon - ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- --==== fileTs.ts (0 errors) ==== -- true ? false ? (param): string => param : null : null -- -+ \ No newline at end of file ++ ~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + + ==== fileTs.ts (0 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff index 5d502ccdfd..599c1a05ff 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff @@ -3,26 +3,23 @@ @@= skipped -0, +0 lines =@@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. fileJs.js(1,5): error TS2304: Cannot find name 'b'. ++fileJs.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,15): error TS2304: Cannot find name 'd'. -fileJs.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,20): error TS2304: Cannot find name 'e'. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. fileTs.ts(1,5): error TS2304: Cannot find name 'b'. -@@= skipped -8, +7 lines =@@ - fileTs.ts(1,20): error TS2304: Cannot find name 'e'. - - --==== fileJs.js (5 errors) ==== -+==== fileJs.js (4 errors) ==== - a ? b : (c) : d => e // Not legal JS; "Unexpected token ':'" at last colon - ~ +@@= skipped -14, +14 lines =@@ !!! error TS2304: Cannot find name 'a'. -@@= skipped -8, +8 lines =@@ + ~ !!! error TS2304: Cannot find name 'b'. - ~ - !!! error TS2304: Cannot find name 'd'. - ~ --!!! error TS8010: Type annotations can only be used in TypeScript files. +-!!! error TS2304: Cannot find name 'd'. +- ~ ++ ~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~ ++!!! error TS2304: Cannot find name 'd'. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff new file mode 100644 index 0000000000..30831764d7 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff @@ -0,0 +1,50 @@ +--- old.privateNamesIncompatibleModifiersJs.errors.txt ++++ new.privateNamesIncompatibleModifiersJs.errors.txt +@@= skipped -0, +0 lines =@@ ++privateNamesIncompatibleModifiersJs.js(3,8): error TS8009: The 'public' modifier can only be used in TypeScript files. + privateNamesIncompatibleModifiersJs.js(3,8): error TS18010: An accessibility modifier cannot be used with a private identifier. ++privateNamesIncompatibleModifiersJs.js(8,8): error TS8009: The 'private' modifier can only be used in TypeScript files. + privateNamesIncompatibleModifiersJs.js(8,8): error TS18010: An accessibility modifier cannot be used with a private identifier. ++privateNamesIncompatibleModifiersJs.js(13,8): error TS8009: The 'protected' modifier can only be used in TypeScript files. + privateNamesIncompatibleModifiersJs.js(13,8): error TS18010: An accessibility modifier cannot be used with a private identifier. + privateNamesIncompatibleModifiersJs.js(18,8): error TS18010: An accessibility modifier cannot be used with a private identifier. + privateNamesIncompatibleModifiersJs.js(23,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +@@= skipped -11, +14 lines =@@ + privateNamesIncompatibleModifiersJs.js(55,8): error TS18010: An accessibility modifier cannot be used with a private identifier. + + +-==== privateNamesIncompatibleModifiersJs.js (12 errors) ==== ++==== privateNamesIncompatibleModifiersJs.js (15 errors) ==== + class A { + /** + * @public + ~~~~~~~ ++ ~~~~~~~ + */ ++ ~~~~~ ++!!! error TS8009: The 'public' modifier can only be used in TypeScript files. + ~~~~~ + !!! error TS18010: An accessibility modifier cannot be used with a private identifier. + #a = 1; +@@= skipped -13, +16 lines =@@ + /** + * @private + ~~~~~~~~ ++ ~~~~~~~~ + */ ++ ~~~~~ ++!!! error TS8009: The 'private' modifier can only be used in TypeScript files. + ~~~~~ + !!! error TS18010: An accessibility modifier cannot be used with a private identifier. + #b = 1; +@@= skipped -8, +11 lines =@@ + /** + * @protected + ~~~~~~~~~~ ++ ~~~~~~~~~~ + */ ++ ~~~~~ ++!!! error TS8009: The 'protected' modifier can only be used in TypeScript files. + ~~~~~ + !!! error TS18010: An accessibility modifier cannot be used with a private identifier. + #c = 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff index 90eb34fe82..5e69107dd6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff @@ -2,48 +2,106 @@ +++ new.propertiesOfGenericConstructorFunctions.errors.txt @@= skipped -0, +0 lines =@@ - ++propertiesOfGenericConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. +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(14,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(26,24): error TS8004: Type parameter declarations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertiesOfGenericConstructorFunctions.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== propertiesOfGenericConstructorFunctions.js (1 errors) ==== ++==== propertiesOfGenericConstructorFunctions.js (16 errors) ==== + /** ++ ~~~ + * @template {string} K ++ ~~~~~~~~~~~~~~~~~~~~~~~ + * @template V ++ ~~~~~~~~~~~~~~ + * @param {string} ik ++ ~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {V} iv ++ ~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function Multimap(ik, iv) { ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** @type {{ [s: string]: V }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + this._map = {}; ++ ~~~~~~~~~~~~~~~~~~~ + // without type annotation ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + this._map2 = { [ik]: iv }; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }; ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** @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'? ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const map = new Multimap("a", 1); + // without type annotation + const map2 = new Multimap("m", 2); + + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = map._map['hi'] + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = map._map2['hi'] + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = map2._map['hi'] + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = map._map2['hi'] ++ ++ + + /** ++ ~~~ + * @class ++ ~~~~~~~~~ + * @template T ++ ~~~~~~~~~~~~~~ + * @param {T} t ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function Cp(t) { ++ ~~~~~~~~~~~~~~~~ + this.x = 1 ++ ~~~~~~~~~~~~~~ + this.y = t ++ ~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + Cp.prototype = { + m1() { return this.x }, + m2() { this.z = this.x + 1; return this.y } @@ -51,12 +109,20 @@ + var cp = new Cp(1) + + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = cp.x + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = cp.y + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = cp.m1() + /** @type {number} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = cp.m2() + + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff index 4a3a8a2346..83418e73a5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff @@ -2,12 +2,32 @@ +++ new.propertyAssignmentUseParentType2.errors.txt @@= skipped -0, +0 lines =@@ -propertyAssignmentUseParentType2.js(11,14): error TS2322: Type '{ (): boolean; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. ++propertyAssignmentUseParentType2.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertyAssignmentUseParentType2.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++propertyAssignmentUseParentType2.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +propertyAssignmentUseParentType2.js(11,14): error TS2322: Type '{ (): true; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. Types of property 'nuo' are incompatible. Type '1000' is not assignable to type '789'. -@@= skipped -15, +15 lines =@@ + +-==== propertyAssignmentUseParentType2.js (1 errors) ==== ++==== propertyAssignmentUseParentType2.js (4 errors) ==== + /** @type {{ (): boolean; nuo: 789 }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const inlined = () => true + inlined.nuo = 789 + + /** @type {{ (): boolean; nuo: 789 }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + export const duplicated = () => true + /** @type {789} */ + duplicated.nuo = 789 + /** @type {{ (): boolean; nuo: 789 }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. export const conflictingDuplicated = () => true ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ (): boolean; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff index 55aaf5a4fd..f83933fb6d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff @@ -4,16 +4,24 @@ -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(2,11): error TS8010: Type annotations can only be used in TypeScript files. +other.js(7,11): error TS2503: Cannot find namespace 'Ns'. ++other.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. ==== prototypePropertyAssignmentMergeAcrossFiles2.js (0 errors) ==== -@@= skipped -15, +15 lines =@@ - ==== other.js (2 errors) ==== +@@= skipped -12, +14 lines =@@ + Ns.Two.prototype = { + } + +-==== other.js (2 errors) ==== ++==== other.js (4 errors) ==== /** * @type {Ns.One} + ~~ +!!! error TS2503: Cannot find namespace 'Ns'. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ var one; one.wat; @@ -23,6 +31,8 @@ * @type {Ns.Two} + ~~ +!!! error TS2503: Cannot find namespace 'Ns'. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ var two; two.wat; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff index cac29e7193..570512ea78 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff @@ -2,12 +2,13 @@ +++ new.prototypePropertyAssignmentMergedTypeReference.errors.txt @@= skipped -0, +0 lines =@@ - ++prototypePropertyAssignmentMergedTypeReference.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +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) ==== ++==== prototypePropertyAssignmentMergedTypeReference.js (3 errors) ==== + var f = function() { + return 12; + }; @@ -15,6 +16,8 @@ + f.prototype.a = "a"; + + /** @type {new () => f} */ ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2749: 'f' refers to a value, but is being used as a type here. Did you mean 'typeof f'? + var x = f; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff new file mode 100644 index 0000000000..82bfb1ef52 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.recursiveTypeReferences2.errors.txt ++++ new.recursiveTypeReferences2.errors.txt +@@= skipped -0, +0 lines =@@ ++bug39372.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. ++bug39372.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. + bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. + Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O + + +-==== bug39372.js (1 errors) ==== ++==== bug39372.js (3 errors) ==== + /** @typedef {ReadonlyArray} JsonArray */ + /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ + + /** +@@= skipped -26, +30 lines =@@ + }} XMLObject */ + + /** @type {XMLObject<{foo:string}>} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const p = {}; + ~ + !!! error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff new file mode 100644 index 0000000000..24b7d9c8d8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff @@ -0,0 +1,98 @@ +--- old.returnTagTypeGuard.errors.txt ++++ new.returnTagTypeGuard.errors.txt +@@= skipped -0, +0 lines =@@ +- ++bug25127.js(6,16): error TS8010: Type annotations can only be used in TypeScript files. ++bug25127.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. ++bug25127.js(18,16): error TS8010: Type annotations can only be used in TypeScript files. ++bug25127.js(19,17): error TS8010: Type annotations can only be used in TypeScript files. ++bug25127.js(25,13): error TS8010: Type annotations can only be used in TypeScript files. ++bug25127.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. ++bug25127.js(33,13): error TS8010: Type annotations can only be used in TypeScript files. ++bug25127.js(39,13): error TS8010: Type annotations can only be used in TypeScript files. ++bug25127.js(48,12): error TS8010: Type annotations can only be used in TypeScript files. ++bug25127.js(55,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== bug25127.js (10 errors) ==== ++ class Entry { ++ constructor() { ++ this.c = 1 ++ } ++ /** ++ * @param {any} x ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @return {this is Entry} ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ isInit(x) { ++ return true ++ } ++ } ++ class Group { ++ constructor() { ++ this.d = 'no' ++ } ++ /** ++ * @param {any} x ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @return {false} ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ isInit(x) { ++ return false ++ } ++ } ++ /** @param {Entry | Group} chunk */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ function f(chunk) { ++ let x = chunk.isInit(chunk) ? chunk.c : chunk.d ++ return x ++ } ++ ++ /** ++ * @param {any} value ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @return {value is boolean} ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function isBoolean(value) { ++ return typeof value === "boolean"; ++ } ++ ++ /** @param {boolean | number} val */ ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ function foo(val) { ++ if (isBoolean(val)) { ++ val; ++ } ++ } ++ ++ /** ++ * @callback Cb ++ * @param {unknown} x ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @return {x is number} ++ */ ++ ++ /** @type {Cb} */ ++ function isNumber(x) { return typeof x === "number" } ++ ++ /** @param {unknown} x */ ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ function g(x) { ++ if (isNumber(x)) { ++ x * 2; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.errors.txt.diff index f8301b5289..612215a628 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.errors.txt.diff @@ -3,23 +3,24 @@ @@= skipped -0, +0 lines =@@ -badTypeArguments.js(1,15): error TS1099: Type argument list cannot be empty. -badTypeArguments.js(2,22): error TS1009: Trailing comma not allowed. -- -- --==== dummyType.d.ts (0 errors) ==== -- declare class C { t: T } -- ++badTypeArguments.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== dummyType.d.ts (0 errors) ==== + declare class C { t: T } + -==== badTypeArguments.js (2 errors) ==== -- /** @param {C.<>} x */ ++==== badTypeArguments.js (1 errors) ==== + /** @param {C.<>} x */ - ~~ -!!! error TS1099: Type argument list cannot be empty. -- /** @param {C.} y */ + /** @param {C.} y */ - ~ -!!! error TS1009: Trailing comma not allowed. -- // @ts-ignore -- /** @param {C.} skipped */ -- function f(x, y, skipped) { -- return x.t + y.t; -- } -- var x = f({ t: 1000 }, { t: 3000 }, { t: 5000 }); -- -+ \ No newline at end of file + // @ts-ignore + /** @param {C.} skipped */ ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(x, y, skipped) { + return x.t + y.t; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff index 2164c25069..7b9ba7bec4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff @@ -6,7 +6,9 @@ -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 TS8010: Type annotations can only be used in TypeScript files. +templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. ++templateInsideCallback.js(17,17): error TS8004: Type parameter declarations can only be used in TypeScript files. 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 @@ -22,10 +24,17 @@ -!!! 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(29,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. ++templateInsideCallback.js(29,5): error TS8017: Signature declarations can only be used in TypeScript files. +templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. ++templateInsideCallback.js(37,5): error TS8017: Signature declarations can only be used in TypeScript files. ++templateInsideCallback.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. ++templateInsideCallback.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. ++templateInsideCallback.js(45,14): error TS8010: Type annotations can only be used in TypeScript files. ++templateInsideCallback.js(48,14): error TS8010: Type annotations can only be used in TypeScript files. ++templateInsideCallback.js(51,31): error TS8016: Type assertion expressions can only be used in TypeScript files. + + -+==== templateInsideCallback.js (5 errors) ==== ++==== templateInsideCallback.js (14 errors) ==== /** * @typedef Oops - ~~~~ @@ -33,7 +42,7 @@ * @template T * @property {T} a * @property {T} b -@@= skipped -27, +14 lines =@@ +@@= skipped -27, +23 lines =@@ /** * @callback Call * @template T @@ -49,12 +58,18 @@ * @type {Call} ~~~~~~~ !!! error TS2315: Type 'Call' is not generic. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2304: Cannot find name 'T'. */ const identity = x => x; ++ ~~~~~~~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ -@@= skipped -10, +12 lines =@@ + !!! error TS7006: Parameter 'x' implicitly has an 'any' type. + +@@= skipped -10, +16 lines =@@ * @property {Object} oh * @property {number} oh.no * @template T @@ -66,11 +81,13 @@ /** * @overload -- * @template T - ~~~~~~~~ --!!! error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag ++ ~~~~~~~~ +!!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+ * @template T ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @template T +- ~~~~~~~~ +-!!! error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag * @template U * @param {T[]} array - ~ @@ -82,14 +99,38 @@ */ /** * @overload -- * @template T - ~~~~~~~~ --!!! error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag ++ ~~~~~~~~ +!!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+ * @template T ++ ~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @template T +- ~~~~~~~~ +-!!! error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag * @param {T[][]} array - ~ -!!! error TS2304: Cannot find name 'T'. * @returns {T[]} */ - /** \ No newline at end of file + /** + * @param {unknown[]} array ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {(x: unknown) => unknown} iterable ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {unknown[]} ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function flatMap(array, iterable = identity) { + /** @type {unknown[]} */ ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const result = []; + for (let i = 0; i < array.length; i += 1) { + result.push(.../** @type {unknown[]} */(iterable(array[i]))); ++ ~~~~~~~~~ ++!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + return result; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff new file mode 100644 index 0000000000..66dfc3b899 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.thisPropertyAssignmentInherited.errors.txt ++++ new.thisPropertyAssignmentInherited.errors.txt +@@= skipped -0, +0 lines =@@ +- ++thisPropertyAssignmentInherited.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== thisPropertyAssignmentInherited.js (1 errors) ==== ++ export class Element { ++ /** ++ * @returns {String} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ get textContent() { ++ return '' ++ } ++ set textContent(x) {} ++ cloneNode() { return this} ++ } ++ export class HTMLElement extends Element {} ++ export class TextElement extends HTMLElement { ++ get innerHTML() { return this.textContent; } ++ set innerHTML(html) { this.textContent = html; } ++ toString() { ++ } ++ } ++ ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff new file mode 100644 index 0000000000..72e6cee565 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.thisTag1.errors.txt ++++ new.thisTag1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (3 errors) ==== ++ /** @this {{ n: number }} Mount Holyoke Preparatory School ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {string} s ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @return {number} ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(s) { ++ return this.n + s.length ++ } ++ ++ const o = { ++ f, ++ n: 1 ++ } ++ o.f('hi') ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.errors.txt.diff new file mode 100644 index 0000000000..48e38e625d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.thisTag2.errors.txt ++++ new.thisTag2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(4,10): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (2 errors) ==== ++ /** @this {string} */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ export function f1() {} ++ ++ /** @this */ ++ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ export function f2() {} ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff new file mode 100644 index 0000000000..94af5b959f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff @@ -0,0 +1,31 @@ +--- old.thisTag3.errors.txt ++++ new.thisTag3.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(2,20): error TS8010: Type annotations can only be used in TypeScript files. + /a.js(7,9): error TS2730: An arrow function cannot have a 'this' parameter. ++/a.js(7,15): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. + /a.js(10,21): error TS2339: Property 'fn' does not exist on type 'C'. + + +-==== /a.js (2 errors) ==== ++==== /a.js (5 errors) ==== + /** + * @typedef {{fn(a: string): void}} T ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + class C { +@@= skipped -11, +16 lines =@@ + * @this {T} + ~~~~ + !!! error TS2730: An arrow function cannot have a 'this' parameter. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {string} a ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + p = (a) => this.fn("" + a); + ~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff index 0d0f4cee34..2c98ff0a48 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff @@ -2,43 +2,81 @@ +++ new.thisTypeOfConstructorFunctions.errors.txt @@= skipped -0, +0 lines =@@ - ++thisTypeOfConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++thisTypeOfConstructorFunctions.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +thisTypeOfConstructorFunctions.js(15,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. ++thisTypeOfConstructorFunctions.js(15,18): error TS8010: Type annotations can only be used in TypeScript files. ++thisTypeOfConstructorFunctions.js(19,2): error TS8004: Type parameter declarations can only be used in TypeScript files. ++thisTypeOfConstructorFunctions.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. +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(38,12): error TS8010: Type annotations can only be used in TypeScript files. +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(41,12): error TS8010: Type annotations can only be used in TypeScript files. +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(43,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== thisTypeOfConstructorFunctions.js (4 errors) ==== ++==== thisTypeOfConstructorFunctions.js (12 errors) ==== + /** ++ ~~~ + * @class ++ ~~~~~~~~~ + * @template T ++ ~~~~~~~~~~~~~~ + * @param {T} t ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function Cp(t) { ++ ~~~~~~~~~~~~~~~~ + /** @type {this} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~ + this.dit = this ++ ~~~~~~~~~~~~~~~~~~~ + this.y = t ++ ~~~~~~~~~~~~~~ + /** @return {this} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ + this.m3 = () => this ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + Cp.prototype = { + /** @return {this} */ + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + m4() { + this.z = this.y; return this + } + } ++ ++ + + /** ++ ~~~ + * @class ++ ~~~~~~~~~ + * @template T ++ ~~~~~~~~~~~~~~ + * @param {T} t ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function Cpp(t) { ++ ~~~~~~~~~~~~~~~~~ + this.y = t ++ ~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + /** @return {this} */ + Cpp.prototype.m2 = function () { + this.z = this.y; return this @@ -51,15 +89,21 @@ + /** @type {Cpp} */ + ~~~ +!!! error TS2749: 'Cpp' refers to a value, but is being used as a type here. Did you mean 'typeof Cpp'? ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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'? ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + 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'? ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var cpn = cp.m4() + + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff index 547bf8d5a5..347c43a51a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff @@ -2,12 +2,16 @@ +++ new.typeFromContextualThisType.errors.txt @@= skipped -0, +0 lines =@@ - ++bug25926.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +bug25926.js(4,18): error TS7006: Parameter 'n' implicitly has an 'any' type. ++bug25926.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +bug25926.js(11,27): error TS7006: Parameter 'm' implicitly has an 'any' type. + + -+==== bug25926.js (2 errors) ==== ++==== bug25926.js (4 errors) ==== + /** @type {{ a(): void; b?(n: number): number; }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const o1 = { + a() { + this.b = n => n; @@ -17,6 +21,8 @@ + }; + + /** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const o2 = { + d() { + this.e = this.f = m => this.g || m; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff index 881af72565..5fbf5175d2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff @@ -5,15 +5,18 @@ -a.js(4,5): error TS7008: Member 'unknowable' implicitly has an 'any' type. -a.js(5,5): error TS7008: Member 'empty' 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(21,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(25,29): error TS7006: Parameter 'l' 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'. -@@= skipped -9, +7 lines =@@ +@@= skipped -7, +6 lines =@@ + 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(55,12): error TS8010: Type annotations can only be used in TypeScript files. --==== a.js (10 errors) ==== -+==== a.js (8 errors) ==== + ==== a.js (10 errors) ==== function A () { // should get any on this-assignments in constructor this.unknown = null @@ -31,4 +34,22 @@ +!!! error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. a.unknown = 1 a.unknown = true - a.unknown = {} \ No newline at end of file + a.unknown = {} +@@= skipped -30, +27 lines =@@ + a.empty.push('hi') + + /** @type {number | undefined} */ ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n; + + // should get any on parameter initialisers +@@= skipped -48, +50 lines =@@ + l.push('ok') + + /** @type {(v: unknown) => v is undefined} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const isUndef = v => v === undefined; + const e = [1, undefined]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.errors.txt.diff new file mode 100644 index 0000000000..1a46a62fda --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.typeFromJSInitializer4.errors.txt ++++ new.typeFromJSInitializer4.errors.txt +@@= skipped -0, +0 lines =@@ ++a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. + a.js(5,12): error TS7006: Parameter 'a' 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} */ ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var n; + + // should get any on parameter initialisers \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff index cd5c4c1215..88c186cd9b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff @@ -3,11 +3,19 @@ @@= skipped -0, +0 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'? ++a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +b.js(3,13): error TS2749: 'B' refers to a value, but is being used as a type here. Did you mean 'typeof B'? ++b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +c.js(3,13): error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? ++c.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +d.js(3,13): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? ++d.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. ++e.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +f.js(5,13): error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? ++f.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. +g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? ++g.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. ++h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== node.d.ts (0 errors) ==== @@ -19,12 +27,14 @@ + this.x = 1; + }; + -+==== a.js (1 errors) ==== ++==== a.js (2 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'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function a(p) { p.x; } + +==== b-ext.js (0 errors) ==== @@ -34,12 +44,14 @@ + } + }; + -+==== b.js (1 errors) ==== ++==== b.js (2 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'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function b(p) { p.x; } + +==== c-ext.js (0 errors) ==== @@ -47,12 +59,14 @@ + this.x = 1; + } + -+==== c.js (1 errors) ==== ++==== c.js (2 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'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function c(p) { p.x; } + +==== d-ext.js (0 errors) ==== @@ -60,12 +74,14 @@ + this.x = 1; + }; + -+==== d.js (1 errors) ==== ++==== d.js (2 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'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function d(p) { p.x; } + +==== e-ext.js (0 errors) ==== @@ -75,13 +91,15 @@ + } + } + -+==== e.js (0 errors) ==== ++==== e.js (1 errors) ==== + const { E } = require("./e-ext"); + + /** @param {E} p */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function e(p) { p.x; } + -+==== f.js (1 errors) ==== ++==== f.js (2 errors) ==== + var F = function () { + this.x = 1; + }; @@ -89,9 +107,11 @@ + /** @param {F} p */ + ~ +!!! error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(p) { p.x; } + -+==== g.js (1 errors) ==== ++==== g.js (2 errors) ==== + function G() { + this.x = 1; + } @@ -99,9 +119,11 @@ + /** @param {G} p */ + ~ +!!! error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function g(p) { p.x; } + -+==== h.js (0 errors) ==== ++==== h.js (1 errors) ==== + class H { + constructor() { + this.x = 1; @@ -109,4 +131,6 @@ + } + + /** @param {H} p */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function h(p) { p.x; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt.diff new file mode 100644 index 0000000000..a495120e4a --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt.diff @@ -0,0 +1,26 @@ +--- old.typeFromPrivatePropertyAssignmentJs.errors.txt ++++ new.typeFromPrivatePropertyAssignmentJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== typeFromPrivatePropertyAssignmentJs.js (0 errors) ==== ++ ++==== a.js (2 errors) ==== ++ class C { ++ /** @type {{ foo?: string } | undefined } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ #a; ++ /** @type {{ foo?: string } | undefined } */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ #b; ++ m() { ++ const a = this.#a || {}; ++ this.#b = this.#b || {}; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff index 46f52a51ad..866f105819 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff @@ -3,10 +3,12 @@ @@= skipped -0, +0 lines =@@ - +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(8,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(11,12): error TS2503: Cannot find namespace 'Outer'. ++a.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (2 errors) ==== ++==== a.js (4 errors) ==== + var Outer = class O { + m(x, y) { } + } @@ -17,11 +19,15 @@ + /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var si + si.m + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var oi + oi.n + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff index 50bfd6b072..9dfd5dfbc3 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, +0 lines =@@ - +main.js(4,12): error TS2503: Cannot find namespace 'Outer'. ++main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== module.js (0 errors) ==== @@ -41,13 +42,15 @@ + }; + return Application; + })(); -+==== main.js (1 errors) ==== ++==== main.js (2 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'. ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x; + x.y; + 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 4fcf12d543..76a9b86416 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, +0 lines =@@ - +main.js(4,12): error TS2503: Cannot find namespace 'Outer'. ++main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== module.js (0 errors) ==== @@ -41,13 +42,15 @@ + }; + return Application; + })(); -+==== main.js (1 errors) ==== ++==== main.js (2 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'. ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x; + x.y; + 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 3cf1ad4cce..8f6a79b070 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, +0 lines =@@ - +use.js(1,12): error TS2503: Cannot find namespace 'Outer'. ++use.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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,10 +23,12 @@ + m() { } + } + -+==== use.js (2 errors) ==== ++==== use.js (3 errors) ==== + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var inner + inner.x + inner.m() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff index 99d17f1f61..7b9bea59fa 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff @@ -3,9 +3,10 @@ @@= skipped -0, +0 lines =@@ - +a.js(10,12): error TS2503: Cannot find namespace 'Outer'. ++a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (1 errors) ==== ++==== a.js (2 errors) ==== + var Outer = {}; + + Outer.Inner = class { @@ -18,6 +19,8 @@ + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var inner + inner.x + inner.m() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff index eaa4b7ab57..11a70d86c0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff @@ -3,9 +3,10 @@ @@= skipped -0, +0 lines =@@ - +a.js(9,12): error TS2503: Cannot find namespace 'Outer'. ++a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (1 errors) ==== ++==== a.js (2 errors) ==== + var Outer = {}; + + Outer.Inner = function () {} @@ -17,6 +18,8 @@ + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var inner + inner.x + inner.m() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff index ee3e704669..a5eae95386 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff @@ -3,10 +3,12 @@ @@= skipped -0, +0 lines =@@ - +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(9,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(12,12): error TS2503: Cannot find namespace 'Outer'. ++a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (2 errors) ==== ++==== a.js (4 errors) ==== + function Outer() { + this.y = 2 + } @@ -18,11 +20,15 @@ + /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var ok + ok.y + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var oc + oc.x + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff index 1d22ed67e3..b80b1327f2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff @@ -4,9 +4,10 @@ - +usage.js(2,13): error TS2339: Property 'Message' does not exist on type 'typeof Inner'. +usage.js(7,12): error TS2503: Cannot find namespace 'Outer'. ++usage.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== usage.js (2 errors) ==== ++==== usage.js (3 errors) ==== + // note that usage is first in the compilation + Outer.Inner.Message = function() { + ~~~~~~~ @@ -18,6 +19,8 @@ + /** @type {Outer.Inner} should be instance type, not static type */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x; + x.name + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff index 8f97d07393..37000fd1ec 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff @@ -3,10 +3,12 @@ @@= skipped -0, +0 lines =@@ - +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(9,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(12,12): error TS2503: Cannot find namespace 'Outer'. ++a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (2 errors) ==== ++==== a.js (4 errors) ==== + var Outer = function O() { + this.y = 2 + } @@ -18,11 +20,15 @@ + /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var ja + ja.y + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var da + da.x + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff index 1f444bc551..e12df41181 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff @@ -3,16 +3,19 @@ @@= skipped -0, +0 lines =@@ - +bug26877.js(1,13): error TS2503: Cannot find namespace 'Emu'. ++bug26877.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. +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 '{}'. +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'. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function ollKorrect(x) { + x._model + const y = new Emu.D() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff index f71a2bea68..9ad605d215 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff @@ -4,15 +4,17 @@ - +a.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. +a.js(8,12): error TS2503: Cannot find namespace 'Outer'. ++a.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +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(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var local + local.y + var inner = new Outer.Inner() @@ -32,10 +36,12 @@ +!!! error TS2339: Property 'Inner' does not exist on type '{}'. + inner.y + -+==== b.js (2 errors) ==== ++==== b.js (3 errors) ==== + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x + x.y + 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 index 8d9ed29fb6..b750247ee2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.errors.txt.diff @@ -3,9 +3,10 @@ @@= skipped -0, +0 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(5,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== typeFromPropertyAssignment40.js (1 errors) ==== ++==== typeFromPropertyAssignment40.js (2 errors) ==== + function Outer() { + var self = this + self.y = 2 @@ -13,6 +14,8 @@ + /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var ok + ok.y + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff index e96d0ee8b7..ce1ce6f8b5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff @@ -3,6 +3,7 @@ @@= skipped -0, +0 lines =@@ - +b.js(3,12): error TS2503: Cannot find namespace 'MC'. ++b.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (0 errors) ==== @@ -12,11 +13,13 @@ + } + MyClass.bar + -+==== b.js (1 errors) ==== ++==== b.js (2 errors) ==== + import MC from './a' + MC.bar + /** @type {MC.bar} */ + ~~ +!!! error TS2503: Cannot find namespace 'MC'. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var x + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff index af12eda3f3..1876bc4daf 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(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. ++b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== def.js (0 errors) ==== @@ -22,7 +23,7 @@ + ~ +!!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. + -+==== b.js (2 errors) ==== ++==== b.js (3 errors) ==== + var msgs = Outer.i.messages() + ~ +!!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. @@ -30,6 +31,8 @@ + /** @param {Outer.Inner} inner */ + ~~~~~ +!!! error TS2702: 'Outer' only refers to a type, but is being used as a namespace here. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + function x(inner) { + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff index 5dfed1d5ae..517637524d 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(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(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (6 errors) ==== ++==== index.js (7 errors) ==== + First.Item = class I {} + ~~~~ +!!! error TS2339: Property 'Item' does not exist on type '{}'. @@ -29,6 +30,8 @@ + /** @type {Workspace.Object} */ + ~~~~~~~~~ +!!! error TS2503: Cannot find namespace 'Workspace'. ++ ~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var am; + +==== roots.js (0 errors) ==== diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff index 943eb88deb..ea5de82244 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff @@ -7,12 +7,15 @@ - -==== bug26885.js (1 errors) ==== +bug26885.js(2,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. ++bug26885.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. ++bug26885.js(8,18): error TS8010: Type annotations can only be used in TypeScript files. +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(15,12): error TS8010: Type annotations can only be used in TypeScript files. +bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. + + -+==== bug26885.js (4 errors) ==== ++==== bug26885.js (7 errors) ==== function Multimap3() { this._map = {}; + ~~~~ @@ -20,7 +23,13 @@ }; Multimap3.prototype = { -@@= skipped -13, +17 lines =@@ + /** + * @param {string} key ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number} the value ok ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ get(key) { return this._map[key + '']; @@ -35,6 +44,8 @@ /** @type {Multimap3} */ + ~~~~~~~~~ +!!! error TS2749: 'Multimap3' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap3'? ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. 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/typeFromPrototypeAssignment4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.errors.txt.diff new file mode 100644 index 0000000000..453587eb1f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.typeFromPrototypeAssignment4.errors.txt ++++ new.typeFromPrototypeAssignment4.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (2 errors) ==== ++ function Multimap4() { ++ this._map = {}; ++ }; ++ ++ Multimap4["prototype"] = { ++ /** ++ * @param {string} key ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @returns {number} the value ok ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ get(key) { ++ return this._map[key + '']; ++ } ++ }; ++ ++ Multimap4["prototype"]["add-on"] = function() {}; ++ Multimap4["prototype"]["addon"] = function() {}; ++ Multimap4["prototype"]["__underscores__"] = function() {}; ++ ++ const map4 = new Multimap4(); ++ map4.get(""); ++ map4["add-on"](); ++ map4.addon(); ++ map4.__underscores__(); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff index c7596d9208..01b7451585 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff @@ -2,10 +2,14 @@ +++ new.typeLookupInIIFE.errors.txt @@= skipped -0, +0 lines =@@ -a.js(3,15): error TS2694: Namespace 'ns' has no exported member 'NotFound'. +- +- +-==== a.js (1 errors) ==== +a.js(3,12): error TS2503: Cannot find namespace 'ns'. - - - ==== a.js (1 errors) ==== ++a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (2 errors) ==== // #22973 var ns = (function() {})(); /** @type {ns.NotFound} */ @@ -13,5 +17,7 @@ -!!! error TS2694: Namespace 'ns' has no exported member 'NotFound'. + ~~ +!!! error TS2503: Cannot find namespace 'ns'. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var crash; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff index 05fed40e02..8cab77cec8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff @@ -2,11 +2,12 @@ +++ new.typeSatisfaction_js.errors.txt @@= skipped -0, +0 lines =@@ -/src/a.js(1,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -- -- --==== /src/a.js (1 errors) ==== -- var v = undefined satisfies 1; ++/src/a.js(1,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + + ==== /src/a.js (1 errors) ==== + var v = undefined satisfies 1; - ~ --!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. -- -+ \ No newline at end of file ++ ~~ + !!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff new file mode 100644 index 0000000000..103ab0bae0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.typeTagNoErasure.errors.txt ++++ new.typeTagNoErasure.errors.txt +@@= skipped -0, +0 lines =@@ ++typeTagNoErasure.js(1,47): error TS8010: Type annotations can only be used in TypeScript files. ++typeTagNoErasure.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + typeTagNoErasure.js(7,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + + +-==== typeTagNoErasure.js (1 errors) ==== ++==== typeTagNoErasure.js (3 errors) ==== + /** @template T @typedef {(data: T1) => T1} Test */ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + /** @type {Test} */ ++ ~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const test = dibbity => dibbity + + test(1) // ok, T=1 \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.errors.txt.diff new file mode 100644 index 0000000000..b1990ffa7d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.typeTagOnFunctionReferencesGeneric.errors.txt ++++ new.typeTagOnFunctionReferencesGeneric.errors.txt +@@= skipped -0, +0 lines =@@ +- ++typeTagOnFunctionReferencesGeneric.js(2,21): error TS8010: Type annotations can only be used in TypeScript files. ++typeTagOnFunctionReferencesGeneric.js(11,11): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== typeTagOnFunctionReferencesGeneric.js (2 errors) ==== ++ /** ++ * @typedef {(m : T) => T} IFn ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ ++ /**@type {IFn}*/ ++ export function inJs(l) { ++ return l; ++ } ++ inJs(1); // lints error. Why? ++ ++ /**@type {IFn}*/ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const inJsArrow = (j) => { ++ return j; ++ } ++ inJsArrow(2); // no error gets linted as expected ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff index 09af25bcff..25e5f4f22d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff @@ -3,7 +3,10 @@ @@= skipped -0, +0 lines =@@ - +mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++use.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +use.js(1,29): error TS2694: Namespace 'C' has no exported member 'Both'. ++use.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ++use.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== commonjs.d.ts (0 errors) ==== @@ -40,14 +43,20 @@ + this.p = 1 + } + -+==== use.js (1 errors) ==== ++==== use.js (4 errors) ==== + /** @type {import('./mod1').Both} */ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ +!!! error TS2694: Namespace 'C' has no exported member 'Both'. + var both1 = { type: 'a', x: 1 }; + /** @type {import('./mod2').Both} */ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var both2 = both1; + /** @type {import('./mod3').Both} */ ++ ~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var both3 = both2; + + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff index 0a4e1b8385..638115260b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff @@ -16,19 +16,25 @@ +mod1.js(20,9): error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. +mod1.js(23,1): error TS2300: Duplicate identifier 'export='. +mod1.js(24,5): error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. ++use.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +use.js(2,32): error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. +use.js(4,12): error TS2503: Cannot find namespace 'mod'. ++use.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== use.js (2 errors) ==== ++==== use.js (4 errors) ==== var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. var b; /** @type {mod.Baz} */ + ~~~ +!!! error TS2503: Cannot find namespace 'mod'. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. var bb; var bbb = new mod.Baz(); @@ -71,7 +77,7 @@ // ok -@@= skipped -42, +56 lines =@@ +@@= skipped -42, +62 lines =@@ /** @typedef {number} Quid */ exports.Quid = 2; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff index 917202641a..9852bbf2b3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff @@ -3,17 +3,34 @@ @@= 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(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +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; }'. +- +- +-==== a.js (2 errors) ==== ++a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +test.ts(1,23): error TS2304: Cannot find name 'Everything'. - - - ==== a.js (2 errors) ==== -@@= skipped -18, +16 lines =@@ ++ ++ ++==== a.js (5 errors) ==== + /** + * @template {{ a: number, b: string }} T,U A Comment + * @template {{ c: boolean }} V uh ... are comments even supported?? +@@= skipped -14, +15 lines =@@ + */ + + /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var tuvwx; /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~~~~ -!!! 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; }'. @@ -21,7 +38,12 @@ !!! related TS2728 a.js:2:28: 'b' is declared here. var wrong; -@@= skipped -12, +11 lines =@@ + /** @type {Everything<{ a: number }>} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS2314: Generic type 'Everything' requires 5 type argument(s). ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var insufficient; ==== 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/typedefOnSemicolonClassElement.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnSemicolonClassElement.errors.txt.diff new file mode 100644 index 0000000000..dee130d325 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnSemicolonClassElement.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.typedefOnSemicolonClassElement.errors.txt ++++ new.typedefOnSemicolonClassElement.errors.txt +@@= skipped -0, +0 lines =@@ +- ++typedefOnSemicolonClassElement.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== typedefOnSemicolonClassElement.js (1 errors) ==== ++ export class Preferences { ++ /** @typedef {string} A */ ++ ; ++ /** @type {A} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ a = 'ok' ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.errors.txt.diff new file mode 100644 index 0000000000..47b5fcc390 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.errors.txt.diff @@ -0,0 +1,96 @@ +--- 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 (4 errors) ==== ++typedefOnStatements.js(53,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(54,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(56,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(57,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(59,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(60,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(61,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(63,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(65,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(66,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(67,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(68,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(69,12): error TS8010: Type annotations can only be used in TypeScript files. ++typedefOnStatements.js(73,16): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== typedefOnStatements.js (22 errors) ==== + /** @typedef {{a: string}} A */ + ; + /** @typedef {{ b: string }} B */ +@@= skipped -64, +82 lines =@@ + + /** + * @param {A} a ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {B} b ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {C} c ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {D} d ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {E} e ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {F} f ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {G} g ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {H} h ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {I} i ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {J} j ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {K} k ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {L} l ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {M} m ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {N} n ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {O} o ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {P} p ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {Q} q ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,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) + /** @type {Alpha} */ ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var alpha = { alpha: "aleph" } + /** @typedef {{ alpha: string }} Alpha */ + return \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.errors.txt.diff new file mode 100644 index 0000000000..0db0a47968 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.errors.txt.diff @@ -0,0 +1,36 @@ +--- old.typedefScope1.errors.txt ++++ new.typedefScope1.errors.txt +@@= skipped -0, +0 lines =@@ ++typedefScope1.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. ++typedefScope1.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. + typedefScope1.js(13,12): error TS2304: Cannot find name 'B'. +- +- +-==== typedefScope1.js (1 errors) ==== ++typedefScope1.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== typedefScope1.js (4 errors) ==== + function B1() { + /** @typedef {number} B */ + /** @type {B} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var ok1 = 0; + } + + function B2() { + /** @typedef {string} B */ + /** @type {B} */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var ok2 = 'hi'; + } + + /** @type {B} */ + ~ + !!! error TS2304: Cannot find name 'B'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var notOK = 0; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff index 53b9db8293..78974a81a4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff @@ -4,9 +4,10 @@ - +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(5,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== typedefTagExtraneousProperty.js (2 errors) ==== ++==== typedefTagExtraneousProperty.js (3 errors) ==== + /** @typedef {Object.} Mmap + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. @@ -16,6 +17,8 @@ + */ + + /** @type {Mmap} */ ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + var y = { bye: "no" }; + y + y.ignoreMe = "ok but just because of the index signature" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.errors.txt.diff new file mode 100644 index 0000000000..a06342012d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.errors.txt.diff @@ -0,0 +1,56 @@ +--- old.typedefTagNested.errors.txt ++++ new.typedefTagNested.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (3 errors) ==== ++ /** @typedef {Object} App ++ * @property {string} name ++ * @property {Object} icons ++ * @property {string} icons.image32 ++ * @property {string} icons.image64 ++ */ ++ var ex; ++ ++ /** @type {App} */ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const app = { ++ name: 'name', ++ icons: { ++ image32: 'x.png', ++ image64: 'y.png', ++ } ++ } ++ ++ /** @typedef {Object} Opp ++ * @property {string} name ++ * @property {Object} oops ++ * @property {string} horrible ++ * @type {string} idea ++ */ ++ var intercessor = 1 ++ ++ /** @type {Opp} */ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ var mistake; ++ ++ /** @typedef {Object} Upp ++ * @property {string} name ++ * @property {Object} not ++ * @property {string} nested ++ */ ++ ++ /** @type {Upp} */ ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ var sala = { name: 'uppsala', not: 0, nested: "ok" }; ++ sala.name ++ sala.not ++ sala.nested ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff new file mode 100644 index 0000000000..7d98bcccd9 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff @@ -0,0 +1,87 @@ +--- old.typedefTagTypeResolution.errors.txt ++++ new.typedefTagTypeResolution.errors.txt +@@= skipped -0, +0 lines =@@ ++github20832.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. + github20832.js(2,15): error TS2304: Cannot find name 'U'. ++github20832.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++github20832.js(6,13): error TS8010: Type annotations can only be used in TypeScript files. ++github20832.js(12,11): error TS8010: Type annotations can only be used in TypeScript files. ++github20832.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. + github20832.js(17,12): error TS2304: Cannot find name 'V'. +- +- +-==== github20832.js (2 errors) ==== ++github20832.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. ++github20832.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. ++github20832.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== github20832.js (10 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 ++ ~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T} ++ ~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function f(x) { ++ ~~~~~~~~~~~~~~~ + return x; ++ ~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** @type T - should be fine, since T will be any */ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const x = 3; ++ ++ + + /** ++ ~~~ + * @callback Cb ++ ~~~~~~~~~~~~~~~ + * @param {V} firstParam ++ ~~~~~~~~~~~~~~~~~~~~~~~~ + ~ + !!! error TS2304: Cannot find name 'V'. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + /** ++ ~~~ + * @template V ++ ~~~~~~~~~~~~~~ + * @param {V} vvvvv ++ ~~~~~~~~~~~~~~~~~~~ ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ ++ ~~~ + function g(vvvvv) { ++ ~~~~~~~~~~~~~~~~~~~ + } ++ ~ ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** @type {Cb} */ ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + const cb = x => {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff index eaa71cd329..2732fe6f60 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff @@ -8,13 +8,32 @@ -==== mod1.js (0 errors) ==== +mod1.js(2,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod1.js(9,12): error TS2304: Cannot find name 'Type1'. ++mod1.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod1.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod1.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. ++mod2.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod2.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. +mod3.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod3.js(10,12): error TS2304: Cannot find name 'StringOrNumber1'. ++mod3.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod3.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod3.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod3.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod3.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. +mod4.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. ++mod4.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod4.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod4.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod4.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod4.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. ++mod5.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod5.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. ++mod6.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. ++mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== mod1.js (2 errors) ==== ++==== mod1.js (5 errors) ==== /** * @typedef {function(string): boolean} + ~~~~~~~~ @@ -23,21 +42,46 @@ * Type1 */ -@@= skipped -11, +18 lines =@@ +@@= skipped -11, +37 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'. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} arg The argument to call it with. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean} The return. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function callIt(func, arg) { + return func(arg); + } + +-==== mod2.js (0 errors) ==== ++==== mod2.js (2 errors) ==== + /** + * @typedef {{ + * num: number, +@@= skipped -19, +27 lines =@@ + /** + * Makes use of a type with a multiline type expression. + * @param {Type2} obj The object. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string|number} The return. ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. */ -@@= skipped -25, +27 lines =@@ + function check(obj) { return obj.boo ? obj.num : obj.str; } -==== mod3.js (0 errors) ==== -+==== mod3.js (2 errors) ==== ++==== mod3.js (7 errors) ==== /** * A function whose signature is very long. * @@ -53,15 +97,27 @@ * @param {StringOrNumber1} func The function. + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'StringOrNumber1'. ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {boolean} bool The condition. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} str The string. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} num The number. -@@= skipped -20, +25 lines =@@ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string|number} The return. ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function use1(func, bool, str, num) { return func(bool, str, num) } -==== mod4.js (0 errors) ==== -+==== mod4.js (2 errors) ==== ++==== mod4.js (7 errors) ==== /** * A function whose signature is very long. * @@ -72,16 +128,67 @@ * number): * (string|number)} StringOrNumber2 */ -@@= skipped -12, +15 lines =@@ +@@= skipped -38, +60 lines =@@ /** * Makes use of a function type with a long signature. * @param {StringOrNumber2} func The function. + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'StringOrNumber2'. ++ ~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {boolean} bool The condition. ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} str The string. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} num The number. -@@= skipped -50, +52 lines =@@ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string|number} The return. ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function use2(func, bool, str, num) { + return func(bool, str, num) + } + +-==== mod5.js (0 errors) ==== ++==== mod5.js (2 errors) ==== + /** + * @typedef {{ + * num: +@@= skipped -24, +36 lines =@@ + /** + * Makes use of a type with a multiline type expression. + * @param {Type5} obj The object. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string|number} The return. ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function check5(obj) { + return obj.boo ? obj.num : obj.str; + } + +-==== mod6.js (0 errors) ==== ++==== mod6.js (2 errors) ==== + /** + * @typedef {{ + * foo: +@@= skipped -19, +23 lines =@@ + /** + * Makes use of a type with a multiline type expression. + * @param {Type6} obj The object. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {*} The return. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function check6(obj) { + return obj.foo; } 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..8b24e13068 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff @@ -0,0 +1,60 @@ +--- old.uniqueSymbolsDeclarationsInJs.errors.txt ++++ new.uniqueSymbolsDeclarationsInJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++uniqueSymbolsDeclarationsInJs.js(4,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++uniqueSymbolsDeclarationsInJs.js(8,15): error TS8010: Type annotations can only be used in TypeScript files. ++uniqueSymbolsDeclarationsInJs.js(9,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++uniqueSymbolsDeclarationsInJs.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. ++uniqueSymbolsDeclarationsInJs.js(14,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++uniqueSymbolsDeclarationsInJs.js(20,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++uniqueSymbolsDeclarationsInJs.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== uniqueSymbolsDeclarationsInJs.js (7 errors) ==== ++ // classes ++ class C { ++ /** ++ * @readonly ++ ~~~~~~~~~ ++ */ ++ ~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++ static readonlyStaticCall = Symbol(); ++ /** ++ * @type {unique symbol} ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @readonly ++ ~~~~~~~~~ ++ */ ++ ~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++ static readonlyStaticType; ++ /** ++ * @type {unique symbol} ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @readonly ++ ~~~~~~~~~ ++ */ ++ ~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++ static readonlyStaticTypeAndCall = Symbol(); ++ static readwriteStaticCall = Symbol(); ++ ++ /** ++ * @readonly ++ ~~~~~~~~~ ++ */ ++ ~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++ readonlyCall = Symbol(); ++ readwriteCall = Symbol(); ++ } ++ ++ /** @type {unique symbol} */ ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ const a = Symbol(); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff new file mode 100644 index 0000000000..503b991f2e --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.uniqueSymbolsDeclarationsInJsErrors.errors.txt ++++ new.uniqueSymbolsDeclarationsInJsErrors.errors.txt +@@= skipped -0, +0 lines =@@ ++uniqueSymbolsDeclarationsInJsErrors.js(3,15): error TS8010: Type annotations can only be used in TypeScript files. + 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(7,15): error TS8010: Type annotations can only be used in TypeScript files. ++uniqueSymbolsDeclarationsInJsErrors.js(8,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. ++uniqueSymbolsDeclarationsInJsErrors.js(12,15): error TS8010: Type annotations can only be used in TypeScript files. + 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) ==== ++==== uniqueSymbolsDeclarationsInJsErrors.js (6 errors) ==== + class C { + /** + * @type {unique symbol} ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + 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} ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + * @readonly ++ ~~~~~~~~~ + */ ++ ~~~~~ ++!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + static readonlyType; + /** + * @type {unique symbol} ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + static readwriteType; + ~~~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff new file mode 100644 index 0000000000..fbad269c96 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.varRequireFromJavascript.errors.txt ++++ new.varRequireFromJavascript.errors.txt +@@= skipped -0, +0 lines =@@ +- ++ex.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. ++use.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== use.js (1 errors) ==== ++ var ex = require('./ex') ++ ++ // values work ++ var crunch = new ex.Crunch(1); ++ crunch.n ++ ++ ++ // types work ++ /** ++ * @param {ex.Crunch} wrap ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(wrap) { ++ wrap.n ++ } ++ ++==== ex.js (1 errors) ==== ++ export class Crunch { ++ /** @param {number} n */ ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor(n) { ++ this.n = n ++ } ++ m() { ++ return this.n ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff new file mode 100644 index 0000000000..ce435ef2b5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.varRequireFromTypescript.errors.txt ++++ new.varRequireFromTypescript.errors.txt +@@= skipped -0, +0 lines =@@ +- ++use.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ++use.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== use.js (2 errors) ==== ++ var ex = require('./ex') ++ ++ // values work ++ var crunch = new ex.Crunch(1); ++ crunch.n ++ ++ ++ // types work ++ /** ++ * @param {ex.Greatest} greatest ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ * @param {ex.Crunch} wrap ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ */ ++ function f(greatest, wrap) { ++ greatest.day ++ wrap.n ++ } ++ ++==== ex.d.ts (0 errors) ==== ++ export type Greatest = { day: 1 } ++ export class Crunch { ++ n: number ++ m(): number ++ constructor(n: number) ++ } ++ \ No newline at end of file diff --git a/testdata/tests/cases/compiler/jsSyntacticDiagnostics.ts b/testdata/tests/cases/compiler/jsSyntacticDiagnostics.ts new file mode 100644 index 0000000000..0c087ddc15 --- /dev/null +++ b/testdata/tests/cases/compiler/jsSyntacticDiagnostics.ts @@ -0,0 +1,102 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @filename: test.js + +// Type annotations should be flagged as errors +function func(x: number): string { + return x.toString(); +} + +// Interface declarations should be flagged as errors +interface Person { + name: string; + age: number; +} + +// Type alias declarations should be flagged as errors +type StringOrNumber = string | number; + +// Enum declarations should be flagged as errors +enum Color { + Red, + Green, + Blue +} + +// Module declarations should be flagged as errors +module MyModule { + export var x = 1; +} + +// Namespace declarations should be flagged as errors +namespace MyNamespace { + export var y = 2; +} + +// Non-null assertions should be flagged as errors +let value = getValue()!; + +// Type assertions should be flagged as errors +let result = (value as string).toUpperCase(); + +// Satisfies expressions should be flagged as errors +let config = {} satisfies Config; + +// Import type should be flagged as errors +import type { SomeType } from './other'; + +// Export type should be flagged as errors +export type { SomeType }; + +// Import equals should be flagged as errors +import lib = require('./lib'); + +// Export equals should be flagged as errors +export = MyModule; + +// TypeScript modifiers should be flagged as errors +class MyClass { + public name: string; + private age: number; + protected id: number; + readonly value: number; + + constructor(public x: number, private y: number) { + this.name = ''; + this.age = 0; + this.id = 0; + this.value = 0; + } +} + +// Optional parameters should be flagged as errors +function optionalParam(x?: number) { + return x || 0; +} + +// Signature declarations should be flagged as errors +function signatureOnly(x: number): string; + +// Type parameters should be flagged as errors +function generic(x: T): T { + return x; +} + +// Type arguments should be flagged as errors +let array = Array(); + +// Implements clause should be flagged as errors +class MyClassWithImplements implements Person { + name = ''; + age = 0; +} + +function getValue(): any { + return null; +} + +interface Config { + name: string; +} \ No newline at end of file From 466a9f8ec4c524dfbbadde830622a479a2092607 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 01:49:49 +0000 Subject: [PATCH 04/31] Add NodeFlagsReparsed check to bail out early for synthesized type annotations Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/program.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index f8c253ac8d..9a2164f07e 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -392,6 +392,11 @@ func (p *Program) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node, dia return } + // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations + if node.Flags&ast.NodeFlagsReparsed != 0 { + return + } + // Handle specific parent-child relationships first switch parent.Kind { case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: From 3e0d26f603d2e9c2995044edde1a43304ca060ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 02:05:20 +0000 Subject: [PATCH 05/31] Update baselines after implementing NodeFlagsReparsed check Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- ...structuringParameterDeclaration.errors.txt | 11 -- .../conformance/jsdocParseAwait.errors.txt | 11 +- ...ForMultipleVariableDeclarations.errors.txt | 12 -- .../amdLikeInputDeclarationEmit.errors.txt | 5 +- ...argumentsObjectCreatesRestForJs.errors.txt | 5 +- ...mentsReferenceInConstructor1_Js.errors.txt | 20 --- ...mentsReferenceInConstructor2_Js.errors.txt | 20 --- ...mentsReferenceInConstructor3_Js.errors.txt | 33 ---- ...mentsReferenceInConstructor4_Js.errors.txt | 8 +- ...mentsReferenceInConstructor5_Js.errors.txt | 29 ---- .../argumentsReferenceInMethod1_Js.errors.txt | 18 -- .../argumentsReferenceInMethod2_Js.errors.txt | 18 -- .../argumentsReferenceInMethod3_Js.errors.txt | 29 ---- .../argumentsReferenceInMethod4_Js.errors.txt | 8 +- .../argumentsReferenceInMethod5_Js.errors.txt | 27 --- .../arrowExpressionBodyJSDoc.errors.txt | 20 +-- .../compiler/arrowExpressionJs.errors.txt | 13 +- .../arrowFunctionJSDocAnnotation.errors.txt | 27 --- ...kJsObjectLiteralHasCheckedKeyof.errors.txt | 5 +- ...eckJsTypeDefNoUnusedLocalMarked.errors.txt | 10 +- .../compiler/constructorPropertyJs.errors.txt | 15 -- ...yTypedParametersOptionalInJSDoc.errors.txt | 26 +-- ...nferenceFromAnnotatedFunctionJs.errors.txt | 20 +-- ...ithAnnotatedOptionalParameterJs.errors.txt | 30 +--- .../compiler/controlFlowInstanceof.errors.txt | 5 +- ...peNode4(strictnullchecks=false).errors.txt | 58 +------ ...ypeNode4(strictnullchecks=true).errors.txt | 58 +------ ...eclarationEmitClassAccessorsJs1.errors.txt | 26 --- ...itClassSetAccessorParamNameInJs.errors.txt | 17 -- ...tClassSetAccessorParamNameInJs2.errors.txt | 15 -- ...tClassSetAccessorParamNameInJs3.errors.txt | 15 -- ...ationEmitLateBoundJSAssignments.errors.txt | 35 ---- ...onEmitObjectLiteralAccessorsJs1.errors.txt | 71 -------- ...xpandoFunctionContextualTypesJs.errors.txt | 11 +- ...expandoFunctionSymbolPropertyJs.errors.txt | 24 --- .../exportDefaultWithJSDoc2.errors.txt | 16 -- ...dedUnicodePlaneIdentifiersJSDoc.errors.txt | 17 -- .../importTypeResolutionJSDocEOF.errors.txt | 15 -- ...larationEmitDoesNotRenameImport.errors.txt | 35 ---- .../jsDeclarationsInheritedTypes.errors.txt | 43 ----- ...tUseNodeModulesPathWithoutError.errors.txt | 51 ------ .../compiler/jsEnumCrossFileExport.errors.txt | 11 +- .../jsEnumTagOnObjectFrozen.errors.txt | 13 +- ...berMergedWithModuleAugmentation.errors.txt | 5 +- ...FileAlternativeUseOfOverloadTag.errors.txt | 67 -------- .../jsFileAlternativeUseOfOverloadTag.js | 13 ++ .../jsFileAlternativeUseOfOverloadTag.js.diff | 15 +- .../jsFileCompilationSyntaxError.errors.txt | 12 -- .../jsFileFunctionOverloads.errors.txt | 44 +---- .../jsFileFunctionOverloads2.errors.txt | 44 +---- .../jsFileImportPreservedWhenUsed.errors.txt | 35 ---- .../compiler/jsFileMethodOverloads.errors.txt | 30 +--- .../jsFileMethodOverloads2.errors.txt | 30 +--- .../jsFileMethodOverloads3.errors.txt | 14 +- .../jsFileMethodOverloads5.errors.txt | 37 ---- .../compiler/jsdocAccessEnumType.errors.txt | 13 -- ...ocArrayObjectPromiseImplicitAny.errors.txt | 38 +---- ...ArrayObjectPromiseNoImplicitAny.errors.txt | 38 +---- .../jsdocBracelessTypeTag1.errors.txt | 8 +- .../compiler/jsdocCallbackAndType.errors.txt | 5 +- .../jsdocClassMissingTypeArguments.errors.txt | 5 +- ...ctionClassPropertiesDeclaration.errors.txt | 8 +- .../jsdocFunctionTypeFalsePositive.errors.txt | 5 +- .../compiler/jsdocIllegalTags.errors.txt | 5 +- .../jsdocImportTypeNodeNamespace.errors.txt | 5 +- .../jsdocImportTypeResolution.errors.txt | 16 -- ...ocParamTagOnPropertyInitializer.errors.txt | 11 -- ...docParameterParsingInfiniteLoop.errors.txt | 5 +- .../jsdocPropertyTagInvalid.errors.txt | 5 +- ...ocReferenceGlobalTypeInCommonJs.errors.txt | 5 +- ...sdocResolveNameFailureInTypedef.errors.txt | 5 +- .../compiler/jsdocRestParameter.errors.txt | 5 +- .../jsdocRestParameter_es6.errors.txt | 11 -- .../compiler/jsdocTypeCast.errors.txt | 17 +- ...TypeGenericInstantiationAttempt.errors.txt | 13 -- ...eNongenericInstantiationAttempt.errors.txt | 40 +---- ...efBeforeParenthesizedExpression.errors.txt | 26 --- .../jsdocTypedefMissingType.errors.txt | 20 --- ...jsdocTypedef_propertyWithNoType.errors.txt | 14 -- ...sizedJSDocCastAtReturnStatement.errors.txt | 28 --- ...nthesizedJSDocCastDoesNotNarrow.errors.txt | 5 +- .../requireOfJsonFileInJsFile.errors.txt | 8 +- ...nConditionalExpressionJSDocCast.errors.txt | 30 ---- .../strictOptionalProperties3.errors.txt | 8 +- .../strictOptionalProperties4.errors.txt | 20 --- .../subclassThisTypeAssignable01.errors.txt | 5 +- .../subclassThisTypeAssignable02.errors.txt | 38 ----- .../compiler/thisInFunctionCallJs.errors.txt | 8 +- .../compiler/topLevelBlockExpando.errors.txt | 47 ----- .../compiler/unicodeEscapesInJSDoc.errors.txt | 31 ---- .../compiler/uniqueSymbolJs.errors.txt | 8 +- ...PropertyInitializerDoesntNarrow.errors.txt | 23 --- .../assertionTypePredicates2.errors.txt | 14 +- ...ertionsAndNonReturningFunctions.errors.txt | 23 +-- .../asyncArrowFunction_allowJs.errors.txt | 17 +- .../asyncFunctionDeclaration16_es5.errors.txt | 32 +--- .../callbackCrossModule.errors.txt | 10 +- .../callbackOnConstructor.errors.txt | 8 +- .../conformance/callbackTag1.errors.txt | 33 ---- .../conformance/callbackTag2.errors.txt | 26 +-- .../conformance/callbackTag3.errors.txt | 13 -- .../conformance/callbackTag4.errors.txt | 29 ---- .../callbackTagNamespace.errors.txt | 21 --- .../callbackTagNestedParameter.errors.txt | 31 ---- .../callbackTagVariadicType.errors.txt | 8 +- .../chainedPrototypeAssignment.errors.txt | 5 +- ...heckExportsObjectAssignProperty.errors.txt | 18 +- ...tsObjectAssignPrototypeProperty.errors.txt | 8 +- .../checkJsdocOptionalParamOrder.errors.txt | 15 +- ...iableDeclaredFunctionExpression.errors.txt | 36 ---- .../checkJsdocParamTag1.errors.txt | 26 --- .../checkJsdocReturnTag1.errors.txt | 11 +- .../checkJsdocReturnTag2.errors.txt | 8 +- .../checkJsdocSatisfiesTag1.errors.txt | 35 +--- .../checkJsdocSatisfiesTag10.errors.txt | 5 +- .../checkJsdocSatisfiesTag11.errors.txt | 27 --- .../checkJsdocSatisfiesTag14.errors.txt | 17 -- .../checkJsdocSatisfiesTag2.errors.txt | 8 +- .../checkJsdocSatisfiesTag3.errors.txt | 11 +- .../checkJsdocSatisfiesTag4.errors.txt | 12 +- .../checkJsdocSatisfiesTag5.errors.txt | 19 --- .../checkJsdocSatisfiesTag6.errors.txt | 5 +- .../checkJsdocSatisfiesTag7.errors.txt | 5 +- .../checkJsdocSatisfiesTag8.errors.txt | 5 +- .../checkJsdocSatisfiesTag9.errors.txt | 5 +- .../conformance/checkJsdocTypeTag1.errors.txt | 32 +--- .../conformance/checkJsdocTypeTag2.errors.txt | 23 +-- .../conformance/checkJsdocTypeTag3.errors.txt | 9 - .../conformance/checkJsdocTypeTag4.errors.txt | 8 +- .../conformance/checkJsdocTypeTag5.errors.txt | 29 +--- .../conformance/checkJsdocTypeTag6.errors.txt | 11 +- .../conformance/checkJsdocTypeTag7.errors.txt | 21 --- .../conformance/checkJsdocTypeTag8.errors.txt | 5 +- ...ckJsdocTypeTagOnObjectProperty2.errors.txt | 8 +- .../checkJsdocTypedefInParamTag1.errors.txt | 55 ------ ...checkJsdocTypedefOnlySourceFile.errors.txt | 5 +- .../checkObjectDefineProperty.errors.txt | 23 +-- .../checkOtherObjectAssignProperty.errors.txt | 8 +- ...checkSpecialPropertyAssignments.errors.txt | 8 +- ...assCanExtendConstructorFunction.errors.txt | 16 +- .../commonJSAliasedExport.errors.txt | 5 +- ...ommonJSImportClassTypeReference.errors.txt | 5 +- ...JSImportExportedClassExpression.errors.txt | 5 +- ...SImportNestedClassTypeReference.errors.txt | 5 +- ...torFunctionMethodTypeParameters.errors.txt | 14 +- .../constructorFunctions.errors.txt | 5 +- .../constructorFunctionsStrict.errors.txt | 8 +- .../constructorTagWithThisTag.errors.txt | 15 -- .../contextualTypeFromJSDoc.errors.txt | 36 ---- ...ontextualTypedSpecialAssignment.errors.txt | 10 +- ...meterDeclaration9(strict=false).errors.txt | 60 ------- ...ameterDeclaration9(strict=true).errors.txt | 16 +- .../submodule/conformance/enumTag.errors.txt | 26 +-- .../conformance/enumTagImported.errors.txt | 13 +- .../enumTagUseBeforeDefCrash.errors.txt | 5 +- .../errorOnFunctionReturnType.errors.txt | 8 +- ...classDeclaration-exportModifier.errors.txt | 37 ---- .../exportNestedNamespaces.errors.txt | 8 +- .../exportedEnumTypeAndValue.errors.txt | 5 +- .../conformance/extendsTag5.errors.txt | 5 +- .../genericSetterInClassTypeJsDoc.errors.txt | 5 +- .../conformance/importTag1.errors.txt | 23 --- .../conformance/importTag11.errors.txt | 10 -- .../conformance/importTag12.errors.txt | 10 -- .../conformance/importTag13.errors.txt | 5 +- .../conformance/importTag14.errors.txt | 5 +- .../importTag15(module=es2015).errors.txt | 11 +- .../importTag15(module=esnext).errors.txt | 11 +- .../conformance/importTag16.errors.txt | 24 --- .../submodule/conformance/importTag16.js | 25 +++ .../submodule/conformance/importTag16.js.diff | 27 ++- .../conformance/importTag17.errors.txt | 14 +- .../conformance/importTag18.errors.txt | 25 --- .../conformance/importTag19.errors.txt | 23 --- .../conformance/importTag2.errors.txt | 23 --- .../conformance/importTag20.errors.txt | 25 --- .../conformance/importTag21.errors.txt | 37 ---- .../conformance/importTag23.errors.txt | 8 +- .../conformance/importTag3.errors.txt | 23 --- .../conformance/importTag4.errors.txt | 11 +- .../conformance/importTag5.errors.txt | 23 --- .../conformance/importTag6.errors.txt | 36 ---- .../conformance/importTag7.errors.txt | 34 ---- .../conformance/importTag8.errors.txt | 34 ---- .../conformance/importTag9.errors.txt | 34 ---- .../conformance/importTypeInJSDoc.errors.txt | 36 ---- .../conformance/inferThis.errors.txt | 14 +- ...ypeParameterOnVariableStatement.errors.txt | 11 +- .../jsDeclarationsClassAccessor.errors.txt | 44 ----- ...ImplementsGenericsSerialization.errors.txt | 8 +- .../jsDeclarationsClassMethod.errors.txt | 11 +- .../jsDeclarationsClasses.errors.txt | 80 +-------- .../jsDeclarationsComputedNames.errors.txt | 32 ---- .../jsDeclarationsDefault.errors.txt | 46 ----- .../conformance/jsDeclarationsDefault.js | 76 +++++++++ .../conformance/jsDeclarationsDefault.js.diff | 78 ++++++++- .../jsDeclarationsEnumTag.errors.txt | 26 +-- ...nsExportAssignedClassExpression.errors.txt | 14 -- ...clarationsExportAssignedClassExpression.js | 16 ++ ...tionsExportAssignedClassExpression.js.diff | 18 +- ...ssignedClassExpressionAnonymous.errors.txt | 14 -- ...sExportAssignedClassExpressionAnonymous.js | 16 ++ ...rtAssignedClassExpressionAnonymous.js.diff | 18 +- ...ClassExpressionAnonymousWithSub.errors.txt | 5 +- ...rationsExportDefinePropertyEmit.errors.txt | 41 +---- ...ctionClassesCjsExportAssignment.errors.txt | 27 +-- .../jsDeclarationsFunctionJSDoc.errors.txt | 53 ------ ...DeclarationsFunctionLikeClasses.errors.txt | 13 +- ...eclarationsFunctionLikeClasses2.errors.txt | 20 +-- ...arationsFunctionPrototypeStatic.errors.txt | 5 +- .../jsDeclarationsFunctions.errors.txt | 41 +---- .../jsDeclarationsFunctionsCjs.errors.txt | 20 +-- .../jsDeclarationsGetterSetter.errors.txt | 157 ----------------- ...portAliasExposedWithinNamespace.errors.txt | 16 +- ...tAliasExposedWithinNamespaceCjs.errors.txt | 16 +- ...eclarationsImportNamespacedType.errors.txt | 5 +- ...larationsJSDocRedirectedLookups.errors.txt | 55 +----- .../jsDeclarationsMissingGenerics.errors.txt | 17 -- .../jsDeclarationsMissingGenerics.js | 23 +++ .../jsDeclarationsMissingGenerics.js.diff | 25 ++- ...clarationsMissingTypeParameters.errors.txt | 15 +- ...larationsModuleReferenceHasEmit.errors.txt | 5 +- .../jsDeclarationsNestedParams.errors.txt | 20 +-- ...ationsOptionalTypeLiteralProps1.errors.txt | 20 --- ...ationsOptionalTypeLiteralProps2.errors.txt | 5 +- ...ameterTagReusesInputNodeInEmit1.errors.txt | 11 +- ...ameterTagReusesInputNodeInEmit2.errors.txt | 8 +- .../jsDeclarationsPrivateFields01.errors.txt | 27 --- .../jsDeclarationsReactComponents.errors.txt | 102 ----------- .../jsDeclarationsReactComponents.js | 74 ++++++++ .../jsDeclarationsReactComponents.js.diff | 76 ++++++++- ...sDeclarationsReexportedCjsAlias.errors.txt | 30 ---- ...ferenceToClassInstanceCrossFile.errors.txt | 5 +- ...sExistingNodesMappingJSDocTypes.errors.txt | 26 +-- ...nsReusesExistingTypeAnnotations.errors.txt | 44 +---- ...thExplicitNoArgumentConstructor.errors.txt | 22 --- .../jsDeclarationsThisTypes.errors.txt | 16 -- .../jsDeclarationsTypeAliases.errors.txt | 16 +- ...TypeReassignmentFromDeclaration.errors.txt | 15 -- ...arationsTypeReassignmentFromDeclaration.js | 19 +++ ...onsTypeReassignmentFromDeclaration.js.diff | 21 ++- ...clarationsTypedefAndImportTypes.errors.txt | 5 +- ...DeclarationsTypedefAndLatebound.errors.txt | 10 +- .../jsDeclarationsTypedefFunction.errors.txt | 27 --- ...edefPropertyAndExportAssignment.errors.txt | 16 +- ...jsDeclarationsUniqueSymbolUsage.errors.txt | 23 --- .../jsdocBindingInUnreachableCode.errors.txt | 14 -- ...ocCatchClauseWithTypeAnnotation.errors.txt | 65 +------ ...onstructorFunctionTypeReference.errors.txt | 5 +- .../conformance/jsdocFunctionType.errors.txt | 23 +-- .../conformance/jsdocImplementsTag.errors.txt | 17 -- .../jsdocImplements_class.errors.txt | 17 +- .../jsdocImplements_interface.errors.txt | 11 +- ...ocImplements_interface_multiple.errors.txt | 8 +- .../jsdocImplements_missingType.errors.txt | 11 -- .../jsdocImplements_missingType.js | 18 ++ .../jsdocImplements_missingType.js.diff | 20 ++- ...cImplements_namespacedInterface.errors.txt | 31 ---- .../jsdocImplements_properties.errors.txt | 11 +- .../jsdocImplements_signatures.errors.txt | 5 +- .../conformance/jsdocImportType.errors.txt | 33 ---- .../conformance/jsdocImportType2.errors.txt | 32 ---- ...ImportTypeReferenceToClassAlias.errors.txt | 5 +- ...rtTypeReferenceToCommonjsModule.errors.txt | 5 +- ...ocImportTypeReferenceToESModule.errors.txt | 5 +- ...ortTypeReferenceToStringLiteral.errors.txt | 5 +- .../jsdocIndexSignature.errors.txt | 14 +- .../conformance/jsdocLiteral.errors.txt | 29 ---- .../jsdocNeverUndefinedNull.errors.txt | 24 --- .../jsdocOuterTypeParameters1.errors.txt | 5 +- .../jsdocOuterTypeParameters2.errors.txt | 5 +- .../conformance/jsdocOverrideTag1.errors.txt | 14 +- .../conformance/jsdocParamTag2.errors.txt | 69 +------- .../jsdocParamTagTypeLiteral.errors.txt | 37 +--- .../jsdocParseBackquotedParamName.errors.txt | 12 +- ...ocParseDotDotDotInJSDocFunction.errors.txt | 5 +- .../jsdocParseHigherOrderFunction.errors.txt | 5 +- .../jsdocParseMatchingBackticks.errors.txt | 36 ---- ...arseParenthesizedJSDocParameter.errors.txt | 5 +- .../jsdocParseStarEquals.errors.txt | 15 +- ...docPostfixEqualsAddsOptionality.errors.txt | 14 +- .../jsdocPrefixPostfixParsing.errors.txt | 38 +---- .../conformance/jsdocPrivateName1.errors.txt | 5 +- .../conformance/jsdocReadonly.errors.txt | 5 +- .../conformance/jsdocReturnTag1.errors.txt | 33 ---- ...sdocSignatureOnReturnedFunction.errors.txt | 63 ------- .../conformance/jsdocTemplateClass.errors.txt | 23 +-- ...sdocTemplateConstructorFunction.errors.txt | 8 +- ...docTemplateConstructorFunction2.errors.txt | 11 +- .../conformance/jsdocTemplateTag.errors.txt | 11 +- .../conformance/jsdocTemplateTag2.errors.txt | 8 +- .../conformance/jsdocTemplateTag3.errors.txt | 23 +-- .../conformance/jsdocTemplateTag5.errors.txt | 20 +-- .../conformance/jsdocTemplateTag6.errors.txt | 44 +---- .../conformance/jsdocTemplateTag7.errors.txt | 8 +- .../conformance/jsdocTemplateTag8.errors.txt | 29 +--- .../jsdocTemplateTagDefault.errors.txt | 32 +--- .../jsdocTemplateTagNameResolution.errors.txt | 5 +- .../conformance/jsdocThisType.errors.txt | 11 +- .../jsdocTypeDefAtStartOfFile.errors.txt | 13 +- .../jsdocTypeReferenceExports.errors.txt | 5 +- .../jsdocTypeReferenceToImport.errors.txt | 8 +- ...erenceToImportOfClassExpression.errors.txt | 5 +- ...nceToImportOfFunctionExpression.errors.txt | 10 +- ...jsdocTypeReferenceToMergedClass.errors.txt | 5 +- .../jsdocTypeReferenceToValue.errors.txt | 5 +- .../jsdocTypeReferenceUseBeforeDef.errors.txt | 11 -- .../conformance/jsdocTypeTag.errors.txt | 74 +------- .../conformance/jsdocTypeTagCast.errors.txt | 65 +------ .../jsdocTypeTagParameterType.errors.txt | 5 +- .../jsdocTypeTagRequiredParameters.errors.txt | 5 +- ...leDeclarationWithTypeAnnotation.errors.txt | 13 -- .../conformance/jsdocVariadicType.errors.txt | 5 +- .../conformance/linkTagEmit1.errors.txt | 31 ---- .../conformance/malformedTags.errors.txt | 13 -- .../moduleExportAssignment.errors.txt | 5 +- .../moduleExportAssignment6.errors.txt | 33 ---- .../moduleExportAssignment7.errors.txt | 44 +---- .../moduleExportNestedNamespaces.errors.txt | 8 +- ...ExportsElementAccessAssignment2.errors.txt | 29 ---- .../optionalBindingParameters3.errors.txt | 8 +- .../optionalBindingParameters4.errors.txt | 13 -- .../conformance/overloadTag1.errors.txt | 23 +-- .../conformance/overloadTag2.errors.txt | 14 +- .../conformance/overloadTag3.errors.txt | 11 +- ...TagBracketsAddOptionalUndefined.errors.txt | 39 ----- ...TagNestedWithoutTopLevelObject3.errors.txt | 5 +- .../paramTagTypeResolution2.errors.txt | 8 +- .../conformance/paramTagWrapping.errors.txt | 11 +- ...esOfGenericConstructorFunctions.errors.txt | 41 +---- ...ropertyAssignmentUseParentType2.errors.txt | 11 +- ...ertyAssignmentMergeAcrossFiles2.errors.txt | 8 +- ...tyAssignmentMergedTypeReference.errors.txt | 5 +- .../recursiveTypeReferences2.errors.txt | 8 +- .../conformance/returnTagTypeGuard.errors.txt | 94 ---------- .../conformance/syntaxErrors.errors.txt | 18 -- .../templateInsideCallback.errors.txt | 26 +-- ...thisPropertyAssignmentInherited.errors.txt | 25 --- .../submodule/conformance/thisTag1.errors.txt | 26 --- .../submodule/conformance/thisTag2.errors.txt | 15 -- .../submodule/conformance/thisTag2.js | 16 ++ .../submodule/conformance/thisTag2.js.diff | 18 +- .../submodule/conformance/thisTag3.errors.txt | 11 +- .../thisTypeOfConstructorFunctions.errors.txt | 20 +-- .../typeFromContextualThisType.errors.txt | 8 +- .../typeFromJSInitializer.errors.txt | 8 +- .../typeFromJSInitializer4.errors.txt | 5 +- .../typeFromParamTagForFunction.errors.txt | 40 +---- ...FromPrivatePropertyAssignmentJs.errors.txt | 22 --- .../typeFromPropertyAssignment.errors.txt | 8 +- .../typeFromPropertyAssignment10.errors.txt | 5 +- .../typeFromPropertyAssignment10_1.errors.txt | 5 +- .../typeFromPropertyAssignment14.errors.txt | 5 +- .../typeFromPropertyAssignment15.errors.txt | 5 +- .../typeFromPropertyAssignment16.errors.txt | 5 +- .../typeFromPropertyAssignment2.errors.txt | 8 +- .../typeFromPropertyAssignment24.errors.txt | 5 +- .../typeFromPropertyAssignment3.errors.txt | 8 +- .../typeFromPropertyAssignment35.errors.txt | 5 +- .../typeFromPropertyAssignment4.errors.txt | 10 +- .../typeFromPropertyAssignment40.errors.txt | 5 +- .../typeFromPropertyAssignment5.errors.txt | 5 +- .../typeFromPropertyAssignment6.errors.txt | 5 +- ...romPropertyAssignmentOutOfOrder.errors.txt | 5 +- .../typeFromPrototypeAssignment3.errors.txt | 11 +- .../typeFromPrototypeAssignment4.errors.txt | 33 ---- .../conformance/typeLookupInIIFE.errors.txt | 5 +- .../conformance/typeTagNoErasure.errors.txt | 8 +- ...eTagOnFunctionReferencesGeneric.errors.txt | 25 --- .../conformance/typedefCrossModule.errors.txt | 11 +- .../typedefCrossModule2.errors.txt | 8 +- .../typedefMultipleTypeParameters.errors.txt | 11 +- .../typedefOnSemicolonClassElement.errors.txt | 13 -- .../typedefOnSemicolonClassElement.js | 23 +++ .../typedefOnSemicolonClassElement.js.diff | 25 ++- .../typedefOnStatements.errors.txt | 56 +----- .../conformance/typedefScope1.errors.txt | 11 +- .../typedefTagExtraneousProperty.errors.txt | 5 +- .../conformance/typedefTagNested.errors.txt | 52 ------ .../typedefTagTypeResolution.errors.txt | 20 +-- .../conformance/typedefTagWrapping.errors.txt | 69 +------- .../uniqueSymbolsDeclarationsInJs.errors.txt | 11 +- ...ueSymbolsDeclarationsInJsErrors.errors.txt | 11 +- .../varRequireFromJavascript.errors.txt | 35 ---- .../varRequireFromTypescript.errors.txt | 34 ---- ...mdLikeInputDeclarationEmit.errors.txt.diff | 5 +- ...entsObjectCreatesRestForJs.errors.txt.diff | 5 +- ...ReferenceInConstructor1_Js.errors.txt.diff | 24 --- ...ReferenceInConstructor2_Js.errors.txt.diff | 24 --- ...ReferenceInConstructor3_Js.errors.txt.diff | 37 ---- ...ReferenceInConstructor4_Js.errors.txt.diff | 29 ---- ...ReferenceInConstructor5_Js.errors.txt.diff | 33 ---- ...mentsReferenceInMethod1_Js.errors.txt.diff | 22 --- ...mentsReferenceInMethod2_Js.errors.txt.diff | 22 --- ...mentsReferenceInMethod3_Js.errors.txt.diff | 33 ---- ...mentsReferenceInMethod4_Js.errors.txt.diff | 27 --- ...mentsReferenceInMethod5_Js.errors.txt.diff | 31 ---- .../arrowExpressionBodyJSDoc.errors.txt.diff | 24 +-- .../arrowExpressionJs.errors.txt.diff | 13 +- ...rowFunctionJSDocAnnotation.errors.txt.diff | 31 ---- ...jectLiteralHasCheckedKeyof.errors.txt.diff | 21 --- ...TypeDefNoUnusedLocalMarked.errors.txt.diff | 10 +- .../constructorPropertyJs.errors.txt.diff | 19 --- ...dParametersOptionalInJSDoc.errors.txt.diff | 62 ------- ...nceFromAnnotatedFunctionJs.errors.txt.diff | 20 +-- ...notatedOptionalParameterJs.errors.txt.diff | 30 +--- .../controlFlowInstanceof.errors.txt.diff | 5 +- ...e4(strictnullchecks=false).errors.txt.diff | 58 +------ ...de4(strictnullchecks=true).errors.txt.diff | 58 +------ ...ationEmitClassAccessorsJs1.errors.txt.diff | 30 ---- ...ssSetAccessorParamNameInJs.errors.txt.diff | 21 --- ...sSetAccessorParamNameInJs2.errors.txt.diff | 19 --- ...sSetAccessorParamNameInJs3.errors.txt.diff | 19 --- ...EmitLateBoundJSAssignments.errors.txt.diff | 39 ----- ...tObjectLiteralAccessorsJs1.errors.txt.diff | 75 -------- ...oFunctionContextualTypesJs.errors.txt.diff | 11 +- ...doFunctionSymbolPropertyJs.errors.txt.diff | 28 --- .../exportDefaultWithJSDoc2.errors.txt.diff | 20 --- ...icodePlaneIdentifiersJSDoc.errors.txt.diff | 21 --- ...portTypeResolutionJSDocEOF.errors.txt.diff | 19 --- ...ionEmitDoesNotRenameImport.errors.txt.diff | 39 ----- ...DeclarationsInheritedTypes.errors.txt.diff | 47 ----- ...odeModulesPathWithoutError.errors.txt.diff | 55 ------ .../jsEnumCrossFileExport.errors.txt.diff | 11 +- .../jsEnumTagOnObjectFrozen.errors.txt.diff | 13 +- ...rgedWithModuleAugmentation.errors.txt.diff | 19 +-- ...lternativeUseOfOverloadTag.errors.txt.diff | 71 -------- ...FileCompilationSyntaxError.errors.txt.diff | 18 +- .../jsFileFunctionOverloads.errors.txt.diff | 44 +---- .../jsFileFunctionOverloads2.errors.txt.diff | 44 +---- ...ileImportPreservedWhenUsed.errors.txt.diff | 39 ----- .../jsFileMethodOverloads.errors.txt.diff | 30 +--- .../jsFileMethodOverloads2.errors.txt.diff | 30 +--- .../jsFileMethodOverloads3.errors.txt.diff | 43 ----- .../jsFileMethodOverloads5.errors.txt.diff | 41 ----- .../jsdocAccessEnumType.errors.txt.diff | 17 -- ...ayObjectPromiseImplicitAny.errors.txt.diff | 38 +---- ...ObjectPromiseNoImplicitAny.errors.txt.diff | 91 +--------- .../jsdocBracelessTypeTag1.errors.txt.diff | 20 +-- .../jsdocCallbackAndType.errors.txt.diff | 19 --- ...cClassMissingTypeArguments.errors.txt.diff | 16 +- ...ClassPropertiesDeclaration.errors.txt.diff | 8 +- ...cFunctionTypeFalsePositive.errors.txt.diff | 12 +- .../compiler/jsdocIllegalTags.errors.txt.diff | 18 +- ...docImportTypeNodeNamespace.errors.txt.diff | 12 +- .../jsdocImportTypeResolution.errors.txt.diff | 20 --- ...amTagOnPropertyInitializer.errors.txt.diff | 15 -- ...rameterParsingInfiniteLoop.errors.txt.diff | 5 +- .../jsdocPropertyTagInvalid.errors.txt.diff | 23 --- ...erenceGlobalTypeInCommonJs.errors.txt.diff | 16 -- ...esolveNameFailureInTypedef.errors.txt.diff | 16 -- .../jsdocRestParameter.errors.txt.diff | 17 +- .../jsdocRestParameter_es6.errors.txt.diff | 15 -- .../compiler/jsdocTypeCast.errors.txt.diff | 47 ----- ...enericInstantiationAttempt.errors.txt.diff | 17 -- ...enericInstantiationAttempt.errors.txt.diff | 93 +--------- ...oreParenthesizedExpression.errors.txt.diff | 30 ---- .../jsdocTypedefMissingType.errors.txt.diff | 35 ++-- ...Typedef_propertyWithNoType.errors.txt.diff | 18 -- ...JSDocCastAtReturnStatement.errors.txt.diff | 32 ---- ...izedJSDocCastDoesNotNarrow.errors.txt.diff | 17 -- .../requireOfJsonFileInJsFile.errors.txt.diff | 33 ---- ...itionalExpressionJSDocCast.errors.txt.diff | 34 ---- .../strictOptionalProperties3.errors.txt.diff | 35 ---- .../strictOptionalProperties4.errors.txt.diff | 24 --- ...bclassThisTypeAssignable01.errors.txt.diff | 19 --- ...bclassThisTypeAssignable02.errors.txt.diff | 42 ----- .../thisInFunctionCallJs.errors.txt.diff | 34 ---- .../topLevelBlockExpando.errors.txt.diff | 51 ------ .../unicodeEscapesInJSDoc.errors.txt.diff | 35 ---- .../compiler/uniqueSymbolJs.errors.txt.diff | 19 +-- ...rtyInitializerDoesntNarrow.errors.txt.diff | 27 --- .../assertionTypePredicates2.errors.txt.diff | 14 +- ...nsAndNonReturningFunctions.errors.txt.diff | 65 ------- ...asyncArrowFunction_allowJs.errors.txt.diff | 17 +- ...cFunctionDeclaration16_es5.errors.txt.diff | 65 +------ .../callbackCrossModule.errors.txt.diff | 10 +- .../callbackOnConstructor.errors.txt.diff | 8 +- .../conformance/callbackTag1.errors.txt.diff | 37 ---- .../conformance/callbackTag2.errors.txt.diff | 65 +------ .../conformance/callbackTag3.errors.txt.diff | 17 -- .../conformance/callbackTag4.errors.txt.diff | 33 ---- .../callbackTagNamespace.errors.txt.diff | 25 --- ...callbackTagNestedParameter.errors.txt.diff | 35 ---- .../callbackTagVariadicType.errors.txt.diff | 8 +- ...chainedPrototypeAssignment.errors.txt.diff | 18 +- ...xportsObjectAssignProperty.errors.txt.diff | 20 +-- ...ectAssignPrototypeProperty.errors.txt.diff | 19 +-- ...eckJsdocOptionalParamOrder.errors.txt.diff | 29 ---- ...DeclaredFunctionExpression.errors.txt.diff | 51 ++---- .../checkJsdocParamTag1.errors.txt.diff | 30 ---- .../checkJsdocReturnTag1.errors.txt.diff | 37 ---- .../checkJsdocReturnTag2.errors.txt.diff | 30 ---- .../checkJsdocSatisfiesTag1.errors.txt.diff | 62 +------ .../checkJsdocSatisfiesTag10.errors.txt.diff | 18 -- .../checkJsdocSatisfiesTag11.errors.txt.diff | 43 ++--- .../checkJsdocSatisfiesTag14.errors.txt.diff | 30 ++-- .../checkJsdocSatisfiesTag2.errors.txt.diff | 8 +- .../checkJsdocSatisfiesTag3.errors.txt.diff | 29 ---- .../checkJsdocSatisfiesTag4.errors.txt.diff | 28 +-- .../checkJsdocSatisfiesTag5.errors.txt.diff | 23 --- .../checkJsdocSatisfiesTag6.errors.txt.diff | 21 --- .../checkJsdocSatisfiesTag7.errors.txt.diff | 18 -- .../checkJsdocSatisfiesTag8.errors.txt.diff | 5 +- .../checkJsdocSatisfiesTag9.errors.txt.diff | 21 --- .../checkJsdocTypeTag1.errors.txt.diff | 54 +----- .../checkJsdocTypeTag2.errors.txt.diff | 25 +-- .../checkJsdocTypeTag3.errors.txt.diff | 13 -- .../checkJsdocTypeTag4.errors.txt.diff | 30 ---- .../checkJsdocTypeTag5.errors.txt.diff | 41 +---- .../checkJsdocTypeTag6.errors.txt.diff | 30 +--- .../checkJsdocTypeTag7.errors.txt.diff | 25 --- .../checkJsdocTypeTag8.errors.txt.diff | 5 +- ...ocTypeTagOnObjectProperty2.errors.txt.diff | 10 +- ...eckJsdocTypedefInParamTag1.errors.txt.diff | 59 ------- ...JsdocTypedefOnlySourceFile.errors.txt.diff | 5 +- .../checkObjectDefineProperty.errors.txt.diff | 48 +----- ...kOtherObjectAssignProperty.errors.txt.diff | 10 +- ...SpecialPropertyAssignments.errors.txt.diff | 24 --- ...nExtendConstructorFunction.errors.txt.diff | 23 +-- .../commonJSAliasedExport.errors.txt.diff | 5 +- ...JSImportClassTypeReference.errors.txt.diff | 5 +- ...ortExportedClassExpression.errors.txt.diff | 5 +- ...rtNestedClassTypeReference.errors.txt.diff | 5 +- ...nctionMethodTypeParameters.errors.txt.diff | 14 +- .../constructorFunctions.errors.txt.diff | 14 +- ...constructorFunctionsStrict.errors.txt.diff | 11 +- .../constructorTagWithThisTag.errors.txt.diff | 19 --- .../contextualTypeFromJSDoc.errors.txt.diff | 40 ----- ...tualTypedSpecialAssignment.errors.txt.diff | 10 +- ...Declaration9(strict=false).errors.txt.diff | 64 ------- ...rDeclaration9(strict=true).errors.txt.diff | 51 ------ .../conformance/enumTag.errors.txt.diff | 47 +---- .../enumTagImported.errors.txt.diff | 13 +- .../enumTagUseBeforeDefCrash.errors.txt.diff | 5 +- .../errorOnFunctionReturnType.errors.txt.diff | 12 +- ...Declaration-exportModifier.errors.txt.diff | 61 ++++--- .../exportNestedNamespaces.errors.txt.diff | 8 +- .../exportedEnumTypeAndValue.errors.txt.diff | 5 +- .../conformance/extendsTag5.errors.txt.diff | 7 +- ...ericSetterInClassTypeJsDoc.errors.txt.diff | 5 +- .../conformance/importTag1.errors.txt.diff | 27 --- .../conformance/importTag11.errors.txt.diff | 15 +- .../conformance/importTag12.errors.txt.diff | 18 +- .../conformance/importTag13.errors.txt.diff | 12 +- .../conformance/importTag14.errors.txt.diff | 12 +- ...importTag15(module=es2015).errors.txt.diff | 31 ---- ...importTag15(module=esnext).errors.txt.diff | 31 ---- .../conformance/importTag16.errors.txt.diff | 28 --- .../conformance/importTag17.errors.txt.diff | 21 +-- .../conformance/importTag18.errors.txt.diff | 29 ---- .../conformance/importTag19.errors.txt.diff | 27 --- .../conformance/importTag2.errors.txt.diff | 27 --- .../conformance/importTag20.errors.txt.diff | 29 ---- .../conformance/importTag21.errors.txt.diff | 41 ----- .../conformance/importTag23.errors.txt.diff | 26 --- .../conformance/importTag3.errors.txt.diff | 27 --- .../conformance/importTag4.errors.txt.diff | 40 ----- .../conformance/importTag5.errors.txt.diff | 27 --- .../conformance/importTag6.errors.txt.diff | 40 ----- .../conformance/importTag7.errors.txt.diff | 38 ----- .../conformance/importTag8.errors.txt.diff | 38 ----- .../conformance/importTag9.errors.txt.diff | 38 ----- .../importTypeInJSDoc.errors.txt.diff | 40 ----- .../conformance/inferThis.errors.txt.diff | 14 +- ...rameterOnVariableStatement.errors.txt.diff | 11 +- ...sDeclarationsClassAccessor.errors.txt.diff | 48 ------ ...mentsGenericsSerialization.errors.txt.diff | 8 +- .../jsDeclarationsClassMethod.errors.txt.diff | 11 +- .../jsDeclarationsClasses.errors.txt.diff | 80 +-------- ...sDeclarationsComputedNames.errors.txt.diff | 36 ---- .../jsDeclarationsDefault.errors.txt.diff | 50 ------ .../jsDeclarationsEnumTag.errors.txt.diff | 26 +-- ...ortAssignedClassExpression.errors.txt.diff | 18 -- ...edClassExpressionAnonymous.errors.txt.diff | 18 -- ...ExpressionAnonymousWithSub.errors.txt.diff | 5 +- ...nsExportDefinePropertyEmit.errors.txt.diff | 41 +---- ...ClassesCjsExportAssignment.errors.txt.diff | 27 +-- ...sDeclarationsFunctionJSDoc.errors.txt.diff | 57 ------- ...rationsFunctionLikeClasses.errors.txt.diff | 13 +- ...ationsFunctionLikeClasses2.errors.txt.diff | 20 +-- ...onsFunctionPrototypeStatic.errors.txt.diff | 5 +- .../jsDeclarationsFunctions.errors.txt.diff | 41 +---- ...jsDeclarationsFunctionsCjs.errors.txt.diff | 20 +-- ...jsDeclarationsGetterSetter.errors.txt.diff | 161 ------------------ ...liasExposedWithinNamespace.errors.txt.diff | 19 +-- ...sExposedWithinNamespaceCjs.errors.txt.diff | 16 +- ...ationsImportNamespacedType.errors.txt.diff | 5 +- ...ionsJSDocRedirectedLookups.errors.txt.diff | 55 +----- ...eclarationsMissingGenerics.errors.txt.diff | 21 --- ...tionsMissingTypeParameters.errors.txt.diff | 15 +- ...ionsModuleReferenceHasEmit.errors.txt.diff | 5 +- ...jsDeclarationsNestedParams.errors.txt.diff | 20 +-- ...sOptionalTypeLiteralProps1.errors.txt.diff | 24 --- ...sOptionalTypeLiteralProps2.errors.txt.diff | 5 +- ...rTagReusesInputNodeInEmit1.errors.txt.diff | 11 +- ...rTagReusesInputNodeInEmit2.errors.txt.diff | 8 +- ...eclarationsPrivateFields01.errors.txt.diff | 31 ---- ...eclarationsReactComponents.errors.txt.diff | 106 ------------ ...arationsReexportedCjsAlias.errors.txt.diff | 34 ---- ...ceToClassInstanceCrossFile.errors.txt.diff | 5 +- ...tingNodesMappingJSDocTypes.errors.txt.diff | 26 +-- ...sesExistingTypeAnnotations.errors.txt.diff | 44 +---- ...licitNoArgumentConstructor.errors.txt.diff | 26 --- .../jsDeclarationsThisTypes.errors.txt.diff | 20 --- .../jsDeclarationsTypeAliases.errors.txt.diff | 16 +- ...eassignmentFromDeclaration.errors.txt.diff | 19 --- ...tionsTypedefAndImportTypes.errors.txt.diff | 5 +- ...rationsTypedefAndLatebound.errors.txt.diff | 10 +- ...eclarationsTypedefFunction.errors.txt.diff | 31 ---- ...ropertyAndExportAssignment.errors.txt.diff | 16 +- ...larationsUniqueSymbolUsage.errors.txt.diff | 27 --- ...ocBindingInUnreachableCode.errors.txt.diff | 18 -- ...chClauseWithTypeAnnotation.errors.txt.diff | 146 ---------------- ...uctorFunctionTypeReference.errors.txt.diff | 5 +- .../jsdocFunctionType.errors.txt.diff | 46 +---- .../jsdocImplementsTag.errors.txt.diff | 21 --- .../jsdocImplements_class.errors.txt.diff | 49 ------ .../jsdocImplements_interface.errors.txt.diff | 41 ----- ...lements_interface_multiple.errors.txt.diff | 30 ---- ...sdocImplements_missingType.errors.txt.diff | 21 ++- ...ements_namespacedInterface.errors.txt.diff | 35 ---- ...jsdocImplements_properties.errors.txt.diff | 37 ---- ...jsdocImplements_signatures.errors.txt.diff | 19 --- .../jsdocImportType.errors.txt.diff | 37 ---- .../jsdocImportType2.errors.txt.diff | 36 ---- ...tTypeReferenceToClassAlias.errors.txt.diff | 5 +- ...eReferenceToCommonjsModule.errors.txt.diff | 5 +- ...ortTypeReferenceToESModule.errors.txt.diff | 5 +- ...peReferenceToStringLiteral.errors.txt.diff | 5 +- .../jsdocIndexSignature.errors.txt.diff | 14 +- .../conformance/jsdocLiteral.errors.txt.diff | 33 ---- .../jsdocNeverUndefinedNull.errors.txt.diff | 28 --- .../jsdocOuterTypeParameters1.errors.txt.diff | 5 +- .../jsdocOuterTypeParameters2.errors.txt.diff | 6 +- .../jsdocOverrideTag1.errors.txt.diff | 39 ----- .../jsdocParamTag2.errors.txt.diff | 142 +-------------- .../jsdocParamTagTypeLiteral.errors.txt.diff | 102 ----------- ...ocParseBackquotedParamName.errors.txt.diff | 24 --- ...seDotDotDotInJSDocFunction.errors.txt.diff | 5 +- ...ocParseHigherOrderFunction.errors.txt.diff | 5 +- ...sdocParseMatchingBackticks.errors.txt.diff | 40 ----- ...arenthesizedJSDocParameter.errors.txt.diff | 5 +- .../jsdocParseStarEquals.errors.txt.diff | 15 +- ...stfixEqualsAddsOptionality.errors.txt.diff | 34 ---- .../jsdocPrefixPostfixParsing.errors.txt.diff | 47 +---- .../jsdocPrivateName1.errors.txt.diff | 16 -- .../conformance/jsdocReadonly.errors.txt.diff | 5 +- .../jsdocReturnTag1.errors.txt.diff | 37 ---- ...ignatureOnReturnedFunction.errors.txt.diff | 67 -------- .../jsdocTemplateClass.errors.txt.diff | 23 +-- ...emplateConstructorFunction.errors.txt.diff | 17 +- ...mplateConstructorFunction2.errors.txt.diff | 27 +-- .../jsdocTemplateTag.errors.txt.diff | 13 +- .../jsdocTemplateTag2.errors.txt.diff | 8 +- .../jsdocTemplateTag3.errors.txt.diff | 30 +--- .../jsdocTemplateTag5.errors.txt.diff | 20 +-- .../jsdocTemplateTag6.errors.txt.diff | 44 +---- .../jsdocTemplateTag7.errors.txt.diff | 14 +- .../jsdocTemplateTag8.errors.txt.diff | 76 +-------- .../jsdocTemplateTagDefault.errors.txt.diff | 48 +----- ...cTemplateTagNameResolution.errors.txt.diff | 21 --- .../conformance/jsdocThisType.errors.txt.diff | 24 +-- .../jsdocTypeDefAtStartOfFile.errors.txt.diff | 13 +- .../jsdocTypeReferenceExports.errors.txt.diff | 5 +- ...jsdocTypeReferenceToImport.errors.txt.diff | 8 +- ...eToImportOfClassExpression.errors.txt.diff | 5 +- ...ImportOfFunctionExpression.errors.txt.diff | 10 +- ...TypeReferenceToMergedClass.errors.txt.diff | 5 +- .../jsdocTypeReferenceToValue.errors.txt.diff | 5 +- ...cTypeReferenceUseBeforeDef.errors.txt.diff | 15 -- .../conformance/jsdocTypeTag.errors.txt.diff | 74 +------- .../jsdocTypeTagCast.errors.txt.diff | 110 ++---------- .../jsdocTypeTagParameterType.errors.txt.diff | 5 +- ...cTypeTagRequiredParameters.errors.txt.diff | 5 +- ...larationWithTypeAnnotation.errors.txt.diff | 17 -- .../jsdocVariadicType.errors.txt.diff | 5 +- .../conformance/linkTagEmit1.errors.txt.diff | 35 ---- .../conformance/malformedTags.errors.txt.diff | 17 -- .../moduleExportAssignment.errors.txt.diff | 5 +- .../moduleExportAssignment6.errors.txt.diff | 37 ---- .../moduleExportAssignment7.errors.txt.diff | 61 +------ ...duleExportNestedNamespaces.errors.txt.diff | 8 +- ...tsElementAccessAssignment2.errors.txt.diff | 33 ---- ...optionalBindingParameters3.errors.txt.diff | 24 --- ...optionalBindingParameters4.errors.txt.diff | 17 -- .../conformance/overloadTag1.errors.txt.diff | 45 +---- .../conformance/overloadTag2.errors.txt.diff | 48 ------ .../conformance/overloadTag3.errors.txt.diff | 11 +- ...acketsAddOptionalUndefined.errors.txt.diff | 43 ----- ...stedWithoutTopLevelObject3.errors.txt.diff | 8 +- .../paramTagTypeResolution2.errors.txt.diff | 8 +- .../paramTagWrapping.errors.txt.diff | 26 +-- ...enericConstructorFunctions.errors.txt.diff | 41 +---- ...tyAssignmentUseParentType2.errors.txt.diff | 22 +-- ...ssignmentMergeAcrossFiles2.errors.txt.diff | 14 +- ...ignmentMergedTypeReference.errors.txt.diff | 5 +- .../recursiveTypeReferences2.errors.txt.diff | 27 --- .../returnTagTypeGuard.errors.txt.diff | 98 ----------- .../conformance/syntaxErrors.errors.txt.diff | 31 ++-- .../templateInsideCallback.errors.txt.diff | 60 ++----- ...ropertyAssignmentInherited.errors.txt.diff | 29 ---- .../conformance/thisTag1.errors.txt.diff | 30 ---- .../conformance/thisTag2.errors.txt.diff | 19 --- .../conformance/thisTag3.errors.txt.diff | 31 ---- ...TypeOfConstructorFunctions.errors.txt.diff | 20 +-- ...typeFromContextualThisType.errors.txt.diff | 8 +- .../typeFromJSInitializer.errors.txt.diff | 29 +--- .../typeFromJSInitializer4.errors.txt.diff | 17 -- ...ypeFromParamTagForFunction.errors.txt.diff | 40 +---- ...rivatePropertyAssignmentJs.errors.txt.diff | 26 --- ...typeFromPropertyAssignment.errors.txt.diff | 8 +- ...peFromPropertyAssignment10.errors.txt.diff | 5 +- ...FromPropertyAssignment10_1.errors.txt.diff | 5 +- ...peFromPropertyAssignment14.errors.txt.diff | 5 +- ...peFromPropertyAssignment15.errors.txt.diff | 5 +- ...peFromPropertyAssignment16.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment2.errors.txt.diff | 8 +- ...peFromPropertyAssignment24.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment3.errors.txt.diff | 8 +- ...peFromPropertyAssignment35.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment4.errors.txt.diff | 10 +- ...peFromPropertyAssignment40.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment5.errors.txt.diff | 5 +- ...ypeFromPropertyAssignment6.errors.txt.diff | 5 +- ...opertyAssignmentOutOfOrder.errors.txt.diff | 5 +- ...peFromPrototypeAssignment3.errors.txt.diff | 15 +- ...peFromPrototypeAssignment4.errors.txt.diff | 37 ---- .../typeLookupInIIFE.errors.txt.diff | 12 +- .../typeTagNoErasure.errors.txt.diff | 20 --- ...nFunctionReferencesGeneric.errors.txt.diff | 29 ---- .../typedefCrossModule.errors.txt.diff | 11 +- .../typedefCrossModule2.errors.txt.diff | 10 +- ...edefMultipleTypeParameters.errors.txt.diff | 32 +--- ...defOnSemicolonClassElement.errors.txt.diff | 17 -- .../typedefOnStatements.errors.txt.diff | 96 ----------- .../conformance/typedefScope1.errors.txt.diff | 36 ---- ...pedefTagExtraneousProperty.errors.txt.diff | 5 +- .../typedefTagNested.errors.txt.diff | 56 ------ .../typedefTagTypeResolution.errors.txt.diff | 29 +--- .../typedefTagWrapping.errors.txt.diff | 123 +------------ ...queSymbolsDeclarationsInJs.errors.txt.diff | 11 +- ...bolsDeclarationsInJsErrors.errors.txt.diff | 21 +-- .../varRequireFromJavascript.errors.txt.diff | 39 ----- .../varRequireFromTypescript.errors.txt.diff | 38 ----- 745 files changed, 1462 insertions(+), 16127 deletions(-) delete mode 100644 testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.errors.txt delete mode 100644 testdata/baselines/reference/conformance/typeTagForMultipleVariableDeclarations.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/constructorPropertyJs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/callbackTagNamespace.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag7.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/esDecorators-classDeclaration-exportModifier.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag11.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag12.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag16.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag18.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag19.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag20.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag21.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag3.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag5.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag6.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag7.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag8.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTag9.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsPrivateFields01.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsReexportedCjsAlias.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImplementsTag.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImplements_namespacedInterface.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImportType.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocImportType2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocLiteral.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/linkTagEmit1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/malformedTags.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/syntaxErrors.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/thisTag2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/typedefTagNested.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/constructorPropertyJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNamespace.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag7.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag16.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag18.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag19.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag20.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag21.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag5.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag6.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag7.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag8.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTag9.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingGenerics.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsPrivateFields01.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReexportedCjsAlias.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplementsTag.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface_multiple.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_namespacedInterface.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_properties.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_signatures.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrivateName1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefOnSemicolonClassElement.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff diff --git a/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.errors.txt b/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.errors.txt deleted file mode 100644 index 69a7672661..0000000000 --- a/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - /** - * @param {{ a: number; b: string }} args - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f({ a, b }) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/jsdocParseAwait.errors.txt b/testdata/baselines/reference/conformance/jsdocParseAwait.errors.txt index fe0f53f431..eac1d028f9 100644 --- a/testdata/baselines/reference/conformance/jsdocParseAwait.errors.txt +++ b/testdata/baselines/reference/conformance/jsdocParseAwait.errors.txt @@ -1,33 +1,24 @@ -/a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(7,7): error TS2322: Type 'number' is not assignable to type 'T'. -/a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (4 errors) ==== +==== /a.js (1 errors) ==== /** * @typedef {object} T * @property {boolean} await */ /** @type {T} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const a = 1; ~ !!! error TS2322: Type 'number' is not assignable to type 'T'. /** @type {T} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const b = { await: false, }; /** * @param {boolean} await - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function c(await) {} \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/typeTagForMultipleVariableDeclarations.errors.txt b/testdata/baselines/reference/conformance/typeTagForMultipleVariableDeclarations.errors.txt deleted file mode 100644 index 49d4f47832..0000000000 --- a/testdata/baselines/reference/conformance/typeTagForMultipleVariableDeclarations.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -typeTagForMultipleVariableDeclarations.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== typeTagForMultipleVariableDeclarations.js (1 errors) ==== - /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var x,y,z; - x - y - z - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt index a565b3bebd..1fafa07a86 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(4,13): error TS8010: Type annotations can only be used in TypeScript files. ExtendedClass.js(17,5): error TS1231: An export assignment must be at the top level of a file or module declaration. 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 '{}'. @@ -13,13 +12,11 @@ ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type } export = BaseClass; } -==== ExtendedClass.js (4 errors) ==== +==== ExtendedClass.js (3 errors) ==== define("lib/ExtendedClass", ["deps/BaseClass"], /** * {typeof import("deps/BaseClass")} * @param {typeof import("deps/BaseClass")} BaseClass - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns */ (BaseClass) => { diff --git a/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt index 710789c4b3..d0da78af1a 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsObjectCreatesRestForJs.errors.txt @@ -1,10 +1,9 @@ main.js(3,9): error TS2554: Expected 0 arguments, but got 3. main.js(5,1): error TS2554: Expected 2 arguments, but got 0. main.js(6,16): error TS2554: Expected 2 arguments, but got 3. -main.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -==== main.js (4 errors) ==== +==== main.js (3 errors) ==== function allRest() { arguments; } allRest(); allRest(1, 2, 3); @@ -21,8 +20,6 @@ main.js(9,12): error TS8010: Type annotations can only be used in TypeScript fil /** * @param {number} x - a thing - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function jsdocced(x) { arguments; } jsdocced(1); diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.errors.txt deleted file mode 100644 index b70af30395..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor1_Js.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class A { - /** - * Constructor - * - * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(foo = {}) { - /** - * @type object - */ - this.arguments = foo; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.errors.txt deleted file mode 100644 index eff8d9204f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor2_Js.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class A { - /** - * Constructor - * - * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(foo = {}) { - /** - * @type object - */ - this["arguments"] = foo; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt deleted file mode 100644 index 154633f65d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -/a.js(11,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class A { - get arguments() { - return { bar: {} }; - } - } - - class B extends A { - /** - * Constructor - * - * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(foo = {}) { - super(); - - /** - * @type object - */ - this.foo = foo; - - /** - * @type object - */ - this.bar = super.arguments.foo; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt index 258872a506..30d6092c3f 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor4_Js.errors.txt @@ -1,16 +1,12 @@ -/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. /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 (3 errors) ==== +==== /a.js (1 errors) ==== class A { /** * Constructor * * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(foo = {}) { const key = "bar"; @@ -22,8 +18,6 @@ /** * @type object - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const arguments = this.arguments; ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.errors.txt deleted file mode 100644 index 8a6cd4bf83..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor5_Js.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -/a.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - const bar = { - arguments: {} - } - - class A { - /** - * Constructor - * - * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(foo = {}) { - /** - * @type object - */ - this.foo = foo; - - /** - * @type object - */ - this.bar = bar.arguments; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.errors.txt deleted file mode 100644 index 19711439dd..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod1_Js.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class A { - /** - * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - m(foo = {}) { - /** - * @type object - */ - this.arguments = foo; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.errors.txt deleted file mode 100644 index c07059ff7b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod2_Js.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class A { - /** - * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - m(foo = {}) { - /** - * @type object - */ - this["arguments"] = foo; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt deleted file mode 100644 index 7ce6ffdfa1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -/a.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class A { - get arguments() { - return { bar: {} }; - } - } - - class B extends A { - /** - * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - m(foo = {}) { - /** - * @type object - */ - this.x = foo; - - /** - * @type object - */ - this.y = super.arguments.bar; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt index 8afe5745a4..8c90a67da1 100644 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod4_Js.errors.txt @@ -1,14 +1,10 @@ -/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. /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 (3 errors) ==== +==== /a.js (1 errors) ==== class A { /** * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ m(foo = {}) { const key = "bar"; @@ -20,8 +16,6 @@ /** * @type object - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const arguments = this.arguments; ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.errors.txt deleted file mode 100644 index fa5cea40af..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod5_Js.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -/a.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - const bar = { - arguments: {} - } - - class A { - /** - * @param {object} [foo={}] - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - m(foo = {}) { - /** - * @type object - */ - this.foo = foo; - - /** - * @type object - */ - this.bar = bar.arguments; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt index a6ee9d2699..d541cfc7e3 100644 --- a/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt @@ -1,32 +1,20 @@ -mytest.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -mytest.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. mytest.js(6,13): error TS8004: Type parameter declarations can only be used in TypeScript files. -mytest.js(6,34): error TS8016: Type assertion expressions can only be used in TypeScript files. mytest.js(6,45): error TS2322: Type 'string' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -mytest.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -mytest.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. mytest.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. -mytest.js(13,34): error TS8016: Type assertion expressions can only be used in TypeScript files. mytest.js(13,61): error TS2322: Type 'string' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -==== mytest.js (10 errors) ==== +==== mytest.js (4 errors) ==== /** * @template T * @param {T|undefined} value value or not - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} result value - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo1 = value => /** @type {string} */({ ...value }); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. @@ -34,17 +22,11 @@ mytest.js(13,61): error TS2322: Type 'string' is not assignable to type 'T'. /** * @template T * @param {T|undefined} value value or not - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} result value - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt b/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt index d832f54e6a..93ae5e06a3 100644 --- a/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt @@ -1,21 +1,12 @@ -mytest.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -mytest.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. mytest.js(6,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -mytest.js(6,45): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== mytest.js (4 errors) ==== +==== mytest.js (1 errors) ==== /** * @template T * @param {T|undefined} value value or not - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} result value - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const cloneObjectGood = value => /** @type {T} */({ ...value }); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file 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 6a5b9b3fd9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/arrowFunctionJSDocAnnotation.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(10,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(11,18): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (3 errors) ==== - /** - * @param {any} v - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function identity(v) { - return v; - } - - const x = identity( - /** - * @param {number} param - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {number=} - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - param => param - ); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt index 73bb691f4d..50e261254c 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt @@ -1,8 +1,7 @@ -file.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. -==== file.js (2 errors) ==== +==== file.js (1 errors) ==== // @ts-check const obj = { x: 1, @@ -11,8 +10,6 @@ file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. /** * @type {keyof typeof obj} - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ let selected = "x"; selected = "z"; // should fail diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt index e48af078d5..855d7577c6 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt @@ -1,6 +1,4 @@ -something.js(3,20): error TS8010: Type annotations can only be used in TypeScript files. something.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -something.js(5,29): error TS8016: Type assertion expressions can only be used in TypeScript files. ==== file.ts (0 errors) ==== @@ -13,15 +11,11 @@ something.js(5,29): error TS8016: Type assertion expressions can only be used in } export = Foo; -==== something.js (3 errors) ==== +==== something.js (1 errors) ==== /** @typedef {typeof import("./file")} Foo */ /** @typedef {(foo: Foo) => string} FooFun */ - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. module.exports = /** @type {FooFun} */(void 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - ~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/constructorPropertyJs.errors.txt b/testdata/baselines/reference/submodule/compiler/constructorPropertyJs.errors.txt deleted file mode 100644 index c678122eeb..0000000000 --- a/testdata/baselines/reference/submodule/compiler/constructorPropertyJs.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -/a.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class C { - /** - * @param {any} a - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - foo(a) { - this.constructor = a; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt index 9a2e347d44..dbf4731034 100644 --- a/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt @@ -1,42 +1,24 @@ -index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(8,28): error TS8010: Type annotations can only be used in TypeScript files. -index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(14,6): error TS8009: The '?' modifier can only be used in TypeScript files. 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(22,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(25,6): error TS8009: The '?' modifier can only be used in TypeScript files. -index.js(25,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (10 errors) ==== +==== index.js (2 errors) ==== /** * * @param {number} num - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function acceptNum(num) {} /** * @typedef {(a: string, b: number) => void} Fn - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** @type {Fn} */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const fn1 = /** * @param [b] - ~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. */ function self(a, b) { acceptNum(b); // error @@ -48,15 +30,9 @@ index.js(28,15): error TS2345: Argument of type 'number | undefined' is not assi }; /** @type {Fn} */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const fn2 = /** * @param {number} [b] - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function self(a, b) { acceptNum(b); // error diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt index 1e3c878649..bc73f48bc1 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt @@ -1,30 +1,20 @@ index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(2,28): error TS2304: Cannot find name 'B'. -index.js(2,41): error TS8010: Type annotations can only be used in TypeScript files. index.js(2,42): error TS2304: Cannot find name 'A'. -index.js(2,47): error TS8010: Type annotations can only be used in TypeScript files. index.js(2,48): error TS2304: Cannot find name 'B'. index.js(2,67): error TS2304: Cannot find name 'B'. index.js(10,12): error TS2315: Type 'Funcs' is not generic. -index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. -index.js(14,21): error TS8016: Type assertion expressions can only be used in TypeScript files. -index.js(20,19): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (12 errors) ==== +==== index.js (6 errors) ==== /** ~~~ * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'B'. - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'A'. - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'B'. ~ @@ -47,20 +37,14 @@ index.js(20,19): error TS8010: Type annotations can only be used in TypeScript f ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2315: Type 'Funcs' is not generic. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {[A, B]} ~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function foo(fns) { ~~~~~~~~~~~~~~~~~~~ return /** @type {any} */ (null); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. } ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. @@ -69,8 +53,6 @@ index.js(20,19): error TS8010: Type annotations can only be used in TypeScript f bar: { fn: /** @param {string} a */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. (a) => {}, thing: "asd", }, diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt index aed736bfb8..adb56c7b62 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt @@ -1,36 +1,21 @@ index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. -index.js(7,21): error TS8016: Type assertion expressions can only be used in TypeScript files. -index.js(12,6): error TS8009: The '?' modifier can only be used in TypeScript files. -index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. -index.js(19,6): error TS8009: The '?' modifier can only be used in TypeScript files. -index.js(19,14): error TS8010: Type annotations can only be used in TypeScript files. -index.js(20,6): error TS8009: The '?' modifier can only be used in TypeScript files. -index.js(20,14): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (10 errors) ==== +==== index.js (1 errors) ==== /** ~~~ * @template T ~~~~~~~~~~~~~~ * @param {(value: T, index: number) => boolean} predicate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function filter(predicate) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return /** @type {any} */ (null); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. } ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. @@ -38,10 +23,6 @@ index.js(20,14): error TS8010: Type annotations can only be used in TypeScript f const a = filter( /** * @param {number} [pose] - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ (pose) => true ); @@ -49,16 +30,7 @@ index.js(20,14): error TS8010: Type annotations can only be used in TypeScript f const b = filter( /** * @param {number} [pose] - ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} [_] - ~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ (pose, _) => true ); diff --git a/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt index 9063921a34..d525041aed 100644 --- a/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/controlFlowInstanceof.errors.txt @@ -1,4 +1,3 @@ -uglify.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. uglify.js(6,7): error TS2339: Property 'val' does not exist on type '{}'. @@ -111,12 +110,10 @@ uglify.js(6,7): error TS2339: Property 'val' does not exist on type '{}'. } // Repro from #27550 (based on uglify code) -==== uglify.js (2 errors) ==== +==== uglify.js (1 errors) ==== /** @constructor */ function AtTop(val) { this.val = val } /** @type {*} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var v = 1; if (v instanceof AtTop) { v.val diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt index f2d8b4bc91..4399f211f5 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt @@ -1,97 +1,43 @@ -input.js(5,30): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(7,30): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(8,34): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(10,35): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. -input.js(13,59): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(16,24): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(17,44): error TS8016: Type assertion expressions can only be used in TypeScript files. input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -input.js(18,43): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(19,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. -input.js(21,46): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(23,40): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(25,33): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(29,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -input.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -input.js(37,70): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== input.js (19 errors) ==== +==== input.js (1 errors) ==== /** * @typedef {{ } & { name?: string }} P */ const something = /** @type {*} */(null); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. export let vLet = /** @type {P} */(something); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. export const vConst = /** @type {P} */(something); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. export function fn(p = /** @type {P} */(something)) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** @param {number} req */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. export class C { field = /** @type {P} */(something); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** @optional */ optField = /** @type {P} */(something); // not a thing - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** @readonly */ roFiled = /** @type {P} */(something); ~~~~~~~~~~ !!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. method(p = /** @type {P} */(something)) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** @param {number} req */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. methodWithRequiredDefault(p = /** @type {P} */(something), req) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. constructor(ctorField = /** @type {P} */(something)) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. get x() { return /** @type {P} */(something) } - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. set x(v) { } } export default /** @type {P} */(something); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. // allows `undefined` on the input side, thanks to the initializer /** * * @param {P} x - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} b - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ - export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file + export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} \ 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 index f2d8b4bc91..4399f211f5 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt @@ -1,97 +1,43 @@ -input.js(5,30): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(7,30): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(8,34): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(10,35): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. -input.js(13,59): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(16,24): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(17,44): error TS8016: Type assertion expressions can only be used in TypeScript files. input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -input.js(18,43): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(19,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. -input.js(21,46): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(23,40): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(25,33): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(29,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -input.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -input.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -input.js(37,70): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== input.js (19 errors) ==== +==== input.js (1 errors) ==== /** * @typedef {{ } & { name?: string }} P */ const something = /** @type {*} */(null); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. export let vLet = /** @type {P} */(something); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. export const vConst = /** @type {P} */(something); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. export function fn(p = /** @type {P} */(something)) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** @param {number} req */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. export class C { field = /** @type {P} */(something); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** @optional */ optField = /** @type {P} */(something); // not a thing - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** @readonly */ roFiled = /** @type {P} */(something); ~~~~~~~~~~ !!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. method(p = /** @type {P} */(something)) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** @param {number} req */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. methodWithRequiredDefault(p = /** @type {P} */(something), req) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. constructor(ctorField = /** @type {P} */(something)) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. get x() { return /** @type {P} */(something) } - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. set x(v) { } } export default /** @type {P} */(something); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. // allows `undefined` on the input side, thanks to the initializer /** * * @param {P} x - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} b - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ - export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file + export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.errors.txt deleted file mode 100644 index dc4ded71e1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassAccessorsJs1.errors.txt +++ /dev/null @@ -1,26 +0,0 @@ -index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (2 errors) ==== - // https://github.com/microsoft/TypeScript/issues/58167 - - export class VFile { - /** - * @returns {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - get path() { - return '' - } - - /** - * @param {URL | string} path - ~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set path(path) { - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt deleted file mode 100644 index 7dbdafd6f7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -foo.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.js (1 errors) ==== - // https://github.com/microsoft/TypeScript/issues/55391 - - export class Foo { - /** - * Bar. - * - * @param {string} baz Baz. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set bar(baz) {} - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt deleted file mode 100644 index 7ac769101d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -foo.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.js (1 errors) ==== - export class Foo { - /** - * Bar. - * - * @param {{ prop: string }} baz Baz. - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set bar({}) {} - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt deleted file mode 100644 index 19362d33d0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -foo.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.js (1 errors) ==== - export class Foo { - /** - * Bar. - * - * @param {{ prop: string | undefined }} baz Baz. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set bar({ prop = 'foo' }) {} - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.errors.txt b/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.errors.txt deleted file mode 100644 index 3a2f165e7f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitLateBoundJSAssignments.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -file.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== file.js (4 errors) ==== - export function foo() {} - foo.bar = 12; - const _private = Symbol(); - foo[_private] = "ok"; - const strMem = "strMemName"; - foo[strMem] = "ok"; - const dashStrMem = "dashed-str-mem"; - foo[dashStrMem] = "ok"; - const numMem = 42; - foo[numMem] = "ok"; - - /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const x = foo[_private]; - /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const y = foo[strMem]; - /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const z = foo[numMem]; - /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const a = foo[dashStrMem]; - \ No newline at end of file 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 9ebbea8d8f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt +++ /dev/null @@ -1,71 +0,0 @@ -index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. -index.js(21,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(28,14): error TS8010: Type annotations can only be used in TypeScript files. -index.js(36,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(46,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (6 errors) ==== - // same type accessors - export const obj1 = { - /** - * my awesome getter (first in source order) - * @returns {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - get x() { - return ""; - }, - /** - * my awesome setter (second in source order) - * @param {string} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set x(a) {}, - }; - - // divergent accessors - export const obj2 = { - /** - * my awesome getter - * @returns {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - get x() { - return ""; - }, - /** - * my awesome setter - * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set x(a) {}, - }; - - export const obj3 = { - /** - * my awesome getter - * @returns {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - get x() { - return ""; - }, - }; - - export const obj4 = { - /** - * my awesome setter - * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set x(a) {}, - }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt index 8936b23ce8..267621261d 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt @@ -1,10 +1,7 @@ -input.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -input.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -input.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== input.js (4 errors) ==== +==== input.js (1 errors) ==== /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ /** @@ -13,8 +10,6 @@ input.js(48,1): error TS2309: An export assignment cannot be used in a module wi /** * @type {StatelessComponent} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const MyComponent = () => /* @type {any} */(null); @@ -33,16 +28,12 @@ input.js(48,1): error TS2309: An export assignment cannot be used in a module wi /** * @type {StatelessComponent} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const check = MyComponent2; /** * * @param {{ props: MyComponentProps }} p - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function expectLiteral(p) {} diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.errors.txt b/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.errors.txt deleted file mode 100644 index 77e0dc9ed8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionSymbolPropertyJs.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -/a.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /types.ts (0 errors) ==== - export const symb = Symbol(); - - export interface TestSymb { - (): void; - readonly [symb]: boolean; - } - -==== /a.js (1 errors) ==== - import { symb } from "./types"; - - /** - * @returns {import("./types").TestSymb} - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function test() { - function inner() {} - inner[symb] = true; - return inner; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.errors.txt b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.errors.txt deleted file mode 100644 index c92317d64c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -a.js(6,27): error TS8016: Type assertion expressions can only be used in TypeScript files. - - -==== a.js (1 errors) ==== - /** - * A number, or a string containing a number. - * @typedef {(number|string)} NumberLike - */ - - export default /** @type {NumberLike[]} */([ ]); - ~~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - -==== b.ts (0 errors) ==== - import A from './a' - A[0] \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt deleted file mode 100644 index 6b83f1862f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -file.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== file.js (2 errors) ==== - /** - * Adds - * @param {number} 𝑚 - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} 𝑀 - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo(𝑚, 𝑀) { - console.log(𝑀 + 𝑚); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.errors.txt b/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.errors.txt deleted file mode 100644 index 44c25b2b53..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importTypeResolutionJSDocEOF.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -usage.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== interfaces.d.ts (0 errors) ==== - export interface Bar { - prop: string - } - -==== usage.js (1 errors) ==== - /** @type {Bar} */ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - export let bar; - - /** @typedef {import('./interfaces').Bar} Bar */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt deleted file mode 100644 index 2ed16c4317..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -index.js(10,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== test/Test.js (0 errors) ==== - /** @module test/Test */ - class Test {} - export default Test; -==== Test.js (0 errors) ==== - /** @module Test */ - class Test {} - export default Test; -==== index.js (1 errors) ==== - import Test from './test/Test.js' - - /** - * @typedef {Object} Options - * @property {typeof import("./Test.js").default} [test] - */ - - class X extends Test { - /** - * @param {Options} options - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(options) { - super(); - if (options.test) { - this.test = new options.test(); - } - } - } - - export default X; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt deleted file mode 100644 index d0f7b071ee..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt +++ /dev/null @@ -1,43 +0,0 @@ -a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. -a.js(20,15): error TS8010: Type annotations can only be used in TypeScript files. -a.js(27,15): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (3 errors) ==== - /** - * @typedef A - * @property {string} a - */ - - /** - * @typedef B - * @property {number} b - */ - - class C1 { - /** - * @type {A} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - value; - } - - class C2 extends C1 { - /** - * @type {A} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - value; - } - - class C3 extends C1 { - /** - * @type {A & B} - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - value; - } - \ No newline at end of file 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 e9ad58087a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt +++ /dev/null @@ -1,51 +0,0 @@ -index.js(7,8): error TS8009: The '?' modifier can only be used in TypeScript files. -index.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== 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 (2 errors) ==== - /** - * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit - */ - - export class NewAjax { - /** - * @param {LionRequestInit} [init] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - case5_unexpectedlyResolvesPathToNodeModules(init) {} - } - - /** - * @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/jsEnumCrossFileExport.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt index ef0503fe04..3be4b9a200 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt @@ -1,11 +1,8 @@ enumDef.js(16,18): error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. -index.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. 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(13,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(18,11): error TS2503: Cannot find namespace 'Host'. -index.js(18,11): error TS8010: Type annotations can only be used in TypeScript files. ==== enumDef.js (1 errors) ==== @@ -29,13 +26,11 @@ index.js(18,11): error TS8010: Type annotations can only be used in TypeScript f !!! error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. x: 12 } -==== index.js (7 errors) ==== +==== index.js (4 errors) ==== var Other = {}; Other.Cls = class { /** * @param {!Host.UserMetrics.Action} p - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~ !!! error TS2503: Cannot find namespace 'Host'. */ @@ -51,8 +46,6 @@ index.js(18,11): error TS8010: Type annotations can only be used in TypeScript f * @type {Host.UserMetrics.Bargh} ~~~~ !!! error TS2503: Cannot find namespace 'Host'. - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var x = "ok"; @@ -60,8 +53,6 @@ index.js(18,11): error TS8010: Type annotations can only be used in TypeScript f * @type {Host.UserMetrics.Blah} ~~~~ !!! error TS2503: Cannot find namespace 'Host'. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var y = "ok"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt index e3d63583c6..2d268cb5a4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.errors.txt @@ -1,11 +1,8 @@ index.js(10,12): error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? -index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(17,16): error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? -usage.js(12,16): error TS8010: Type annotations can only be used in TypeScript files. -==== usage.js (1 errors) ==== +==== usage.js (0 errors) ==== const { Thing, useThing, cbThing } = require("./index"); useThing(Thing.a); @@ -18,15 +15,13 @@ usage.js(12,16): error TS8010: Type annotations can only be used in TypeScript f cbThing(type => { /** @type {LogEntry} */ - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const logEntry = { time: Date.now(), type, }; }); -==== index.js (4 errors) ==== +==== index.js (2 errors) ==== /** @enum {string} */ const Thing = Object.freeze({ a: "thing", @@ -39,8 +34,6 @@ usage.js(12,16): error TS8010: Type annotations can only be used in TypeScript f * @param {Thing} x ~~~~~ !!! error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function useThing(x) {} @@ -48,8 +41,6 @@ usage.js(12,16): error TS8010: Type annotations can only be used in TypeScript f /** * @param {(x: Thing) => void} x - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? */ diff --git a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt index 3b92affccd..b210254502 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt @@ -1,14 +1,11 @@ /index.ts(1,23): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. /index.ts(3,16): error TS2671: Cannot augment module './test' because it resolves to a non-module entity. /index.ts(11,10): error TS2749: 'Abcde' refers to a value, but is being used as a type here. Did you mean 'typeof Abcde'? -/test.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. -==== /test.js (1 errors) ==== +==== /test.js (0 errors) ==== class Abcde { /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. x; } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt deleted file mode 100644 index 04fe429763..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt +++ /dev/null @@ -1,67 +0,0 @@ -jsFileAlternativeUseOfOverloadTag.js(7,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileAlternativeUseOfOverloadTag.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileAlternativeUseOfOverloadTag.js(25,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileAlternativeUseOfOverloadTag.js(38,7): error TS8017: Signature declarations can only be used in TypeScript files. - - -==== jsFileAlternativeUseOfOverloadTag.js (4 errors) ==== - // These are a few examples of existing alternative uses of @overload tag. - // They will not work as expected with our implementation, but we are - // trying to make sure that our changes do not result in any crashes here. - - const example1 = { - /** - * @overload Example1(value) - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. - * Creates Example1 - * @param value [String] - */ - constructor: function Example1(value, options) {}, - }; - - const example2 = { - /** - * Example 2 - * - * @overload Example2(value) - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. - * Creates Example2 - * @param value [String] - * @param secretAccessKey [String] - * @param sessionToken [String] - * @example Creates with string value - * const example = new Example(''); - * @overload Example2(options) - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. - * Creates Example2 - * @option options value [String] - * @example Creates with options object - * const example = new Example2({ - * value: '', - * }); - */ - constructor: function Example2() {}, - }; - - const example3 = { - /** - * @overload evaluate(options = {}, [callback]) - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. - * Evaluate something - * @note Something interesting - * @param options [map] - * @return [string] returns evaluation result - * @return [null] returns nothing if callback provided - * @callback callback function (error, result) - * If callback is provided it will be called with evaluation result - * @param error [Error] - * @param result [String] - * @see callback - */ - evaluate: function evaluate(options, callback) {}, - }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js index 13ef5bec9b..30fd9c4e05 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js @@ -109,3 +109,16 @@ const example3 = { //// [jsFileAlternativeUseOfOverloadTag.d.ts] export type callback = (error: any, result: any) ; + + +//// [DtsFileErrors] + + +dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected. + + +==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ==== + export type callback = (error: any, result: any) ; + ~ +!!! error TS1005: '=>' expected. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff index 6e8d9cbba7..72bb7b12fe 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff @@ -83,4 +83,17 @@ - * If callback is provided it will be called with evaluation result - */ -type callback = (error: any, result: any) => any; -+export type callback = (error: any, result: any) ; \ No newline at end of file ++export type callback = (error: any, result: any) ; ++ ++ ++//// [DtsFileErrors] ++ ++ ++dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected. ++ ++ ++==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ==== ++ export type callback = (error: any, result: any) ; ++ ~ ++!!! error TS1005: '=>' expected. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.errors.txt deleted file mode 100644 index f3297c29b3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (1 errors) ==== - /** - * @type {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @type {string} - */ - var v; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt index 6a3458a11a..7bb8e3c33b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt @@ -1,49 +1,25 @@ -jsFileFunctionOverloads.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads.js(12,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads.js(27,14): error TS8010: Type annotations can only be used in TypeScript files. jsFileFunctionOverloads.js(29,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -jsFileFunctionOverloads.js(34,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads.js(41,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads.js(48,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads.js(51,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads.js(54,31): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== jsFileFunctionOverloads.js (15 errors) ==== +==== jsFileFunctionOverloads.js (1 errors) ==== /** * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} x * @returns {'number'} */ /** * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} x * @returns {'string'} */ /** * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {boolean} x * @returns {'boolean'} */ /** * @param {unknown} x - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function getTypeName(x) { return typeof x; @@ -52,11 +28,7 @@ jsFileFunctionOverloads.js(54,31): error TS8016: Type assertion expressions can /** * @template T * @param {T} x - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const identity = x => x; ~~~~~~~ @@ -66,8 +38,6 @@ jsFileFunctionOverloads.js(54,31): error TS8016: Type assertion expressions can * @template T * @template U * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {T[]} array * @param {(x: T) => U[]} iterable * @returns {U[]} @@ -75,31 +45,19 @@ jsFileFunctionOverloads.js(54,31): error TS8016: Type assertion expressions can /** * @template T * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {T[][]} array * @returns {T[]} */ /** * @param {unknown[]} array - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(x: unknown) => unknown} iterable - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {unknown[]} - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function flatMap(array, iterable = identity) { /** @type {unknown[]} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const result = []; for (let i = 0; i < array.length; i += 1) { result.push(.../** @type {unknown[]} */(iterable(array[i]))); - ~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. } return result; } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt index d829abbfdf..5c79ce98e6 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt @@ -1,47 +1,23 @@ -jsFileFunctionOverloads2.js(3,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(11,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(25,14): error TS8010: Type annotations can only be used in TypeScript files. jsFileFunctionOverloads2.js(27,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(32,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(37,5): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(41,12): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(42,12): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(43,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(46,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileFunctionOverloads2.js(49,31): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== jsFileFunctionOverloads2.js (15 errors) ==== +==== jsFileFunctionOverloads2.js (1 errors) ==== // Also works if all @overload tags are combined in one comment. /** * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} x * @returns {'number'} * * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} x * @returns {'string'} * * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {boolean} x * @returns {'boolean'} * * @param {unknown} x - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function getTypeName(x) { return typeof x; @@ -50,11 +26,7 @@ jsFileFunctionOverloads2.js(49,31): error TS8016: Type assertion expressions can /** * @template T * @param {T} x - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const identity = x => x; ~~~~~~~ @@ -64,37 +36,23 @@ jsFileFunctionOverloads2.js(49,31): error TS8016: Type assertion expressions can * @template T * @template U * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {T[]} array * @param {(x: T) => U[]} iterable * @returns {U[]} * * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {T[][]} array * @returns {T[]} * * @param {unknown[]} array - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(x: unknown) => unknown} iterable - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {unknown[]} - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function flatMap(array, iterable = identity) { /** @type {unknown[]} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const result = []; for (let i = 0; i < array.length; i += 1) { result.push(.../** @type {unknown[]} */(iterable(array[i]))); - ~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. } return result; } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt deleted file mode 100644 index 93f7034cec..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileImportPreservedWhenUsed.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -index.js(6,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== dash.d.ts (0 errors) ==== - type ObjectIterator = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; - - interface LoDashStatic { - mapValues(obj: T | null | undefined, callback: ObjectIterator): { [P in keyof T]: TResult }; - } - declare const _: LoDashStatic; - export = _; -==== Consts.ts (0 errors) ==== - export const INDEX_FIELD = '__INDEX'; -==== index.js (2 errors) ==== - import * as _ from './dash'; - import { INDEX_FIELD } from './Consts'; - - export class Test { - /** - * @param {object} obj - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {object} vm - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - test(obj, vm) { - let index = 0; - vm.objects = _.mapValues( - obj, - object => ({ ...object, [INDEX_FIELD]: index++ }), - ); - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt index ba633b3e86..90be28a763 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt @@ -1,16 +1,7 @@ jsFileMethodOverloads.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -jsFileMethodOverloads.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileMethodOverloads.js(13,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileMethodOverloads.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileMethodOverloads.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. -jsFileMethodOverloads.js(31,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileMethodOverloads.js(36,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileMethodOverloads.js(40,6): error TS8009: The '?' modifier can only be used in TypeScript files. -jsFileMethodOverloads.js(40,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used in TypeScript files. -==== jsFileMethodOverloads.js (10 errors) ==== +==== jsFileMethodOverloads.js (1 errors) ==== /** ~~~ * @template T @@ -23,8 +14,6 @@ jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used ~~~~~ * @param {T} value ~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~ constructor(value) { @@ -39,8 +28,6 @@ jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used ~~~~~ * @overload ~~~~~~~~~~~~~~ - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {Example} this ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {'number'} @@ -51,8 +38,6 @@ jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used ~~~~~ * @overload ~~~~~~~~~~~~~~ - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {Example} this ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {'string'} @@ -63,8 +48,6 @@ jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used ~~~~~ * @returns {string} ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~ getTypeName() { @@ -81,8 +64,6 @@ jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used ~~~~~~~~~~~~~~~~ * @overload ~~~~~~~~~~~~~~ - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {(y: T) => U} fn ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {U} @@ -93,8 +74,6 @@ jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used ~~~~~ * @overload ~~~~~~~~~~~~~~ - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @returns {T} ~~~~~~~~~~~~~~~~~ */ @@ -103,15 +82,8 @@ jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used ~~~~~ * @param {(y: T) => unknown} [fn] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {unknown} ~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~ transform(fn) { diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt index de0e8c7b33..63e598a9a7 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt @@ -1,16 +1,7 @@ jsFileMethodOverloads2.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -jsFileMethodOverloads2.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileMethodOverloads2.js(14,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileMethodOverloads2.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileMethodOverloads2.js(22,16): error TS8010: Type annotations can only be used in TypeScript files. -jsFileMethodOverloads2.js(30,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileMethodOverloads2.js(34,7): error TS8017: Signature declarations can only be used in TypeScript files. -jsFileMethodOverloads2.js(37,6): error TS8009: The '?' modifier can only be used in TypeScript files. -jsFileMethodOverloads2.js(37,14): error TS8010: Type annotations can only be used in TypeScript files. -jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be used in TypeScript files. -==== jsFileMethodOverloads2.js (10 errors) ==== +==== jsFileMethodOverloads2.js (1 errors) ==== // Also works if all @overload tags are combined in one comment. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** @@ -25,8 +16,6 @@ jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be use ~~~~~ * @param {T} value ~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~ constructor(value) { @@ -41,8 +30,6 @@ jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be use ~~~~~ * @overload ~~~~~~~~~~~~~~ - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {Example} this ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {'number'} @@ -51,8 +38,6 @@ jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be use ~~~~ * @overload ~~~~~~~~~~~~~~ - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {Example} this ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {'string'} @@ -61,8 +46,6 @@ jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be use ~~~~ * @returns {string} ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~ getTypeName() { @@ -79,8 +62,6 @@ jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be use ~~~~~~~~~~~~~~~~ * @overload ~~~~~~~~~~~~~~ - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {(y: T) => U} fn ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @returns {U} @@ -89,23 +70,14 @@ jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be use ~~~~ * @overload ~~~~~~~~~~~~~~ - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @returns {T} ~~~~~~~~~~~~~~~~~ * ~~~~ * @param {(y: T) => unknown} [fn] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {unknown} ~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~ transform(fn) { diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt index 2a0c68a364..edc21e0e06 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads3.errors.txt @@ -1,18 +1,12 @@ /a.js(2,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -/a.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. /a.js(7,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -/a.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. -/a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (6 errors) ==== +==== /a.js (2 errors) ==== /** * @overload ~~~~~~~~ !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} x */ @@ -20,18 +14,12 @@ * @overload ~~~~~~~~ !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} x */ /** * @param {string | number} x - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string | number} - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id(x) { return x; diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.errors.txt deleted file mode 100644 index 8f5dbb85e2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads5.errors.txt +++ /dev/null @@ -1,37 +0,0 @@ -/a.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. -/a.js(8,5): error TS8017: Signature declarations can only be used in TypeScript files. -/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(16,4): error TS8009: The '?' modifier can only be used in TypeScript files. -/a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (5 errors) ==== - /** - * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @param {string} a - * @return {void} - */ - - /** - * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @param {number} a - * @param {number} [b] - * @return {void} - */ - - /** - * @param {string | number} a - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} [b] - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export const foo = function (a, b) { } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.errors.txt deleted file mode 100644 index 6179099634..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocAccessEnumType.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -/b.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.ts (0 errors) ==== - export enum E { A } - -==== /b.js (1 errors) ==== - import { E } from "./a"; - /** @type {E} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const e = E.A; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt index 77e72d7c06..1cc294cbf3 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt @@ -1,67 +1,37 @@ -jsdocArrayObjectPromiseImplicitAny.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(23,13): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. 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(32,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseImplicitAny.js(37,13): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocArrayObjectPromiseImplicitAny.js (14 errors) ==== +==== jsdocArrayObjectPromiseImplicitAny.js (2 errors) ==== /** @type {Array} */ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var anyArray = [5]; /** @type {Array} */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var numberArray = [5]; /** * @param {Array} arr - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Array} - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnAnyArray(arr) { return arr; } /** @type {Promise} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var anyPromise = Promise.resolve(5); /** @type {Promise} */ - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var numberPromise = Promise.resolve(5); /** * @param {Promise} pr - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Promise} - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnAnyPromise(pr) { return pr; } /** @type {Object} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var anyObject = {valueOf: 1}; // not an error since assigning to any. ~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type '() => Object'. @@ -69,17 +39,11 @@ jsdocArrayObjectPromiseImplicitAny.js(37,13): error TS8010: Type annotations can /** @type {Object} */ ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var paramedObject = {valueOf: 1}; /** * @param {Object} obj - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Object} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnAnyObject(obj) { return obj; diff --git a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt index ba87c8a5e2..5940696a86 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt @@ -1,49 +1,29 @@ jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS2314: Generic type 'Array' requires 1 type argument(s). -jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseNoImplicitAny.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS2314: Generic type 'Array' requires 1 type argument(s). -jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS2314: Generic type 'Array' requires 1 type argument(s). -jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). -jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseNoImplicitAny.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). -jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS2314: Generic type 'Promise' requires 1 type argument(s). -jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseNoImplicitAny.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. 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(32,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseNoImplicitAny.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocArrayObjectPromiseNoImplicitAny.js(37,13): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocArrayObjectPromiseNoImplicitAny.js (20 errors) ==== +==== jsdocArrayObjectPromiseNoImplicitAny.js (8 errors) ==== /** @type {Array} */ ~~~~~ !!! error TS2314: Generic type 'Array' requires 1 type argument(s). - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var notAnyArray = [5]; /** @type {Array} */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var numberArray = [5]; /** * @param {Array} arr ~~~~~ !!! error TS2314: Generic type 'Array' requires 1 type argument(s). - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Array} ~~~~~ !!! error TS2314: Generic type 'Array' requires 1 type argument(s). - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnNotAnyArray(arr) { return arr; @@ -52,34 +32,24 @@ jsdocArrayObjectPromiseNoImplicitAny.js(37,13): error TS8010: Type annotations c /** @type {Promise} */ ~~~~~~~ !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var notAnyPromise = Promise.resolve(5); /** @type {Promise} */ - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var numberPromise = Promise.resolve(5); /** * @param {Promise} pr ~~~~~~~ !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Promise} ~~~~~~~ !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnNotAnyPromise(pr) { return pr; } /** @type {Object} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. ~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type '() => Object'. @@ -87,17 +57,11 @@ jsdocArrayObjectPromiseNoImplicitAny.js(37,13): error TS8010: Type annotations c /** @type {Object} */ ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var paramedObject = {valueOf: 1}; /** * @param {Object} obj - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {Object} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function returnNotAnyObject(obj) { return obj; diff --git a/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt index c74e98002d..d8a5fdf957 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocBracelessTypeTag1.errors.txt @@ -1,10 +1,8 @@ index.js(12,14): error TS7006: Parameter 'arg' implicitly has an 'any' type. -index.js(16,11): error TS8010: Type annotations can only be used in TypeScript files. -index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(20,16): error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. -==== index.js (4 errors) ==== +==== index.js (2 errors) ==== /** @type () => string */ function fn1() { return 42; @@ -23,13 +21,9 @@ index.js(20,16): error TS2322: Type '"other"' is not assignable to type '"bar" | } /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const obj1 = { type: "foo", prop: 10 }; /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const obj2 = { type: "other", prop: 10 }; ~~~~ !!! error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. diff --git a/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt index 7aa0ea517b..b3a6719491 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt @@ -1,15 +1,12 @@ -/a.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(8,3): error TS2554: Expected 0 arguments, but got 1. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** * @template T * @callback B */ /** @type {B} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let b; b(); b(1); diff --git a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt index d8741ee681..d5f6e77370 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt @@ -1,9 +1,8 @@ /a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. /a.js(4,13): error TS2314: Generic type 'C' requires 1 type argument(s). -/a.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (3 errors) ==== +==== /a.js (2 errors) ==== /** @template T */ ~~~~~~~~~~~~~~~~~~ class C {} @@ -13,7 +12,5 @@ /** @param {C} p */ ~ !!! error TS2314: Generic type 'C' requires 1 type argument(s). - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(p) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt index b379063415..eef47833f9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt @@ -1,19 +1,13 @@ -/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. /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 - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number | undefined} y - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function Foo(x, y) { if (!(this instanceof Foo)) { diff --git a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt index 455e6373fa..4147bce1d5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocFunctionTypeFalsePositive.errors.txt @@ -1,11 +1,8 @@ -/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. /a.js(1,13): error TS1098: Type parameter list cannot be empty. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** @param {<} x */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~ !!! error TS1098: Type parameter list cannot be empty. function f(x) {} diff --git a/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt index 5c841db181..959e2ee1c0 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt @@ -1,10 +1,9 @@ /a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. /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(6,18): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (4 errors) ==== +==== /a.js (3 errors) ==== class C { /** @template T */ @@ -19,8 +18,6 @@ /** @return {number} */ ~~~~~~ !!! error TS1093: Type annotation cannot appear on a constructor declaration. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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 index 6317bb3a85..ba53f8f4d7 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.errors.txt @@ -1,4 +1,3 @@ -Main.js(2,21): error TS8016: Type assertion expressions can only be used in TypeScript files. Main.js(2,49): error TS2694: Namespace '"GeometryType"' has no exported member 'default'. @@ -8,11 +7,9 @@ Main.js(2,49): error TS2694: Namespace '"GeometryType"' has no exported member ' } export default _default; -==== Main.js (2 errors) ==== +==== Main.js (1 errors) ==== export default function () { return /** @type {import('./GeometryType.js').default} */ ('Point'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~ !!! error TS2694: Namespace '"GeometryType"' has no exported member 'default'. } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.errors.txt deleted file mode 100644 index a4dde98c04..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeResolution.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -usage.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== module.js (0 errors) ==== - export class MyClass { - } - -==== usage.js (1 errors) ==== - /** - * @typedef {Object} options - * @property {import("./module").MyClass} option - */ - /** @type {options} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - let v; \ No newline at end of file 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 0a6294dbe2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocParamTagOnPropertyInitializer.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -/a.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class Foo { - /**@param {string} x */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - m = x => x.toLowerCase(); - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt index 1c2aba3722..1b0b2a8cd2 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocParameterParsingInfiniteLoop.errors.txt @@ -1,15 +1,12 @@ example.js(3,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -example.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -==== example.js (2 errors) ==== +==== 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ let x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt index 8d67fad378..e265271517 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt @@ -1,8 +1,7 @@ /a.js(3,15): error TS2552: Cannot find name 'sting'. Did you mean 'string'? -/a.js(6,13): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** * @typedef MyType * @property {sting} [x] @@ -11,8 +10,6 @@ */ /** @param {MyType} p */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export function f(p) { } ==== /b.js (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt index cd1699ba7a..5db1b60f68 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt @@ -1,12 +1,9 @@ -a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(4,1): error TS2686: 'Puppeteer' refers to a UMD global, but the current file is a module. Consider adding an import instead. -==== a.js (2 errors) ==== +==== a.js (1 errors) ==== const other = require('./other'); /** @type {Puppeteer.Keyboard} */ - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var ppk; Puppeteer.connect; ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt index 14a84ea7f4..220be597bd 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocResolveNameFailureInTypedef.errors.txt @@ -1,12 +1,9 @@ -/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(7,14): error TS2304: Cannot find name 'CantResolveThis'. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** * @param {Ty} x - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(x) {} diff --git a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt index bbfd3a3054..40e75b1fda 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocRestParameter.errors.txt @@ -1,12 +1,9 @@ -/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. /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 */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(a) { a; // number | undefined // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. 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 513fc0e8f0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocRestParameter_es6.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - /** @param {...number} a */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - function f(...a) { - a; // number[] - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt index 01bcefaa58..c104964181 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.errors.txt @@ -1,41 +1,26 @@ -jsdocTypeCast.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocTypeCast.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. jsdocTypeCast.js(6,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. -jsdocTypeCast.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. jsdocTypeCast.js(10,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. -jsdocTypeCast.js(13,16): error TS8010: Type annotations can only be used in TypeScript files. -jsdocTypeCast.js(14,24): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== jsdocTypeCast.js (7 errors) ==== +==== jsdocTypeCast.js (2 errors) ==== /** * @param {string} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(x) { /** @type {'a' | 'b'} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let a = (x); // Error ~ !!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. a; /** @type {'a' | 'b'} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let b = (((x))); // Error ~ !!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. b; /** @type {'a' | 'b'} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let c = /** @type {'a' | 'b'} */ (x); // Ok - ~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. c; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt deleted file mode 100644 index 9b921928ad..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - /** - * @param {Array<*>} list - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function thing(list) { - return list; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt index 6e9bdbe4cd..095a8b3c6b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt @@ -1,27 +1,17 @@ -index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(2,19): error TS2315: Type 'Boolean' is not generic. -index2.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index2.js(2,19): error TS2304: Cannot find name 'Void'. -index3.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index3.js(2,19): error TS2304: Cannot find name 'Undefined'. -index4.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index4.js(2,19): error TS2315: Type 'Function' is not generic. -index5.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index5.js(2,19): error TS2315: Type 'String' is not generic. -index6.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index6.js(2,19): error TS2315: Type 'Number' is not generic. -index7.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index7.js(2,19): error TS2315: Type 'Object' is not generic. 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,12): error TS8010: Type annotations can only be used in TypeScript files. index8.js(4,15): error TS2304: Cannot find name 'T'. -==== index.js (2 errors) ==== +==== index.js (1 errors) ==== /** * @param {(m: Boolean) => string} somebody - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~ !!! error TS2315: Type 'Boolean' is not generic. */ @@ -29,11 +19,9 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. return 'Hello ' + somebody; } -==== index2.js (2 errors) ==== +==== index2.js (1 errors) ==== /** * @param {(m: Void) => string} somebody - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~ !!! error TS2304: Cannot find name 'Void'. */ @@ -42,11 +30,9 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index3.js (2 errors) ==== +==== index3.js (1 errors) ==== /** * @param {(m: Undefined) => string} somebody - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2304: Cannot find name 'Undefined'. */ @@ -55,11 +41,9 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index4.js (2 errors) ==== +==== index4.js (1 errors) ==== /** * @param {(m: Function) => string} somebody - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~ !!! error TS2315: Type 'Function' is not generic. */ @@ -68,11 +52,9 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index5.js (2 errors) ==== +==== index5.js (1 errors) ==== /** * @param {(m: String) => string} somebody - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2315: Type 'String' is not generic. */ @@ -81,11 +63,9 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index6.js (2 errors) ==== +==== index6.js (1 errors) ==== /** * @param {(m: Number) => string} somebody - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2315: Type 'Number' is not generic. */ @@ -94,11 +74,9 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. } -==== index7.js (2 errors) ==== +==== index7.js (1 errors) ==== /** * @param {(m: Object) => string} somebody - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. */ @@ -106,15 +84,13 @@ index8.js(4,15): error TS2304: Cannot find name 'T'. return 'Hello ' + somebody; } -==== index8.js (3 errors) ==== +==== 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 TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'T'. */ diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt deleted file mode 100644 index 1fc29f1c18..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt +++ /dev/null @@ -1,26 +0,0 @@ -test.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. -test.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== test.js (2 errors) ==== - // @ts-check - /** @typedef {number} NotADuplicateIdentifier */ - - (2 * 2); - - /** @typedef {number} AlsoNotADuplicate */ - - (2 * 2) + 1; - - - /** - * - * @param a {NotADuplicateIdentifier} - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param b {AlsoNotADuplicate} - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function makeSureTypedefsAreStillRecognized(a, b) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt deleted file mode 100644 index 609b81fb99..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypedefMissingType.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -/a.js(12,11): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - // Bad: missing a type - /** @typedef T */ - - const t = 0; - - // OK: missing a type, but have property tags. - /** - * @typedef Person - * @property {string} name - */ - - /** @type Person */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const person = { name: "" }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.errors.txt deleted file mode 100644 index 1c04ce3660..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypedef_propertyWithNoType.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -/a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - /** - * @typedef Foo - * @property foo - */ - - /** @type {Foo} */ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const x = { foo: 0 }; - \ 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 8352788abe..0000000000 --- a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. -index.js(10,23): error TS8016: Type assertion expressions can only be used in TypeScript files. - - -==== index.js (4 errors) ==== - /** @type {Map>} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const cache = new Map() - - /** - * @param {string} key - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {() => string} - ~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const getStringGetter = (key) => { - return () => { - return /** @type {string} */ (cache.get(key)) - ~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt index e611537c22..c50bcf83c9 100644 --- a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt @@ -1,13 +1,10 @@ -index.js(3,20): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(12,8): error TS2678: Type '"invalid"' is not comparable to type '"bar" | "foo"'. -==== index.js (2 errors) ==== +==== index.js (1 errors) ==== let value = ""; switch (/** @type {"foo" | "bar"} */ (value)) { - ~~~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. case "bar": value; break; diff --git a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.errors.txt b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.errors.txt index 0f38871554..247aaa31b5 100644 --- a/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/requireOfJsonFileInJsFile.errors.txt @@ -1,20 +1,16 @@ /user.js(2,7): error TS2339: Property 'b' does not exist on type '{ a: number; }'. -/user.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. /user.js(5,7): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. /user.js(9,7): error TS2339: Property 'b' does not exist on type '{ a: number; }'. -/user.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. /user.js(12,7): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. -==== /user.js (6 errors) ==== +==== /user.js (4 errors) ==== const json0 = require("./json.json"); json0.b; // Error (good) ~ !!! error TS2339: Property 'b' does not exist on type '{ a: number; }'. /** @type {{ b: number }} */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const json1 = require("./json.json"); // No error (bad) ~~~~~ !!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. @@ -27,8 +23,6 @@ !!! error TS2339: Property 'b' does not exist on type '{ a: number; }'. /** @type {{ b: number }} */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const js1 = require("./js.js"); // Error (good) ~~~ !!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. diff --git a/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.errors.txt b/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.errors.txt deleted file mode 100644 index a28d718802..0000000000 --- a/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. -file.js(10,23): error TS8016: Type assertion expressions can only be used in TypeScript files. - - -==== file.js (4 errors) ==== - // Don't peek into conditional return expression if it's wrapped in a cast - /** @type {Map} */ - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const sources = new Map(); - /** - - * @param {string=} type the type of source that should be generated - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {String} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function source(type = "javascript") { - return /** @type {String} */ ( - ~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - type - ? sources.get(type) - : sources.get("some other thing") - ); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt index 4ae57460a2..8ff969056a 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt @@ -1,22 +1,18 @@ -a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. 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(13,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (4 errors) ==== +==== a.js (2 errors) ==== /** * @typedef {object} A * @property {number} [value] */ /** @type {A} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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. @@ -28,8 +24,6 @@ a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type */ /** @type {B} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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. 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 22bb3f9e68..0000000000 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -a.js(6,22): error TS8016: Type assertion expressions can only be used in TypeScript files. -a.js(9,22): error TS8016: Type assertion expressions can only be used in TypeScript files. - - -==== a.js (2 errors) ==== - /** - * @typedef Foo - * @property {number} [foo] - */ - - const x = /** @type {Foo} */ ({}); - ~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - x.foo; // number | undefined - - const y = /** @type {Required} */ ({}); - ~~~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - y.foo; // number - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt index c83d18d3df..e97bdfb5ac 100644 --- a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable01.errors.txt @@ -1,4 +1,3 @@ -file1.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -59,10 +58,8 @@ 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 (2 errors) ==== +==== file1.js (1 errors) ==== /** @type {ClassComponent} */ - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const test9 = new C(); ~~~~~ !!! error TS2322: Type 'C' is not assignable to type 'ClassComponent'. diff --git a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.errors.txt b/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.errors.txt deleted file mode 100644 index f5367336f4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/subclassThisTypeAssignable02.errors.txt +++ /dev/null @@ -1,38 +0,0 @@ -file1.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== tile1.ts (0 errors) ==== - interface Lifecycle> { - oninit?(vnode: Vnode): number; - [_: number]: any; - } - - interface Vnode> { - tag: Component; - } - - interface Component> { - view(this: State, vnode: Vnode): number; - } - - interface ClassComponent extends Lifecycle> { - oninit?(vnode: Vnode): number; - view(vnode: Vnode): number; - } - - interface MyAttrs { id: number } - class C implements ClassComponent { - view(v: Vnode) { return 0; } - - // Must declare a compatible-ish index signature or else - // we won't correctly implement ClassComponent. - [_: number]: unknown; - } - - const test8: ClassComponent = new C(); -==== file1.js (1 errors) ==== - /** @type {ClassComponent} */ - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const test9 = new C(); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt index 9c144e6eb8..d752c5ddc4 100644 --- a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt @@ -1,10 +1,8 @@ /a.js(9,26): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. /a.js(15,31): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -/a.js(21,20): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(29,20): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (4 errors) ==== +==== /a.js (2 errors) ==== class Test { constructor() { /** @type {number[]} */ @@ -32,8 +30,6 @@ forEacher() { this.data.forEach( /** @this {Test} */ - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function (d) { console.log(d === this.data.length) }, this) @@ -42,8 +38,6 @@ finder() { this.data.find( /** @this {Test} */ - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function (d) { return d === this.data.length }, this) diff --git a/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.errors.txt b/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.errors.txt deleted file mode 100644 index b5528326fc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/topLevelBlockExpando.errors.txt +++ /dev/null @@ -1,47 +0,0 @@ -check.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== check.ts (0 errors) ==== - // https://github.com/microsoft/TypeScript/issues/31972 - interface Person { - first: string; - last: string; - } - - { - const dice = () => Math.floor(Math.random() * 6); - dice.first = 'Rando'; - dice.last = 'Calrissian'; - const diceP: Person = dice; - } - -==== check.js (1 errors) ==== - // Creates a type { first:string, last: string } - /** - * @typedef {Object} Human - creates a new type named 'SpecialType' - * @property {string} first - a string property of SpecialType - * @property {string} last - a number property of SpecialType - */ - - /** - * @param {Human} param used as a validation tool - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function doHumanThings(param) {} - - const dice1 = () => Math.floor(Math.random() * 6); - // dice1.first = 'Rando'; - dice1.last = 'Calrissian'; - - // doHumanThings(dice) - - // but inside a block... you can't call a human - { - const dice2 = () => Math.floor(Math.random() * 6); - dice2.first = 'Rando'; - dice2.last = 'Calrissian'; - - doHumanThings(dice2) - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.errors.txt deleted file mode 100644 index 1bd8adcb17..0000000000 --- a/testdata/baselines/reference/submodule/compiler/unicodeEscapesInJSDoc.errors.txt +++ /dev/null @@ -1,31 +0,0 @@ -file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== file.js (4 errors) ==== - /** - * @param {number} \u0061 - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} a\u0061 - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo(a, aa) { - console.log(a + aa); - } - - /** - * @param {number} \u{0061} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} a\u{0061} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function bar(a, aa) { - console.log(a + aa); - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/uniqueSymbolJs.errors.txt b/testdata/baselines/reference/submodule/compiler/uniqueSymbolJs.errors.txt index 8cf9a0f7a6..162596d71b 100644 --- a/testdata/baselines/reference/submodule/compiler/uniqueSymbolJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/uniqueSymbolJs.errors.txt @@ -1,21 +1,15 @@ -a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(5,18): error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type. -a.js(5,22): error TS8010: Type annotations can only be used in TypeScript files. a.js(5,23): error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? -==== a.js (4 errors) ==== +==== a.js (2 errors) ==== /** @type {unique symbol} */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const foo = Symbol(); /** @typedef {{ [foo]: boolean }} A */ /** @typedef {{ [key: foo] boolean }} B */ ~~~ !!! error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type. - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt b/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt deleted file mode 100644 index 82bae20398..0000000000 --- a/testdata/baselines/reference/submodule/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -Compilation.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -Compilation.js(7,33): error TS8010: Type annotations can only be used in TypeScript files. - - -==== Compilation.js (2 errors) ==== - // from webpack/lib/Compilation.js and filed at #26427 - /** @param {{ [s: string]: number }} map */ - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - function mappy(map) {} - - export class C { - constructor() { - /** @type {{ [assetName: string]: number}} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - this.assets = {}; - } - m() { - mappy(this.assets) - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt index 433ff9717a..1ae40a0c49 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.errors.txt @@ -1,11 +1,7 @@ -assertionTypePredicates2.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -assertionTypePredicates2.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. -assertionTypePredicates2.js(14,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -assertionTypePredicates2.js(19,16): error TS8010: Type annotations can only be used in TypeScript files. assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. -==== assertionTypePredicates2.js (5 errors) ==== +==== assertionTypePredicates2.js (1 errors) ==== /** * @typedef {{ x: number }} A */ @@ -16,23 +12,15 @@ assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name i /** * @param {A} a - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns { asserts a is B } - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo = (a) => { if (/** @type { B } */ (a).y !== 0) throw TypeError(); - ~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. return undefined; }; export const main = () => { /** @type { A } */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const a = { x: 1 }; foo(a); ~~~ diff --git a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt index 45b3dbf312..7925bfb827 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/assertionsAndNonReturningFunctions.errors.txt @@ -1,22 +1,11 @@ -assertionsAndNonReturningFunctions.js(1,22): error TS8010: Type annotations can only be used in TypeScript files. -assertionsAndNonReturningFunctions.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -assertionsAndNonReturningFunctions.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -assertionsAndNonReturningFunctions.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. -assertionsAndNonReturningFunctions.js(22,14): error TS8010: Type annotations can only be used in TypeScript files. -assertionsAndNonReturningFunctions.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. assertionsAndNonReturningFunctions.js(46,9): error TS7027: Unreachable code detected. -assertionsAndNonReturningFunctions.js(51,12): error TS8010: Type annotations can only be used in TypeScript files. assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code detected. -==== assertionsAndNonReturningFunctions.js (9 errors) ==== +==== assertionsAndNonReturningFunctions.js (2 errors) ==== /** @typedef {(check: boolean) => asserts check} AssertFunc */ - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {AssertFunc} */ - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const assert = check => { if (!check) throw new Error(); } @@ -28,11 +17,7 @@ assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code dete /** * @param {boolean} check - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {asserts check} - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function assert2(check) { if (!check) throw new Error(); @@ -40,8 +25,6 @@ assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code dete /** * @returns {never} - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function fail() { throw new Error(); @@ -49,8 +32,6 @@ assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code dete /** * @param {*} x - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f1(x) { if (!!true) { @@ -75,8 +56,6 @@ assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code dete /** * @param {boolean} b - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f2(b) { switch (b) { diff --git a/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt b/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt index b1623a20e1..6dc5427f14 100644 --- a/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/asyncArrowFunction_allowJs.errors.txt @@ -1,23 +1,16 @@ file.js(2,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(6,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -file.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -file.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -==== file.js (10 errors) ==== +==== 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const a = () => 0 // Error (good) @@ -25,8 +18,6 @@ file.js(21,12): error TS8010: Type annotations can only be used in TypeScript fi ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const b = async () => 0 // No error (bad) @@ -34,8 +25,6 @@ file.js(21,12): error TS8010: Type annotations can only be used in TypeScript fi ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const c = async () => { return 0 } @@ -45,8 +34,6 @@ file.js(21,12): error TS8010: Type annotations can only be used in TypeScript fi ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const d = async () => { return "" } @@ -55,8 +42,6 @@ file.js(21,12): error TS8010: Type annotations can only be used in TypeScript fi ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (p) => {} // Error (good) diff --git a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt index 60a4a4e6fd..edd678f512 100644 --- a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt @@ -1,63 +1,41 @@ -/a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. /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(21,14): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(28,7): error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. Type 'Promise' is not assignable to type 'string'. -/a.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(34,14): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.d.ts (0 errors) ==== declare class Thenable { then(): void; } -==== /a.js (12 errors) ==== +==== /a.js (2 errors) ==== /** * @callback T1 * @param {string} str - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string} */ /** * @callback T2 * @param {string} str - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {Promise} */ /** * @callback T3 * @param {string} str - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {Thenable} */ /** * @param {string} str - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @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'? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const f1 = async str => { return str; } /** @type {T1} */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const f2 = async str => { ~~ !!! error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. @@ -67,26 +45,18 @@ /** * @param {string} str - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {Promise} - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const f3 = async str => { return str; } /** @type {T2} */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const f4 = async str => { return str; } /** @type {T3} */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const f5 = async str => { return str; } diff --git a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt index 199df83367..5a59e1a49e 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt @@ -1,14 +1,10 @@ -mod1.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -use.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. -==== mod1.js (2 errors) ==== +==== mod1.js (1 errors) ==== /** @callback Con - some kind of continuation * @param {object | undefined} error - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {any} I don't even know what this should return */ module.exports = C @@ -18,10 +14,8 @@ use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. this.p = 1 } -==== use.js (2 errors) ==== +==== use.js (1 errors) ==== /** @param {import('./mod1').Con} k */ - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace 'C' has no exported member 'Con'. function f(k) { diff --git a/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt index 6e71f37aab..9b0c649c61 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackOnConstructor.errors.txt @@ -1,16 +1,12 @@ -callbackOnConstructor.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. callbackOnConstructor.js(12,12): error TS2304: Cannot find name 'ValueGetter_2'. -callbackOnConstructor.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -==== callbackOnConstructor.js (3 errors) ==== +==== callbackOnConstructor.js (1 errors) ==== export class Preferences { assignability = "no" /** * @callback ValueGetter_2 * @param {string} name - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean|number|string|undefined} */ constructor() {} @@ -20,7 +16,5 @@ callbackOnConstructor.js(12,12): error TS8010: Type annotations can only be used /** @type {ValueGetter_2} */ ~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'ValueGetter_2'. - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var ooscope2 = s => s.length > 0 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt deleted file mode 100644 index d038d2a366..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -cb.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -cb.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -cb.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -cb.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== cb.js (4 errors) ==== - /** @callback Sid - * @param {string} s - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {string} What were you expecting - */ - var x = 1 - - /** @type {Sid} smallId */ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var sid = s => s + "!"; - - - /** @type {NoReturn} */ - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var noreturn = obj => void obj.title - - /** - * @callback NoReturn - * @param {{ e: number, m: number, title: string }} s - Knee deep, shores, etc - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt index 1e4a502f9e..2dbccc172d 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt @@ -1,34 +1,20 @@ -cb.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -cb.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -cb.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. -cb.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. -cb.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. -cb.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. -cb.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. -cb.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. -==== cb.js (9 errors) ==== +==== cb.js (1 errors) ==== /** @template T * @callback Id * @param {T} t - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} Maybe just return 120 and cast it? */ var x = 1 /** @type {Id} I actually wanted to write `const "120"` */ - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var one_twenty = s => "120"; /** @template S * @callback SharedId * @param {S} ego - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {S} */ class SharedClass { @@ -40,27 +26,17 @@ cb.js(33,12): error TS8010: Type annotations can only be used in TypeScript file } } /** @type {SharedId} */ - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var outside = n => n + 1; /** @type {Final<{ fantasy }, { heroes }>} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var noreturn = (barts, tidus, noctis) => "cecil" /** * @template V,X * @callback Final * @param {V} barts - "Barts" - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {X} tidus - Titus - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {X & V} noctis - "Prince Noctis Lucius Caelum" - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {"cecil" | "zidane"} */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt deleted file mode 100644 index 7a623fc91d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -cb.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== cb.js (1 errors) ==== - /** @callback Miracle - * @returns {string} What were you expecting - */ - /** @type {Miracle} smallId */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var sid = () => "!"; - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt deleted file mode 100644 index e954de0262..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (4 errors) ==== - /** - * @callback C - * @this {{ a: string, b: number }} - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} b - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {boolean} - */ - - /** @type {C} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const cb = function (a, b) { - this - return true - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagNamespace.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTagNamespace.errors.txt deleted file mode 100644 index 4e2173acbd..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackTagNamespace.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -namespaced.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -namespaced.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== namespaced.js (2 errors) ==== - /** - * @callback NS.Nested.Inner - * @param {Object} space - spaaaaaaaaace - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {Object} peace - peaaaaaaaaace - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {string | number} - */ - var x = 1; - /** @type {NS.Nested.Inner} */ - function f(space, peace) { - return '1' - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt deleted file mode 100644 index f80630c317..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt +++ /dev/null @@ -1,31 +0,0 @@ -cb_nested.js(4,4): error TS8010: Type annotations can only be used in TypeScript files. -cb_nested.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -cb_nested.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== cb_nested.js (3 errors) ==== - /** - * @callback WorksWithPeopleCallback - * @param {Object} person - * @param {string} person.name - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {number} [person.age] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {void} - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - - /** - * For each person, calls your callback. - * @param {WorksWithPeopleCallback} callback - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {void} - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function eachPerson(callback) { - callback({ name: "Empty" }); - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt index bd5c4a55ea..b6e60aa623 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt @@ -1,20 +1,14 @@ -callbackTagVariadicType.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -callbackTagVariadicType.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. callbackTagVariadicType.js(9,18): error TS2554: Expected 1 arguments, but got 2. -==== callbackTagVariadicType.js (3 errors) ==== +==== callbackTagVariadicType.js (1 errors) ==== /** * @callback Foo * @param {...string} args - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number} */ /** @type {Foo} */ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const x = () => 1 var res = x('a', 'b') ~~~ diff --git a/testdata/baselines/reference/submodule/conformance/chainedPrototypeAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/chainedPrototypeAssignment.errors.txt index df7b1cc637..54fcff7501 100644 --- a/testdata/baselines/reference/submodule/conformance/chainedPrototypeAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/chainedPrototypeAssignment.errors.txt @@ -1,4 +1,3 @@ -mod.js(11,17): error TS8010: Type annotations can only be used in TypeScript files. use.js(3,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. use.js(4,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. @@ -18,7 +17,7 @@ use.js(4,9): error TS7009: 'new' expression, whose target lacks a construct sign ==== types.d.ts (0 errors) ==== declare function require(name: string): any; declare var exports: any; -==== mod.js (1 errors) ==== +==== mod.js (0 errors) ==== /// var A = function A() { this.a = 1 @@ -30,8 +29,6 @@ use.js(4,9): error TS7009: 'new' expression, whose target lacks a construct sign exports.B = B A.prototype = B.prototype = { /** @param {number} n */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. m(n) { return n + 1 } diff --git a/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignProperty.errors.txt index 415c04b63f..db9ca448b3 100644 --- a/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignProperty.errors.txt @@ -1,19 +1,15 @@ -index.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(4,19): error TS2306: File 'mod1.js' is not a module. -index.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(9,19): error TS2306: File 'mod2.js' is not a module. mod1.js(1,23): error TS2304: Cannot find name 'exports'. mod1.js(2,23): error TS2304: Cannot find name 'exports'. mod1.js(3,23): error TS2304: Cannot find name 'exports'. mod1.js(4,23): error TS2304: Cannot find name 'exports'. mod1.js(5,23): error TS2304: Cannot find name 'exports'. -mod1.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. mod2.js(1,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. mod2.js(2,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. mod2.js(3,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. mod2.js(4,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. mod2.js(5,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -mod2.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. validator.ts(3,21): error TS2306: File 'mod1.js' is not a module. validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. @@ -65,7 +61,7 @@ validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. m2.rwAccessors = "no"; m2.setonlyAccessor = 0; -==== mod1.js (6 errors) ==== +==== mod1.js (5 errors) ==== Object.defineProperty(exports, "thing", { value: 42, writable: true }); ~~~~~~~ !!! error TS2304: Cannot find name 'exports'. @@ -82,14 +78,12 @@ validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. ~~~~~~~ !!! error TS2304: Cannot find name 'exports'. /** @param {string} str */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } }); -==== mod2.js (6 errors) ==== +==== mod2.js (5 errors) ==== Object.defineProperty(module.exports, "thing", { value: "yes", writable: true }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -106,18 +100,14 @@ validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @param {string} str */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } }); -==== index.js (4 errors) ==== +==== index.js (2 errors) ==== /** * @type {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const q = require("./mod1").thing; ~~~~~~~~ @@ -125,8 +115,6 @@ validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. /** * @type {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const u = require("./mod2").thing; ~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt index 4b4f0824b7..15c06af9b4 100644 --- a/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt @@ -1,6 +1,4 @@ -mod1.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. mod1.js(6,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -mod1.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. validator.ts(5,12): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. @@ -32,12 +30,10 @@ validator.ts(5,12): error TS7009: 'new' expression, whose target lacks a constru m1.setonlyAccessor = 0; -==== mod1.js (3 errors) ==== +==== mod1.js (1 errors) ==== /** * @constructor * @param {string} name - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Person(name) { this.name = name; @@ -53,8 +49,6 @@ validator.ts(5,12): error TS7009: 'new' expression, whose target lacks a constru Object.defineProperty(Person.prototype, "readonlyAccessor", { get() { return 21.75 } }); Object.defineProperty(Person.prototype, "setonlyAccessor", { /** @param {string} str */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt index 5cd4a951fc..b29c988e17 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocOptionalParamOrder.errors.txt @@ -1,25 +1,12 @@ -0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. -0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(7,20): error TS1016: A required parameter cannot follow an optional parameter. -==== 0.js (5 errors) ==== +==== 0.js (1 errors) ==== // @ts-check /** * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} [b] - ~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} c - ~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function foo(a, b, c) {} ~ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt deleted file mode 100644 index 378fed3054..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -0.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. -0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. -0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== 0.js (5 errors) ==== - // @ts-check - /** - * @param {number=} n - ~~~~~~~~~~~~~~~~~~ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} [s] - ~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - var x = function foo(n, s) {} - var y; - /** - * @param {boolean!} b - */ - y = function bar(b) {} - - /** - * @param {string} s - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - var one = function (s) { }, two = function (untyped) { }; - \ No newline at end of file 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 db9e3ee341..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocParamTag1.errors.txt +++ /dev/null @@ -1,26 +0,0 @@ -0.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. -0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. -0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== 0.js (4 errors) ==== - // @ts-check - /** - * @param {number=} n - ~~~~~~~~~~~~~~~~~~ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} [s] - ~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo(n, s) {} - - foo(); - foo(1); - foo(1, "hi"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.errors.txt index 01aae892fd..47f1a3209d 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag1.errors.txt @@ -1,15 +1,10 @@ -returns.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. -returns.js(10,14): error TS8010: Type annotations can only be used in TypeScript files. -returns.js(17,14): error TS8010: Type annotations can only be used in TypeScript files. returns.js(20,12): error TS2872: This kind of expression is always truthy. -==== returns.js (4 errors) ==== +==== returns.js (1 errors) ==== // @ts-check /** * @returns {string} This comment is not currently exposed - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f() { return "hello"; @@ -17,8 +12,6 @@ returns.js(20,12): error TS2872: This kind of expression is always truthy. /** * @returns {string=} This comment is not currently exposed - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f1() { return "hello world"; @@ -26,8 +19,6 @@ returns.js(20,12): error TS2872: This kind of expression is always truthy. /** * @returns {string|number} This comment is not currently exposed - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f2() { return 5 || "hello"; diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt index f4ff7b544b..c5ab204ed8 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocReturnTag2.errors.txt @@ -1,17 +1,13 @@ -returns.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. returns.js(6,5): error TS2322: Type 'number' is not assignable to type 'string'. -returns.js(10,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (5 errors) ==== +==== returns.js (3 errors) ==== // @ts-check /** * @returns {string} This comment is not currently exposed - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f() { return 5; @@ -21,8 +17,6 @@ returns.js(13,12): error TS2872: This kind of expression is always truthy. /** * @returns {string | number} This comment is not currently exposed - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f1() { return 5 || true; diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt index 50cf3ee028..501d8cad97 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.errors.txt @@ -1,20 +1,9 @@ -/a.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(20,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -/a.js(21,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(21,44): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. -/a.js(22,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(22,38): error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. -/a.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(25,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -/a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(28,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -/a.js(29,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -/a.js(30,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -/a.js(31,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(31,49): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. -==== /a.js (14 errors) ==== +==== /a.js (3 errors) ==== /** * @typedef {Object} T1 * @property {number} a @@ -27,8 +16,6 @@ /** * @typedef {(x: string) => string} T3 - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** @@ -37,42 +24,22 @@ */ const t1 = /** @satisfies {T1} */ ({ a: 1 }); - ~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); - ~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ~ !!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. const t3 = /** @satisfies {T1} */ ({}); - ~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ~ !!! error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. !!! related TS2728 /a.js:3:23: 'a' is declared here. /** @type {T2} */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const t4 = /** @satisfies {T2} */ ({ a: "a" }); - ~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. /** @type {(m: string) => string} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const t5 = /** @satisfies {T3} */((m) => m.substring(0)); - ~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. const t6 = /** @satisfies {[number, number]} */ ([1, 2]); - ~~~~~~~~~~~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. const t7 = /** @satisfies {T4} */ ({ a: 'test' }); - ~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); - ~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ~ !!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt index 3bbbbcf766..4b23f0cb68 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt @@ -1,14 +1,11 @@ -/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. -==== /a.js (3 errors) ==== +==== /a.js (2 errors) ==== /** @typedef {"a" | "b" | "c" | "d"} Keys */ const p = /** @satisfies {Partial>} */ ({ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.errors.txt deleted file mode 100644 index 819418995f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -/a.js(20,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - /** - * @typedef {Object} T1 - * @property {number} a - */ - - /** - * @typedef {Object} T2 - * @property {number} a - */ - - /** - * @satisfies {T1} - * @satisfies {T2} - */ - const t1 = { a: 1 }; - - /** - * @satisfies {number} - */ - const t2 = /** @satisfies {number} */ (1); - ~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.errors.txt deleted file mode 100644 index 2e6505907f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -/a.js(10,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - /** - * @typedef {Object} T1 - * @property {number} a - */ - - /** - * @satisfies T1 - */ - const t1 = { a: 1 }; - const t2 = /** @satisfies T1 */ ({ a: 1 }); - ~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt index 105399008c..c3c65f4fb8 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt @@ -1,21 +1,15 @@ /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,34): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -==== /a.js (4 errors) ==== +==== /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. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const p = /** @satisfies {Predicates} */ ({ - ~~~~~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1 }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt index 99553fbb9c..bb8cbbe319 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt @@ -1,16 +1,9 @@ -/a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(2,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(3,7): error TS7006: Parameter 's' implicitly has an 'any' type. -/a.js(8,17): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -==== /a.js (4 errors) ==== +==== /a.js (1 errors) ==== /** @type {{ f(s: string): void } & Record }} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. f(s) { }, // "incorrect" implicit any on 's' ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. @@ -19,6 +12,4 @@ // This needs to not crash (outer node is not expression) /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt index 56579a341a..17573f218b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.errors.txt @@ -1,26 +1,20 @@ -/a.js(5,32): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(5,43): error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. -/b.js(6,32): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** * @typedef {Object} Foo * @property {number} a */ export default /** @satisfies {Foo} */ ({}); - ~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. ~ !!! error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. !!! related TS2728 /a.js:3:23: 'a' is declared here. -==== /b.js (1 errors) ==== +==== /b.js (0 errors) ==== /** * @typedef {Object} Foo * @property {number} a */ - export default /** @satisfies {Foo} */ ({ a: 1 }); - ~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. \ No newline at end of file + export default /** @satisfies {Foo} */ ({ a: 1 }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.errors.txt deleted file mode 100644 index bea5a7f98f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -/a.js(1,31): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(3,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files. - - -==== /a.js (2 errors) ==== - /** @typedef {{ move(distance: number): void }} Movable */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - - const car = /** @satisfies {Movable & Record} */ ({ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - start() { }, - move(d) { - // d should be number - }, - stop() { } - }) - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt index 419811ba64..81d15c6038 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt @@ -1,8 +1,7 @@ -/a.js(8,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(14,11): error TS2339: Property 'y' does not exist on type '{ x: number; }'. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** * @typedef {Object} Point2d * @property {number} x @@ -11,8 +10,6 @@ // Undesirable behavior today with type annotation const a = /** @satisfies {Partial} */ ({ x: 10 }); - ~~~~~~~~~~~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. // Should OK console.log(a.x.toFixed()); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt index 6027645310..509ca8498b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt @@ -1,14 +1,11 @@ -/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. -==== /a.js (3 errors) ==== +==== /a.js (2 errors) ==== /** @typedef {"a" | "b" | "c" | "d"} Keys */ const p = /** @satisfies {Record} */ ({ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt index d244830f7a..cc59dca024 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt @@ -1,9 +1,8 @@ /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(4,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -==== /a.js (3 errors) ==== +==== /a.js (2 errors) ==== /** @typedef {Object.} Facts */ ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. @@ -12,8 +11,6 @@ // Should be able to detect a failure here const x = /** @satisfies {Facts} */ ({ - ~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. m: true, s: "false" }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt index 4d80f8a161..41ef78bd24 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.errors.txt @@ -1,8 +1,7 @@ -/a.js(9,40): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(11,26): error TS2353: Object literal may only specify known properties, and 'd' does not exist in type 'Color'. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** * @typedef {Object} Color * @property {number} r @@ -12,8 +11,6 @@ // All of these should be Colors, but I only use some of them here. export const Palette = /** @satisfies {Record} */ ({ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' ~ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt index 2ee8c3fe3d..beeb1723a4 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag1.errors.txt @@ -1,46 +1,26 @@ -0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(20,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -0.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(24,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -0.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(28,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -0.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(33,11): error TS8010: Type annotations can only be used in TypeScript files. -0.js(38,11): error TS8010: Type annotations can only be used in TypeScript files. 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 (14 errors) ==== +==== 0.js (4 errors) ==== // @ts-check /** @type {String} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var S = "hello world"; /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = 10; /** @type {*} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var anyT = 2; anyT = "hello"; /** @type {?} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var anyT1 = 2; anyT1 = "hi"; /** @type {Function} */ - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const x = (a) => a + 1; x(1); @@ -48,8 +28,6 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const y = (a) => a + 1; y(1); @@ -57,8 +35,6 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const x1 = (a) => a + 1; x1(0); @@ -66,22 +42,16 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const x2 = (a) => a + 1; x2(0); /** * @type {object} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var props = {}; /** * @type {Object} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var props = {}; ~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt index 0037830996..76933dc06a 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag2.errors.txt @@ -1,30 +1,19 @@ -0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(3,5): error TS2322: Type 'boolean' is not assignable to type 'String'. -0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. 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(8,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(12,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -0.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -0.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(23,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -0.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (13 errors) ==== +==== 0.js (6 errors) ==== // @ts-check /** @type {String} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var S = true; ~ !!! error TS2322: Type 'boolean' is not assignable to type 'String'. /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = "hello"; ~ !!! error TS2322: Type 'string' is not assignable to type 'number'. @@ -33,8 +22,6 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const x1 = (a) => a + 1; x1("string"); @@ -42,13 +29,9 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const x2 = (a) => a + 1; /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var a; a = x2(0); @@ -56,8 +39,6 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const x3 = (a) => a.concat("hi"); x3(0); @@ -65,7 +46,5 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const x4 = (a) => a + 1; x4(0); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.errors.txt deleted file mode 100644 index 9c9c1482a7..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag3.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -test.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== test.js (1 errors) ==== - /** @type {Array} */ - ~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var nns; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt index 34fe05424b..6735c424bd 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt @@ -1,26 +1,20 @@ -test.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(5,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. -test.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (4 errors) ==== +==== test.js (2 errors) ==== /** Also should error for jsdoc typedefs * @template {string} U * @typedef {{ b: U }} B */ /** @type {A} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'string'. var a; /** @type {B} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'string'. var b; diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt index 4c6ab8cfea..285e2ac7c4 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt @@ -1,37 +1,24 @@ -test.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(5,14): error TS2322: Type 'number' is not assignable to type 'string'. -test.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. 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(11,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(12,14): error TS2322: Type 'number' is not assignable to type 'string'. -test.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. 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(17,18): error TS8010: Type annotations can only be used in TypeScript files. -test.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(24,5): error TS2322: Type 'number' is not assignable to type '0 | 1 | 2'. -test.js(26,19): error TS8010: Type annotations can only be used in TypeScript files. -test.js(26,39): error TS8010: Type annotations can only be used in TypeScript files. -test.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (15 errors) ==== +==== 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} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var g = function (x) { return x } ~ !!! error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. @@ -40,15 +27,11 @@ test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. /** @type {{ (x: number): string }} */ function i(x) { return x } /** @type {{ (x: number): string }} */ - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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 }} */ - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var k = function (x) { return x } ~ !!! error TS2322: Type '(x: number) => number' is not assignable to type '(x: number) => string'. @@ -56,25 +39,17 @@ test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Argle} */ function blargle(s) { return 0; } /** @type {0 | 1 | 2} - assignment should not error */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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 */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Gioconda} */ function monaLisa(sb) { @@ -82,8 +57,6 @@ test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. } /** @type {2 | 3} - overloads are not supported, so there will be an error */ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var twothree = monaLisa(false); ~~~~~~~~ !!! error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt index 5728863037..34a62935d5 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag6.errors.txt @@ -1,22 +1,17 @@ -test.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. test.js(7,5): error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. -test.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. 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(29,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (6 errors) ==== +==== test.js (3 errors) ==== /** @type {number} */ function f() { return 1 } /** @type {{ prop: string }} */ - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var g = function (prop) { ~ !!! error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. @@ -39,16 +34,12 @@ test.js(30,7): error TS2322: Type '(more: any) => void' is not assignable to typ function funcWithMoreParameters(more) {} // error /** @type {() => void} */ - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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} */ - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const arrowWithMoreParameters = (more) => {}; // error ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag7.errors.txt deleted file mode 100644 index d55ab67029..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag7.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -test.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. -test.js(2,28): error TS8010: Type annotations can only be used in TypeScript files. - - -==== test.js (2 errors) ==== - /** - * @typedef {(a: string, b: number) => void} Foo - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - - class C { - /** @type {Foo} */ - foo(a, b) {} - - /** @type {(optional?) => void} */ - methodWithOptionalParameters() {} - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag8.errors.txt index 7edae23af4..0003987b1f 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag8.errors.txt @@ -1,14 +1,11 @@ -index.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. index.js(4,20): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. -==== index.js (2 errors) ==== +==== index.js (1 errors) ==== // https://github.com/microsoft/TypeScript/issues/57953 /** * @param {Number|BigInt} n - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. */ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt index b35214d3bd..0eb1d13321 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt @@ -1,11 +1,9 @@ 0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string'. 0.js(10,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? 0.js(12,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -0.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (5 errors) ==== +==== 0.js (3 errors) ==== // @ts-check var lol; const obj = { @@ -32,11 +30,7 @@ } lol = "string" /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var s = obj.method1(0); /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var s1 = obj.method2("0"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt deleted file mode 100644 index 9ffb5fb668..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt +++ /dev/null @@ -1,55 +0,0 @@ -0.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== 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 - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo(opts) { - opts.x; - } - - foo({x: 'abc'}); - - /** - * @typedef {Object} AnotherOpts - * @property anotherX {string} - * @property anotherY {string=} - * - * @param {AnotherOpts} opts - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo1(opts) { - opts.anotherX; - } - - foo1({anotherX: "world"}); - - /** - * @typedef {object} Opts1 - * @property {string} x - * @property {string=} y - * @property {string} [z] - * @property {string} [w="hi"] - * - * @param {Opts1} opts - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo2(opts) { - opts.x; - } - foo2({x: 'abc'}); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt index 7b4ffa2e5c..7cb22b9170 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt @@ -1,10 +1,9 @@ 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(10,12): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (4 errors) ==== +==== 0.js (3 errors) ==== // @ts-check var exports = {}; @@ -21,7 +20,5 @@ /** @type {exports.SomeName} */ ~~~~~~~ !!! error TS2503: Cannot find namespace 'exports'. - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const myString = 'str'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkObjectDefineProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/checkObjectDefineProperty.errors.txt index 4ec82ca6fb..26d070eca5 100644 --- a/testdata/baselines/reference/submodule/conformance/checkObjectDefineProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkObjectDefineProperty.errors.txt @@ -1,13 +1,6 @@ -index.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(19,10): error TS2741: Property 'name' is missing in type '{}' but required in type '{ name: string; }'. -index.js(21,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(23,11): error TS2339: Property 'zip' does not exist on type '{}'. -index.js(26,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(28,11): error TS2339: Property 'houseNumber' does not exist on type '{}'. -index.js(33,29): error TS8016: Type assertion expressions can only be used in TypeScript files. -index.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(38,12): error TS8010: Type annotations can only be used in TypeScript files. validate.ts(3,3): error TS2339: Property 'name' does not exist on type '{}'. validate.ts(4,3): error TS2339: Property 'middleInit' does not exist on type '{}'. validate.ts(5,3): error TS2339: Property 'lastName' does not exist on type '{}'. @@ -68,7 +61,7 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ ~~~~~~~~~~ !!! error TS2339: Property 'middleInit' does not exist on type '{}'. -==== index.js (10 errors) ==== +==== index.js (3 errors) ==== const x = {}; Object.defineProperty(x, "name", { value: "Charles", writable: true }); Object.defineProperty(x, "middleInit", { value: "H" }); @@ -77,8 +70,6 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ Object.defineProperty(x, "houseNumber", { get() { return 21.75 } }); Object.defineProperty(x, "zipStr", { /** @param {string} str */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.zip = Number(str) } @@ -86,8 +77,6 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ /** * @param {{name: string}} named - ~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function takeName(named) { return named.name; } @@ -97,8 +86,6 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ !!! related TS2728 index.js:15:13: 'name' is declared here. /** * @type {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var a = x.zip; ~~~ @@ -106,8 +93,6 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ /** * @type {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var b = x.houseNumber; ~~~~~~~~~~~ @@ -117,17 +102,11 @@ validate.ts(17,3): error TS2339: Property 'middleInit' does not exist on type '{ const needsExemplar = (_ = x) => void 0; const expected = /** @type {{name: string, readonly middleInit: string, readonly lastName: string, zip: number, readonly houseNumber: number, zipStr: string}} */(/** @type {*} */(null)); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** * * @param {typeof returnExemplar} a - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof needsExemplar} b - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function match(a, b) {} diff --git a/testdata/baselines/reference/submodule/conformance/checkOtherObjectAssignProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/checkOtherObjectAssignProperty.errors.txt index d705696e41..b339a4e9ee 100644 --- a/testdata/baselines/reference/submodule/conformance/checkOtherObjectAssignProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkOtherObjectAssignProperty.errors.txt @@ -1,7 +1,5 @@ importer.js(1,21): error TS2306: File 'mod1.js' is not a module. mod1.js(2,23): error TS2304: Cannot find name 'exports'. -mod1.js(5,11): error TS8010: Type annotations can only be used in TypeScript files. -mod1.js(7,22): error TS8016: Type assertion expressions can only be used in TypeScript files. mod1.js(8,23): error TS2304: Cannot find name 'exports'. mod1.js(11,23): error TS2304: Cannot find name 'exports'. mod1.js(14,23): error TS2304: Cannot find name 'exports'. @@ -28,7 +26,7 @@ mod1.js(16,23): error TS2304: Cannot find name 'exports'. mod.bad2 = 0; mod.bad3 = 0; -==== mod1.js (8 errors) ==== +==== mod1.js (6 errors) ==== const obj = { value: 42, writable: true }; Object.defineProperty(exports, "thing", obj); ~~~~~~~ @@ -36,12 +34,8 @@ mod1.js(16,23): error TS2304: Cannot find name 'exports'. /** * @type {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ let str = /** @type {string} */("other"); - ~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. Object.defineProperty(exports, str, { value: 42, writable: true }); ~~~~~~~ !!! error TS2304: Cannot find name 'exports'. diff --git a/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt b/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt index 13dca913e1..b5466ed2eb 100644 --- a/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkSpecialPropertyAssignments.errors.txt @@ -1,20 +1,14 @@ -bug24252.js(4,20): error TS8010: Type annotations can only be used in TypeScript files. -bug24252.js(6,20): error TS8010: Type annotations can only be used in TypeScript files. bug24252.js(8,9): error TS2322: Type 'string[]' is not assignable to type 'number[]'. Type 'string' is not assignable to type 'number'. -==== bug24252.js (3 errors) ==== +==== bug24252.js (1 errors) ==== var A = {}; A.B = class { m() { /** @type {string[]} */ - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x = []; /** @type {number[]} */ - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var y; y = x; ~ diff --git a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt index a927e4935d..193de9fab6 100644 --- a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt @@ -1,12 +1,8 @@ -first.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. -first.js(27,16): error TS8010: Type annotations can only be used in TypeScript files. first.js(27,21): error TS8020: JSDoc types can only be used inside documentation comments. -first.js(28,16): error TS8010: Type annotations can only be used in TypeScript files. first.js(44,4): error TS2339: Property 'numberOxen' does not exist on type 'Sql'. first.js(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. generic.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -generic.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. generic.js(9,22): error TS8011: Type arguments can only be used in TypeScript files. 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'. @@ -18,12 +14,10 @@ second.ts(14,25): error TS2507: Type '{ (numberOxen: number): void; circle: (wag second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== first.js (7 errors) ==== +==== first.js (4 errors) ==== /** * @constructor * @param {number} numberOxen - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Wagon(numberOxen) { this.numberOxen = numberOxen @@ -50,13 +44,9 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con } /** * @param {Array.} files - ~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. * @param {"csv" | "json" | "xmlolololol"} format - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * This is not assignable, so should have a type error */ load(files, format) { @@ -117,15 +107,13 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con ~~~~~~~~~~ !!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (8 errors) ==== +==== generic.js (7 errors) ==== /** ~~~ * @template T ~~~~~~~~~~~~~~ * @param {T} flavour ~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function Soup(flavour) { diff --git a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.errors.txt index b777eed4c2..9702659e53 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.errors.txt @@ -1,16 +1,13 @@ bug43713.js(1,9): error TS2305: Module '"./commonJSAliasedExport"' has no exported member 'funky'. -bug43713.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. commonJSAliasedExport.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. commonJSAliasedExport.js(7,16): error TS2339: Property 'funky' does not exist on type '(ast: any) => any'. -==== bug43713.js (2 errors) ==== +==== bug43713.js (1 errors) ==== const { funky } = require('./commonJSAliasedExport'); ~~~~~ !!! error TS2305: Module '"./commonJSAliasedExport"' has no exported member 'funky'. /** @type {boolean} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var diddy var diddy = funky(1) diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt index 86c5a0bc37..c197d18d54 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.errors.txt @@ -1,14 +1,11 @@ main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? -main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -==== main.js (2 errors) ==== +==== main.js (1 errors) ==== const { K } = require("./mod1"); /** @param {K} k */ ~ !!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(k) { k.values() } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt index 67b4896a77..6b47881065 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.errors.txt @@ -1,14 +1,11 @@ main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? -main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -==== main.js (2 errors) ==== +==== main.js (1 errors) ==== const { K } = require("./mod1"); /** @param {K} k */ ~ !!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(k) { k.values() } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt index a7631a2d1c..109a57b0b7 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.errors.txt @@ -1,14 +1,11 @@ main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? -main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -==== main.js (2 errors) ==== +==== main.js (1 errors) ==== const { K } = require("./mod1"); /** @param {K} k */ ~ !!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(k) { k.values() } diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt index e9f9548286..b4eefc5d4f 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt @@ -1,22 +1,16 @@ constructorFunctionMethodTypeParameters.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -constructorFunctionMethodTypeParameters.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. constructorFunctionMethodTypeParameters.js(19,30): error TS8004: Type parameter declarations can only be used in TypeScript files. constructorFunctionMethodTypeParameters.js(22,16): error TS2304: Cannot find name 'T'. -constructorFunctionMethodTypeParameters.js(22,16): error TS8010: Type annotations can only be used in TypeScript files. -constructorFunctionMethodTypeParameters.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find name 'T'. -constructorFunctionMethodTypeParameters.js(24,17): error TS8010: Type annotations can only be used in TypeScript files. -==== constructorFunctionMethodTypeParameters.js (8 errors) ==== +==== constructorFunctionMethodTypeParameters.js (4 errors) ==== /** ~~~ * @template {string} T ~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} t ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function Cls(t) { @@ -47,18 +41,12 @@ constructorFunctionMethodTypeParameters.js(24,17): error TS8010: Type annotation ~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} u ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} ~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ function (t, u) { diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorFunctions.errors.txt index 4b88dc27f2..5f9dbe9c67 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctions.errors.txt @@ -6,11 +6,10 @@ index.js(19,39): error TS2350: Only a void function can be called with the 'new' index.js(23,15): error TS2350: Only a void function can be called with the 'new' keyword. index.js(27,39): error TS2350: Only a void function can be called with the 'new' keyword. index.js(31,15): error TS2350: Only a void function can be called with the 'new' keyword. -index.js(51,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(55,13): error TS2554: Expected 1 arguments, but got 0. -==== index.js (10 errors) ==== +==== index.js (9 errors) ==== function C1() { if (!(this instanceof C1)) return new C1(); ~~~~~~~~ @@ -78,8 +77,6 @@ index.js(55,13): error TS2554: Expected 1 arguments, but got 0. /** * @constructor * @param {number} num - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function C7(num) {} diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt index c04db7e412..0744aa6348 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctionsStrict.errors.txt @@ -1,14 +1,10 @@ -a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. a.js(8,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -a.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. 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 */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function C(x) { this.x = x } @@ -22,8 +18,6 @@ a.js(20,9): error TS7009: 'new' expression, whose target lacks a construct signa c.y = undefined // ok /** @param {number} x */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function A(x) { if (!(this instanceof A)) { return new A(x) diff --git a/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.errors.txt deleted file mode 100644 index 94aa8c76e0..0000000000 --- a/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -classthisboth.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. - - -==== classthisboth.js (1 errors) ==== - /** - * @class - * @this {{ e: number, m: number }} - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * this-tag should win, both 'e' and 'm' should be defined. - */ - function C() { - this.e = this.m + 1 - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.errors.txt b/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.errors.txt deleted file mode 100644 index 01b19be75d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/contextualTypeFromJSDoc.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. -index.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (3 errors) ==== - /** @type {Array<[string, {x?:number, y?:number}]>} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const arr = [ - ['a', { x: 1 }], - ['b', { y: 2 }] - ]; - - /** @return {Array<[string, {x?:number, y?:number}]>} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - function f() { - return [ - ['a', { x: 1 }], - ['b', { y: 2 }] - ]; - } - - class C { - /** @param {Array<[string, {x?:number, y?:number}]>} value */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - set x(value) { } - get x() { - return [ - ['a', { x: 1 }], - ['b', { y: 2 }] - ]; - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt index 2119300f7b..104d117c37 100644 --- a/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/contextualTypedSpecialAssignment.errors.txt @@ -1,17 +1,13 @@ -mod.js(2,34): error TS8010: Type annotations can only be used in TypeScript files. -test.js(3,9): error TS8010: Type annotations can only be used in TypeScript files. test.js(15,5): error TS2322: Type 'string' is not assignable to type '"done"'. test.js(16,7): error TS7006: Parameter 'n' implicitly has an 'any' type. test.js(57,17): error TS2339: Property 'x' does not exist on type 'Thing'. test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. -==== test.js (5 errors) ==== +==== test.js (4 errors) ==== /** @typedef {{ status: 'done' m(n: number): void - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. }} DoneStatus */ // property assignment @@ -89,11 +85,9 @@ test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. m(n) { } } -==== mod.js (1 errors) ==== +==== mod.js (0 errors) ==== // module.exports assignment /** @type {{ status: 'done', m(n: number): void }} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. module.exports = { status: "done", m(n) { } diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).errors.txt b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).errors.txt deleted file mode 100644 index fc60e1398b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).errors.txt +++ /dev/null @@ -1,60 +0,0 @@ -index.js(3,4): error TS8010: Type annotations can only be used in TypeScript files. -index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (4 errors) ==== - /** - * @param {Object} [config] - * @param {Partial>} [config.additionalFiles] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function prepareConfig({ - additionalFiles: { - json = [] - } = {} - } = {}) { - json // string[] - } - - export function prepareConfigWithoutAnnotation({ - additionalFiles: { - json = [] - } = {} - } = {}) { - json - } - - /** @type {(param: { - ~~~~~~~~~ - additionalFiles?: Partial>; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - }) => void} */ - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - export const prepareConfigWithContextualSignature = ({ - additionalFiles: { - json = [] - } = {} - } = {})=> { - json // string[] - } - - // Additional repros from https://github.com/microsoft/TypeScript/issues/59936 - - /** - * @param {{ a?: { json?: string[] }}} [config] - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f1({ a: { json = [] } = {} } = {}) { return json } - - /** - * @param {[[string[]?]?]} [x] - ~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f2([[json = []] = []] = []) { return json } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).errors.txt b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).errors.txt index 3919e83d80..6f0315e559 100644 --- a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).errors.txt @@ -1,16 +1,10 @@ -index.js(3,4): error TS8010: Type annotations can only be used in TypeScript files. index.js(15,9): error TS7031: Binding element 'json' implicitly has an 'any[]' type. -index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (5 errors) ==== +==== index.js (1 errors) ==== /** * @param {Object} [config] * @param {Partial>} [config.additionalFiles] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function prepareConfig({ additionalFiles: { @@ -31,12 +25,8 @@ index.js(40,12): error TS8010: Type annotations can only be used in TypeScript f } /** @type {(param: { - ~~~~~~~~~ additionalFiles?: Partial>; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }) => void} */ - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const prepareConfigWithContextualSignature = ({ additionalFiles: { json = [] @@ -49,15 +39,11 @@ index.js(40,12): error TS8010: Type annotations can only be used in TypeScript f /** * @param {{ a?: { json?: string[] }}} [config] - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f1({ a: { json = [] } = {} } = {}) { return json } /** * @param {[[string[]?]?]} [x] - ~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f2([[json = []] = []] = []) { return json } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt index 85291e5660..800958af53 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt @@ -1,19 +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(24,13): error TS8010: Type annotations can only be used in TypeScript files. 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(25,12): error TS8010: Type annotations can only be used in TypeScript files. 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(26,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(29,16): error TS8010: Type annotations can only be used in TypeScript files. -a.js(31,16): error TS8010: Type annotations can only be used in TypeScript files. -a.js(33,16): error TS8010: Type annotations can only be used in TypeScript files. 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(35,16): error TS8010: Type annotations can only be used in TypeScript files. 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(41,13): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (13 errors) ==== +==== a.js (5 errors) ==== /** @enum {string} */ const Target = { START: "start", @@ -40,37 +32,23 @@ a.js(41,13): error TS8010: Type annotations can only be used in TypeScript files /** @param {Target} t ~~~~~~ !!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Second} s ~~~~~~ !!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Fs} f ~~ !!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function consume(t,s,f) { /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var str = t /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var num = s /** @type {(n: number) => number} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var v = Target.START v = Target.UNKNOWN // error, can't find 'UNKNOWN' ~~~~~~~ @@ -79,8 +57,6 @@ a.js(41,13): error TS8010: Type annotations can only be used in TypeScript files v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums } /** @param {string} s */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function ff(s) { // element access with arbitrary string is an error only with noImplicitAny if (!Target[s]) { diff --git a/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt index 0dd2853c71..5180e90595 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/enumTagImported.errors.txt @@ -1,33 +1,24 @@ type.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. -type.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -type.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. 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'? -value.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -==== type.js (4 errors) ==== +==== type.js (2 errors) ==== /** @typedef {import("./mod1").TestEnum} TE */ ~~~~~~~~ !!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. /** @type {TE} */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const test = 'add' /** @type {import("./mod1").TestEnum} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~ !!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. const tost = 'remove' -==== value.js (2 errors) ==== +==== 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'? - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const tist = TestEnum.ADD diff --git a/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt index 77fb494250..5aebbf567d 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/enumTagUseBeforeDefCrash.errors.txt @@ -1,8 +1,7 @@ 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(7,11): error TS8010: Type annotations can only be used in TypeScript files. -==== bug27134.js (2 errors) ==== +==== bug27134.js (1 errors) ==== /** * @enum {number} */ @@ -12,8 +11,6 @@ bug27134.js(7,11): error TS8010: Type annotations can only be used in TypeScript * @type {foo} ~~~ !!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var s; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt index d836ce588b..ba00327c67 100644 --- a/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt @@ -1,12 +1,10 @@ -foo.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. foo.js(21,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. Type 'void' is not assignable to type 'Promise'. -foo.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. Type 'void' is not assignable to type 'never'. -==== foo.js (4 errors) ==== +==== foo.js (2 errors) ==== /** * @callback FunctionReturningPromise * @returns {Promise} @@ -27,8 +25,6 @@ foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'Functio } /** @type {FunctionReturningPromise} */ - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var testPromise4 = function() { ~~~~~~~~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. @@ -56,8 +52,6 @@ foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'Functio } /** @type {FunctionReturningNever} */ - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var testNever4 = function() { ~~~~~~~~~~ !!! error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. diff --git a/testdata/baselines/reference/submodule/conformance/esDecorators-classDeclaration-exportModifier.errors.txt b/testdata/baselines/reference/submodule/conformance/esDecorators-classDeclaration-exportModifier.errors.txt deleted file mode 100644 index 0b4320fc34..0000000000 --- a/testdata/baselines/reference/submodule/conformance/esDecorators-classDeclaration-exportModifier.errors.txt +++ /dev/null @@ -1,37 +0,0 @@ -global.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== global.js (1 errors) ==== - /** @type {*} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var dec; - -==== file1.js (0 errors) ==== - // ok - @dec export class C1 { } - -==== file2.js (0 errors) ==== - // ok - @dec export default class C2 {} - -==== file3.js (0 errors) ==== - // error - export @dec default class C3 {} - -==== file4.js (0 errors) ==== - // ok - export @dec class C4 {} - -==== file5.js (0 errors) ==== - // ok - export default @dec class C5 {} - -==== file6.js (0 errors) ==== - // error - @dec export @dec class C6 {} - -==== file7.js (0 errors) ==== - // error - @dec export default @dec class C7 {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt index 2c7f39bc4d..de19b01701 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt @@ -1,9 +1,7 @@ mod.js(2,11): error TS2339: Property 'K' does not exist on type '{}'. use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. -use.js(8,13): error TS8010: Type annotations can only be used in TypeScript files. use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -use.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. ==== mod.js (1 errors) ==== @@ -19,7 +17,7 @@ use.js(9,13): error TS8010: Type annotations can only be used in TypeScript file } } -==== use.js (5 errors) ==== +==== use.js (3 errors) ==== import * as s from './mod' var k = new s.n.K() @@ -30,15 +28,11 @@ use.js(9,13): error TS8010: Type annotations can only be used in TypeScript file /** @param {s.n.K} c - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2694: Namespace '"mod"' has no exported member 'n'. @param {s.Classic} classic */ ~~~~~~~~~ !!! error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(c, classic) { c.x classic.p diff --git a/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt b/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt index 3b932a0925..3e7597d212 100644 --- a/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportedEnumTypeAndValue.errors.txt @@ -1,5 +1,4 @@ use.js(3,12): error TS2749: 'MyEnum' refers to a value, but is being used as a type here. Did you mean 'typeof MyEnum'? -use.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ==== def.js (0 errors) ==== @@ -10,13 +9,11 @@ use.js(3,12): error TS8010: Type annotations can only be used in TypeScript file }; export default MyEnum; -==== use.js (2 errors) ==== +==== 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'? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const v = MyEnum.b; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt index d02d586fdd..cd19b650c7 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt @@ -1,5 +1,4 @@ /a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -/a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. /a.js(26,16): error TS8011: Type arguments can only be used in TypeScript files. /a.js(29,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. Types of property 'b' are incompatible. @@ -12,7 +11,7 @@ /a.js(44,16): error TS8011: Type arguments can only be used in TypeScript files. -==== /a.js (8 errors) ==== +==== /a.js (7 errors) ==== /** ~~~ * @typedef {{ @@ -39,8 +38,6 @@ ~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~ constructor(a) { diff --git a/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt b/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt index 7cca88f625..1b263f9b6c 100644 --- a/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt @@ -1,8 +1,7 @@ genericSetterInClassTypeJsDoc.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -genericSetterInClassTypeJsDoc.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. -==== genericSetterInClassTypeJsDoc.js (2 errors) ==== +==== genericSetterInClassTypeJsDoc.js (1 errors) ==== /** ~~~ * @template T @@ -17,8 +16,6 @@ genericSetterInClassTypeJsDoc.js(7,17): error TS8010: Type annotations can only /** @param {T} initialValue */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor(initialValue) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this.#value = initialValue; diff --git a/testdata/baselines/reference/submodule/conformance/importTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag1.errors.txt deleted file mode 100644 index 3af1a68f43..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag1.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /types.ts (0 errors) ==== - export interface Foo { - a: number; - } - -==== /foo.js (2 errors) ==== - /** - * @import { Foo } from "./types" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param { Foo } foo - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(foo) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag11.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag11.errors.txt deleted file mode 100644 index c9b5bd4721..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag11.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. - - -==== /foo.js (1 errors) ==== - /** - * @import foo - ~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag12.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag12.errors.txt deleted file mode 100644 index 3baf3abbb3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag12.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. - - -==== /foo.js (1 errors) ==== - /** - * @import foo from - ~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag13.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag13.errors.txt index e4ca640f68..958d6225ec 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag13.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag13.errors.txt @@ -1,11 +1,8 @@ -/foo.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. /foo.js(1,15): error TS1141: String literal expected. -==== /foo.js (2 errors) ==== +==== /foo.js (1 errors) ==== /** @import x = require("types") */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~ !!! error TS1141: String literal expected. diff --git a/testdata/baselines/reference/submodule/conformance/importTag14.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag14.errors.txt index 081a17b460..b2aace2a64 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag14.errors.txt @@ -1,13 +1,10 @@ -/foo.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. /foo.js(1,25): error TS2306: File '/foo.js' is not a module. /foo.js(1,33): error TS1464: Type import attributes should have exactly one key - 'resolution-mode' - with value 'import' or 'require'. /foo.js(1,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. -==== /foo.js (4 errors) ==== +==== /foo.js (3 errors) ==== /** @import * as f from "./foo" with */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~ !!! error TS2306: File '/foo.js' is not a module. ~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt b/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt index bcf9743c9c..45e47c28ad 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag15(module=es2015).errors.txt @@ -1,27 +1,18 @@ -1.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. 1.js(1,30): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. -1.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. 1.js(2,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. -1.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. ==== 0.ts (0 errors) ==== export interface I { } -==== 1.js (5 errors) ==== +==== 1.js (2 errors) ==== /** @import { I } from './0' with { type: "json" } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. /** @import * as foo from './0' with { type: "json" } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. /** @param {I} a */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(a) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt b/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt index 20988474b6..3b98c15768 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag15(module=esnext).errors.txt @@ -1,27 +1,18 @@ -1.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. 1.js(1,30): error TS2857: Import attributes cannot be used with type-only imports or exports. -1.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. 1.js(2,33): error TS2857: Import attributes cannot be used with type-only imports or exports. -1.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. ==== 0.ts (0 errors) ==== export interface I { } -==== 1.js (5 errors) ==== +==== 1.js (2 errors) ==== /** @import { I } from './0' with { type: "json" } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2857: Import attributes cannot be used with type-only imports or exports. /** @import * as foo from './0' with { type: "json" } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2857: Import attributes cannot be used with type-only imports or exports. /** @param {I} a */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(a) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag16.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag16.errors.txt deleted file mode 100644 index 8957179bec..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag16.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -b.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. -b.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -b.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.ts (0 errors) ==== - export default interface Foo {} - export interface I {} - -==== b.js (3 errors) ==== - /** @import Foo, { I } from "./a" */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - - /** - * @param {Foo} a - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {I} b - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function foo(a, b) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag16.js b/testdata/baselines/reference/submodule/conformance/importTag16.js index fb3f1bd1b8..b086bf0a00 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag16.js +++ b/testdata/baselines/reference/submodule/conformance/importTag16.js @@ -29,3 +29,28 @@ import type Foo, { I } from "./a"; * @param {I} b */ export declare function foo(a: Foo, b: I): void; + + +//// [DtsFileErrors] + + +b.d.ts(1,8): error TS1363: A type-only import can specify a default import or named bindings, but not both. + + +==== a.d.ts (0 errors) ==== + export default interface Foo { + } + export interface I { + } + +==== b.d.ts (1 errors) ==== + import type Foo, { I } from "./a"; + ~~~~~~~~~~~~~~~ +!!! error TS1363: A type-only import can specify a default import or named bindings, but not both. + /** @import Foo, { I } from "./a" */ + /** + * @param {Foo} a + * @param {I} b + */ + export declare function foo(a: Foo, b: I): void; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag16.js.diff b/testdata/baselines/reference/submodule/conformance/importTag16.js.diff index 05093643ec..72602ad3cf 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag16.js.diff +++ b/testdata/baselines/reference/submodule/conformance/importTag16.js.diff @@ -13,4 +13,29 @@ -export function foo(a: Foo, b: I): void; -import type Foo from "./a"; -import type { I } from "./a"; -+export declare function foo(a: Foo, b: I): void; \ No newline at end of file ++export declare function foo(a: Foo, b: I): void; ++ ++ ++//// [DtsFileErrors] ++ ++ ++b.d.ts(1,8): error TS1363: A type-only import can specify a default import or named bindings, but not both. ++ ++ ++==== a.d.ts (0 errors) ==== ++ export default interface Foo { ++ } ++ export interface I { ++ } ++ ++==== b.d.ts (1 errors) ==== ++ import type Foo, { I } from "./a"; ++ ~~~~~~~~~~~~~~~ ++!!! error TS1363: A type-only import can specify a default import or named bindings, but not both. ++ /** @import Foo, { I } from "./a" */ ++ /** ++ * @param {Foo} a ++ * @param {I} b ++ */ ++ export declare function foo(a: Foo, b: I): void; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt index 9d38acca34..defcfc35bc 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag17.errors.txt @@ -1,8 +1,4 @@ -/a.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. -/a.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. -/a.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. /a.js(5,15): error TS2749: 'Import' refers to a value, but is being used as a type here. Did you mean 'typeof Import'? -/a.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. /a.js(12,15): error TS2749: 'Require' refers to a value, but is being used as a type here. Did you mean 'typeof Require'? @@ -24,18 +20,12 @@ ==== /node_modules/@types/foo/index.d.cts (0 errors) ==== export declare const Require: "script"; -==== /a.js (6 errors) ==== +==== /a.js (2 errors) ==== /** @import { Import } from 'foo' with { 'resolution-mode': 'import' } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. /** @import { Require } from 'foo' with { 'resolution-mode': 'require' } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. /** * @returns { Import } - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2749: 'Import' refers to a value, but is being used as a type here. Did you mean 'typeof Import'? */ @@ -45,8 +35,6 @@ /** * @returns { Require } - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~ !!! error TS2749: 'Require' refers to a value, but is being used as a type here. Did you mean 'typeof Require'? */ diff --git a/testdata/baselines/reference/submodule/conformance/importTag18.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag18.errors.txt deleted file mode 100644 index c74cb5dd57..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag18.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -b.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.ts (0 errors) ==== - export interface Foo {} - -==== b.js (2 errors) ==== - /** - * @import { - ~~~~~~~~~ - * Foo - ~~~~~~~~~ - * } from "./a" - ~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param {Foo} a - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function foo(a) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag19.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag19.errors.txt deleted file mode 100644 index 4911aa13d6..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag19.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -b.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.ts (0 errors) ==== - export interface Foo {} - -==== b.js (2 errors) ==== - /** - * @import { Foo } - ~~~~~~~~~~~~~~~ - * from "./a" - ~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param {Foo} a - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function foo(a) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag2.errors.txt deleted file mode 100644 index 352f0888c9..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag2.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /types.ts (0 errors) ==== - export interface Foo { - a: number; - } - -==== /foo.js (2 errors) ==== - /** - * @import * as types from "./types" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param { types.Foo } foo - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function f(foo) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag20.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag20.errors.txt deleted file mode 100644 index 638b4c606b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag20.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -b.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.ts (0 errors) ==== - export interface Foo {} - -==== b.js (2 errors) ==== - /** - * @import - ~~~~~~~ - * { Foo - ~~~~~~~~ - * } from './a' - ~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param {Foo} a - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function foo(a) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag21.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag21.errors.txt deleted file mode 100644 index e6924e1a42..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag21.errors.txt +++ /dev/null @@ -1,37 +0,0 @@ -test.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. - - -==== node_modules/tslib/package.json (0 errors) ==== - { - "name": "tslib", - "exports": { - ".": { - "module": { - "types": "./modules/index.d.ts", - "default": "./tslib.es6.mjs" - }, - "import": { - "node": "./modules/index.js", - "default": { - "types": "./modules/index.d.ts", - "default": "./tslib.es6.mjs" - } - }, - "default": "./tslib.js" - }, - "./*": "./*", - "./": "./" - } - } - -==== node_modules/tslib/modules/index.d.ts (0 errors) ==== - export {}; - -==== node_modules/tslib/tslib.d.ts (0 errors) ==== - export {}; - -==== test.js (1 errors) ==== - /** @import * as tslib from "tslib" */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - /** @type {typeof tslib} T */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt index 8354b35caf..03bedf5694 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag23.errors.txt @@ -1,5 +1,3 @@ -/b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -/b.js(5,18): error TS8005: 'implements' clauses can only be used in TypeScript files. /b.js(6,14): error TS2420: Class 'C' incorrectly implements interface 'I'. Property 'foo' is missing in type 'C' but required in type 'I'. @@ -9,16 +7,12 @@ foo(): void; } -==== /b.js (3 errors) ==== +==== /b.js (1 errors) ==== /** * @import * as NS from './a' - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. */ /** @implements {NS.I} */ - ~~~~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. export class C {} ~ !!! error TS2420: Class 'C' incorrectly implements interface 'I'. diff --git a/testdata/baselines/reference/submodule/conformance/importTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag3.errors.txt deleted file mode 100644 index 281bec33d3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag3.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /types.ts (0 errors) ==== - export default interface Foo { - a: number; - } - -==== /foo.js (2 errors) ==== - /** - * @import Foo from "./types" - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param { Foo } foo - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function f(foo) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt index 0888f0f549..dbfd8ad5b4 100644 --- a/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importTag4.errors.txt @@ -1,8 +1,5 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. /foo.js(2,14): error TS2300: Duplicate identifier 'Foo'. -/foo.js(6,4): error TS8006: 'import type' declarations can only be used in TypeScript files. /foo.js(6,14): error TS2300: Duplicate identifier 'Foo'. -/foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.ts (0 errors) ==== @@ -10,27 +7,21 @@ a: number; } -==== /foo.js (5 errors) ==== +==== /foo.js (2 errors) ==== /** * @import { Foo } from "./types" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~ !!! error TS2300: Duplicate identifier 'Foo'. */ /** * @import { Foo } from "./types" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~ !!! error TS2300: Duplicate identifier 'Foo'. */ /** * @param { Foo } foo - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(foo) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag5.errors.txt deleted file mode 100644 index 3af1a68f43..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag5.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /types.ts (0 errors) ==== - export interface Foo { - a: number; - } - -==== /foo.js (2 errors) ==== - /** - * @import { Foo } from "./types" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param { Foo } foo - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(foo) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag6.errors.txt deleted file mode 100644 index 2f47546def..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag6.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -/foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /types.ts (0 errors) ==== - export interface A { - a: number; - } - export interface B { - a: number; - } - -==== /foo.js (3 errors) ==== - /** - * @import { - ~~~~~~~~~ - * A, - ~~~~~~~~~ - * B, - ~~~~~~~~~ - * } from "./types" - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param { A } a - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param { B } b - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(a, b) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag7.errors.txt deleted file mode 100644 index 3a2da4dc64..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag7.errors.txt +++ /dev/null @@ -1,34 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /types.ts (0 errors) ==== - export interface A { - a: number; - } - export interface B { - a: number; - } - -==== /foo.js (3 errors) ==== - /** - * @import { - ~~~~~~~~~ - * A, - ~~~~~ - * B } from "./types" - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param { A } a - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param { B } b - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(a, b) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag8.errors.txt deleted file mode 100644 index 6e83fa9137..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag8.errors.txt +++ /dev/null @@ -1,34 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /types.ts (0 errors) ==== - export interface A { - a: number; - } - export interface B { - a: number; - } - -==== /foo.js (3 errors) ==== - /** - * @import - ~~~~~~~ - * { A, B } - ~~~~~~~~~~~ - * from "./types" - ~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param { A } a - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param { B } b - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(a, b) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTag9.errors.txt b/testdata/baselines/reference/submodule/conformance/importTag9.errors.txt deleted file mode 100644 index 949bcf7a45..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTag9.errors.txt +++ /dev/null @@ -1,34 +0,0 @@ -/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /types.ts (0 errors) ==== - export interface A { - a: number; - } - export interface B { - a: number; - } - -==== /foo.js (3 errors) ==== - /** - * @import - ~~~~~~~ - * * as types - ~~~~~~~~~~~~~ - * from "./types" - ~~~~~~~~~~~~~~~~~ -!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** - * @param { types.A } a - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param { types.B } b - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(a, b) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.errors.txt b/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.errors.txt deleted file mode 100644 index 8a490ca77c..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -index.js(5,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -index.js(7,22): error TS8016: Type assertion expressions can only be used in TypeScript files. -index.js(8,22): error TS8016: Type assertion expressions can only be used in TypeScript files. - - -==== externs.d.ts (0 errors) ==== - declare namespace MyClass { - export interface Bar { - doer: (x: string) => void; - } - } - declare class MyClass { - field: string; - static Bar: (x: string, y?: number) => void; - constructor(x: MyClass.Bar); - } - declare global { - const Foo: typeof MyClass; - } - export = MyClass; -==== index.js (3 errors) ==== - /** - * @typedef {import("./externs")} Foo - */ - - let a = /** @type {Foo} */(/** @type {*} */(undefined)); - ~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - a = new Foo({doer: Foo.Bar}); - const q = /** @type {import("./externs").Bar} */({ doer: q => q }); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - const r = /** @type {typeof import("./externs").Bar} */(r => r); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt b/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt index 62ce9fe76f..9e255670bb 100644 --- a/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt @@ -1,12 +1,8 @@ /a.js(1,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -/a.js(4,15): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. /a.js(9,6): error TS8004: Type parameter declarations can only be used in TypeScript files. -/a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(14,17): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (6 errors) ==== +==== /a.js (2 errors) ==== export class C { /** @@ -15,12 +11,8 @@ ~~~~~~~~~~~~~~~~~~ * @this {T} ~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} ~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ static a() { @@ -39,12 +31,8 @@ ~~~~~~~~~~~~~~~~~~ * @this {T} ~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} ~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ b() { diff --git a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt index b43eba6b31..81c4e9569e 100644 --- a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt @@ -1,18 +1,11 @@ -instantiateTemplateTagTypeParameterOnVariableStatement.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -instantiateTemplateTagTypeParameterOnVariableStatement.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. instantiateTemplateTagTypeParameterOnVariableStatement.js(6,12): error TS8004: Type parameter declarations can only be used in TypeScript files. -instantiateTemplateTagTypeParameterOnVariableStatement.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -==== instantiateTemplateTagTypeParameterOnVariableStatement.js (4 errors) ==== +==== instantiateTemplateTagTypeParameterOnVariableStatement.js (1 errors) ==== /** * @template T * @param {T} a - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {(b: T) => T} - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const seq = a => b => b; ~~~~~~~~~~~~ @@ -22,7 +15,5 @@ instantiateTemplateTagTypeParameterOnVariableStatement.js(11,12): error TS8010: const text2 = "world"; /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var text3 = seq(text1)(text2); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt deleted file mode 100644 index 20aac67c9b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt +++ /dev/null @@ -1,44 +0,0 @@ -argument.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. -argument.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== supplement.d.ts (0 errors) ==== - export { }; - declare module "./argument.js" { - interface Argument { - idlType: any; - default: null; - } - } -==== base.js (0 errors) ==== - export class Base { - constructor() { } - - toJSON() { - const json = { type: undefined, name: undefined, inheritance: undefined }; - return json; - } - } -==== argument.js (2 errors) ==== - import { Base } from "./base.js"; - export class Argument extends Base { - /** - * @param {*} tokeniser - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - static parse(tokeniser) { - return; - } - - get type() { - return "argument"; - } - - /** - * @param {*} defs - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - *validate(defs) { } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt index 1caaac6dad..399be9da33 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt @@ -1,21 +1,17 @@ lib.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -lib.js(3,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -lib.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. ==== interface.ts (0 errors) ==== export interface Encoder { encode(value: T): Uint8Array } -==== lib.js (3 errors) ==== +==== lib.js (1 errors) ==== /** ~~~ * @template T ~~~~~~~~~~~~~~ * @implements {IEncoder} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. */ ~~~ export class Encoder { @@ -24,8 +20,6 @@ lib.js(7,16): error TS8010: Type annotations can only be used in TypeScript file ~~~~~~~ * @param {T} value ~~~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ encode(value) { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt index b6d0dec2c9..57d5ec44df 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassMethod.errors.txt @@ -4,9 +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(36,16): error TS8010: Type annotations can only be used in TypeScript files. -jsDeclarationsClassMethod.js(37,16): error TS8010: Type annotations can only be used in TypeScript files. -jsDeclarationsClassMethod.js(38,18): error TS8010: Type annotations can only be used in TypeScript files. 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 +11,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 (11 errors) ==== function C1() { /** * A comment prop @@ -63,14 +60,8 @@ jsDeclarationsClassMethod.js(61,30): error TS7006: Parameter 'y' implicitly has /** * A comment method1 * @param {number} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} y - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ method1(x, y) { return x + y; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt index 0a3209f691..2cc0898d34 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt @@ -1,40 +1,14 @@ -index.js(13,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(24,15): error TS8010: Type annotations can only be used in TypeScript files. -index.js(30,15): error TS8010: Type annotations can only be used in TypeScript files. index.js(31,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -index.js(38,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(40,34): error TS8016: Type assertion expressions can only be used in TypeScript files. -index.js(43,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(48,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(50,34): error TS8016: Type assertion expressions can only be used in TypeScript files. -index.js(53,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(58,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(59,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(65,15): error TS8010: Type annotations can only be used in TypeScript files. -index.js(71,15): error TS8010: Type annotations can only be used in TypeScript files. index.js(72,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -index.js(79,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(84,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(89,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(94,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(97,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(104,15): error TS8010: Type annotations can only be used in TypeScript files. -index.js(108,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(109,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(111,25): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(115,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(116,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(153,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(161,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(167,2): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(173,23): error TS8011: Type arguments can only be used in TypeScript files. -index.js(175,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(183,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== index.js (34 errors) ==== +==== index.js (8 errors) ==== export class A {} export class B { @@ -48,11 +22,7 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T export class D { /** * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} b - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(a, b) {} } @@ -71,8 +41,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @type {T & U} ~~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ field; @@ -85,8 +53,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @type {T & U} ~~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @readonly ~~~~~~~~~~~~~~~~ ~~~~~~~~~ @@ -106,22 +72,16 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @return {U} ~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ get f1() { return /** @type {*} */(null); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** ~~~~~~~ * @param {U} _p ~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ set f1(_p) {} @@ -132,22 +92,16 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @return {U} ~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ get f2() { return /** @type {*} */(null); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** ~~~~~~~ * @param {U} _p ~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ set f3(_p) {} @@ -158,12 +112,8 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ constructor(a, b) {} @@ -176,8 +126,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @type {string} ~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ static staticField; @@ -190,8 +138,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @type {string} ~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @readonly ~~~~~~~~~~~~~~~~ ~~~~~~~~~ @@ -211,8 +157,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @return {string} ~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ static get s1() { return ""; } @@ -223,8 +167,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @param {string} _p ~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ static set s1(_p) {} @@ -235,8 +177,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @return {string} ~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ static get s2() { return ""; } @@ -247,8 +187,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @param {string} _p ~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ static set s3(_p) {} @@ -271,8 +209,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @type {T & U} ~~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ field; @@ -281,12 +217,8 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ constructor(a, b) {} @@ -304,13 +236,9 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T * @param {A} a ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {B} b ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ ~~~~~~~ @@ -372,8 +300,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @param {T} param ~~~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ constructor(param) { @@ -406,8 +332,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T ~~~~~~~ * @param {U} param ~~~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ constructor(param) { @@ -423,8 +347,6 @@ index.js(183,20): error TS8016: Type assertion expressions can only be used in T !!! error TS8004: Type parameter declarations can only be used in TypeScript files. var x = /** @type {*} */(null); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. export class VariableBase extends x {} diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.errors.txt deleted file mode 100644 index fdaeb2a1ed..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsComputedNames.errors.txt +++ /dev/null @@ -1,32 +0,0 @@ -index2.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (0 errors) ==== - const TopLevelSym = Symbol(); - const InnerSym = Symbol(); - module.exports = { - [TopLevelSym](x = 12) { - return x; - }, - items: { - [InnerSym]: (arg = {x: 12}) => arg.x - } - } - -==== index2.js (1 errors) ==== - const TopLevelSym = Symbol(); - const InnerSym = Symbol(); - - export class MyClass { - static [TopLevelSym] = 12; - [InnerSym] = "ok"; - /** - * @param {typeof TopLevelSym | typeof InnerSym} _p - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(_p = InnerSym) { - // switch on _p - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt deleted file mode 100644 index 259adab29d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt +++ /dev/null @@ -1,46 +0,0 @@ -index3.js(2,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -index4.js(3,20): error TS8016: Type assertion expressions can only be used in TypeScript files. - - -==== index1.js (0 errors) ==== - export default 12; - -==== index2.js (0 errors) ==== - export default function foo() { - return foo; - } - export const x = foo; - export { foo as bar }; - -==== index3.js (1 errors) ==== - export default class Foo { - a = /** @type {Foo} */(null); - ~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - }; - export const X = Foo; - export { Foo as Bar }; - -==== index4.js (1 errors) ==== - import Fab from "./index3"; - class Bar extends Fab { - x = /** @type {Bar} */(null); - ~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - } - export default Bar; - -==== index5.js (0 errors) ==== - // merge type alias and const (OK) - export default 12; - /** - * @typedef {string | number} default - */ - -==== index6.js (0 errors) ==== - // merge type alias and function (OK) - export default function func() {}; - /** - * @typedef {string | number} default - */ - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js index bafa2fc294..fabe4f7586 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js @@ -113,3 +113,79 @@ export type default = string | number; // merge type alias and function (OK) export default function func(): void; export type default = string | number; + + +//// [DtsFileErrors] + + +out/index5.d.ts(3,1): error TS1128: Declaration or statement expected. +out/index5.d.ts(3,8): error TS2304: Cannot find name 'type'. +out/index5.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. +out/index5.d.ts(3,21): error TS1128: Declaration or statement expected. +out/index5.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. +out/index5.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. +out/index6.d.ts(3,1): error TS1128: Declaration or statement expected. +out/index6.d.ts(3,8): error TS2304: Cannot find name 'type'. +out/index6.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. +out/index6.d.ts(3,21): error TS1128: Declaration or statement expected. +out/index6.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. +out/index6.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. + + +==== out/index1.d.ts (0 errors) ==== + declare const _default: number; + export default _default; + +==== out/index2.d.ts (0 errors) ==== + export default function foo(): typeof foo; + export declare const x: typeof foo; + export { foo as bar }; + +==== out/index3.d.ts (0 errors) ==== + export default class Foo { + a: Foo; + } + export declare const X: typeof Foo; + export { Foo as Bar }; + +==== out/index4.d.ts (0 errors) ==== + import Fab from "./index3"; + declare class Bar extends Fab { + x: Bar; + } + export default Bar; + +==== out/index5.d.ts (6 errors) ==== + declare const _default: number; + export default _default; + export type default = string | number; + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2304: Cannot find name 'type'. + ~~~~~~~ +!!! error TS2457: Type alias name cannot be 'default'. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + +==== out/index6.d.ts (6 errors) ==== + // merge type alias and function (OK) + export default function func(): void; + export type default = string | number; + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2304: Cannot find name 'type'. + ~~~~~~~ +!!! error TS2457: Type alias name cannot be 'default'. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff index c9e29891cb..913922e847 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff @@ -81,4 +81,80 @@ -export default func; +// merge type alias and function (OK) +export default function func(): void; -+export type default = string | number; \ No newline at end of file ++export type default = string | number; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/index5.d.ts(3,1): error TS1128: Declaration or statement expected. ++out/index5.d.ts(3,8): error TS2304: Cannot find name 'type'. ++out/index5.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. ++out/index5.d.ts(3,21): error TS1128: Declaration or statement expected. ++out/index5.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. ++out/index5.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. ++out/index6.d.ts(3,1): error TS1128: Declaration or statement expected. ++out/index6.d.ts(3,8): error TS2304: Cannot find name 'type'. ++out/index6.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. ++out/index6.d.ts(3,21): error TS1128: Declaration or statement expected. ++out/index6.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. ++out/index6.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. ++ ++ ++==== out/index1.d.ts (0 errors) ==== ++ declare const _default: number; ++ export default _default; ++ ++==== out/index2.d.ts (0 errors) ==== ++ export default function foo(): typeof foo; ++ export declare const x: typeof foo; ++ export { foo as bar }; ++ ++==== out/index3.d.ts (0 errors) ==== ++ export default class Foo { ++ a: Foo; ++ } ++ export declare const X: typeof Foo; ++ export { Foo as Bar }; ++ ++==== out/index4.d.ts (0 errors) ==== ++ import Fab from "./index3"; ++ declare class Bar extends Fab { ++ x: Bar; ++ } ++ export default Bar; ++ ++==== out/index5.d.ts (6 errors) ==== ++ declare const _default: number; ++ export default _default; ++ export type default = string | number; ++ ~~~~~~ ++!!! error TS1128: Declaration or statement expected. ++ ~~~~ ++!!! error TS2304: Cannot find name 'type'. ++ ~~~~~~~ ++!!! error TS2457: Type alias name cannot be 'default'. ++ ~ ++!!! error TS1128: Declaration or statement expected. ++ ~~~~~~ ++!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ++ ~~~~~~ ++!!! error TS2693: 'number' only refers to a type, but is being used as a value here. ++ ++==== out/index6.d.ts (6 errors) ==== ++ // merge type alias and function (OK) ++ export default function func(): void; ++ export type default = string | number; ++ ~~~~~~ ++!!! error TS1128: Declaration or statement expected. ++ ~~~~ ++!!! error TS2304: Cannot find name 'type'. ++ ~~~~~~~ ++!!! error TS2457: Type alias name cannot be 'default'. ++ ~ ++!!! error TS1128: Declaration or statement expected. ++ ~~~~~~ ++!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ++ ~~~~~~ ++!!! error TS2693: 'number' only refers to a type, but is being used as a value here. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt index 46095ddf92..7312ed2c66 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnumTag.errors.txt @@ -1,18 +1,10 @@ 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(23,12): error TS8010: Type annotations can only be used in TypeScript files. 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(24,12): error TS8010: Type annotations can only be used in TypeScript files. 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(25,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(28,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(30,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(32,16): error TS8010: Type annotations can only be used in TypeScript files. 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(34,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(38,13): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (12 errors) ==== +==== index.js (4 errors) ==== /** @enum {string} */ export const Target = { START: "start", @@ -38,43 +30,27 @@ index.js(38,13): error TS8010: Type annotations can only be used in TypeScript f * @param {Target} t ~~~~~~ !!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Second} s ~~~~~~ !!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Fs} f ~~ !!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function consume(t,s,f) { /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var str = t /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var num = s /** @type {(n: number) => number} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var v = Target.START v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums } /** @param {string} s */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export function ff(s) { // element access with arbitrary string is an error only with noImplicitAny if (!Target[s]) { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt deleted file mode 100644 index 284aac91f5..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - module.exports = class Thing { - /** - * @param {number} p - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(p) { - this.t = 12 + p; - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js index d72f029c4f..57400ad02e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js @@ -26,3 +26,19 @@ declare const _default: { new (p: number): import("."); }; export = _default; + + +//// [DtsFileErrors] + + +out/index.d.ts(2,22): error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? + + +==== out/index.d.ts (1 errors) ==== + declare const _default: { + new (p: number): import("."); + ~~~~~~~~~~~ +!!! error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? + }; + export = _default; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js.diff index b241b7da65..d30ea0a4a7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpression.js.diff @@ -15,4 +15,20 @@ +declare const _default: { + new (p: number): import("."); +}; -+export = _default; \ No newline at end of file ++export = _default; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/index.d.ts(2,22): error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? ++ ++ ++==== out/index.d.ts (1 errors) ==== ++ declare const _default: { ++ new (p: number): import("."); ++ ~~~~~~~~~~~ ++!!! error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? ++ }; ++ export = _default; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt deleted file mode 100644 index 678a855563..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - module.exports = class { - /** - * @param {number} p - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(p) { - this.t = 12 + p; - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js index 88c972a765..b6ac685f16 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js @@ -26,3 +26,19 @@ declare const _default: { new (p: number): import("."); }; export = _default; + + +//// [DtsFileErrors] + + +out/index.d.ts(2,22): error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? + + +==== out/index.d.ts (1 errors) ==== + declare const _default: { + new (p: number): import("."); + ~~~~~~~~~~~ +!!! error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? + }; + export = _default; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js.diff index 67efa37324..e6561361bb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.js.diff @@ -15,4 +15,20 @@ +declare const _default: { + new (p: number): import("."); +}; -+export = _default; \ No newline at end of file ++export = _default; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/index.d.ts(2,22): error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? ++ ++ ++==== out/index.d.ts (1 errors) ==== ++ declare const _default: { ++ new (p: number): import("."); ++ ~~~~~~~~~~~ ++!!! error TS1340: Module '.' does not refer to a type, but is used as a type here. Did you mean 'typeof import('.')'? ++ }; ++ export = _default; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt index 0f328f4d77..22d27100d3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt @@ -1,17 +1,14 @@ index.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(9,16): error TS2339: Property 'Sub' does not exist on type 'typeof exports'. -==== index.js (3 errors) ==== +==== index.js (2 errors) ==== module.exports = class { ~~~~~~~~~~~~~~~~~~~~~~~~ /** ~~~~~~~ * @param {number} p ~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ constructor(p) { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt index 2dd0d5a6d1..03fad2748c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt @@ -1,28 +1,15 @@ index.js(1,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(3,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(4,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(7,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. -index.js(11,38): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(12,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(12,58): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(19,13): error TS8010: Type annotations can only be used in TypeScript files. -index.js(21,38): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(22,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(22,58): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. 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(35,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. 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(45,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. 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`. @@ -33,7 +20,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 (33 errors) ==== +==== index.js (20 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`. @@ -47,18 +34,10 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} b - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function d(a, b) { return /** @type {*} */(null); } - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. Object.defineProperty(module.exports, "d", { value: d }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -73,23 +52,15 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install ~~~~~~~~~~~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T & U} ~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function e(a, b) { return /** @type {*} */(null); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. Object.defineProperty(module.exports, "e", { value: e }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -102,8 +73,6 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install ~~~~~~~~~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f(a) { @@ -124,11 +93,7 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof module.exports.b}} b - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ @@ -142,11 +107,7 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof module.exports.b}} b - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt index 233640da0e..3331f7cf27 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt @@ -1,41 +1,28 @@ context.js(4,14): error TS1340: Module './timer' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./timer')'? 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(6,31): error TS2694: Namespace 'Hook' has no exported member 'HookHandler'. -context.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. context.js(34,14): error TS2350: Only a void function can be called with the 'new' keyword. -context.js(40,16): error TS8010: Type annotations can only be used in TypeScript files. -context.js(41,16): error TS8010: Type annotations can only be used in TypeScript files. -context.js(42,18): error TS8010: Type annotations can only be used in TypeScript files. context.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -hook.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. 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(5,12): error TS8010: Type annotations can only be used in TypeScript files. hook.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -timer.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -==== timer.js (1 errors) ==== +==== timer.js (0 errors) ==== /** * @param {number} timeout - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Timer(timeout) { this.timeout = timeout; } module.exports = Timer; -==== hook.js (4 errors) ==== +==== hook.js (2 errors) ==== /** * @typedef {(arg: import("./context")) => void} HookHandler - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~ !!! 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 - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Hook(handle) { this.handle = handle; @@ -44,7 +31,7 @@ timer.js(2,12): error TS8010: Type annotations can only be used in TypeScript fi ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== context.js (9 errors) ==== +==== context.js (5 errors) ==== /** * Imports * @@ -80,8 +67,6 @@ timer.js(2,12): error TS8010: Type annotations can only be used in TypeScript fi * * @class * @param {Input} input - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Context(input) { @@ -95,14 +80,8 @@ timer.js(2,12): error TS8010: Type annotations can only be used in TypeScript fi Context.prototype = { /** * @param {Input} input - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {HookHandler=} handle - ~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {State} - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ construct(input, handle = () => void 0) { return input; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.errors.txt deleted file mode 100644 index 987611553a..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionJSDoc.errors.txt +++ /dev/null @@ -1,53 +0,0 @@ -source.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -source.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -source.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. -source.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. -source.js(26,18): error TS8010: Type annotations can only be used in TypeScript files. - - -==== source.js (5 errors) ==== - /** - * Foos a bar together using an `a` and a `b` - * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} b - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function foo(a, b) {} - - /** - * Legacy - DO NOT USE - */ - export class Aleph { - /** - * Impossible to construct. - * @param {Aleph} a - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {null} b - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(a, b) { - /** - * Field is always null - */ - this.field = b; - } - - /** - * Doesn't actually do anything - * @returns {void} - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - doIt() {} - } - - /** - * Not the speed of light - */ - export const c = 12; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt index 811928d788..cd9c5cdf28 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.errors.txt @@ -1,18 +1,11 @@ referencer.js(4,12): error TS2749: 'Point' refers to a value, but is being used as a type here. Did you mean 'typeof Point'? -referencer.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -source.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -source.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. source.js(7,16): error TS2350: Only a void function can be called with the 'new' keyword. -==== source.js (3 errors) ==== +==== source.js (1 errors) ==== /** * @param {number} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} y - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function Point(x, y) { if (!(this instanceof Point)) { @@ -24,15 +17,13 @@ source.js(7,16): error TS2350: Only a void function can be called with the 'new' this.y = y; } -==== referencer.js (2 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'? - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function magnitude(p) { return Math.sqrt(p.x ** 2 + p.y ** 2); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt index 5c65377f0e..ab252908a8 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt @@ -1,19 +1,11 @@ referencer.js(3,23): error TS2350: Only a void function can be called with the 'new' keyword. -source.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. 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(13,16): error TS8010: Type annotations can only be used in TypeScript files. -source.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -source.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. source.js(40,16): error TS2350: Only a void function can be called with the 'new' keyword. -source.js(53,16): error TS8010: Type annotations can only be used in TypeScript files. -source.js(62,16): error TS8010: Type annotations can only be used in TypeScript files. -==== source.js (8 errors) ==== +==== source.js (2 errors) ==== /** * @param {number} len - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function Vec(len) { /** @@ -27,8 +19,6 @@ source.js(62,16): error TS8010: Type annotations can only be used in TypeScript * @param {Vec} other ~~~ !!! error TS2749: 'Vec' refers to a value, but is being used as a type here. Did you mean 'typeof Vec'? - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ dot(other) { if (other.storage.length !== this.storage.length) { @@ -51,11 +41,7 @@ source.js(62,16): error TS8010: Type annotations can only be used in TypeScript /** * @param {number} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} y - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function Point2D(x, y) { if (!(this instanceof Point2D)) { @@ -75,8 +61,6 @@ source.js(62,16): error TS8010: Type annotations can only be used in TypeScript }, /** * @param {number} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ set x(x) { this.storage[0] = x; @@ -86,8 +70,6 @@ source.js(62,16): error TS8010: Type annotations can only be used in TypeScript }, /** * @param {number} y - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ set y(y) { this.storage[1] = y; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt index c11eccc426..0b7c06dc92 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt @@ -1,8 +1,7 @@ source.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -source.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -==== source.js (2 errors) ==== +==== source.js (1 errors) ==== module.exports = MyClass; ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -17,6 +16,4 @@ source.js(12,12): error TS8010: Type annotations can only be used in TypeScript * * @callback DoneCB * @param {number} failures - Number of failures that occurred. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt index d6a37d4559..499a3260d4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt @@ -1,25 +1,12 @@ -index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. -index.js(14,45): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(14,59): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(20,13): error TS8010: Type annotations can only be used in TypeScript files. -index.js(22,45): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(22,59): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(38,21): error TS2349: This expression is not callable. Type '{ y: any; }' has no call signatures. -index.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(48,21): error TS2349: This expression is not callable. Type '{ y: any; }' has no call signatures. -==== index.js (17 errors) ==== +==== index.js (4 errors) ==== export function a() {} export function b() {} @@ -30,18 +17,10 @@ index.js(48,21): error TS2349: This expression is not callable. /** * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} b - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {string} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function d(a, b) { return /** @type {*} */(null); } - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. @@ -51,23 +30,15 @@ index.js(48,21): error TS2349: This expression is not callable. ~~~~~~~~~~~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T & U} ~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ export function e(a, b) { return /** @type {*} */(null); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. @@ -77,8 +48,6 @@ index.js(48,21): error TS2349: This expression is not callable. ~~~~~~~~~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ export function f(a) { @@ -92,11 +61,7 @@ index.js(48,21): error TS2349: This expression is not callable. /** * @param {{x: string}} a - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof b}} b - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function g(a, b) { return a.x && b.y(); @@ -109,11 +74,7 @@ index.js(48,21): error TS2349: This expression is not callable. /** * @param {{x: string}} a - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof b}} b - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function hh(a, b) { return a.x && b.y(); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt index 835bd25779..e4e224acd2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.errors.txt @@ -1,17 +1,11 @@ index.js(4,18): error TS2339: Property 'cat' does not exist on type '() => void'. index.js(7,18): error TS2339: Property 'Cls' does not exist on type '() => void'. -index.js(14,57): error TS8016: Type assertion expressions can only be used in TypeScript files. -index.js(22,57): error TS8016: Type assertion expressions can only be used in TypeScript files. index.js(31,18): error TS2339: Property 'self' does not exist on type '(a: any) => any'. -index.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. 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(44,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (11 errors) ==== +==== index.js (5 errors) ==== module.exports.a = function a() {} module.exports.b = function b() {} @@ -30,8 +24,6 @@ index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install * @return {string} */ module.exports.d = function d(a, b) { return /** @type {*} */(null); } - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** * @template T,U @@ -40,8 +32,6 @@ index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install * @return {T & U} */ module.exports.e = function e(a, b) { return /** @type {*} */(null); } - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. /** * @template T @@ -56,11 +46,7 @@ index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof module.exports.b}} b - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ @@ -72,11 +58,7 @@ index.js(45,23): error TS2580: Cannot find name 'module'. Do you need to install /** * @param {{x: string}} a - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{y: typeof module.exports.b}} b - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt deleted file mode 100644 index 61478e833e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt +++ /dev/null @@ -1,157 +0,0 @@ -index.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(33,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(44,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(52,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(66,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(72,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(81,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(85,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(94,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(98,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(107,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(111,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (12 errors) ==== - export class A { - get x() { - return 12; - } - } - - export class B { - /** - * @param {number} _arg - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set x(_arg) { - } - } - - export class C { - get x() { - return 12; - } - set x(_arg) { - } - } - - export class D {} - Object.defineProperty(D.prototype, "x", { - get() { - return 12; - } - }); - - export class E {} - Object.defineProperty(E.prototype, "x", { - /** - * @param {number} _arg - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set(_arg) {} - }); - - export class F {} - Object.defineProperty(F.prototype, "x", { - get() { - return 12; - }, - /** - * @param {number} _arg - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set(_arg) {} - }); - - export class G {} - Object.defineProperty(G.prototype, "x", { - /** - * @param {number[]} args - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set(...args) {} - }); - - export class H {} - Object.defineProperty(H.prototype, "x", { - set() {} - }); - - - export class I {} - Object.defineProperty(I.prototype, "x", { - /** - * @param {number} v - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - set: (v) => {} - }); - - /** - * @param {number} v - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const jSetter = (v) => {} - export class J {} - Object.defineProperty(J.prototype, "x", { - set: jSetter - }); - - /** - * @param {number} v - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const kSetter1 = (v) => {} - /** - * @param {number} v - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const kSetter2 = (v) => {} - export class K {} - Object.defineProperty(K.prototype, "x", { - set: Math.random() ? kSetter1 : kSetter2 - }); - - /** - * @param {number} v - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const lSetter1 = (v) => {} - /** - * @param {string} v - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const lSetter2 = (v) => {} - export class L {} - Object.defineProperty(L.prototype, "x", { - set: Math.random() ? lSetter1 : lSetter2 - }); - - /** - * @param {number | boolean} v - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const mSetter1 = (v) => {} - /** - * @param {string | boolean} v - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const mSetter2 = (v) => {} - export class M {} - Object.defineProperty(M.prototype, "x", { - set: Math.random() ? mSetter1 : mSetter2 - }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt index ae5714a2fb..4fca94994d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt @@ -1,27 +1,21 @@ file.js(4,11): error TS2315: Type 'Object' is not generic. -file.js(4,11): error TS8010: Type annotations can only be used in TypeScript files. file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. 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(6,11): error TS8010: Type annotations can only be used in TypeScript files. 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. -file2.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. -==== file.js (7 errors) ==== +==== file.js (6 errors) ==== /** * @namespace myTypes * @global * @type {Object} ~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const myTypes = { // SOME PROPS HERE @@ -48,7 +42,7 @@ file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript f !!! error TS2300: Duplicate identifier 'myTypes'. export {myTypes}; -==== file2.js (6 errors) ==== +==== file2.js (3 errors) ==== import {myTypes} from './file.js'; /** @@ -57,8 +51,6 @@ file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript f * @type {Object} ~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const testFnTypes = { // SOME PROPS HERE @@ -74,11 +66,7 @@ file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript f * @param {testFnTypes.input} input - Input. ~~~~~~~~~~~ !!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number|null} Result. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function testFn(input) { if (typeof input === 'number') { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt index 3d4538f04f..e25ccebe0d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt @@ -1,20 +1,16 @@ file.js(4,11): error TS2315: Type 'Object' is not generic. -file.js(4,11): error TS8010: Type annotations can only be used in TypeScript files. file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. 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(6,11): error TS8010: Type annotations can only be used in TypeScript files. 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. -file2.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. file2.js(28,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== file2.js (7 errors) ==== +==== file2.js (4 errors) ==== const {myTypes} = require('./file.js'); /** @@ -23,8 +19,6 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi * @type {Object} ~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const testFnTypes = { // SOME PROPS HERE @@ -40,11 +34,7 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi * @param {testFnTypes.input} input - Input. ~~~~~~~~~~~ !!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number|null} Result. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function testFn(input) { if (typeof input === 'number') { @@ -57,15 +47,13 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi module.exports = {testFn, testFnTypes}; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== file.js (7 errors) ==== +==== file.js (6 errors) ==== /** * @namespace myTypes * @global * @type {Object} ~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const myTypes = { // SOME PROPS HERE diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt index 8c103d7bf9..8634dc2259 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportNamespacedType.errors.txt @@ -1,12 +1,9 @@ -file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(2,29): error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. -==== file.js (2 errors) ==== +==== file.js (1 errors) ==== import { dummy } from './mod1' /** @type {import('./mod1').Dotted.Name} - should work */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. var dot2 diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt index a998c2975b..38ff884b7d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt @@ -1,111 +1,60 @@ -index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(5,12): error TS2304: Cannot find name 'Void'. -index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(6,12): error TS2304: Cannot find name 'Undefined'. -index.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(7,12): error TS2304: Cannot find name 'Null'. -index.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(11,12): error TS2552: Cannot find name 'array'. Did you mean 'Array'? -index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(12,12): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? -index.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,12): error TS2315: Type 'Object' is not generic. -index.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. 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(30,12): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (25 errors) ==== +==== index.js (8 errors) ==== // these are recognized as TS concepts by the checker /** @type {String} */const a = ""; - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Number} */const b = 0; - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Boolean} */const c = true; - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Void} */const d = undefined; ~~~~ !!! error TS2304: Cannot find name 'Void'. - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Undefined} */const e = undefined; ~~~~~~~~~ !!! error TS2304: Cannot find name 'Undefined'. - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Null} */const f = null; ~~~~ !!! error TS2304: Cannot find name 'Null'. - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Function} */const g = () => void 0; - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {array} */const i = []; ~~~~~ !!! error TS2552: Cannot find name 'array'. Did you mean 'Array'? !!! related TS2728 lib.es5.d.ts:--:--: 'Array' is declared here. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @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. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Object} */const k = {x: "x"}; ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. // 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; - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. // @ts-ignore /** @type {bool} */const m = true; - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. // @ts-ignore /** @type {int} */const n = true; - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. // @ts-ignore /** @type {float} */const o = true; - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. // @ts-ignore /** @type {integer} */const p = true; - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. // 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'? - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file +!!! 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/jsDeclarationsMissingGenerics.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.errors.txt deleted file mode 100644 index bfa6424fd3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== file.js (2 errors) ==== - /** - * @param {Array} x - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function x(x) {} - /** - * @param {Promise} x - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function y(x) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js index aeb030f791..2c0479618c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js @@ -30,3 +30,26 @@ declare function x(x: Array): void; * @param {Promise} x */ declare function y(x: Promise): void; + + +//// [DtsFileErrors] + + +out/file.d.ts(4,23): error TS2314: Generic type 'Array' requires 1 type argument(s). +out/file.d.ts(8,23): error TS2314: Generic type 'Promise' requires 1 type argument(s). + + +==== out/file.d.ts (2 errors) ==== + /** + * @param {Array} x + */ + declare function x(x: Array): void; + ~~~~~ +!!! error TS2314: Generic type 'Array' requires 1 type argument(s). + /** + * @param {Promise} x + */ + declare function y(x: Promise): void; + ~~~~~~~ +!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js.diff index 3b0d2bc189..2b4a65312f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingGenerics.js.diff @@ -10,4 +10,27 @@ * @param {Promise} x */ -declare function y(x: Promise): void; -+declare function y(x: Promise): void; \ No newline at end of file ++declare function y(x: Promise): void; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/file.d.ts(4,23): error TS2314: Generic type 'Array' requires 1 type argument(s). ++out/file.d.ts(8,23): error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ ++ ++==== out/file.d.ts (2 errors) ==== ++ /** ++ * @param {Array} x ++ */ ++ declare function x(x: Array): void; ++ ~~~~~ ++!!! error TS2314: Generic type 'Array' requires 1 type argument(s). ++ /** ++ * @param {Promise} x ++ */ ++ declare function y(x: Promise): void; ++ ~~~~~~~ ++!!! error TS2314: Generic type 'Promise' requires 1 type argument(s). ++ \ 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 index 1b1c69fbf4..7d37afc7c5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.errors.txt @@ -1,20 +1,11 @@ -file.js(2,5): error TS8009: The '?' modifier can only be used in TypeScript files. -file.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -file.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. 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,13): error TS8010: Type annotations can only be used in TypeScript files. -==== file.js (6 errors) ==== +==== file.js (2 errors) ==== /** * @param {Array=} y desc - ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ - ~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. function x(y) { } // @ts-ignore @@ -24,8 +15,6 @@ file.js(18,13): error TS8010: Type annotations can only be used in TypeScript fi /** * @return {(Array.<> | null)} list of devices - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. ~~ @@ -36,7 +25,5 @@ file.js(18,13): error TS8010: Type annotations can only be used in TypeScript fi /** * * @return {?Promise} A promise - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function w() { return null; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt index e88c9122c1..30a9f935a7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt @@ -1,8 +1,7 @@ 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(9,11): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (2 errors) ==== +==== index.js (1 errors) ==== /** * @module A */ @@ -14,8 +13,6 @@ index.js(9,11): error TS8010: Type annotations can only be used in TypeScript fi * @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`. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export let el = null; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt index e35e04bb1f..6874eb5fa6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt @@ -1,25 +1,15 @@ -file.js(5,9): error TS8010: Type annotations can only be used in TypeScript files. -file.js(7,19): error TS8010: Type annotations can only be used in TypeScript files. file.js(7,26): error TS8020: JSDoc types can only be used inside documentation comments. -file.js(16,9): error TS8010: Type annotations can only be used in TypeScript files. -file.js(20,19): error TS8010: Type annotations can only be used in TypeScript files. file.js(20,26): error TS8020: JSDoc types can only be used inside documentation comments. -==== file.js (6 errors) ==== +==== 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 TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. */ @@ -31,18 +21,10 @@ file.js(20,26): error TS8020: JSDoc types can only be used inside documentation * 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 TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt deleted file mode 100644 index f4b11a3dbf..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -foo.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.js (1 errors) ==== - /** - * foo - * - * @public - * @param {object} opts - * @param {number} opts.a - * @param {number} [opts.b] - * @param {number} [opts.c] - * @returns {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo({ a, b, c }) { - return a + b + c; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt index c21df17ed0..b9d1131349 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt @@ -1,10 +1,9 @@ -foo.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. foo.js(11,16): error TS7031: Binding element 'a' implicitly has an 'any' type. foo.js(11,19): error TS7031: Binding element 'b' implicitly has an 'any' type. foo.js(11,22): error TS7031: Binding element 'c' implicitly has an 'any' type. -==== foo.js (4 errors) ==== +==== foo.js (3 errors) ==== /** * foo * @@ -14,8 +13,6 @@ foo.js(11,22): error TS7031: Binding element 'c' implicitly has an 'any' type. * @param {number} [opts.b] * @param {number} [opts.c] * @returns {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function foo({ a, b, c }) { ~ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt index 0b482248a9..810b53ae05 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt @@ -1,9 +1,6 @@ base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. file.js(1,15): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? file.js(4,12): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? -file.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. ==== base.js (1 errors) ==== @@ -21,7 +18,7 @@ file.js(12,14): error TS8010: Type annotations can only be used in TypeScript fi ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -==== file.js (5 errors) ==== +==== file.js (2 errors) ==== /** @typedef {import('./base')} BaseFactory */ ~~~~~~~~~~~~~~~~ !!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? @@ -30,8 +27,6 @@ file.js(12,14): error TS8010: Type annotations can only be used in TypeScript fi * @param {import('./base')} factory ~~~~~~~~~~~~~~~~ !!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** @enum {import('./base')} */ const couldntThinkOfAny = {} @@ -39,11 +34,7 @@ file.js(12,14): error TS8010: Type annotations can only be used in TypeScript fi /** * * @param {InstanceType} base - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {InstanceType} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const test = (base) => { return base; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt index d77a96cd6e..fef4bd8c6b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt @@ -1,6 +1,4 @@ base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -file.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. ==== base.js (1 errors) ==== @@ -18,17 +16,13 @@ file.js(6,14): error TS8010: Type annotations can only be used in TypeScript fil ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -==== file.js (2 errors) ==== +==== file.js (0 errors) ==== /** @typedef {typeof import('./base')} BaseFactory */ /** * * @param {InstanceType} base - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {InstanceType} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const test = (base) => { return base; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsPrivateFields01.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsPrivateFields01.errors.txt deleted file mode 100644 index 19c468ba24..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsPrivateFields01.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -file.js(12,23): error TS8010: Type annotations can only be used in TypeScript files. - - -==== file.js (1 errors) ==== - export class C { - #hello = "hello"; - #world = 100; - - #calcHello() { - return this.#hello; - } - - get #screamingHello() { - return this.#hello.toUpperCase(); - } - /** @param value {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - set #screamingHello(value) { - throw "NO"; - } - - getWorld() { - return this.#world; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.errors.txt deleted file mode 100644 index 7cc5111a4f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.errors.txt +++ /dev/null @@ -1,102 +0,0 @@ -jsDeclarationsReactComponents2.jsx(3,11): error TS8010: Type annotations can only be used in TypeScript files. -jsDeclarationsReactComponents3.jsx(3,11): error TS8010: Type annotations can only be used in TypeScript files. - - -==== jsDeclarationsReactComponents1.jsx (0 errors) ==== - /// - import React from "react"; - import PropTypes from "prop-types" - - const TabbedShowLayout = ({ - }) => { - return ( -
- ); - }; - - TabbedShowLayout.propTypes = { - version: PropTypes.number, - - }; - - TabbedShowLayout.defaultProps = { - tabs: undefined - }; - - export default TabbedShowLayout; - -==== jsDeclarationsReactComponents2.jsx (1 errors) ==== - import React from "react"; - /** - * @type {React.SFC} - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const TabbedShowLayout = () => { - return ( -
- ok -
- ); - }; - - TabbedShowLayout.defaultProps = { - tabs: "default value" - }; - - export default TabbedShowLayout; - -==== jsDeclarationsReactComponents3.jsx (1 errors) ==== - import React from "react"; - /** - * @type {{defaultProps: {tabs: string}} & ((props?: {elem: string}) => JSX.Element)} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const TabbedShowLayout = () => { - return ( -
- ok -
- ); - }; - - TabbedShowLayout.defaultProps = { - tabs: "default value" - }; - - export default TabbedShowLayout; - -==== jsDeclarationsReactComponents4.jsx (0 errors) ==== - import React from "react"; - const TabbedShowLayout = (/** @type {{className: string}}*/prop) => { - return ( -
- ok -
- ); - }; - - TabbedShowLayout.defaultProps = { - tabs: "default value" - }; - - export default TabbedShowLayout; -==== jsDeclarationsReactComponents5.jsx (0 errors) ==== - import React from 'react'; - import PropTypes from 'prop-types'; - - function Tree({ allowDropOnRoot }) { - return
- } - - Tree.propTypes = { - classes: PropTypes.object, - }; - - Tree.defaultProps = { - classes: {}, - parentSource: 'parent_id', - }; - - export default Tree; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js index 9f7053416e..d7751ce4d7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js @@ -227,3 +227,77 @@ declare function Tree({ allowDropOnRoot }: { allowDropOnRoot: any; }): JSX.Element; export default Tree; + + +//// [DtsFileErrors] + + +out/jsDeclarationsReactComponents1.d.ts(1,23): error TS2307: Cannot find module 'prop-types' or its corresponding type declarations. +out/jsDeclarationsReactComponents1.d.ts(3,15): error TS2503: Cannot find namespace 'JSX'. +out/jsDeclarationsReactComponents2.d.ts(1,19): error TS2307: Cannot find module 'react' or its corresponding type declarations. +out/jsDeclarationsReactComponents3.d.ts(10,7): error TS2503: Cannot find namespace 'JSX'. +out/jsDeclarationsReactComponents4.d.ts(2,18): error TS2503: Cannot find namespace 'JSX'. +out/jsDeclarationsReactComponents5.d.ts(3,5): error TS2503: Cannot find namespace 'JSX'. + + +==== out/jsDeclarationsReactComponents1.d.ts (2 errors) ==== + import PropTypes from "prop-types"; + ~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'prop-types' or its corresponding type declarations. + declare const TabbedShowLayout: { + ({}: {}): JSX.Element; + ~~~ +!!! error TS2503: Cannot find namespace 'JSX'. + propTypes: { + version: PropTypes.Requireable; + }; + defaultProps: { + tabs: undefined; + }; + }; + export default TabbedShowLayout; + +==== out/jsDeclarationsReactComponents2.d.ts (1 errors) ==== + import React from "react"; + ~~~~~~~ +!!! error TS2307: Cannot find module 'react' or its corresponding type declarations. + /** + * @type {React.SFC} + */ + declare const TabbedShowLayout: React.SFC; + export default TabbedShowLayout; + +==== out/jsDeclarationsReactComponents3.d.ts (1 errors) ==== + /** + * @type {{defaultProps: {tabs: string}} & ((props?: {elem: string}) => JSX.Element)} + */ + declare const TabbedShowLayout: { + defaultProps: { + tabs: string; + }; + } & ((props?: { + elem: string; + }) => JSX.Element); + ~~~ +!!! error TS2503: Cannot find namespace 'JSX'. + export default TabbedShowLayout; + +==== out/jsDeclarationsReactComponents4.d.ts (1 errors) ==== + declare const TabbedShowLayout: { + (prop: any): JSX.Element; + ~~~ +!!! error TS2503: Cannot find namespace 'JSX'. + defaultProps: { + tabs: string; + }; + }; + export default TabbedShowLayout; + +==== out/jsDeclarationsReactComponents5.d.ts (1 errors) ==== + declare function Tree({ allowDropOnRoot }: { + allowDropOnRoot: any; + }): JSX.Element; + ~~~ +!!! error TS2503: Cannot find namespace 'JSX'. + export default Tree; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js.diff index 0ebe91954f..2fed74569e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.js.diff @@ -144,4 +144,78 @@ - } -} -import PropTypes from 'prop-types'; -+export default Tree; \ No newline at end of file ++export default Tree; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/jsDeclarationsReactComponents1.d.ts(1,23): error TS2307: Cannot find module 'prop-types' or its corresponding type declarations. ++out/jsDeclarationsReactComponents1.d.ts(3,15): error TS2503: Cannot find namespace 'JSX'. ++out/jsDeclarationsReactComponents2.d.ts(1,19): error TS2307: Cannot find module 'react' or its corresponding type declarations. ++out/jsDeclarationsReactComponents3.d.ts(10,7): error TS2503: Cannot find namespace 'JSX'. ++out/jsDeclarationsReactComponents4.d.ts(2,18): error TS2503: Cannot find namespace 'JSX'. ++out/jsDeclarationsReactComponents5.d.ts(3,5): error TS2503: Cannot find namespace 'JSX'. ++ ++ ++==== out/jsDeclarationsReactComponents1.d.ts (2 errors) ==== ++ import PropTypes from "prop-types"; ++ ~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'prop-types' or its corresponding type declarations. ++ declare const TabbedShowLayout: { ++ ({}: {}): JSX.Element; ++ ~~~ ++!!! error TS2503: Cannot find namespace 'JSX'. ++ propTypes: { ++ version: PropTypes.Requireable; ++ }; ++ defaultProps: { ++ tabs: undefined; ++ }; ++ }; ++ export default TabbedShowLayout; ++ ++==== out/jsDeclarationsReactComponents2.d.ts (1 errors) ==== ++ import React from "react"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module 'react' or its corresponding type declarations. ++ /** ++ * @type {React.SFC} ++ */ ++ declare const TabbedShowLayout: React.SFC; ++ export default TabbedShowLayout; ++ ++==== out/jsDeclarationsReactComponents3.d.ts (1 errors) ==== ++ /** ++ * @type {{defaultProps: {tabs: string}} & ((props?: {elem: string}) => JSX.Element)} ++ */ ++ declare const TabbedShowLayout: { ++ defaultProps: { ++ tabs: string; ++ }; ++ } & ((props?: { ++ elem: string; ++ }) => JSX.Element); ++ ~~~ ++!!! error TS2503: Cannot find namespace 'JSX'. ++ export default TabbedShowLayout; ++ ++==== out/jsDeclarationsReactComponents4.d.ts (1 errors) ==== ++ declare const TabbedShowLayout: { ++ (prop: any): JSX.Element; ++ ~~~ ++!!! error TS2503: Cannot find namespace 'JSX'. ++ defaultProps: { ++ tabs: string; ++ }; ++ }; ++ export default TabbedShowLayout; ++ ++==== out/jsDeclarationsReactComponents5.d.ts (1 errors) ==== ++ declare function Tree({ allowDropOnRoot }: { ++ allowDropOnRoot: any; ++ }): JSX.Element; ++ ~~~ ++!!! error TS2503: Cannot find namespace 'JSX'. ++ export default Tree; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReexportedCjsAlias.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReexportedCjsAlias.errors.txt deleted file mode 100644 index 0e2caeb326..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReexportedCjsAlias.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -lib.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== main.js (0 errors) ==== - const { SomeClass, SomeClass: Another } = require('./lib'); - - module.exports = { - SomeClass, - Another - } -==== lib.js (1 errors) ==== - /** - * @param {string} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function bar(a) { - return a + a; - } - - class SomeClass { - a() { - return 1; - } - } - - module.exports = { - bar, - SomeClass - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt index 9e9c17045f..f263e9f33f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt @@ -1,6 +1,5 @@ index.js(7,19): error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? index.js(14,18): error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? -index.js(14,18): error TS8010: Type annotations can only be used in TypeScript files. ==== test.js (0 errors) ==== @@ -17,7 +16,7 @@ index.js(14,18): error TS8010: Type annotations can only be used in TypeScript f } module.exports = { Rectangle }; -==== index.js (3 errors) ==== +==== index.js (2 errors) ==== const {Rectangle} = require('./rectangle'); class Render { @@ -36,8 +35,6 @@ index.js(14,18): error TS8010: Type annotations can only be used in TypeScript f * @returns {Rectangle} the rect ~~~~~~~~~ !!! error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ addRectangle() { const obj = new Rectangle(); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt index 51d795ae7f..42bdb51664 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt @@ -1,64 +1,40 @@ -index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -index.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(22,12): error TS2315: Type 'Object' is not generic. -index.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(22,18): error TS8020: JSDoc types can only be used inside documentation comments. -==== index.js (12 errors) ==== +==== index.js (4 errors) ==== /** @type {?} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const a = null; /** @type {*} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const b = null; /** @type {string?} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const c = null; /** @type {string=} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const d = null; /** @type {string!} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const g = null; /** @type {Object.} */ ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. 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 ee3503cd91..4734b8e4b1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt @@ -1,41 +1,19 @@ -index.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(11,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(44,9): error TS1051: A 'set' accessor cannot have an optional parameter. -index.js(44,9): error TS8009: The '?' modifier can only be used in TypeScript files. -index.js(44,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(54,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(64,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(74,17): error TS8010: Type annotations can only be used in TypeScript files. index.js(82,9): error TS1051: A 'set' accessor cannot have an optional parameter. -index.js(82,9): error TS8009: The '?' modifier can only be used in TypeScript files. -index.js(82,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(87,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(92,17): error TS8010: Type annotations can only be used in TypeScript files. -index.js(97,17): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (16 errors) ==== +==== index.js (2 errors) ==== class С1 { /** @type {string=} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. p1 = undefined; /** @type {string | undefined} */ - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. p2 = undefined; /** @type {?string} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. p3 = null; /** @type {string | null} */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. p4 = null; } @@ -71,10 +49,6 @@ index.js(97,17): error TS8010: Type annotations can only be used in TypeScript f /** @param {string=} value */ ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1051: A 'set' accessor cannot have an optional parameter. - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set p1(value) { this.p1 = value; } @@ -85,8 +59,6 @@ index.js(97,17): error TS8010: Type annotations can only be used in TypeScript f } /** @param {string | undefined} value */ - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set p2(value) { this.p2 = value; } @@ -97,8 +69,6 @@ index.js(97,17): error TS8010: Type annotations can only be used in TypeScript f } /** @param {?string} value */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set p3(value) { this.p3 = value; } @@ -109,8 +79,6 @@ index.js(97,17): error TS8010: Type annotations can only be used in TypeScript f } /** @param {string | null} value */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set p4(value) { this.p4 = value; } @@ -121,31 +89,21 @@ index.js(97,17): error TS8010: Type annotations can only be used in TypeScript f /** @param {string=} value */ ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1051: A 'set' accessor cannot have an optional parameter. - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set p1(value) { this.p1 = value; } /** @param {string | undefined} value */ - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set p2(value) { this.p2 = value; } /** @param {?string} value */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set p3(value) { this.p3 = value; } /** @param {string | null} value */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. set p4(value) { this.p4 = value; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt deleted file mode 100644 index 7b708a7261..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (2 errors) ==== - export class Super { - /** - * @param {string} firstArg - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} secondArg - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(firstArg, secondArg) { } - } - - export class Sub extends Super { - constructor() { - super('first', 'second'); - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt deleted file mode 100644 index c4236c5118..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -index.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - export class A { - /** @returns {this} */ - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - method() { - return this; - } - } - export default class Base extends A { - // This method is required to reproduce #35932 - verify() { } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt index b4904279c5..324fb0ae0d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt @@ -1,11 +1,7 @@ -index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. -mixed.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -mixed.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. mixed.js(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== index.js (2 errors) ==== +==== index.js (0 errors) ==== export {}; // flag file as module /** * @typedef {string | number | symbol} PropName @@ -16,8 +12,6 @@ mixed.js(14,1): error TS2309: An export assignment cannot be used in a module wi * * @callback NumberToStringCb * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string} */ @@ -32,22 +26,16 @@ mixed.js(14,1): error TS2309: An export assignment cannot be used in a module wi * @template T * @callback Identity * @param {T} x - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} */ -==== mixed.js (3 errors) ==== +==== mixed.js (1 errors) ==== /** * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType */ /** * @param {number} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {SomeType} - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function doTheThing(x) { return {x: ""+x}; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt deleted file mode 100644 index f6682d013d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /some-mod.d.ts (0 errors) ==== - interface Item { - x: string; - } - declare const items: Item[]; - export = items; -==== index.js (1 errors) ==== - /** @type {typeof import("/some-mod")} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const items = []; - module.exports = items; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js index a299370c13..be70025cd8 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js @@ -20,3 +20,22 @@ module.exports = items; //// [index.d.ts] export = items; + + +//// [DtsFileErrors] + + +/out/index.d.ts(1,10): error TS2304: Cannot find name 'items'. + + +==== /some-mod.d.ts (0 errors) ==== + interface Item { + x: string; + } + declare const items: Item[]; + export = items; +==== /out/index.d.ts (1 errors) ==== + export = items; + ~~~~~ +!!! error TS2304: Cannot find name 'items'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js.diff index d980260319..046f34d1e2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReassignmentFromDeclaration.js.diff @@ -11,4 +11,23 @@ //// [index.d.ts] export = items; -/** @type {typeof import("/some-mod")} */ --declare const items: typeof import("/some-mod"); \ No newline at end of file +-declare const items: typeof import("/some-mod"); ++ ++ ++//// [DtsFileErrors] ++ ++ ++/out/index.d.ts(1,10): error TS2304: Cannot find name 'items'. ++ ++ ++==== /some-mod.d.ts (0 errors) ==== ++ interface Item { ++ x: string; ++ } ++ declare const items: Item[]; ++ export = items; ++==== /out/index.d.ts (1 errors) ==== ++ export = items; ++ ~~~~~ ++!!! error TS2304: Cannot find name 'items'. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt index 0fc20f0ff0..23837dfb7d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt @@ -1,5 +1,4 @@ conn.js(11,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -usage.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. usage.js(11,37): error TS2694: Namespace 'Conn' has no exported member 'Whatever'. usage.js(16,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -19,7 +18,7 @@ usage.js(16,1): error TS2309: An export assignment cannot be used in a module wi ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== usage.js (3 errors) ==== +==== usage.js (2 errors) ==== /** * @typedef {import("./conn")} Conn */ @@ -27,8 +26,6 @@ usage.js(16,1): error TS2309: An export assignment cannot be used in a module wi class Wrap { /** * @param {Conn} c - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(c) { this.connItem = c.item; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt index 0fe7f869b6..4c105d6974 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt @@ -1,19 +1,15 @@ -LazySet.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. LazySet.js(13,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (1 errors) ==== +==== index.js (0 errors) ==== const LazySet = require("./LazySet"); /** @type {LazySet} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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 @@ -21,8 +17,6 @@ index.js(3,12): error TS8010: Type annotations can only be used in TypeScript fi class LazySet { /** * @param {LazySet} iterable - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ addAll(iterable) {} [Symbol.iterator]() {} diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.errors.txt deleted file mode 100644 index 5c14f33baf..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefFunction.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -foo.js(3,10): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.js (3 errors) ==== - /** - * @typedef {{ - * [id: string]: [Function, Function]; - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * }} ResolveRejectMap - */ - - let id = 0 - - /** - * @param {ResolveRejectMap} handlers - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {Promise} - ~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const send = handlers => new Promise((resolve, reject) => { - handlers[++id] = [resolve, reject] - }) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt index d4efe653ab..0bb4eb949a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt @@ -1,14 +1,10 @@ index.js(3,37): error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. -index.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. -index.js(16,16): error TS8010: Type annotations can only be used in TypeScript files. index.js(21,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -module.js(11,11): error TS8010: Type annotations can only be used in TypeScript files. module.js(24,12): error TS2315: Type 'Object' is not generic. -module.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. module.js(27,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== index.js (4 errors) ==== +==== index.js (2 errors) ==== const {taskGroups, taskNameToGroup} = require('./module.js'); /** @typedef {import('./module.js').TaskGroup} TaskGroup */ @@ -26,11 +22,7 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w class MainThreadTasks { /** * @param {TaskGroup} x - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {TaskNode} y - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(x, y){} } @@ -38,7 +30,7 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w module.exports = MainThreadTasks; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== module.js (4 errors) ==== +==== module.js (2 errors) ==== /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ /** @@ -50,8 +42,6 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w /** * @type {{[P in TaskGroupIds]: {id: P, label: string}}} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const taskGroups = { parseHTML: { @@ -67,8 +57,6 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w /** @type {Object} */ ~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const taskNameToGroup = {}; module.exports = { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt deleted file mode 100644 index 83c112d3a8..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -b.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. -b.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (0 errors) ==== - export const kSymbol = Symbol("my-symbol"); - - /** - * @typedef {{[kSymbol]: true}} WithSymbol - */ -==== b.js (2 errors) ==== - /** - * @returns {import('./a').WithSymbol} - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {import('./a').WithSymbol} value - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function b(value) { - return value; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.errors.txt deleted file mode 100644 index baacb4d3c7..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocBindingInUnreachableCode.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -bug27341.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== bug27341.js (1 errors) ==== - if (false) { - /** - * @param {string} s - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const x = function (s) { - }; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt index a9f5fa3ec7..38388986e6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt @@ -1,36 +1,15 @@ -foo.js(11,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(12,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(13,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(14,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(16,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(17,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(18,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(19,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(20,31): error TS8010: Type annotations can only be used in TypeScript files. foo.js(20,54): error TS2339: Property 'foo' does not exist on type 'unknown'. -foo.js(21,31): error TS8010: Type annotations can only be used in TypeScript files. 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(22,31): error TS8010: Type annotations can only be used in TypeScript files. foo.js(23,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. -foo.js(23,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(27,23): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(34,14): error TS8010: Type annotations can only be used in TypeScript files. foo.js(35,7): error TS2492: Cannot redeclare identifier 'err' in catch clause. -foo.js(39,14): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(44,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(45,31): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(46,31): error TS8010: Type annotations can only be used in TypeScript files. foo.js(46,45): error TS2339: Property 'x' does not exist on type '{}'. -foo.js(47,31): error TS8010: Type annotations can only be used in TypeScript files. 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(48,31): error TS8010: Type annotations can only be used in TypeScript files. foo.js(49,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. -foo.js(49,31): error TS8010: Type annotations can only be used in TypeScript files. -==== foo.js (30 errors) ==== +==== foo.js (9 errors) ==== /** * @typedef {any} Any */ @@ -42,56 +21,30 @@ foo.js(49,31): error TS8010: Type annotations can only be used in TypeScript fil function fn() { try { } catch (x) { } // should be OK try { } catch (/** @type {any} */ err) { } // should be OK - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Any} */ err) { } // should be OK - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {unknown} */ err) { } // should be OK - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Unknown} */ err) { } // should be OK - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (err) { err.foo; } // should be OK try { } catch (/** @type {any} */ err) { err.foo; } // should be OK - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Any} */ err) { err.foo; } // should be OK - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {unknown} */ err) { console.log(err); } // should be OK - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Unknown} */ err) { console.log(err); } // should be OK - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {unknown} */ err) { err.foo; } // error in the body - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2339: Property 'foo' does not exist on type 'unknown'. try { } catch (/** @type {Unknown} */ err) { err.foo; } // error in the body - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! 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. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {object} */ err) { } // error in the type ~~~~~~ !!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { console.log(); } // @ts-ignore catch (/** @type {number} */ err) { // e should not be a `number` - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. console.log(err.toLowerCase()); } @@ -99,8 +52,6 @@ foo.js(49,31): error TS8010: Type annotations can only be used in TypeScript fil try { } catch (err) { /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let err; ~~~ !!! error TS2492: Cannot redeclare identifier 'err' in catch clause. @@ -108,37 +59,23 @@ foo.js(49,31): error TS8010: Type annotations can only be used in TypeScript fil try { } catch (err) { /** @type {boolean} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var err; } try { } catch ({ x }) { } // should be OK try { } catch (/** @type {any} */ { x }) { x.foo; } // should be OK - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {Any} */ { x }) { x.foo;} // should be OK - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {unknown} */ { x }) { console.log(x); } // error in the destructure - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2339: Property 'x' does not exist on type '{}'. try { } catch (/** @type {Unknown} */ { x }) { console.log(x); } // error in the destructure - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! 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. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. try { } catch (/** @type {object} */ { x }) { } // error in the type ~~~~~~ !!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt index 46e867bc80..0ecef16650 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocConstructorFunctionTypeReference.errors.txt @@ -1,8 +1,7 @@ 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(8,12): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocConstructorFunctionTypeReference.js (2 errors) ==== +==== jsdocConstructorFunctionTypeReference.js (1 errors) ==== var Validator = function VFunc() { this.flags = "gim" }; @@ -13,8 +12,6 @@ jsdocConstructorFunctionTypeReference.js(8,12): error TS8010: Type annotations c * @param {Validator} state ~~~~~~~~~ !!! error TS2749: 'Validator' refers to a value, but is being used as a type here. Did you mean 'typeof Validator'? - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var validateRegExpFlags = function(state) { return state.flags diff --git a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt index 37c7202738..bed5688d1f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt @@ -1,32 +1,23 @@ functions.js(3,13): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -functions.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. 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(13,13): error TS8010: Type annotations can only be used in TypeScript files. functions.js(15,14): error TS7006: Parameter 'c' implicitly has an 'any' type. -functions.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. functions.js(30,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -functions.js(30,12): error TS8010: Type annotations can only be used in TypeScript files. 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(36,12): error TS8010: Type annotations can only be used in TypeScript files. 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(49,13): error TS8010: Type annotations can only be used in TypeScript files. functions.js(51,26): error TS7006: Parameter 'dref' implicitly has an 'any' type. -functions.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. -==== functions.js (18 errors) ==== +==== functions.js (11 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id1(c) { ~ @@ -44,8 +35,6 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id2(c) { ~ @@ -55,8 +44,6 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ class C { /** @param {number} n */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor(n) { this.length = n; } @@ -70,8 +57,6 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var f = function (ab, onetwo) { return ab === "a" ? 3 : 4; } ~~ !!! error TS7006: Parameter 'ab' implicitly has an 'any' type. @@ -82,8 +67,6 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ /** * @constructor * @param {number} n - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function D(n) { this.length = n; @@ -99,8 +82,6 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ * @return {D} ~ !!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var construct = function(dref) { return new dref(33); } ~~~~ @@ -112,8 +93,6 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ /** * @constructor * @param {number} n - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var E = function(n) { this.not_length_on_purpose = n; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplementsTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplementsTag.errors.txt deleted file mode 100644 index 1da7f3e732..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplementsTag.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -/a.js(6,17): error TS8005: 'implements' clauses can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - /** - * @typedef { { foo: string } } A - */ - - /** - * @implements { A } - ~~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - */ - class B { - foo = '' - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.errors.txt index a43a519a00..8581f9865b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_class.errors.txt @@ -1,36 +1,23 @@ -/a.js(2,18): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(5,18): error TS8005: 'implements' clauses can only be used in TypeScript files. -/a.js(10,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -/a.js(12,18): error TS8010: Type annotations can only be used in TypeScript files. /a.js(13,5): error TS2416: Property 'method' in type 'B2' is not assignable to the same property in base type 'A'. Type '() => string' is not assignable to type '() => number'. Type 'string' is not assignable to type 'number'. -/a.js(16,18): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(17,7): error TS2720: Class 'B3' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? Property 'method' is missing in type 'B3' but required in type 'A'. -==== /a.js (7 errors) ==== +==== /a.js (2 errors) ==== class A { /** @return {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. method() { throw new Error(); } } /** @implements {A} */ - ~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B { method() { return 0 } } /** @implements A */ - ~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B2 { /** @return {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. method() { return "" } ~~~~~~ !!! error TS2416: Property 'method' in type 'B2' is not assignable to the same property in base type 'A'. @@ -39,8 +26,6 @@ } /** @implements {A} */ - ~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B3 { ~~ !!! error TS2720: Class 'B3' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface.errors.txt index f765111c90..ed55466360 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface.errors.txt @@ -1,9 +1,6 @@ -/a.js(1,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -/a.js(7,18): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(9,5): error TS2416: Property 'mNumber' in type 'B2' is not assignable to the same property in base type 'A'. Type '() => string' is not assignable to type '() => number'. Type 'string' is not assignable to type 'number'. -/a.js(13,17): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(14,7): error TS2420: Class 'B3' incorrectly implements interface 'A'. Property 'mNumber' is missing in type 'B3' but required in type 'A'. @@ -12,18 +9,14 @@ interface A { mNumber(): number; } -==== /a.js (5 errors) ==== +==== /a.js (2 errors) ==== /** @implements A */ - ~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B { mNumber() { return 0; } } /** @implements {A} */ - ~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B2 { mNumber() { ~~~~~~~ @@ -34,8 +27,6 @@ } } /** @implements A */ - ~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B3 { ~~ !!! error TS2420: Class 'B3' incorrectly implements interface 'A'. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface_multiple.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface_multiple.errors.txt index 946e60604a..334422ee60 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface_multiple.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_interface_multiple.errors.txt @@ -1,5 +1,3 @@ -/a.js(2,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -/a.js(14,16): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(17,7): error TS2420: Class 'BadSquare' incorrectly implements interface 'Drawable'. Property 'draw' is missing in type 'BadSquare' but required in type 'Drawable'. @@ -11,11 +9,9 @@ interface Sizable { size(): number; } -==== /a.js (3 errors) ==== +==== /a.js (1 errors) ==== /** * @implements {Drawable} - ~~~~~~~~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. * @implements Sizable **/ class Square { @@ -28,8 +24,6 @@ } /** * @implements Drawable - ~~~~~~~~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. * @implements {Sizable} **/ class BadSquare { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.errors.txt deleted file mode 100644 index 2a8c36723f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -/a.js(2,16): error TS8005: 'implements' clauses can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class A { constructor() { this.x = 0; } } - /** @implements */ - -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js index 222dea0291..0d5243e60c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js @@ -16,3 +16,21 @@ declare class A { /** @implements */ declare class B implements { } + + +//// [DtsFileErrors] + + +out/a.d.ts(5,27): error TS1097: 'implements' list cannot be empty. + + +==== out/a.d.ts (1 errors) ==== + declare class A { + constructor(); + } + /** @implements */ + declare class B implements { + +!!! error TS1097: 'implements' list cannot be empty. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js.diff b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js.diff index 0f948ec122..643e190e6e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_missingType.js.diff @@ -10,4 +10,22 @@ /** @implements */ -declare class B { +declare class B implements { - } \ No newline at end of file + } ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/a.d.ts(5,27): error TS1097: 'implements' list cannot be empty. ++ ++ ++==== out/a.d.ts (1 errors) ==== ++ declare class A { ++ constructor(); ++ } ++ /** @implements */ ++ declare class B implements { ++ ++!!! error TS1097: 'implements' list cannot be empty. ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_namespacedInterface.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_namespacedInterface.errors.txt deleted file mode 100644 index 577f1a2988..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_namespacedInterface.errors.txt +++ /dev/null @@ -1,31 +0,0 @@ -/a.js(1,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -/a.js(7,18): error TS8005: 'implements' clauses can only be used in TypeScript files. - - -==== /defs.d.ts (0 errors) ==== - declare namespace N { - interface A { - mNumber(): number; - } - interface AT { - gen(): T; - } - } -==== /a.js (2 errors) ==== - /** @implements N.A */ - ~~~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B { - mNumber() { - return 0; - } - } - /** @implements {N.AT} */ - ~~~~~~~~~~~~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class BAT { - gen() { - return ""; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_properties.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_properties.errors.txt index 159012fca2..5d509a500f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_properties.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_properties.errors.txt @@ -1,15 +1,10 @@ -/a.js(2,17): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(3,7): error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? Property 'x' is missing in type 'B' but required in type 'A'. -/a.js(5,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -/a.js(10,18): error TS8005: 'implements' clauses can only be used in TypeScript files. -==== /a.js (4 errors) ==== +==== /a.js (1 errors) ==== class A { constructor() { this.x = 0; } } /** @implements A*/ - ~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B {} ~ !!! error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? @@ -17,15 +12,11 @@ !!! related TS2728 /a.js:1:27: 'x' is declared here. /** @implements A*/ - ~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B2 { x = 10 } /** @implements {A}*/ - ~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B3 { constructor() { this.x = 10 } } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImplements_signatures.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImplements_signatures.errors.txt index 56fcb0bd9c..1ababbc2c2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImplements_signatures.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImplements_signatures.errors.txt @@ -1,4 +1,3 @@ -/a.js(1,18): error TS8005: 'implements' clauses can only be used in TypeScript files. /a.js(2,7): error TS2420: Class 'B' incorrectly implements interface 'Sig'. Index signature for type 'string' is missing in type 'B'. @@ -7,10 +6,8 @@ interface Sig { [index: string]: string } -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** @implements {Sig} */ - ~~~ -!!! error TS8005: 'implements' clauses can only be used in TypeScript files. class B { ~ !!! error TS2420: Class 'B' incorrectly implements interface 'Sig'. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportType.errors.txt deleted file mode 100644 index 166ff64c9a..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportType.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -use.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -use.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== use.js (2 errors) ==== - /// - /** @typedef {import("./mod1")} C - * @type {C} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var c; - c.chunk; - - const D = require("./mod1"); - /** @type {D} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - 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/jsdocImportType2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportType2.errors.txt deleted file mode 100644 index 30f9404c8d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportType2.errors.txt +++ /dev/null @@ -1,32 +0,0 @@ -use.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -use.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== use.js (2 errors) ==== - /// - /** @typedef {import("./mod1")} C - * @type {C} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var c; - c.chunk; - - const D = require("./mod1"); - /** @type {D} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - 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/jsdocImportTypeReferenceToClassAlias.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt index b8355a36f6..0a42dea7d4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt @@ -1,5 +1,4 @@ test.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'C'. -test.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. ==== mod1.js (0 errors) ==== @@ -8,13 +7,11 @@ test.js(2,13): error TS8010: Type annotations can only be used in TypeScript fil } module.exports.C = C -==== test.js (2 errors) ==== +==== test.js (1 errors) ==== /** @typedef {import('./mod1').C} X */ ~ !!! error TS2694: Namespace '"mod1"' has no exported member 'C'. /** @param {X} c */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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 index fd692f18ae..7cfc65e1df 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt @@ -1,5 +1,4 @@ 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')'? -test.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. ==== ex.d.ts (0 errors) ==== @@ -8,12 +7,10 @@ test.js(1,13): error TS8010: Type annotations can only be used in TypeScript fil } export = config; -==== test.js (2 errors) ==== +==== 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')'? - ~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function demo(a) { a.fix } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt index b8c79dc5f0..b5f2e2a2bf 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToESModule.errors.txt @@ -1,16 +1,13 @@ 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')'? -test.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. ==== ex.d.ts (0 errors) ==== export var config: {} -==== test.js (2 errors) ==== +==== 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')'? - ~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function demo(a) { a.config } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt index a491c8d50d..84a4804709 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt @@ -1,14 +1,11 @@ -a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(1,26): error TS2694: Namespace '"b"' has no exported member 'FOO'. ==== b.js (0 errors) ==== export const FOO = "foo"; -==== a.js (2 errors) ==== +==== a.js (1 errors) ==== /** @type {import('./b').FOO} */ - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"b"' has no exported member 'FOO'. let x; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt index bcc6e31b3c..0572ee15d8 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt @@ -1,47 +1,35 @@ indices.js(1,12): error TS2315: Type 'Object' is not generic. -indices.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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,12): error TS8010: Type annotations can only be used in TypeScript files. 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,12): error TS8010: Type annotations can only be used in TypeScript files. 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,13): error TS8010: Type annotations can only be used in TypeScript files. indices.js(7,19): error TS8020: JSDoc types can only be used inside documentation comments. -==== indices.js (12 errors) ==== +==== indices.js (8 errors) ==== /** @type {Object.} */ ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. var o1; /** @type {Object.} */ ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. var o2; /** @type {Object.} */ ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. var o3; /** @param {Object.} o */ ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8020: JSDoc types can only be used inside documentation comments. function f(o) { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocLiteral.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocLiteral.errors.txt deleted file mode 100644 index 1ba28333e0..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocLiteral.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -in.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -in.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -in.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -in.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -in.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== in.js (5 errors) ==== - /** - * @param {'literal'} p1 - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {"literal"} p2 - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {'literal' | 'other'} p3 - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {'literal' | number} p4 - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {12 | true | 'str'} p5 - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(p1, p2, p3, p4, p5) { - return p1 + p2 + p3 + p4 + p5 + '.'; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.errors.txt deleted file mode 100644 index e452be0f5a..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocNeverUndefinedNull.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -in.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -in.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -in.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -in.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== in.js (4 errors) ==== - /** - * @param {never} p1 - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {undefined} p2 - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {null} p3 - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {void} nothing - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(p1, p2, p3) { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt index e20efba707..c0a05d7652 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters1.errors.txt @@ -1,14 +1,11 @@ jsdocOuterTypeParameters1.js(1,14): error TS2304: Cannot find name 'T'. -jsdocOuterTypeParameters1.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. jsdocOuterTypeParameters1.js(7,35): error TS2339: Property 'foo' does not exist on type 'Bar'. -==== jsdocOuterTypeParameters1.js (3 errors) ==== +==== jsdocOuterTypeParameters1.js (2 errors) ==== /** @return {T} */ ~ !!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const dedupingMixin = function(mixin) {}; /** @template {T} */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt index be5eb731dd..f78e45da6b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOuterTypeParameters2.errors.txt @@ -1,14 +1,11 @@ jsdocOuterTypeParameters1.js(1,14): error TS2304: Cannot find name 'T'. -jsdocOuterTypeParameters1.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. jsdocOuterTypeParameters1.js(7,35): error TS2339: Property 'foo' does not exist on type 'Bar'. -==== jsdocOuterTypeParameters1.js (3 errors) ==== +==== jsdocOuterTypeParameters1.js (2 errors) ==== /** @return {T} */ ~ !!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const dedupingMixin = function(mixin) {}; /** @template T */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt index f31b733fc3..d6655383b2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt @@ -1,23 +1,15 @@ -0.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -0.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. -0.js(20,16): error TS8010: Type annotations can only be used in TypeScript files. -0.js(21,18): error TS8010: Type annotations can only be used in TypeScript files. 0.js(27,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'A'. 0.js(32,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. 0.js(40,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. -==== 0.js (7 errors) ==== +==== 0.js (3 errors) ==== class A { /** * @method * @param {string | number} a - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean} - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ foo (a) { return typeof a === 'string' @@ -32,11 +24,7 @@ * @override * @method * @param {string | number} a - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean} - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ foo (a) { return super.foo(a) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.errors.txt index 3ae3296eb6..f796c7c463 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.errors.txt @@ -1,61 +1,26 @@ -0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(26,4): error TS8010: Type annotations can only be used in TypeScript files. -0.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(33,4): error TS8010: Type annotations can only be used in TypeScript files. -0.js(36,4): error TS8010: Type annotations can only be used in TypeScript files. -0.js(41,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(43,4): error TS8010: Type annotations can only be used in TypeScript files. -0.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(50,4): error TS8010: Type annotations can only be used in TypeScript files. -0.js(56,12): error TS8010: Type annotations can only be used in TypeScript files. -0.js(66,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(70,20): error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name. -0.js(71,12): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (20 errors) ==== +==== 0.js (1 errors) ==== // Object literal syntax /** * @param {{a: string, b: string}} obj - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good1({a, b}, x) {} /** * @param {{a: string, b: string}} obj - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{c: number, d: number}} OBJECTION - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good2({a, b}, {c, d}) {} /** * @param {number} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{a: string, b: string}} obj - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} y - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good3(x, {a, b}, y) {} /** * @param {{a: string, b: string}} obj - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good4({a, b}) {} @@ -63,64 +28,36 @@ /** * @param {Object} obj * @param {string} obj.a - this is like the saddest way to specify a type - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} obj.b - but it sure does allow a lot of documentation - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} x - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good5({a, b}, x) {} /** * @param {Object} obj * @param {string} obj.a - ~~~~~~~~~~~~~~~~~~~~~ * @param {string} obj.b - but it sure does allow a lot of documentation - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Object} OBJECTION - documentation here too - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} OBJECTION.c - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} OBJECTION.d - meh - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function good6({a, b}, {c, d}) {} /** * @param {number} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Object} obj * @param {string} obj.a - ~~~~~~~~~~~~~~~~~~~~~ * @param {string} obj.b - ~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} y - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good7(x, {a, b}, y) {} /** * @param {Object} obj * @param {string} obj.a - ~~~~~~~~~~~~~~~~~~~~~ * @param {string} obj.b - ~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function good8({a, b}) {} /** * @param {{ a: string }} argument - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function good9({ a }) { console.log(arguments, a); @@ -131,8 +68,6 @@ * @param {string} obj.a * @param {string} obj.b - and x's type gets used for both parameters * @param {string} x - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function bad1(x, {a, b}) {} /** @@ -140,8 +75,6 @@ ~ !!! error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name. * @param {{a: string, b: string}} obj - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function bad2(x, {a, b}) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt index 7a8acf159d..7a62f459cb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.errors.txt @@ -1,17 +1,9 @@ -0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(3,20): error TS8024: JSDoc '@param' tag has name 'unrelated', but there is no parameter with that name. -0.js(12,4): error TS8010: Type annotations can only be used in TypeScript files. -0.js(25,4): error TS8010: Type annotations can only be used in TypeScript files. -0.js(36,4): error TS8010: Type annotations can only be used in TypeScript files. -0.js(45,4): error TS8010: Type annotations can only be used in TypeScript files. -0.js(58,4): error TS8010: Type annotations can only be used in TypeScript files. -==== 0.js (7 errors) ==== +==== 0.js (1 errors) ==== /** * @param {Object} notSpecial - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @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. @@ -24,16 +16,10 @@ /** * @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 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function foo1(opts1) { opts1.x; } @@ -43,12 +29,8 @@ /** * @param {Object[]} opts2 * @param {string} opts2[].anotherX - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string=} opts2[].anotherY - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function foo2(/** @param opts2 bad idea theatre! */opts2) { opts2[0].anotherX; } @@ -58,10 +40,7 @@ /** * @param {object} opts3 * @param {string} opts3.x - ~~~~~~~~~~~~~~~~~~~~~~~ */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function foo3(opts3) { opts3.x; } @@ -70,14 +49,9 @@ /** * @param {object[]} opts4 * @param {string} opts4[].x - ~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string=} opts4[].y - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} [opts4[].z] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {string} [opts4[].w="hi"] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function foo4(opts4) { opts4[0].x; @@ -88,22 +62,13 @@ /** * @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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function foo5(opts5) { opts5[0].what.bad[0].idea; opts5[0].unnest; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt index db753b7b9d..4a853ebcdf 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseBackquotedParamName.errors.txt @@ -1,20 +1,10 @@ -a.js(2,4): error TS8009: The '?' modifier can only be used in TypeScript files. -a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(3,20): error TS8010: Type annotations can only be used in TypeScript files. a.js(5,18): error TS1016: A required parameter cannot follow an optional parameter. -==== a.js (4 errors) ==== +==== a.js (1 errors) ==== /** * @param {string=} `args` - ~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param `bwarg` {?number?} - ~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(args, bwarg) { ~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt index 7e11a2a1b4..4d4beab51f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt @@ -1,9 +1,8 @@ a.js(3,12): error TS7006: Parameter 'callback' implicitly has an 'any' type. -a.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. a.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -==== a.js (3 errors) ==== +==== a.js (2 errors) ==== // from bcryptjs /** @param {function(...[*])} callback */ function g(callback) { @@ -14,8 +13,6 @@ a.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? /** * @type {!function(...number):string} - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt index 2f537e498f..ff420a46d1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseHigherOrderFunction.errors.txt @@ -1,16 +1,13 @@ paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -paren.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (4 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x = (s, id) => id(s) ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. 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 4e8aa1f93b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseMatchingBackticks.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -jsdocParseMatchingBackticks.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocParseMatchingBackticks.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -jsdocParseMatchingBackticks.js(7,19): error TS8010: Type annotations can only be used in TypeScript files. -jsdocParseMatchingBackticks.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. -jsdocParseMatchingBackticks.js(9,24): error TS8010: Type annotations can only be used in TypeScript files. -jsdocParseMatchingBackticks.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== jsdocParseMatchingBackticks.js (6 errors) ==== - /** - * `@param` initial at-param is OK in title comment - * @param {string} x hi there `@param` - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} y hi there `@ * param - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * this is the margin - * so we'll drop everything before it - `@param` @param {string} z hello??? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * `@param` @param {string} alpha hello??? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * `@ * param` @param {string} beta hello??? - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} gamma - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function f(x, y, z, alpha, beta, gamma) { - return x + y + z + alpha + beta + gamma - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt index e875fad048..89b948713c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt @@ -1,15 +1,12 @@ paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -paren.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. paren.js(2,9): error TS7006: Parameter 's' implicitly has an 'any' type. -==== paren.js (3 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x = s => s.toString() ~ !!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt index 6d388ca6ec..b4c0510f9b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocParseStarEquals.errors.txt @@ -1,25 +1,14 @@ a.js(1,5): error TS1047: A rest parameter cannot be optional. -a.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. -a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. -a.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. a.js(3,12): error TS2370: A rest parameter must be of an array type. -a.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. a.js(12,14): error TS7006: Parameter 'f' implicitly has an 'any' type. -==== a.js (7 errors) ==== +==== a.js (3 errors) ==== /** @param {...*=} args ~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. @return {*=} */ ~~~~ !!! error TS1047: A rest parameter cannot be optional. - ~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(...args) { ~~~~~~~ !!! error TS2370: A rest parameter must be of an array type. @@ -27,8 +16,6 @@ a.js(12,14): error TS7006: Parameter 'f' implicitly has an 'any' type. } /** @type *= */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt index 3c242247a5..718c106001 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt @@ -1,17 +1,9 @@ -a.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. -a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. 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(12,5): error TS8009: The '?' modifier can only be used in TypeScript files. -a.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (6 errors) ==== +==== a.js (2 errors) ==== /** @param {number=} a */ - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(a) { a = 1 a = null // should not be allowed @@ -27,10 +19,6 @@ a.js(12,13): error TS8010: Type annotations can only be used in TypeScript files f(1) /** @param {???!?number?=} a */ - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function g(a) { a = 1 a = null diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt index 81683026ae..f6d00af955 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocPrefixPostfixParsing.errors.txt @@ -1,61 +1,25 @@ -prefixPostfix.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -prefixPostfix.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. prefixPostfix.js(18,21): error TS7006: Parameter 'a' implicitly has an 'any' type. prefixPostfix.js(18,39): error TS7006: Parameter 'h' implicitly has an 'any' type. prefixPostfix.js(18,48): error TS7006: Parameter 'k' implicitly has an 'any' type. -==== prefixPostfix.js (15 errors) ==== +==== prefixPostfix.js (3 errors) ==== /** * @param {number![]} x - number[] - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {!number[]} y - number[] - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(number[])!} z - number[] - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number?[]} a - parse error without parentheses * @param {?number[]} b - number[] | null - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(number[])?} c - number[] | null - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...?number} e - (number | null)[] - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?} f - number[] | null - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number!?} g - number[] | null - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?!} h - parse error without parentheses (also nonsensical) * @param {...number[]} i - number[][] - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number![]?} j - number[][] | null - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?[]!} k - parse error without parentheses * @param {number extends number ? true : false} l - conditional types work - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {[number, number?]} m - [number, (number | undefined)?] - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f(x, y, z, a, b, c, e, f, g, h, i, j, k, l, m) { ~ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt index 7ea0393e0d..d6c7a99ac5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocPrivateName1.errors.txt @@ -1,12 +1,9 @@ -jsdocPrivateName1.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. jsdocPrivateName1.js(3,5): error TS2322: Type 'number' is not assignable to type 'boolean'. -==== jsdocPrivateName1.js (2 errors) ==== +==== jsdocPrivateName1.js (1 errors) ==== class A { /** @type {boolean} some number value */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. #foo = 3 // Error because not assignable to boolean ~~~~ !!! error TS2322: Type 'number' is not assignable to type 'boolean'. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt index 1284cb8387..43fe18d5d5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt @@ -1,12 +1,11 @@ jsdocReadonly.js(3,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. jsdocReadonly.js(4,8): error TS8009: The 'private' modifier can only be used in TypeScript files. -jsdocReadonly.js(5,15): error TS8010: Type annotations can only be used in TypeScript files. jsdocReadonly.js(9,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. jsdocReadonly.js(11,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. jsdocReadonly.js(23,3): error TS2540: Cannot assign to 'y' because it is a read-only property. -==== jsdocReadonly.js (6 errors) ==== +==== jsdocReadonly.js (5 errors) ==== class LOL { /** * @readonly @@ -18,8 +17,6 @@ jsdocReadonly.js(23,3): error TS2540: Cannot assign to 'y' because it is a read- * @type {number} ~~~~~~~ !!! error TS8009: The 'private' modifier can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * Order rules do not apply to JSDoc */ x = 1 diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt deleted file mode 100644 index 1dddcd094b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocReturnTag1.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -returns.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. -returns.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. -returns.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== returns.js (3 errors) ==== - /** - * @returns {string} This comment is not currently exposed - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f() { - return 5; - } - - /** - * @returns {string=} This comment is not currently exposed - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f1() { - return 5; - } - - /** - * @returns {string|number} This comment is not currently exposed - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f2() { - return 5 || "hello"; - } - \ No newline at end of file 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 29b0ca1188..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.errors.txt +++ /dev/null @@ -1,63 +0,0 @@ -jsdocSignatureOnReturnedFunction.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -jsdocSignatureOnReturnedFunction.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. -jsdocSignatureOnReturnedFunction.js(5,18): error TS8010: Type annotations can only be used in TypeScript files. -jsdocSignatureOnReturnedFunction.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. -jsdocSignatureOnReturnedFunction.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. -jsdocSignatureOnReturnedFunction.js(16,18): error TS8010: Type annotations can only be used in TypeScript files. -jsdocSignatureOnReturnedFunction.js(24,16): error TS8016: Type assertion expressions can only be used in TypeScript files. -jsdocSignatureOnReturnedFunction.js(31,16): error TS8016: Type assertion expressions can only be used in TypeScript files. - - -==== jsdocSignatureOnReturnedFunction.js (8 errors) ==== - function f1() { - /** - * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} b - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - return (a, b) => { - return a + b; - } - } - - function f2() { - /** - * @param {number} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} b - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - return function (a, b){ - return a + b; - } - } - - function f3() { - /** @type {(a: number, b: number) => number} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - return (a, b) => { - return a + b; - } - } - - function f4() { - /** @type {(a: number, b: number) => number} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - return function (a, b){ - return a + b; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt index 3d7b368d69..2ca7b00aaf 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt @@ -1,23 +1,14 @@ templateTagOnClasses.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -templateTagOnClasses.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. -templateTagOnClasses.js(7,22): error TS8010: Type annotations can only be used in TypeScript files. -templateTagOnClasses.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. -templateTagOnClasses.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. -templateTagOnClasses.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. -templateTagOnClasses.js(16,16): error TS8010: Type annotations can only be used in TypeScript files. -templateTagOnClasses.js(17,17): error TS8010: Type annotations can only be used in TypeScript files. templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to type 'number'. -==== templateTagOnClasses.js (9 errors) ==== +==== templateTagOnClasses.js (2 errors) ==== /** ~~~ * @template T ~~~~~~~~~~~~~~ * @typedef {(t: T) => T} Id ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ /** @template T */ @@ -26,12 +17,8 @@ templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to ~~~~~~~~~~~ /** @typedef {(t: T) => T} Id2 */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @param {T} x */ ~~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor (x) { ~~~~~~~~~~~~~~~~~~~~~ this.a = x @@ -44,20 +31,12 @@ templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to ~~~~~~~ * @param {T} x ~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Id} y ~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Id2} alpha ~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} ~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ foo(x, y, alpha) { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt index d362e11e78..258b41f69c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt @@ -1,25 +1,19 @@ templateTagOnConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -templateTagOnConstructorFunctions.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. -templateTagOnConstructorFunctions.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -==== templateTagOnConstructorFunctions.js (3 errors) ==== +==== templateTagOnConstructorFunctions.js (1 errors) ==== /** ~~~ * @template U ~~~~~~~~~~~~~~ * @typedef {(u: U) => U} Id ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ /** ~~~ * @param {T} t ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T ~~~~~~~~~~~~~~ */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt index 9fe82440e2..88d214edd0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt @@ -1,17 +1,12 @@ templateTagWithNestedTypeLiteral.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -templateTagWithNestedTypeLiteral.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -templateTagWithNestedTypeLiteral.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. -templateTagWithNestedTypeLiteral.js(30,12): error TS8010: Type annotations can only be used in TypeScript files. -==== templateTagWithNestedTypeLiteral.js (5 errors) ==== +==== templateTagWithNestedTypeLiteral.js (2 errors) ==== /** ~~~ * @param {T} t ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T ~~~~~~~~~~~~~~ */ @@ -40,8 +35,6 @@ templateTagWithNestedTypeLiteral.js(30,12): error TS8010: Type annotations can o z.t = 2 z.u = false /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let answer = z.add(3, { nested: 4 }) // lookup in typedef should not crash the compiler, even when the type is unknown @@ -52,7 +45,5 @@ templateTagWithNestedTypeLiteral.js(30,12): error TS8010: Type annotations can o !!! error TS2304: Cannot find name 'T'. */ /** @type {A} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const options = { value: null }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt index 20e84085b6..a28b08944c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt @@ -1,20 +1,15 @@ forgot.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -forgot.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. forgot.js(8,15): error TS8004: Type parameter declarations can only be used in TypeScript files. -forgot.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. forgot.js(13,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -forgot.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (7 errors) ==== +==== forgot.js (4 errors) ==== /** ~~~ * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T ~~~~~~~~~~~~~~ */ @@ -34,8 +29,6 @@ forgot.js(23,1): error TS2322: Type '(keyframes: Keyframe[] | PropertyIndexedKey ~~~ * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T ~~~~~~~~~~~~~~ * @returns {function(): T} @@ -43,8 +36,6 @@ forgot.js(23,1): error TS2322: Type '(keyframes: Keyframe[] | PropertyIndexedKey ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function g(a) { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt index 734af7a3bf..efab5bd351 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt @@ -1,18 +1,12 @@ -github17339.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. -github17339.js(5,15): error TS8010: Type annotations can only be used in TypeScript files. github17339.js(7,4): error TS8004: Type parameter declarations can only be used in TypeScript files. -==== github17339.js (3 errors) ==== +==== github17339.js (1 errors) ==== var obj = { /** * @template T * @param {T} a - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ x: function (a) { ~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt index 04c6b96d39..81a8913437 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt @@ -1,18 +1,11 @@ a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(11,13): error TS8010: Type annotations can only be used in TypeScript files. 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 TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. a.js(21,50): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (12 errors) ==== +==== a.js (5 errors) ==== /** ~~~ * @template {{ a: number, b: string }} T,U A Comment @@ -25,28 +18,16 @@ a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} t ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} u ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {V} v ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {W} w ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {X} x ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {W | X} ~~~~~~~~~~~~~~~~~~ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f(t, u, v, w, x) { @@ -83,8 +64,6 @@ a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} x ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function g(x) { } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt index 58751af3dd..bf5d19e95c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt @@ -2,28 +2,22 @@ a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScr a.js(8,16): error TS2315: Type 'Object' is not generic. a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. a.js(14,16): error TS2304: Cannot find name 'K'. -a.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. a.js(15,18): error TS2304: Cannot find name 'V'. -a.js(15,18): error TS8010: Type annotations can only be used in TypeScript files. a.js(18,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. a.js(28,16): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(29,16): error TS2315: Type 'Object' is not generic. a.js(30,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. a.js(35,16): error TS2304: Cannot find name 'K'. -a.js(35,16): error TS8010: Type annotations can only be used in TypeScript files. a.js(36,18): error TS2304: Cannot find name 'V'. -a.js(36,18): error TS8010: Type annotations can only be used in TypeScript files. a.js(39,21): error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. a.js(51,16): error TS2315: Type 'Object' is not generic. a.js(52,10): error TS2339: Property '_map' does not exist on type '{ Multimap3: { (): void; prototype: { get(key: K): V; }; }; }'. a.js(57,16): error TS2304: Cannot find name 'K'. -a.js(57,16): error TS8010: Type annotations can only be used in TypeScript files. a.js(58,18): error TS2304: Cannot find name 'V'. -a.js(58,18): error TS8010: Type annotations can only be used in TypeScript files. a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. -==== a.js (23 errors) ==== +==== a.js (17 errors) ==== /** ~~~ * Should work for function declarations @@ -55,13 +49,9 @@ a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K) * @param {K} key the key ok ~ !!! error TS2304: Cannot find name 'K'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {V} the value ok ~ !!! error TS2304: Cannot find name 'V'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ get(key) { return this._map[key + '']; @@ -95,13 +85,9 @@ a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K) * @param {K} key the key ok ~ !!! error TS2304: Cannot find name 'K'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {V} the value ok ~ !!! error TS2304: Cannot find name 'V'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ get: function(key) { return this._map[key + '']; @@ -131,13 +117,9 @@ a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K) * @param {K} key the key ok ~ !!! error TS2304: Cannot find name 'K'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {V} the value ok ~ !!! error TS2304: Cannot find name 'V'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ get(key) { return this._map[key + '']; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt index e724a31559..fef8fdb70c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt @@ -1,40 +1,22 @@ a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. a.js(11,64): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. a.js(23,64): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(28,14): error TS8010: Type annotations can only be used in TypeScript files. a.js(34,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(38,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(39,14): error TS8010: Type annotations can only be used in TypeScript files. a.js(45,54): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(50,14): error TS8010: Type annotations can only be used in TypeScript files. a.js(56,62): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(63,16): error TS8010: Type annotations can only be used in TypeScript files. a.js(65,22): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(69,16): error TS8010: Type annotations can only be used in TypeScript files. a.js(77,40): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(81,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (22 errors) ==== +==== a.js (8 errors) ==== /** ~~~ * @template const T ~~~~~~~~~~~~~~~~~~~~ * @param {T} x ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f1(x) { @@ -56,12 +38,8 @@ a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files ~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} x ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f2(x) { @@ -83,12 +61,8 @@ a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files ~~~~~~~~~~~~~~~~~~~~ * @param {T} x ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T[]} ~~~~~~~~~~~~~~~~~ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f3(x) { @@ -109,12 +83,8 @@ a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files ~~~~~~~~~~~~~~~~~~~~ * @param {[T, T]} x ~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f4(x) { @@ -135,12 +105,8 @@ a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files ~~~~~~~~~~~~~~~~~~~~ * @param {{ x: T, y: T}} obj ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f5(obj) { @@ -167,8 +133,6 @@ a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files ~~~~~~~ * @param {T} x ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ constructor(x) {} @@ -186,8 +150,6 @@ a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files * @param {U} x ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ ~~~~~~~ @@ -216,12 +178,8 @@ a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} args ~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f6(...args) { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt index 2a7998035b..e1c76679e3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt @@ -2,11 +2,9 @@ a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScr a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class a.js(9,12): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter -a.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (6 errors) ==== +==== a.js (4 errors) ==== /** ~~~ * @template const T @@ -39,12 +37,8 @@ a.js(14,14): error TS8010: Type annotations can only be used in TypeScript files !!! error TS1273: 'private' modifier cannot appear on a type parameter * @param {T} x ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f(x) { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt index 350fe00154..35e879af8b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt @@ -1,18 +1,10 @@ a.js(2,14): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias -a.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. -a.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. 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(23,18): error TS8010: Type annotations can only be used in TypeScript files. -a.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. -a.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. 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(42,18): error TS8010: Type annotations can only be used in TypeScript files. -a.js(46,11): error TS8010: Type annotations can only be used in TypeScript files. -a.js(51,11): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -23,10 +15,9 @@ a.js(56,1): error TS2322: Type 'Invariant' is not assignable to type 'I Type 'unknown' is not assignable to type 'string'. a.js(56,33): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias -a.js(60,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (18 errors) ==== +==== a.js (9 errors) ==== /** * @template out T ~~~ @@ -37,15 +28,11 @@ a.js(60,12): error TS8010: Type annotations can only be used in TypeScript files /** * @type {Covariant} - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ let super_covariant = { x: 1 }; /** * @type {Covariant} - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ let sub_covariant = { x: '' }; @@ -61,21 +48,15 @@ a.js(60,12): error TS8010: Type annotations can only be used in TypeScript files !!! 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 - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** * @type {Contravariant} - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ let super_contravariant = { f: (x) => {} }; /** * @type {Contravariant} - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ let sub_contravariant = { f: (x) => {} }; @@ -91,21 +72,15 @@ a.js(60,12): error TS8010: Type annotations can only be used in TypeScript files !!! 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 - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ /** * @type {Invariant} - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ let super_invariant = { f: (x) => {} }; /** * @type {Invariant} - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ let sub_invariant = { f: (x) => { return "" } }; @@ -132,8 +107,6 @@ a.js(60,12): error TS8010: Type annotations can only be used in TypeScript files !!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @param {T} x ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f(x) {} diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt index 36ffe95d38..222236d979 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt @@ -1,46 +1,28 @@ -file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(9,20): error TS2322: Type 'number' is not assignable to type 'string'. -file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(13,21): error TS8004: Type parameter declarations can only be used in TypeScript files. 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(46,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(49,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. -file.js(54,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(57,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. -file.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. -file.js(63,12): error TS8010: Type annotations can only be used in TypeScript files. -==== file.js (18 errors) ==== +==== file.js (8 errors) ==== /** * @template {string | number} [T=string] - ok: defaults are permitted * @typedef {[T]} A */ /** @type {A} */ // ok, default for `T` in `A` is `string` - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const aDefault1 = [""]; /** @type {A} */ // error: `number` is not assignable to string` - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const aDefault2 = [0]; ~ !!! error TS2322: Type 'number' is not assignable to type 'string'. /** @type {A} */ // ok, `T` is provided for `A` - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const aString = [""]; /** @type {A} */ // ok, `T` is provided for `A` - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const aNumber = [0]; @@ -113,12 +95,8 @@ file.js(63,12): error TS8010: Type annotations can only be used in TypeScript fi ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f1(a, b) {} @@ -137,12 +115,8 @@ file.js(63,12): error TS8010: Type annotations can only be used in TypeScript fi !!! error TS2706: Required type parameters may not follow optional type parameters. * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f2(a, b) {} @@ -161,12 +135,8 @@ file.js(63,12): error TS8010: Type annotations can only be used in TypeScript fi ~~~~~~~~~~~~~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f3(a, b) {} diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt index f537a718bb..64df35ea66 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt @@ -1,8 +1,7 @@ -file.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. file.js(10,7): error TS2322: Type 'string' is not assignable to type 'number'. -==== file.js (2 errors) ==== +==== file.js (1 errors) ==== /** * @template T * @template {keyof T} K @@ -12,8 +11,6 @@ file.js(10,7): error TS2322: Type 'string' is not assignable to type 'number'. const x = { a: 1 }; /** @type {Foo} */ - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const y = "a"; ~ !!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt index 42dfb99747..94ee1d5f47 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocThisType.errors.txt @@ -1,9 +1,6 @@ -/a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(3,10): error TS2339: Property 'test' does not exist on type 'Foo'. -/a.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. /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'? -/a.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.d.ts (0 errors) ==== @@ -13,10 +10,8 @@ export type M = (this: Foo) => void; -==== /a.js (6 errors) ==== +==== /a.js (3 errors) ==== /** @type {import('./types').M} */ - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const f1 = function() { this.test(); ~~~~ @@ -29,8 +24,6 @@ } /** @type {(this: import('./types').Foo) => void} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const f3 = function() { this.test(); ~~~~ @@ -46,8 +39,6 @@ ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? !!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const f5 = function() { this.test(); } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt index 76400daa8b..be8a7c7817 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeDefAtStartOfFile.errors.txt @@ -1,26 +1,17 @@ -dtsEquivalent.js(1,19): error TS8010: Type annotations can only be used in TypeScript files. index.js(1,12): error TS2304: Cannot find name 'AnyEffect'. -index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(3,12): error TS2304: Cannot find name 'Third'. -index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -==== dtsEquivalent.js (1 errors) ==== +==== dtsEquivalent.js (0 errors) ==== /** @typedef {{[k: string]: any}} AnyEffect */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @typedef {number} Third */ -==== index.js (4 errors) ==== +==== index.js (2 errors) ==== /** @type {AnyEffect} */ ~~~~~~~~~ !!! error TS2304: Cannot find name 'AnyEffect'. - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let b; /** @type {Third} */ ~~~~~ !!! error TS2304: Cannot find name 'Third'. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let c; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt index 7316217e08..edfbb88499 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceExports.errors.txt @@ -1,15 +1,12 @@ bug27342.js(3,11): error TS2709: Cannot use namespace 'exports' as a type. -bug27342.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -==== bug27342.js (2 errors) ==== +==== bug27342.js (1 errors) ==== module.exports = {} /** * @type {exports} ~~~~~~~ !!! error TS2709: Cannot use namespace 'exports' as a type. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var x diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt index d320911fca..f5b86a1c28 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImport.errors.txt @@ -1,17 +1,13 @@ 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(3,12): error TS8010: Type annotations can only be used in TypeScript files. 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(8,12): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocTypeReferenceToImport.js (4 errors) ==== +==== jsdocTypeReferenceToImport.js (2 errors) ==== const C = require('./ex').C; const D = require('./ex')?.C; /** @type {C} c */ ~ !!! error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var c = new C() c.start c.end @@ -19,8 +15,6 @@ jsdocTypeReferenceToImport.js(8,12): error TS8010: Type annotations can only be /** @type {D} c */ ~ !!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var d = new D() d.start d.end diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt index 4f8dedb966..d5614f6c67 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt @@ -1,5 +1,4 @@ MC.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -MW.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -20,14 +19,12 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with ~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== MW.js (2 errors) ==== +==== MW.js (1 errors) ==== /** @typedef {import("./MC")} MC */ class MW { /** * @param {MC} compiler the compiler - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(compiler) { this.compiler = compiler; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt index 457939b4a3..38ff7cb972 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt @@ -1,11 +1,9 @@ MC.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -MC.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. MW.js(1,15): error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? -MW.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== MC.js (2 errors) ==== +==== MC.js (1 errors) ==== const MW = require("./MW"); /** @typedef {number} Meyerhauser */ @@ -15,8 +13,6 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** @type {any} */ ~~~~~~~~~~~~~~~~~~~~~~ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x = {} ~~~~~~~~~~~~~~ return new MW(x); @@ -25,7 +21,7 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with ~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== MW.js (3 errors) ==== +==== MW.js (2 errors) ==== /** @typedef {import("./MC")} MC */ ~~~~~~~~~~~~~~ !!! error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? @@ -33,8 +29,6 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with class MW { /** * @param {MC} compiler the compiler - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(compiler) { this.compiler = compiler; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt index c80fc447ac..84eb478f76 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToMergedClass.errors.txt @@ -1,14 +1,11 @@ jsdocTypeReferenceToMergedClass.js(2,12): error TS2503: Cannot find namespace 'Workspace'. -jsdocTypeReferenceToMergedClass.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -==== jsdocTypeReferenceToMergedClass.js (2 errors) ==== +==== jsdocTypeReferenceToMergedClass.js (1 errors) ==== var Workspace = {} /** @type {Workspace.Project} */ ~~~~~~~~~ !!! error TS2503: Cannot find namespace 'Workspace'. - ~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var p; p.isServiceProject() diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt index 4075900f03..bee4d86738 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToValue.errors.txt @@ -1,13 +1,10 @@ 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,13): error TS8010: Type annotations can only be used in TypeScript files. -==== foo.js (2 errors) ==== +==== 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'? - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function process(image) { return new image(1, 1) } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt deleted file mode 100644 index 297f4d1c9d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -bug25097.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== bug25097.js (1 errors) ==== - /** @type {C | null} */ - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const c = null - class C { - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt index 43f1bb940d..00b96eaed6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTag.errors.txt @@ -1,27 +1,3 @@ -a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(52,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(61,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(67,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(70,12): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -30,125 +6,77 @@ b.ts(20,5): error TS2403: Subsequent variable declarations must have the same ty b.ts(21,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 (24 errors) ==== +==== a.js (0 errors) ==== /** @type {String} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var S; /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var s; /** @type {Number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var N; /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n; /** @type {BigInt} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var BI; /** @type {bigint} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var bi; /** @type {Boolean} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var B; /** @type {boolean} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var b; /** @type {Void} */ - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var V; /** @type {void} */ - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var v; /** @type {Undefined} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var U; /** @type {undefined} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var u; /** @type {Null} */ - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var Nl; /** @type {null} */ - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var nl; /** @type {Array} */ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var A; /** @type {array} */ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var a; /** @type {Promise} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var P; /** @type {promise} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var p; /** @type {?number} */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var nullable; /** @type {Object} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var Obj; /** @type {object} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var obj; /** @type {Function} */ - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var Func; /** @type {(s: string) => number} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var f; /** @type {new (s: string) => { s: string }} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var ctor; ==== b.ts (6 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt index b5820c483c..5ca40c9e5b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt @@ -1,67 +1,34 @@ -b.js(2,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(4,20): error TS8016: Type assertion expressions can only be used in TypeScript files. 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(6,12): error TS8010: Type annotations can only be used in TypeScript files. -b.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -b.js(12,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(13,25): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(43,23): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(44,23): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(45,23): error TS8016: Type assertion expressions can only be used in TypeScript files. b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. -b.js(47,26): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(48,26): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(49,26): error TS8016: Type assertion expressions can only be used in TypeScript files. b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x -b.js(51,24): error TS8016: Type assertion expressions can only be used in TypeScript files. b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. -b.js(52,24): error TS8016: Type assertion expressions can only be used in TypeScript files. b.js(52,38): error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. -b.js(53,24): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(59,23): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. -b.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. -b.js(66,15): error TS8016: Type assertion expressions can only be used in TypeScript files. 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(71,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -b.js(72,27): error TS8016: Type assertion expressions can only be used in TypeScript files. ==== a.ts (0 errors) ==== var W: string; -==== b.js (30 errors) ==== +==== b.js (9 errors) ==== // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); - ~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. var W = /** @type {string} */(4); // Error - ~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~ !!! 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 {*} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var a; /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var s; var a = /** @type {*} */("" + 4); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. var s = "" + /** @type {*} */(4); - ~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. class SomeBase { constructor() { @@ -92,68 +59,42 @@ b.js(72,27): error TS8016: Type assertion expressions can only be used in TypeSc var someFakeClass = new SomeFakeClass(); someBase = /** @type {SomeBase} */(someDerived); - ~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someBase = /** @type {SomeBase} */(someBase); - ~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someBase = /** @type {SomeBase} */(someOther); // Error - ~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. !!! related TS2728 b.js:17:9: 'p' is declared here. someDerived = /** @type {SomeDerived} */(someDerived); - ~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someDerived = /** @type {SomeDerived} */(someBase); - ~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someDerived = /** @type {SomeDerived} */(someOther); // Error - ~~~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x someOther = /** @type {SomeOther} */(someDerived); // Error - ~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~~~~ !!! error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someBase); // Error - ~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~ !!! error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someOther); - ~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someFakeClass = someBase; someFakeClass = someDerived; someBase = someFakeClass; // Error someBase = /** @type {SomeBase} */(someFakeClass); - ~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. // Type assertion cannot be a type-predicate type /** @type {number | string} */ - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var numOrStr; /** @type {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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 TS8016: Type assertion expressions can only be used in TypeScript files. ~~~~~~~~ !!! error TS2454: Variable 'numOrStr' is used before being assigned. str = numOrStr; // Error, no narrowing occurred @@ -166,10 +107,6 @@ b.js(72,27): error TS8016: Type assertion expressions can only be used in TypeSc var asConst1 = /** @type {const} */(1); - ~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. var asConst2 = /** @type {const} */({ - ~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. x: 1 }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt index 2981a9a97a..4b79a3d468 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagParameterType.errors.txt @@ -1,16 +1,13 @@ a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (4 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (value) => { ~~~~~ !!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt index 7bcea37453..96a1ffda77 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagRequiredParameters.errors.txt @@ -1,5 +1,4 @@ a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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. @@ -7,13 +6,11 @@ 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 (7 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (value) => { ~~~~~ !!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt deleted file mode 100644 index eda597adb2..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -foo.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.js (2 errors) ==== - /** @type {boolean} */ - var /** @type {string} */ x, - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - /** @type {number} */ y; - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt index 576757de2d..908bca4dda 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocVariadicType.errors.txt @@ -1,15 +1,12 @@ a.js(2,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -a.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== 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. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo = function (a, b, ...r) { }; diff --git a/testdata/baselines/reference/submodule/conformance/linkTagEmit1.errors.txt b/testdata/baselines/reference/submodule/conformance/linkTagEmit1.errors.txt deleted file mode 100644 index 46f2899173..0000000000 --- a/testdata/baselines/reference/submodule/conformance/linkTagEmit1.errors.txt +++ /dev/null @@ -1,31 +0,0 @@ -linkTagEmit1.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== declarations.d.ts (0 errors) ==== - declare namespace NS { - type R = number - } -==== linkTagEmit1.js (1 errors) ==== - /** @typedef {number} N */ - /** - * @typedef {Object} D1 - * @property {1} e Just link to {@link NS.R} this time - * @property {1} m Wyatt Earp loved {@link N integers} I bet. - */ - - /** @typedef {number} Z @see N {@link N} */ - - /** - * @param {number} integer {@link Z} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function computeCommonSourceDirectoryOfFilenames(integer) { - return integer + 1 // pls pls pls - } - - /** {@link https://hvad} */ - var see3 = true - - /** @typedef {number} Attempt {@link https://wat} {@linkcode I think lingcod is better} {@linkplain or lutefisk}*/ - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/malformedTags.errors.txt b/testdata/baselines/reference/submodule/conformance/malformedTags.errors.txt deleted file mode 100644 index 6dadd48632..0000000000 --- a/testdata/baselines/reference/submodule/conformance/malformedTags.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -myFile02.js(4,10): error TS8010: Type annotations can only be used in TypeScript files. - - -==== myFile02.js (1 errors) ==== - /** - * Checks if `value` is classified as an `Array` object. - * - * @type Function - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - var isArray = Array.isArray; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment.errors.txt index 82e3ea212c..8472709b9b 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment.errors.txt @@ -1,4 +1,3 @@ -npmlog.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. npmlog.js(5,14): error TS2741: Property 'y' is missing in type 'EE' but required in type 'typeof import("npmlog")'. npmlog.js(8,16): error TS2339: Property 'on' does not exist on type 'typeof import("npmlog")'. npmlog.js(10,8): error TS2339: Property 'x' does not exist on type 'EE'. @@ -17,11 +16,9 @@ use.js(3,8): error TS2339: Property 'on' does not exist on type 'typeof import(" ~~ !!! error TS2339: Property 'on' does not exist on type 'typeof import("npmlog")'. -==== npmlog.js (6 errors) ==== +==== npmlog.js (5 errors) ==== class EE { /** @param {string} s */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. on(s) { } } var npmlog = module.exports = new EE() diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.errors.txt deleted file mode 100644 index c8cc7510e8..0000000000 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment6.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -webpackLibNormalModule.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. -webpackLibNormalModule.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== webpackLibNormalModule.js (2 errors) ==== - class C { - /** @param {number} x */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor(x) { - this.x = x - this.exports = [x] - } - /** @param {number} y */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - m(y) { - return this.x + y - } - } - function exec() { - const module = new C(12); - return module.exports; // should be fine because `module` is defined locally - } - - function tricky() { - // (a trickier variant of what webpack does) - const module = new C(12); - return () => { - return module.exports; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt index a6d7b08281..88bbc580cf 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt @@ -6,28 +6,14 @@ index.ts(6,24): error TS2694: Namespace '"mod".export=' has no exported member ' index.ts(7,24): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. 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(2,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(2,28): error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. -main.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(3,28): error TS2694: Namespace '"mod".export=' has no exported member 'AnotherThing'. -main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(4,28): error TS2694: Namespace '"mod".export=' has no exported member 'foo'. -main.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(5,28): error TS2694: Namespace '"mod".export=' has no exported member 'qux'. -main.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(6,28): error TS2694: Namespace '"mod".export=' has no exported member 'baz'. -main.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(7,28): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. -main.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(8,28): error TS2694: Namespace '"mod".export=' has no exported member 'literal'. -main.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -main.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. -main.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -main.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -main.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -main.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(20,35): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. -main.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. mod.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -54,41 +40,27 @@ mod.js(6,1): error TS2309: An export assignment cannot be used in a module with } ~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== main.js (22 errors) ==== +==== main.js (8 errors) ==== /** * @param {import("./mod").Thing} a - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. * @param {import("./mod").AnotherThing} b - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'AnotherThing'. * @param {import("./mod").foo} c - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'foo'. * @param {import("./mod").qux} d - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'qux'. * @param {import("./mod").baz} e - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. * @param {import("./mod").buz} f - ~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. * @param {import("./mod").literal} g - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'literal'. */ @@ -98,28 +70,14 @@ mod.js(6,1): error TS2309: An export assignment cannot be used in a module with /** * @param {typeof import("./mod").Thing} a - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").AnotherThing} b - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").foo} c - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").qux} d - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").baz} e - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {typeof import("./mod").buz} f - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. * @param {typeof import("./mod").literal} g - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function jsvalues(a, b, c, d, e, f, g) { return a.length + b.length + c() + d() + e() + f() + g.length diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt index ac254aad3d..b3f788da0c 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt @@ -1,9 +1,7 @@ mod.js(2,18): error TS2339: Property 'K' does not exist on type '{}'. use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. -use.js(8,13): error TS8010: Type annotations can only be used in TypeScript files. use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -use.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. ==== mod.js (1 errors) ==== @@ -19,7 +17,7 @@ use.js(9,13): error TS8010: Type annotations can only be used in TypeScript file } } -==== use.js (5 errors) ==== +==== use.js (3 errors) ==== import * as s from './mod' var k = new s.n.K() @@ -30,15 +28,11 @@ use.js(9,13): error TS8010: Type annotations can only be used in TypeScript file /** @param {s.n.K} c - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2694: Namespace '"mod"' has no exported member 'n'. @param {s.Classic} classic */ ~~~~~~~~~ !!! error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(c, classic) { c.x classic.p 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 076d9091ed..0000000000 --- a/testdata/baselines/reference/submodule/conformance/moduleExportsElementAccessAssignment2.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -file1.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -file1.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -file1.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== file1.js (3 errors) ==== - // this file _should_ be a global file - var GlobalThing = { x: 12 }; - - /** - * @param {*} type - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {*} ctor - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {*} exports - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(type, ctor, exports) { - 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/optionalBindingParameters3.errors.txt b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt index f3adde836d..3e8e002141 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt @@ -1,9 +1,7 @@ -/a.js(7,4): error TS8009: The '?' modifier can only be used in TypeScript files. -/a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. /a.js(9,12): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -==== /a.js (3 errors) ==== +==== /a.js (1 errors) ==== /** * @typedef Foo * @property {string} a @@ -11,10 +9,6 @@ /** * @param {Foo} [options] - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function f({ a = "a" }) {} ~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt deleted file mode 100644 index cd3cefdc7a..0000000000 --- a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -/a.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - /** - * @param {{ cause?: string }} [options] - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo({ cause } = {}) { - return cause; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt index bef1101f75..c9b3fb4a96 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/overloadTag1.errors.txt @@ -1,38 +1,21 @@ -overloadTag1.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. -overloadTag1.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. -overloadTag1.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -overloadTag1.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -overloadTag1.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. overloadTag1.js(26,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. -overloadTag1.js(29,5): error TS8017: Signature declarations can only be used in TypeScript files. -overloadTag1.js(34,5): error TS8017: Signature declarations can only be used in TypeScript files. -==== overloadTag1.js (8 errors) ==== +==== overloadTag1.js (1 errors) ==== /** * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} a * @param {number} b * @returns {number} * * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a * @param {boolean} b * @returns {string} * * @param {string | number} a - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string | number} b - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string | number} - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ export function overloaded(a,b) { if (typeof a === "string" && typeof b === "string") { @@ -50,15 +33,11 @@ overloadTag1.js(34,5): error TS8017: Signature declarations can only be used in /** * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} a * @param {number} b * @returns {number} * * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a * @param {boolean} b * @returns {string} diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt index bf6ba6af1a..c45c97b5eb 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt @@ -1,13 +1,9 @@ -overloadTag2.js(8,9): error TS8017: Signature declarations can only be used in TypeScript files. overloadTag2.js(14,9): error TS2394: This overload signature is not compatible with its implementation signature. -overloadTag2.js(14,9): error TS8017: Signature declarations can only be used in TypeScript files. -overloadTag2.js(19,9): error TS8017: Signature declarations can only be used in TypeScript files. -overloadTag2.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. 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 (7 errors) ==== +==== overloadTag2.js (3 errors) ==== export class Foo { #a = true ? 1 : "1" #b @@ -16,8 +12,6 @@ overloadTag2.js(30,9): error TS2554: Expected 1-2 arguments, but got 0. * Should not have an implicit any error, because constructor's return type is always implicit * @constructor * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a * @param {number} b */ @@ -27,21 +21,15 @@ overloadTag2.js(30,9): error TS2554: Expected 1-2 arguments, but got 0. ~~~~~~~~ !!! error TS2394: This overload signature is not compatible with its implementation signature. !!! related TS2750 overloadTag2.js:25:5: The implementation signature is declared here. - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} a */ /** * @constructor * @overload - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a *//** * @constructor * @param {number | string} a - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ constructor(a, b) { ~ diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt index b0b69f1a02..f916c78085 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt @@ -1,10 +1,7 @@ /a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -/a.js(7,9): error TS8017: Signature declarations can only be used in TypeScript files. -/a.js(12,16): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (4 errors) ==== +==== /a.js (1 errors) ==== /** ~~~ * @template T @@ -19,8 +16,6 @@ ~~~~~~~~~~~~~~~~~~~ * @overload ~~~~~~~~~~~~~~~~ - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. */ ~~~~~~~ constructor() { } @@ -31,8 +26,6 @@ ~~~~~~~ * @param {T} value ~~~~~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~~~~~ bar(value) { } @@ -42,8 +35,6 @@ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type {Foo} */ - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. let foo; foo = new Foo(); \ No newline at end of file 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 4db1632b27..0000000000 --- a/testdata/baselines/reference/submodule/conformance/paramTagBracketsAddOptionalUndefined.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -a.js(2,4): error TS8009: The '?' modifier can only be used in TypeScript files. -a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. -a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. -a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (6 errors) ==== - /** - * @param {number} [p] - ~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number=} q - ~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} [r=101] - ~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(p, q, r) { - 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() - f(undefined, undefined, undefined) - f(1, 2, 3) - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt index 2b6b4fafc4..2694186a29 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt @@ -1,13 +1,10 @@ -paramTagNestedWithoutTopLevelObject3.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. paramTagNestedWithoutTopLevelObject3.js(3,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. paramTagNestedWithoutTopLevelObject3.js(6,16): error TS2339: Property 'bar' does not exist on type 'object'. -==== paramTagNestedWithoutTopLevelObject3.js (3 errors) ==== +==== paramTagNestedWithoutTopLevelObject3.js (2 errors) ==== /** * @param {object} xyz - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} xyz.bar.p ~~~~~~~~~ !!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. diff --git a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt index 394caf4255..1c28c99665 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt @@ -1,21 +1,15 @@ 38572.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -38572.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -38572.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -==== 38572.js (3 errors) ==== +==== 38572.js (1 errors) ==== /** ~~~ * @template T ~~~~~~~~~~~~~~ * @param {T} a ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {{[K in keyof T]: (value: T[K]) => void }} b ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f(a, b) { diff --git a/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt index a5288d8ed5..bc43cc7750 100644 --- a/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/paramTagWrapping.errors.txt @@ -1,24 +1,15 @@ 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(3,5): error TS8010: Type annotations can only be used in TypeScript files. -good.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -good.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -==== good.js (3 errors) ==== +==== good.js (0 errors) ==== /** * @param * {number} x Arg x. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * y Arg y. * @param {number} z - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * Arg z. */ function good(x, y, z) { diff --git a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt index 6df4d6017e..b929519474 100644 --- a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt @@ -1,22 +1,9 @@ propertiesOfGenericConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. 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(14,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. propertiesOfGenericConstructorFunctions.js(26,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. -propertiesOfGenericConstructorFunctions.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. -==== propertiesOfGenericConstructorFunctions.js (16 errors) ==== +==== propertiesOfGenericConstructorFunctions.js (3 errors) ==== /** ~~~ * @template {string} K @@ -25,20 +12,14 @@ propertiesOfGenericConstructorFunctions.js(49,12): error TS8010: Type annotation ~~~~~~~~~~~~~~ * @param {string} ik ~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {V} iv ~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function Multimap(ik, iv) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** @type {{ [s: string]: V }} */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. this._map = {}; ~~~~~~~~~~~~~~~~~~~ // without type annotation @@ -52,27 +33,17 @@ propertiesOfGenericConstructorFunctions.js(49,12): error TS8010: Type annotation /** @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'? - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const map = new Multimap("a", 1); // without type annotation const map2 = new Multimap("m", 2); /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = map._map['hi'] /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = map._map2['hi'] /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = map2._map['hi'] /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = map._map2['hi'] @@ -85,8 +56,6 @@ propertiesOfGenericConstructorFunctions.js(49,12): error TS8010: Type annotation ~~~~~~~~~~~~~~ * @param {T} t ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function Cp(t) { @@ -105,20 +74,12 @@ propertiesOfGenericConstructorFunctions.js(49,12): error TS8010: Type annotation var cp = new Cp(1) /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = cp.x /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = cp.y /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = cp.m1() /** @type {number} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n = cp.m2() \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt index 3cb3cec4d4..af718cddbf 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/propertyAssignmentUseParentType2.errors.txt @@ -1,28 +1,19 @@ -propertyAssignmentUseParentType2.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -propertyAssignmentUseParentType2.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -propertyAssignmentUseParentType2.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. propertyAssignmentUseParentType2.js(11,14): error TS2322: Type '{ (): true; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. Types of property 'nuo' are incompatible. Type '1000' is not assignable to type '789'. -==== propertyAssignmentUseParentType2.js (4 errors) ==== +==== propertyAssignmentUseParentType2.js (1 errors) ==== /** @type {{ (): boolean; nuo: 789 }} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const inlined = () => true inlined.nuo = 789 /** @type {{ (): boolean; nuo: 789 }} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const duplicated = () => true /** @type {789} */ duplicated.nuo = 789 /** @type {{ (): boolean; nuo: 789 }} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export const conflictingDuplicated = () => true ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ (): true; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. diff --git a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt index 1fa6526ad3..d7cd47b9f3 100644 --- a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt @@ -1,7 +1,5 @@ other.js(2,11): error TS2503: Cannot find namespace 'Ns'. -other.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. other.js(7,11): error TS2503: Cannot find namespace 'Ns'. -other.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. ==== prototypePropertyAssignmentMergeAcrossFiles2.js (0 errors) ==== @@ -15,13 +13,11 @@ other.js(7,11): error TS8010: Type annotations can only be used in TypeScript fi Ns.Two.prototype = { } -==== other.js (4 errors) ==== +==== other.js (2 errors) ==== /** * @type {Ns.One} ~~ !!! error TS2503: Cannot find namespace 'Ns'. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var one; one.wat; @@ -29,8 +25,6 @@ other.js(7,11): error TS8010: Type annotations can only be used in TypeScript fi * @type {Ns.Two} ~~ !!! error TS2503: Cannot find namespace 'Ns'. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ var two; two.wat; diff --git a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt index bde9cba210..fcf4d43ce1 100644 --- a/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt @@ -1,10 +1,9 @@ -prototypePropertyAssignmentMergedTypeReference.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. 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 (3 errors) ==== +==== prototypePropertyAssignmentMergedTypeReference.js (2 errors) ==== var f = function() { return 12; }; @@ -12,8 +11,6 @@ prototypePropertyAssignmentMergedTypeReference.js(8,5): error TS2322: Type '() = f.prototype.a = "a"; /** @type {new () => f} */ - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2749: 'f' refers to a value, but is being used as a type here. Did you mean 'typeof f'? var x = f; diff --git a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt index 4b26205ee0..9c2df0fa3e 100644 --- a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt @@ -1,14 +1,10 @@ -bug39372.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. -bug39372.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -==== bug39372.js (3 errors) ==== +==== bug39372.js (1 errors) ==== /** @typedef {ReadonlyArray} JsonArray */ /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ /** @@ -31,8 +27,6 @@ bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type 'XMLObject< }} XMLObject */ /** @type {XMLObject<{foo:string}>} */ - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const p = {}; ~ !!! error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. diff --git a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt deleted file mode 100644 index 682666b0a2..0000000000 --- a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt +++ /dev/null @@ -1,94 +0,0 @@ -bug25127.js(6,16): error TS8010: Type annotations can only be used in TypeScript files. -bug25127.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. -bug25127.js(18,16): error TS8010: Type annotations can only be used in TypeScript files. -bug25127.js(19,17): error TS8010: Type annotations can only be used in TypeScript files. -bug25127.js(25,13): error TS8010: Type annotations can only be used in TypeScript files. -bug25127.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. -bug25127.js(33,13): error TS8010: Type annotations can only be used in TypeScript files. -bug25127.js(39,13): error TS8010: Type annotations can only be used in TypeScript files. -bug25127.js(48,12): error TS8010: Type annotations can only be used in TypeScript files. -bug25127.js(55,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== bug25127.js (10 errors) ==== - class Entry { - constructor() { - this.c = 1 - } - /** - * @param {any} x - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {this is Entry} - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - isInit(x) { - return true - } - } - class Group { - constructor() { - this.d = 'no' - } - /** - * @param {any} x - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {false} - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - isInit(x) { - return false - } - } - /** @param {Entry | Group} chunk */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - function f(chunk) { - let x = chunk.isInit(chunk) ? chunk.c : chunk.d - return x - } - - /** - * @param {any} value - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {value is boolean} - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function isBoolean(value) { - return typeof value === "boolean"; - } - - /** @param {boolean | number} val */ - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - function foo(val) { - if (isBoolean(val)) { - val; - } - } - - /** - * @callback Cb - * @param {unknown} x - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {x is number} - */ - - /** @type {Cb} */ - function isNumber(x) { return typeof x === "number" } - - /** @param {unknown} x */ - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - function g(x) { - if (isNumber(x)) { - x * 2; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/syntaxErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/syntaxErrors.errors.txt deleted file mode 100644 index ed9e7d8d5b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/syntaxErrors.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -badTypeArguments.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== dummyType.d.ts (0 errors) ==== - declare class C { t: T } - -==== badTypeArguments.js (1 errors) ==== - /** @param {C.<>} x */ - /** @param {C.} y */ - // @ts-ignore - /** @param {C.} skipped */ - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - function f(x, y, skipped) { - return x.t + y.t; - } - var x = f({ t: 1000 }, { t: 3000 }, { t: 5000 }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt index d616b6c166..891191db93 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt @@ -1,20 +1,12 @@ templateInsideCallback.js(15,11): error TS2315: Type 'Call' is not generic. -templateInsideCallback.js(15,11): error TS8010: Type annotations can only be used in TypeScript files. templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. templateInsideCallback.js(17,17): error TS8004: Type parameter declarations can only be used in TypeScript files. templateInsideCallback.js(17,18): error TS7006: Parameter 'x' implicitly has an 'any' type. templateInsideCallback.js(29,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -templateInsideCallback.js(29,5): error TS8017: Signature declarations can only be used in TypeScript files. templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -templateInsideCallback.js(37,5): error TS8017: Signature declarations can only be used in TypeScript files. -templateInsideCallback.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. -templateInsideCallback.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. -templateInsideCallback.js(45,14): error TS8010: Type annotations can only be used in TypeScript files. -templateInsideCallback.js(48,14): error TS8010: Type annotations can only be used in TypeScript files. -templateInsideCallback.js(51,31): error TS8016: Type assertion expressions can only be used in TypeScript files. -==== templateInsideCallback.js (14 errors) ==== +==== templateInsideCallback.js (6 errors) ==== /** * @typedef Oops * @template T @@ -32,8 +24,6 @@ templateInsideCallback.js(51,31): error TS8016: Type assertion expressions can o * @type {Call} ~~~~~~~ !!! error TS2315: Type 'Call' is not generic. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'T'. */ @@ -56,8 +46,6 @@ templateInsideCallback.js(51,31): error TS8016: Type assertion expressions can o * @overload ~~~~~~~~ !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @template T * @template U * @param {T[]} array @@ -68,32 +56,20 @@ templateInsideCallback.js(51,31): error TS8016: Type assertion expressions can o * @overload ~~~~~~~~ !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. - ~~~~~~~~ -!!! error TS8017: Signature declarations can only be used in TypeScript files. * @template T * @param {T[][]} array * @returns {T[]} */ /** * @param {unknown[]} array - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(x: unknown) => unknown} iterable - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {unknown[]} - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function flatMap(array, iterable = identity) { /** @type {unknown[]} */ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const result = []; for (let i = 0; i < array.length; i += 1) { result.push(.../** @type {unknown[]} */(iterable(array[i]))); - ~~~~~~~~~ -!!! error TS8016: Type assertion expressions can only be used in TypeScript files. } return result; } diff --git a/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt b/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt deleted file mode 100644 index c72a3549d6..0000000000 --- a/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -thisPropertyAssignmentInherited.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== thisPropertyAssignmentInherited.js (1 errors) ==== - export class Element { - /** - * @returns {String} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - get textContent() { - return '' - } - set textContent(x) {} - cloneNode() { return this} - } - export class HTMLElement extends Element {} - export class TextElement extends HTMLElement { - get innerHTML() { return this.textContent; } - set innerHTML(html) { this.textContent = html; } - toString() { - } - } - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt deleted file mode 100644 index ce65e2b664..0000000000 --- a/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt +++ /dev/null @@ -1,26 +0,0 @@ -a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (3 errors) ==== - /** @this {{ n: number }} Mount Holyoke Preparatory School - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} s - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {number} - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(s) { - return this.n + s.length - } - - const o = { - f, - n: 1 - } - o.f('hi') - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTag2.errors.txt deleted file mode 100644 index 6e86e460d4..0000000000 --- a/testdata/baselines/reference/submodule/conformance/thisTag2.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(4,10): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (2 errors) ==== - /** @this {string} */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - export function f1() {} - - /** @this */ - -!!! error TS8010: Type annotations can only be used in TypeScript files. - export function f2() {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag2.js b/testdata/baselines/reference/submodule/conformance/thisTag2.js index 7c2c5ca1b6..dd2582eb78 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag2.js +++ b/testdata/baselines/reference/submodule/conformance/thisTag2.js @@ -15,3 +15,19 @@ export function f2() {} export declare function f1(this: string): void; /** @this */ export declare function f2(this: ): void; + + +//// [DtsFileErrors] + + +a.d.ts(4,34): error TS1110: Type expected. + + +==== a.d.ts (1 errors) ==== + /** @this {string} */ + export declare function f1(this: string): void; + /** @this */ + export declare function f2(this: ): void; + ~ +!!! error TS1110: Type expected. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag2.js.diff b/testdata/baselines/reference/submodule/conformance/thisTag2.js.diff index 673962e838..5835164347 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag2.js.diff +++ b/testdata/baselines/reference/submodule/conformance/thisTag2.js.diff @@ -8,4 +8,20 @@ +export declare function f1(this: string): void; /** @this */ -export function f2(this: any): void; -+export declare function f2(this: ): void; \ No newline at end of file ++export declare function f2(this: ): void; ++ ++ ++//// [DtsFileErrors] ++ ++ ++a.d.ts(4,34): error TS1110: Type expected. ++ ++ ++==== a.d.ts (1 errors) ==== ++ /** @this {string} */ ++ export declare function f1(this: string): void; ++ /** @this */ ++ export declare function f2(this: ): void; ++ ~ ++!!! error TS1110: Type expected. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt index 8d31eaf609..81623b16ce 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt @@ -1,15 +1,10 @@ -/a.js(2,20): error TS8010: Type annotations can only be used in TypeScript files. /a.js(7,9): error TS2730: An arrow function cannot have a 'this' parameter. -/a.js(7,15): error TS8010: Type annotations can only be used in TypeScript files. -/a.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. /a.js(10,21): error TS2339: Property 'fn' does not exist on type 'C'. -==== /a.js (5 errors) ==== +==== /a.js (2 errors) ==== /** * @typedef {{fn(a: string): void}} T - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ class C { @@ -17,11 +12,7 @@ * @this {T} ~~~~ !!! error TS2730: An arrow function cannot have a 'this' parameter. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} a - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ p = (a) => this.fn("" + a); ~~ diff --git a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt index fa72e8b073..54f8e76591 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt @@ -1,18 +1,12 @@ thisTypeOfConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -thisTypeOfConstructorFunctions.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. thisTypeOfConstructorFunctions.js(15,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -thisTypeOfConstructorFunctions.js(15,18): error TS8010: Type annotations can only be used in TypeScript files. thisTypeOfConstructorFunctions.js(19,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -thisTypeOfConstructorFunctions.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. 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(38,12): error TS8010: Type annotations can only be used in TypeScript files. 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(41,12): error TS8010: Type annotations can only be used in TypeScript files. 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(43,12): error TS8010: Type annotations can only be used in TypeScript files. -==== thisTypeOfConstructorFunctions.js (12 errors) ==== +==== thisTypeOfConstructorFunctions.js (6 errors) ==== /** ~~~ * @class @@ -21,8 +15,6 @@ thisTypeOfConstructorFunctions.js(43,12): error TS8010: Type annotations can onl ~~~~~~~~~~~~~~ * @param {T} t ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function Cp(t) { @@ -45,8 +37,6 @@ thisTypeOfConstructorFunctions.js(43,12): error TS8010: Type annotations can onl /** @return {this} */ ~~~~ !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. m4() { this.z = this.y; return this } @@ -62,8 +52,6 @@ thisTypeOfConstructorFunctions.js(43,12): error TS8010: Type annotations can onl ~~~~~~~~~~~~~~ * @param {T} t ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function Cpp(t) { @@ -85,21 +73,15 @@ thisTypeOfConstructorFunctions.js(43,12): error TS8010: Type annotations can onl /** @type {Cpp} */ ~~~ !!! error TS2749: 'Cpp' refers to a value, but is being used as a type here. Did you mean 'typeof Cpp'? - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var cpn = cp.m4() \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt index d14c932bc3..204843acf2 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromContextualThisType.errors.txt @@ -1,13 +1,9 @@ -bug25926.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. bug25926.js(4,18): error TS7006: Parameter 'n' implicitly has an 'any' type. -bug25926.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. bug25926.js(11,27): error TS7006: Parameter 'm' implicitly has an 'any' type. -==== bug25926.js (4 errors) ==== +==== bug25926.js (2 errors) ==== /** @type {{ a(): void; b?(n: number): number; }} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const o1 = { a() { this.b = n => n; @@ -17,8 +13,6 @@ bug25926.js(11,27): error TS7006: Parameter 'm' implicitly has an 'any' type. }; /** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const o2 = { d() { this.e = this.f = m => this.g || m; diff --git a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt index 8132992835..ed898025a1 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer.errors.txt @@ -1,5 +1,4 @@ a.js(7,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -a.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(25,29): error TS7006: Parameter 'l' 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'. @@ -7,10 +6,9 @@ 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(55,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (10 errors) ==== +==== a.js (8 errors) ==== function A () { // should get any on this-assignments in constructor this.unknown = null @@ -34,8 +32,6 @@ a.js(55,12): error TS8010: Type annotations can only be used in TypeScript files a.empty.push('hi') /** @type {number | undefined} */ - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n; // should get any on parameter initialisers @@ -84,8 +80,6 @@ a.js(55,12): error TS8010: Type annotations can only be used in TypeScript files l.push('ok') /** @type {(v: unknown) => v is undefined} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const isUndef = v => v === undefined; const e = [1, undefined]; diff --git a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt index 2420e98bc6..58532b712f 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromJSInitializer4.errors.txt @@ -1,13 +1,10 @@ -a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(5,12): error TS7006: Parameter 'a' 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} */ - ~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var n; // should get any on parameter initialisers diff --git a/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt index 140cb31c8c..e8effaa456 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromParamTagForFunction.errors.txt @@ -1,17 +1,9 @@ a.js(3,13): error TS2749: 'A' refers to a value, but is being used as a type here. Did you mean 'typeof A'? -a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. b.js(3,13): error TS2749: 'B' refers to a value, but is being used as a type here. Did you mean 'typeof B'? -b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. c.js(3,13): error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? -c.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. d.js(3,13): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? -d.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. -e.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. f.js(5,13): error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? -f.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? -g.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. -h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. ==== node.d.ts (0 errors) ==== @@ -23,14 +15,12 @@ h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. this.x = 1; }; -==== a.js (2 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'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function a(p) { p.x; } ==== b-ext.js (0 errors) ==== @@ -40,14 +30,12 @@ h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. } }; -==== b.js (2 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'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function b(p) { p.x; } ==== c-ext.js (0 errors) ==== @@ -55,14 +43,12 @@ h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. this.x = 1; } -==== c.js (2 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'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function c(p) { p.x; } ==== d-ext.js (0 errors) ==== @@ -70,14 +56,12 @@ h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. this.x = 1; }; -==== d.js (2 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'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function d(p) { p.x; } ==== e-ext.js (0 errors) ==== @@ -87,15 +71,13 @@ h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. } } -==== e.js (1 errors) ==== +==== e.js (0 errors) ==== const { E } = require("./e-ext"); /** @param {E} p */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function e(p) { p.x; } -==== f.js (2 errors) ==== +==== f.js (1 errors) ==== var F = function () { this.x = 1; }; @@ -103,11 +85,9 @@ h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. /** @param {F} p */ ~ !!! error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function f(p) { p.x; } -==== g.js (2 errors) ==== +==== g.js (1 errors) ==== function G() { this.x = 1; } @@ -115,11 +95,9 @@ h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. /** @param {G} p */ ~ !!! error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function g(p) { p.x; } -==== h.js (1 errors) ==== +==== h.js (0 errors) ==== class H { constructor() { this.x = 1; @@ -127,6 +105,4 @@ h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. } /** @param {H} p */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function h(p) { p.x; } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt deleted file mode 100644 index 47cfde701e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -a.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. -a.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== typeFromPrivatePropertyAssignmentJs.js (0 errors) ==== - -==== a.js (2 errors) ==== - class C { - /** @type {{ foo?: string } | undefined } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - #a; - /** @type {{ foo?: string } | undefined } */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - #b; - m() { - const a = this.#a || {}; - this.#b = this.#b || {}; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt index 960917e2ab..1419e4c079 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment.errors.txt @@ -1,10 +1,8 @@ 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(8,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(11,12): error TS2503: Cannot find namespace 'Outer'. -a.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (4 errors) ==== +==== a.js (2 errors) ==== var Outer = class O { m(x, y) { } } @@ -15,15 +13,11 @@ a.js(11,12): error TS8010: Type annotations can only be used in TypeScript files /** @type {Outer} */ ~~~~~ !!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var si si.m /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var oi oi.n diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt index 5f37a1a95c..c21a2f0d69 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10.errors.txt @@ -1,5 +1,4 @@ main.js(4,12): error TS2503: Cannot find namespace 'Outer'. -main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ==== module.js (0 errors) ==== @@ -38,15 +37,13 @@ main.js(4,12): error TS8010: Type annotations can only be used in TypeScript fil }; return Application; })(); -==== main.js (2 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'. - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x; x.y; 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 121f976dcf..4bad2fe72d 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment10_1.errors.txt @@ -1,5 +1,4 @@ main.js(4,12): error TS2503: Cannot find namespace 'Outer'. -main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. ==== module.js (0 errors) ==== @@ -38,15 +37,13 @@ main.js(4,12): error TS8010: Type annotations can only be used in TypeScript fil }; return Application; })(); -==== main.js (2 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'. - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x; x.y; 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 edfb33ec5c..aa43d4abec 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt @@ -1,5 +1,4 @@ use.js(1,12): error TS2503: Cannot find namespace 'Outer'. -use.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. 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 '{}'. @@ -19,12 +18,10 @@ work.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. m() { } } -==== use.js (3 errors) ==== +==== use.js (2 errors) ==== /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var inner inner.x inner.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt index a2e98e904f..3b6a9cb547 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment15.errors.txt @@ -1,8 +1,7 @@ a.js(10,12): error TS2503: Cannot find namespace 'Outer'. -a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (1 errors) ==== var Outer = {}; Outer.Inner = class { @@ -15,8 +14,6 @@ a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var inner inner.x inner.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt index 985e91c5d9..c1019b00ed 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment16.errors.txt @@ -1,8 +1,7 @@ a.js(9,12): error TS2503: Cannot find namespace 'Outer'. -a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (1 errors) ==== var Outer = {}; Outer.Inner = function () {} @@ -14,8 +13,6 @@ a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var inner inner.x inner.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt index 4bab2a25af..6226eec805 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment2.errors.txt @@ -1,10 +1,8 @@ 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(9,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(12,12): error TS2503: Cannot find namespace 'Outer'. -a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (4 errors) ==== +==== a.js (2 errors) ==== function Outer() { this.y = 2 } @@ -16,15 +14,11 @@ a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files /** @type {Outer} */ ~~~~~ !!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var ok ok.y /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var oc oc.x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt index fc34af3b5d..34809387cc 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment24.errors.txt @@ -1,9 +1,8 @@ usage.js(2,13): error TS2339: Property 'Message' does not exist on type 'typeof Inner'. usage.js(7,12): error TS2503: Cannot find namespace 'Outer'. -usage.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -==== usage.js (3 errors) ==== +==== usage.js (2 errors) ==== // note that usage is first in the compilation Outer.Inner.Message = function() { ~~~~~~~ @@ -15,8 +14,6 @@ usage.js(7,12): error TS8010: Type annotations can only be used in TypeScript fi /** @type {Outer.Inner} should be instance type, not static type */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x; x.name diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt index 2e3325886a..da2e5fcef7 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment3.errors.txt @@ -1,10 +1,8 @@ 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(9,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(12,12): error TS2503: Cannot find namespace 'Outer'. -a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (4 errors) ==== +==== a.js (2 errors) ==== var Outer = function O() { this.y = 2 } @@ -16,15 +14,11 @@ a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files /** @type {Outer} */ ~~~~~ !!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var ja ja.y /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var da da.x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt index 85cbd4dfec..5b0afce0fd 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt @@ -1,17 +1,14 @@ bug26877.js(1,13): error TS2503: Cannot find namespace 'Emu'. -bug26877.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. 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 '{}'. second.js(3,5): error TS2339: Property 'D' does not exist on type '{}'. -==== bug26877.js (5 errors) ==== +==== bug26877.js (4 errors) ==== /** @param {Emu.D} x */ ~~~ !!! error TS2503: Cannot find namespace 'Emu'. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function ollKorrect(x) { x._model 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 0c138c8576..1b87c06947 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt @@ -1,16 +1,14 @@ a.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. a.js(8,12): error TS2503: Cannot find namespace 'Outer'. -a.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. 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(1,12): error TS8010: Type annotations can only be used in TypeScript files. b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. ==== def.js (0 errors) ==== var Outer = {}; -==== a.js (4 errors) ==== +==== a.js (3 errors) ==== Outer.Inner = class { ~~~~~ !!! error TS2339: Property 'Inner' does not exist on type '{}'. @@ -23,8 +21,6 @@ b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var local local.y var inner = new Outer.Inner() @@ -32,12 +28,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 (3 errors) ==== +==== b.js (2 errors) ==== /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x x.y 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 index ac4e72e7ac..9e6a8111a7 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment40.errors.txt @@ -1,8 +1,7 @@ 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(5,12): error TS8010: Type annotations can only be used in TypeScript files. -==== typeFromPropertyAssignment40.js (2 errors) ==== +==== typeFromPropertyAssignment40.js (1 errors) ==== function Outer() { var self = this self.y = 2 @@ -10,8 +9,6 @@ typeFromPropertyAssignment40.js(5,12): error TS8010: Type annotations can only b /** @type {Outer} */ ~~~~~ !!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var ok ok.y \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt index 29aa3d30d1..d247630d9d 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment5.errors.txt @@ -1,5 +1,4 @@ b.js(3,12): error TS2503: Cannot find namespace 'MC'. -b.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ==== a.js (0 errors) ==== @@ -9,13 +8,11 @@ b.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. } MyClass.bar -==== b.js (2 errors) ==== +==== b.js (1 errors) ==== import MC from './a' MC.bar /** @type {MC.bar} */ ~~ !!! error TS2503: Cannot find namespace 'MC'. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt index 131d5ef72a..48dce5754d 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment6.errors.txt @@ -2,7 +2,6 @@ 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. -b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. ==== def.js (0 errors) ==== @@ -19,7 +18,7 @@ b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. -==== b.js (3 errors) ==== +==== b.js (2 errors) ==== var msgs = Outer.i.messages() ~ !!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. @@ -27,8 +26,6 @@ b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. /** @param {Outer.Inner} inner */ ~~~~~ !!! error TS2702: 'Outer' only refers to a type, but is being used as a namespace here. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. function x(inner) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt index c130193ccb..c10ea07ed6 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt @@ -4,10 +4,9 @@ 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(6,12): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (7 errors) ==== +==== index.js (6 errors) ==== First.Item = class I {} ~~~~ !!! error TS2339: Property 'Item' does not exist on type '{}'. @@ -26,8 +25,6 @@ index.js(6,12): error TS8010: Type annotations can only be used in TypeScript fi /** @type {Workspace.Object} */ ~~~~~~~~~ !!! error TS2503: Cannot find namespace 'Workspace'. - ~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var am; ==== roots.js (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt index 236d0b8917..b10885cf37 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment3.errors.txt @@ -1,13 +1,10 @@ bug26885.js(2,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -bug26885.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. -bug26885.js(8,18): error TS8010: Type annotations can only be used in TypeScript files. 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(15,12): error TS8010: Type annotations can only be used in TypeScript files. bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -==== bug26885.js (7 errors) ==== +==== bug26885.js (4 errors) ==== function Multimap3() { this._map = {}; ~~~~ @@ -17,11 +14,7 @@ bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a constru Multimap3.prototype = { /** * @param {string} key - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number} the value ok - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ get(key) { return this._map[key + '']; @@ -33,8 +26,6 @@ bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a constru /** @type {Multimap3} */ ~~~~~~~~~ !!! error TS2749: 'Multimap3' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap3'? - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. 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/typeFromPrototypeAssignment4.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.errors.txt deleted file mode 100644 index c0e6bca225..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPrototypeAssignment4.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -a.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. -a.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (2 errors) ==== - function Multimap4() { - this._map = {}; - }; - - Multimap4["prototype"] = { - /** - * @param {string} key - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {number} the value ok - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - get(key) { - return this._map[key + '']; - } - }; - - Multimap4["prototype"]["add-on"] = function() {}; - Multimap4["prototype"]["addon"] = function() {}; - Multimap4["prototype"]["__underscores__"] = function() {}; - - const map4 = new Multimap4(); - map4.get(""); - map4["add-on"](); - map4.addon(); - map4.__underscores__(); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt b/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt index 099947c796..b8f89f9c63 100644 --- a/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeLookupInIIFE.errors.txt @@ -1,14 +1,11 @@ a.js(3,12): error TS2503: Cannot find namespace 'ns'. -a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (1 errors) ==== // #22973 var ns = (function() {})(); /** @type {ns.NotFound} */ ~~ !!! error TS2503: Cannot find namespace 'ns'. - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var crash; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt index aa2f3adc03..6104c81d3a 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt @@ -1,16 +1,10 @@ -typeTagNoErasure.js(1,47): error TS8010: Type annotations can only be used in TypeScript files. -typeTagNoErasure.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. typeTagNoErasure.js(7,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -==== typeTagNoErasure.js (3 errors) ==== +==== typeTagNoErasure.js (1 errors) ==== /** @template T @typedef {(data: T1) => T1} Test */ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @type {Test} */ - ~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const test = dibbity => dibbity test(1) // ok, T=1 diff --git a/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.errors.txt b/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.errors.txt deleted file mode 100644 index 2f3f0daa0a..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typeTagOnFunctionReferencesGeneric.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -typeTagOnFunctionReferencesGeneric.js(2,21): error TS8010: Type annotations can only be used in TypeScript files. -typeTagOnFunctionReferencesGeneric.js(11,11): error TS8010: Type annotations can only be used in TypeScript files. - - -==== typeTagOnFunctionReferencesGeneric.js (2 errors) ==== - /** - * @typedef {(m : T) => T} IFn - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - - /**@type {IFn}*/ - export function inJs(l) { - return l; - } - inJs(1); // lints error. Why? - - /**@type {IFn}*/ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const inJsArrow = (j) => { - return j; - } - inJsArrow(2); // no error gets linted as expected - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt index d7f4773664..cec769759b 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt @@ -1,8 +1,5 @@ mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -use.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. use.js(1,29): error TS2694: Namespace 'C' has no exported member 'Both'. -use.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -use.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ==== commonjs.d.ts (0 errors) ==== @@ -39,20 +36,14 @@ use.js(5,12): error TS8010: Type annotations can only be used in TypeScript file this.p = 1 } -==== use.js (4 errors) ==== +==== use.js (1 errors) ==== /** @type {import('./mod1').Both} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~ !!! error TS2694: Namespace 'C' has no exported member 'Both'. var both1 = { type: 'a', x: 1 }; /** @type {import('./mod2').Both} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var both2 = both1; /** @type {import('./mod3').Both} */ - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var both3 = both2; diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt index 32621780e8..d48c75aeb1 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt @@ -6,25 +6,19 @@ mod1.js(10,1): error TS2309: An export assignment cannot be used in a module wit mod1.js(20,9): error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. mod1.js(23,1): error TS2300: Duplicate identifier 'export='. mod1.js(24,5): error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. -use.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. use.js(2,32): error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. use.js(4,12): error TS2503: Cannot find namespace 'mod'. -use.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -==== use.js (4 errors) ==== +==== use.js (2 errors) ==== var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~ !!! error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. var b; /** @type {mod.Baz} */ ~~~ !!! error TS2503: Cannot find namespace 'mod'. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var bb; var bbb = new mod.Baz(); diff --git a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt index a14ac15276..430e0df3e9 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt @@ -1,12 +1,9 @@ -a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. 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). -a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. test.ts(1,23): error TS2304: Cannot find name 'Everything'. -==== a.js (5 errors) ==== +==== a.js (2 errors) ==== /** * @template {{ a: number, b: string }} T,U A Comment * @template {{ c: boolean }} V uh ... are comments even supported?? @@ -16,13 +13,9 @@ test.ts(1,23): error TS2304: Cannot find name 'Everything'. */ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var tuvwx; /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~~~~ !!! 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. @@ -31,8 +24,6 @@ test.ts(1,23): error TS2304: Cannot find name 'Everything'. /** @type {Everything<{ a: number }>} */ ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2314: Generic type 'Everything' requires 5 type argument(s). - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var insufficient; ==== test.ts (1 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.errors.txt deleted file mode 100644 index c8fd5c0f55..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -typedefOnSemicolonClassElement.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. - - -==== typedefOnSemicolonClassElement.js (1 errors) ==== - export class Preferences { - /** @typedef {string} A */ - ; - /** @type {A} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - a = 'ok' - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js index cacffe05a6..68931be143 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js +++ b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js @@ -28,3 +28,26 @@ export declare class Preferences { /** @type {A} */ a: A; } + + +//// [DtsFileErrors] + + +dist/typedefOnSemicolonClassElement.d.ts(2,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +dist/typedefOnSemicolonClassElement.d.ts(4,8): error TS2693: 'A' only refers to a type, but is being used as a value here. +dist/typedefOnSemicolonClassElement.d.ts(5,1): error TS1128: Declaration or statement expected. + + +==== dist/typedefOnSemicolonClassElement.d.ts (3 errors) ==== + export declare class Preferences { + export type A = string; + ~~~~~~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + /** @type {A} */ + a: A; + ~ +!!! error TS2693: 'A' only refers to a type, but is being used as a value here. + } + ~ +!!! error TS1128: Declaration or statement expected. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js.diff b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js.diff index 627fc205d3..b1d29ecaf0 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefOnSemicolonClassElement.js.diff @@ -23,4 +23,27 @@ /** @type {A} */ - a: string; + a: A; - } \ No newline at end of file + } ++ ++ ++//// [DtsFileErrors] ++ ++ ++dist/typedefOnSemicolonClassElement.d.ts(2,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. ++dist/typedefOnSemicolonClassElement.d.ts(4,8): error TS2693: 'A' only refers to a type, but is being used as a value here. ++dist/typedefOnSemicolonClassElement.d.ts(5,1): error TS1128: Declaration or statement expected. ++ ++ ++==== dist/typedefOnSemicolonClassElement.d.ts (3 errors) ==== ++ export declare class Preferences { ++ export type A = string; ++ ~~~~~~ ++!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. ++ /** @type {A} */ ++ a: A; ++ ~ ++!!! error TS2693: 'A' only refers to a type, but is being used as a value here. ++ } ++ ~ ++!!! error TS1128: Declaration or statement expected. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt index 8fafd56565..d6726678a1 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefOnStatements.errors.txt @@ -2,27 +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(53,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(54,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(56,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(57,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(59,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(60,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(61,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(63,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(65,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(66,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(67,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(68,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(69,12): error TS8010: Type annotations can only be used in TypeScript files. -typedefOnStatements.js(73,16): error TS8010: Type annotations can only be used in TypeScript files. -==== typedefOnStatements.js (22 errors) ==== +==== typedefOnStatements.js (4 errors) ==== /** @typedef {{a: string}} A */ ; /** @typedef {{ b: string }} B */ @@ -84,62 +66,26 @@ typedefOnStatements.js(73,16): error TS8010: Type annotations can only be used i /** * @param {A} a - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {B} b - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {C} c - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {D} d - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {E} e - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {F} f - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {G} g - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {H} h - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {I} i - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {J} j - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {K} k - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {L} l - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {M} m - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {N} n - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {O} o - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {P} p - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Q} q - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,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) /** @type {Alpha} */ - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var alpha = { alpha: "aleph" } /** @typedef {{ alpha: string }} Alpha */ return diff --git a/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt index 9e860099ca..78efa2ed36 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefScope1.errors.txt @@ -1,30 +1,21 @@ -typedefScope1.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -typedefScope1.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. typedefScope1.js(13,12): error TS2304: Cannot find name 'B'. -typedefScope1.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -==== typedefScope1.js (4 errors) ==== +==== typedefScope1.js (1 errors) ==== function B1() { /** @typedef {number} B */ /** @type {B} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var ok1 = 0; } function B2() { /** @typedef {string} B */ /** @type {B} */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var ok2 = 'hi'; } /** @type {B} */ ~ !!! error TS2304: Cannot find name 'B'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var notOK = 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt index 8d8a80c58b..ab86dff568 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt @@ -1,9 +1,8 @@ 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(5,12): error TS8010: Type annotations can only be used in TypeScript files. -==== typedefTagExtraneousProperty.js (3 errors) ==== +==== typedefTagExtraneousProperty.js (2 errors) ==== /** @typedef {Object.} Mmap ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. @@ -13,8 +12,6 @@ typedefTagExtraneousProperty.js(5,12): error TS8010: Type annotations can only b */ /** @type {Mmap} */ - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. var y = { bye: "no" }; y y.ignoreMe = "ok but just because of the index signature" diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagNested.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagNested.errors.txt deleted file mode 100644 index 9f35474160..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typedefTagNested.errors.txt +++ /dev/null @@ -1,52 +0,0 @@ -a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -a.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (3 errors) ==== - /** @typedef {Object} App - * @property {string} name - * @property {Object} icons - * @property {string} icons.image32 - * @property {string} icons.image64 - */ - var ex; - - /** @type {App} */ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - const app = { - name: 'name', - icons: { - image32: 'x.png', - image64: 'y.png', - } - } - - /** @typedef {Object} Opp - * @property {string} name - * @property {Object} oops - * @property {string} horrible - * @type {string} idea - */ - var intercessor = 1 - - /** @type {Opp} */ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var mistake; - - /** @typedef {Object} Upp - * @property {string} name - * @property {Object} not - * @property {string} nested - */ - - /** @type {Upp} */ - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - var sala = { name: 'uppsala', not: 0, nested: "ok" }; - sala.name - sala.not - sala.nested - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt index 00b89304f2..f3e513e45b 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt @@ -1,16 +1,10 @@ github20832.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. github20832.js(2,15): error TS2304: Cannot find name 'U'. -github20832.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -github20832.js(6,13): error TS8010: Type annotations can only be used in TypeScript files. -github20832.js(12,11): error TS8010: Type annotations can only be used in TypeScript files. github20832.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. github20832.js(17,12): error TS2304: Cannot find name 'V'. -github20832.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -github20832.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -github20832.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -==== github20832.js (10 errors) ==== +==== github20832.js (4 errors) ==== // #20832 ~~~~~~~~~ /** @typedef {U} T - should be "error, can't find type named 'U' */ @@ -23,12 +17,8 @@ github20832.js(26,12): error TS8010: Type annotations can only be used in TypeSc ~~~~~~~~~~~~~~ * @param {U} x ~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} ~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function f(x) { @@ -40,8 +30,6 @@ github20832.js(26,12): error TS8010: Type annotations can only be used in TypeSc !!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type T - should be fine, since T will be any */ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const x = 3; @@ -54,8 +42,6 @@ github20832.js(26,12): error TS8010: Type annotations can only be used in TypeSc ~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'V'. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ /** @@ -64,8 +50,6 @@ github20832.js(26,12): error TS8010: Type annotations can only be used in TypeSc ~~~~~~~~~~~~~~ * @param {V} vvvvv ~~~~~~~~~~~~~~~~~~~ - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ ~~~ function g(vvvvv) { @@ -75,7 +59,5 @@ github20832.js(26,12): error TS8010: Type annotations can only be used in TypeSc !!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type {Cb} */ - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const cb = x => {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt index 15ebfd7180..6b2506e05c 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt @@ -1,31 +1,12 @@ mod1.js(2,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? mod1.js(9,12): error TS2304: Cannot find name 'Type1'. -mod1.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -mod1.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -mod1.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. -mod2.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -mod2.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. mod3.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? mod3.js(10,12): error TS2304: Cannot find name 'StringOrNumber1'. -mod3.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -mod3.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -mod3.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -mod3.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -mod3.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. mod4.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. -mod4.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -mod4.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -mod4.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -mod4.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -mod4.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. -mod5.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -mod5.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. -mod6.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. -==== mod1.js (5 errors) ==== +==== mod1.js (2 errors) ==== /** * @typedef {function(string): boolean} ~~~~~~~~ @@ -40,20 +21,14 @@ mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript fi * @param {Type1} func The function to call. ~~~~~ !!! error TS2304: Cannot find name 'Type1'. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} arg The argument to call it with. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean} The return. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function callIt(func, arg) { return func(arg); } -==== mod2.js (2 errors) ==== +==== mod2.js (0 errors) ==== /** * @typedef {{ * num: number, @@ -65,17 +40,13 @@ mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript fi /** * Makes use of a type with a multiline type expression. * @param {Type2} obj The object. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string|number} The return. - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function check(obj) { return obj.boo ? obj.num : obj.str; } -==== mod3.js (7 errors) ==== +==== mod3.js (2 errors) ==== /** * A function whose signature is very long. * @@ -91,26 +62,16 @@ mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript fi * @param {StringOrNumber1} func The function. ~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'StringOrNumber1'. - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {boolean} bool The condition. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} str The string. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} num The number. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string|number} The return. - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function use1(func, bool, str, num) { return func(bool, str, num) } -==== mod4.js (7 errors) ==== +==== mod4.js (2 errors) ==== /** * A function whose signature is very long. * @@ -127,26 +88,16 @@ mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript fi * @param {StringOrNumber2} func The function. ~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'StringOrNumber2'. - ~~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {boolean} bool The condition. - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} str The string. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} num The number. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string|number} The return. - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function use2(func, bool, str, num) { return func(bool, str, num) } -==== mod5.js (2 errors) ==== +==== mod5.js (0 errors) ==== /** * @typedef {{ * num: @@ -161,17 +112,13 @@ mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript fi /** * Makes use of a type with a multiline type expression. * @param {Type5} obj The object. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {string|number} The return. - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function check5(obj) { return obj.boo ? obj.num : obj.str; } -==== mod6.js (2 errors) ==== +==== mod6.js (0 errors) ==== /** * @typedef {{ * foo: @@ -184,11 +131,7 @@ mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript fi /** * Makes use of a type with a multiline type expression. * @param {Type6} obj The object. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {*} The return. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ function check6(obj) { return obj.foo; diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt index 0cbf74bd2f..9018979fea 100644 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt @@ -1,13 +1,10 @@ uniqueSymbolsDeclarationsInJs.js(4,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -uniqueSymbolsDeclarationsInJs.js(8,15): error TS8010: Type annotations can only be used in TypeScript files. uniqueSymbolsDeclarationsInJs.js(9,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -uniqueSymbolsDeclarationsInJs.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. uniqueSymbolsDeclarationsInJs.js(14,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. uniqueSymbolsDeclarationsInJs.js(20,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -uniqueSymbolsDeclarationsInJs.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -==== uniqueSymbolsDeclarationsInJs.js (7 errors) ==== +==== uniqueSymbolsDeclarationsInJs.js (4 errors) ==== // classes class C { /** @@ -19,8 +16,6 @@ uniqueSymbolsDeclarationsInJs.js(26,12): error TS8010: Type annotations can only static readonlyStaticCall = Symbol(); /** * @type {unique symbol} - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @readonly ~~~~~~~~~ */ @@ -29,8 +24,6 @@ uniqueSymbolsDeclarationsInJs.js(26,12): error TS8010: Type annotations can only static readonlyStaticType; /** * @type {unique symbol} - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @readonly ~~~~~~~~~ */ @@ -50,7 +43,5 @@ uniqueSymbolsDeclarationsInJs.js(26,12): error TS8010: Type annotations can only } /** @type {unique symbol} */ - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. const a = Symbol(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt index d90bb47220..8aa86600fd 100644 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt @@ -1,25 +1,18 @@ -uniqueSymbolsDeclarationsInJsErrors.js(3,15): error TS8010: Type annotations can only be used in TypeScript files. 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(7,15): error TS8010: Type annotations can only be used in TypeScript files. uniqueSymbolsDeclarationsInJsErrors.js(8,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -uniqueSymbolsDeclarationsInJsErrors.js(12,15): error TS8010: Type annotations can only be used in TypeScript files. 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 (6 errors) ==== +==== uniqueSymbolsDeclarationsInJsErrors.js (3 errors) ==== class C { /** * @type {unique symbol} - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ 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} - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. * @readonly ~~~~~~~~~ */ @@ -28,8 +21,6 @@ uniqueSymbolsDeclarationsInJsErrors.js(14,12): error TS1331: A property of a cla static readonlyType; /** * @type {unique symbol} - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. */ static readwriteType; ~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt b/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt deleted file mode 100644 index 48cf899dce..0000000000 --- a/testdata/baselines/reference/submodule/conformance/varRequireFromJavascript.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -ex.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. -use.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== use.js (1 errors) ==== - var ex = require('./ex') - - // values work - var crunch = new ex.Crunch(1); - crunch.n - - - // types work - /** - * @param {ex.Crunch} wrap - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(wrap) { - wrap.n - } - -==== ex.js (1 errors) ==== - export class Crunch { - /** @param {number} n */ - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor(n) { - this.n = n - } - m() { - return this.n - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt b/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt deleted file mode 100644 index 9f8b937fb6..0000000000 --- a/testdata/baselines/reference/submodule/conformance/varRequireFromTypescript.errors.txt +++ /dev/null @@ -1,34 +0,0 @@ -use.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -use.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. - - -==== use.js (2 errors) ==== - var ex = require('./ex') - - // values work - var crunch = new ex.Crunch(1); - crunch.n - - - // types work - /** - * @param {ex.Greatest} greatest - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {ex.Crunch} wrap - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(greatest, wrap) { - greatest.day - wrap.n - } - -==== ex.d.ts (0 errors) ==== - export type Greatest = { day: 1 } - export class Crunch { - n: number - m(): number - constructor(n: number) - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff index e97b67e851..c2a498e7f1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/amdLikeInputDeclarationEmit.errors.txt.diff @@ -2,7 +2,6 @@ +++ new.amdLikeInputDeclarationEmit.errors.txt @@= skipped -0, +0 lines =@@ - -+ExtendedClass.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. +ExtendedClass.js(17,5): error TS1231: An export assignment must be at the top level of a file or module declaration. +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,13 +16,11 @@ + } + export = BaseClass; + } -+==== ExtendedClass.js (4 errors) ==== ++==== ExtendedClass.js (3 errors) ==== + define("lib/ExtendedClass", ["deps/BaseClass"], + /** + * {typeof import("deps/BaseClass")} + * @param {typeof import("deps/BaseClass")} BaseClass -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns + */ + (BaseClass) => { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff index c567267282..a310bbe6cb 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsObjectCreatesRestForJs.errors.txt.diff @@ -5,10 +5,9 @@ +main.js(3,9): error TS2554: Expected 0 arguments, but got 3. +main.js(5,1): error TS2554: Expected 2 arguments, but got 0. +main.js(6,16): error TS2554: Expected 2 arguments, but got 3. -+main.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== main.js (4 errors) ==== ++==== main.js (3 errors) ==== + function allRest() { arguments; } + allRest(); + allRest(1, 2, 3); @@ -25,8 +24,6 @@ + + /** + * @param {number} x - a thing -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function jsdocced(x) { arguments; } + jsdocced(1); diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.errors.txt.diff deleted file mode 100644 index a55d6adb72..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor1_Js.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.argumentsReferenceInConstructor1_Js.errors.txt -+++ new.argumentsReferenceInConstructor1_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class A { -+ /** -+ * Constructor -+ * -+ * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(foo = {}) { -+ /** -+ * @type object -+ */ -+ this.arguments = foo; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.errors.txt.diff deleted file mode 100644 index fb97c19836..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor2_Js.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.argumentsReferenceInConstructor2_Js.errors.txt -+++ new.argumentsReferenceInConstructor2_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class A { -+ /** -+ * Constructor -+ * -+ * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(foo = {}) { -+ /** -+ * @type object -+ */ -+ this["arguments"] = foo; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff deleted file mode 100644 index b54e8f4889..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.argumentsReferenceInConstructor3_Js.errors.txt -+++ new.argumentsReferenceInConstructor3_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(11,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class A { -+ get arguments() { -+ return { bar: {} }; -+ } -+ } -+ -+ class B extends A { -+ /** -+ * Constructor -+ * -+ * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(foo = {}) { -+ super(); -+ -+ /** -+ * @type object -+ */ -+ this.foo = foo; -+ -+ /** -+ * @type object -+ */ -+ this.bar = super.arguments.foo; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff deleted file mode 100644 index 24fdf4fb4c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor4_Js.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.argumentsReferenceInConstructor4_Js.errors.txt -+++ new.argumentsReferenceInConstructor4_Js.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. - /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 (1 errors) ==== -+==== /a.js (3 errors) ==== - class A { - /** - * Constructor - * - * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(foo = {}) { - const key = "bar"; -@@= skipped -17, +21 lines =@@ - - /** - * @type object -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const arguments = this.arguments; - ~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.errors.txt.diff deleted file mode 100644 index a1b7e4a866..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor5_Js.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.argumentsReferenceInConstructor5_Js.errors.txt -+++ new.argumentsReferenceInConstructor5_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ const bar = { -+ arguments: {} -+ } -+ -+ class A { -+ /** -+ * Constructor -+ * -+ * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(foo = {}) { -+ /** -+ * @type object -+ */ -+ this.foo = foo; -+ -+ /** -+ * @type object -+ */ -+ this.bar = bar.arguments; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.errors.txt.diff deleted file mode 100644 index 8511d94fc8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod1_Js.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.argumentsReferenceInMethod1_Js.errors.txt -+++ new.argumentsReferenceInMethod1_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class A { -+ /** -+ * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ m(foo = {}) { -+ /** -+ * @type object -+ */ -+ this.arguments = foo; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.errors.txt.diff deleted file mode 100644 index d9c725589d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod2_Js.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.argumentsReferenceInMethod2_Js.errors.txt -+++ new.argumentsReferenceInMethod2_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class A { -+ /** -+ * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ m(foo = {}) { -+ /** -+ * @type object -+ */ -+ this["arguments"] = foo; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff deleted file mode 100644 index a3ad683ddd..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.argumentsReferenceInMethod3_Js.errors.txt -+++ new.argumentsReferenceInMethod3_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class A { -+ get arguments() { -+ return { bar: {} }; -+ } -+ } -+ -+ class B extends A { -+ /** -+ * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ m(foo = {}) { -+ /** -+ * @type object -+ */ -+ this.x = foo; -+ -+ /** -+ * @type object -+ */ -+ this.y = super.arguments.bar; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff deleted file mode 100644 index 2b5f4a26fc..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod4_Js.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.argumentsReferenceInMethod4_Js.errors.txt -+++ new.argumentsReferenceInMethod4_Js.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. - /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 (1 errors) ==== -+==== /a.js (3 errors) ==== - class A { - /** - * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - m(foo = {}) { - const key = "bar"; -@@= skipped -15, +19 lines =@@ - - /** - * @type object -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const arguments = this.arguments; - ~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.errors.txt.diff deleted file mode 100644 index 232dcba758..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod5_Js.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.argumentsReferenceInMethod5_Js.errors.txt -+++ new.argumentsReferenceInMethod5_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ const bar = { -+ arguments: {} -+ } -+ -+ class A { -+ /** -+ * @param {object} [foo={}] -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ m(foo = {}) { -+ /** -+ * @type object -+ */ -+ this.foo = foo; -+ -+ /** -+ * @type object -+ */ -+ this.bar = bar.arguments; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff index 5a1d97f303..4a9a7795da 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff @@ -8,55 +8,35 @@ - - -==== mytest.js (2 errors) ==== -+mytest.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+mytest.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. +mytest.js(6,13): error TS8004: Type parameter declarations can only be used in TypeScript files. -+mytest.js(6,34): error TS8016: Type assertion expressions can only be used in TypeScript files. +mytest.js(6,45): error TS2322: Type 'string' is not assignable to type 'T'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -+mytest.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+mytest.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. +mytest.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. -+mytest.js(13,34): error TS8016: Type assertion expressions can only be used in TypeScript files. +mytest.js(13,61): error TS2322: Type 'string' is not assignable to type 'T'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. + + -+==== mytest.js (10 errors) ==== ++==== mytest.js (4 errors) ==== /** * @template T * @param {T|undefined} value value or not -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} result value -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo1 = value => /** @type {string} */({ ...value }); - ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. - /** - * @template T - * @param {T|undefined} value value or not -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -20, +24 lines =@@ * @returns {T} result value -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff index 75bdc9bdef..70fd2ab097 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff @@ -2,24 +2,15 @@ +++ new.arrowExpressionJs.errors.txt @@= skipped -0, +0 lines =@@ - -+mytest.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+mytest.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. +mytest.js(6,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -+mytest.js(6,45): error TS8016: Type assertion expressions can only be used in TypeScript files. + + -+==== mytest.js (4 errors) ==== ++==== mytest.js (1 errors) ==== + /** + * @template T + * @param {T|undefined} value value or not -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} result value -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const cloneObjectGood = value => /** @type {T} */({ ...value }); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file ++!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file 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 49612ac80d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowFunctionJSDocAnnotation.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.arrowFunctionJSDocAnnotation.errors.txt -+++ new.arrowFunctionJSDocAnnotation.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(10,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(11,18): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (3 errors) ==== -+ /** -+ * @param {any} v -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function identity(v) { -+ return v; -+ } -+ -+ const x = identity( -+ /** -+ * @param {number} param -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {number=} -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ param => param -+ ); -+ \ No newline at end of file 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 51da005600..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.checkJsObjectLiteralHasCheckedKeyof.errors.txt -+++ new.checkJsObjectLiteralHasCheckedKeyof.errors.txt -@@= skipped -0, +0 lines =@@ -+file.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. - file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. - - --==== file.js (1 errors) ==== -+==== file.js (2 errors) ==== - // @ts-check - const obj = { - x: 1, -@@= skipped -9, +10 lines =@@ - - /** - * @type {keyof typeof obj} -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - let selected = "x"; - selected = "z"; // should fail \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff index 556c1c9f23..af290d6fc7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff @@ -2,9 +2,7 @@ +++ new.checkJsTypeDefNoUnusedLocalMarked.errors.txt @@= skipped -0, +0 lines =@@ - -+something.js(3,20): error TS8010: Type annotations can only be used in TypeScript files. +something.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+something.js(5,29): error TS8016: Type assertion expressions can only be used in TypeScript files. + + +==== file.ts (0 errors) ==== @@ -17,15 +15,11 @@ + } + + export = Foo; -+==== something.js (3 errors) ==== ++==== something.js (1 errors) ==== + /** @typedef {typeof import("./file")} Foo */ + + /** @typedef {(foo: Foo) => string} FooFun */ -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + + module.exports = /** @type {FooFun} */(void 0); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ ~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file ++!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/constructorPropertyJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/constructorPropertyJs.errors.txt.diff deleted file mode 100644 index fc372dd974..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/constructorPropertyJs.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.constructorPropertyJs.errors.txt -+++ new.constructorPropertyJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class C { -+ /** -+ * @param {any} a -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ foo(a) { -+ this.constructor = a; -+ } -+ } -+ \ No newline at end of file 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 4e58d4e5f8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contextuallyTypedParametersOptionalInJSDoc.errors.txt.diff +++ /dev/null @@ -1,62 +0,0 @@ ---- old.contextuallyTypedParametersOptionalInJSDoc.errors.txt -+++ new.contextuallyTypedParametersOptionalInJSDoc.errors.txt -@@= skipped -0, +0 lines =@@ -+index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(8,28): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(14,6): error TS8009: The '?' modifier can only be used in TypeScript files. - 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(22,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(25,6): error TS8009: The '?' modifier can only be used in TypeScript files. -+index.js(25,14): error TS8010: Type annotations can only be used in TypeScript files. - 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 (2 errors) ==== -+==== index.js (10 errors) ==== - /** - * - * @param {number} num -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function acceptNum(num) {} - - /** - * @typedef {(a: string, b: number) => void} Fn -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - - /** @type {Fn} */ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const fn1 = - /** - * @param [b] -+ ~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. - */ - function self(a, b) { - acceptNum(b); // error -@@= skipped -29, +47 lines =@@ - }; - - /** @type {Fn} */ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const fn2 = - /** - * @param {number} [b] -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function self(a, b) { - acceptNum(b); // error \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff index e04771cf80..d461cd3e25 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff @@ -4,31 +4,21 @@ - +index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(2,28): error TS2304: Cannot find name 'B'. -+index.js(2,41): error TS8010: Type annotations can only be used in TypeScript files. +index.js(2,42): error TS2304: Cannot find name 'A'. -+index.js(2,47): error TS8010: Type annotations can only be used in TypeScript files. +index.js(2,48): error TS2304: Cannot find name 'B'. +index.js(2,67): error TS2304: Cannot find name 'B'. +index.js(10,12): error TS2315: Type 'Funcs' is not generic. -+index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(14,21): error TS8016: Type assertion expressions can only be used in TypeScript files. -+index.js(20,19): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (12 errors) ==== ++==== index.js (6 errors) ==== + /** + ~~~ + * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS2304: Cannot find name 'B'. -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2304: Cannot find name 'A'. -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2304: Cannot find name 'B'. + ~ @@ -51,20 +41,14 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~ +!!! error TS2315: Type 'Funcs' is not generic. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {[A, B]} + ~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function foo(fns) { + ~~~~~~~~~~~~~~~~~~~ + return /** @type {any} */ (null); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. @@ -73,8 +57,6 @@ + bar: { + fn: + /** @param {string} a */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + (a) => {}, + thing: "asd", + }, diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff index cde4ad76e0..f9fcccb0b7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff @@ -3,38 +3,23 @@ @@= skipped -0, +0 lines =@@ - +index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(7,21): error TS8016: Type assertion expressions can only be used in TypeScript files. -+index.js(12,6): error TS8009: The '?' modifier can only be used in TypeScript files. -+index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(19,6): error TS8009: The '?' modifier can only be used in TypeScript files. -+index.js(19,14): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(20,6): error TS8009: The '?' modifier can only be used in TypeScript files. -+index.js(20,14): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (10 errors) ==== ++==== index.js (1 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + * @param {(value: T, index: number) => boolean} predicate + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function filter(predicate) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + return /** @type {any} */ (null); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. @@ -42,10 +27,6 @@ + const a = filter( + /** + * @param {number} [pose] -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + (pose) => true + ); @@ -53,16 +34,7 @@ + const b = filter( + /** + * @param {number} [pose] -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} [_] -+ ~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + (pose, _) => true + ); diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff index e738d43017..fecec633bc 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/controlFlowInstanceof.errors.txt.diff @@ -2,7 +2,6 @@ +++ new.controlFlowInstanceof.errors.txt @@= skipped -0, +0 lines =@@ - -+uglify.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +uglify.js(6,7): error TS2339: Property 'val' does not exist on type '{}'. + + @@ -115,12 +114,10 @@ + } + + // Repro from #27550 (based on uglify code) -+==== uglify.js (2 errors) ==== ++==== uglify.js (1 errors) ==== + /** @constructor */ + function AtTop(val) { this.val = val } + /** @type {*} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var v = 1; + if (v instanceof AtTop) { + v.val 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 index c17c27d755..be2c0f1f43 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt.diff @@ -2,100 +2,46 @@ +++ new.declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt @@= skipped -0, +0 lines =@@ - -+input.js(5,30): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(7,30): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(8,34): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(10,35): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(13,59): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(16,24): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(17,44): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+input.js(18,43): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(19,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(21,46): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(23,40): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(25,33): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(29,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(37,70): error TS8016: Type assertion expressions can only be used in TypeScript files. + + -+==== input.js (19 errors) ==== ++==== input.js (1 errors) ==== + /** + * @typedef {{ } & { name?: string }} P + */ + + const something = /** @type {*} */(null); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export let vLet = /** @type {P} */(something); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + export const vConst = /** @type {P} */(something); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export function fn(p = /** @type {P} */(something)) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** @param {number} req */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export class C { + field = /** @type {P} */(something); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @optional */ optField = /** @type {P} */(something); // not a thing -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @readonly */ roFiled = /** @type {P} */(something); + ~~~~~~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + method(p = /** @type {P} */(something)) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @param {number} req */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + methodWithRequiredDefault(p = /** @type {P} */(something), req) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + constructor(ctorField = /** @type {P} */(something)) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + get x() { return /** @type {P} */(something) } -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + set x(v) { } + } + + export default /** @type {P} */(something); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + // allows `undefined` on the input side, thanks to the initializer + /** + * + * @param {P} x -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ -+ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file ++ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} \ No newline at end of file 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 index 04ec488f90..b0ef4e3123 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt.diff @@ -2,100 +2,46 @@ +++ new.declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt @@= skipped -0, +0 lines =@@ - -+input.js(5,30): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(7,30): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(8,34): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(10,35): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(13,59): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(16,24): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(17,44): error TS8016: Type assertion expressions can only be used in TypeScript files. +input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+input.js(18,43): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(19,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(21,46): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(23,40): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(25,33): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(29,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -+input.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(37,70): error TS8016: Type assertion expressions can only be used in TypeScript files. + + -+==== input.js (19 errors) ==== ++==== input.js (1 errors) ==== + /** + * @typedef {{ } & { name?: string }} P + */ + + const something = /** @type {*} */(null); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export let vLet = /** @type {P} */(something); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + export const vConst = /** @type {P} */(something); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export function fn(p = /** @type {P} */(something)) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** @param {number} req */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + export function fnWithRequiredDefaultParam(p = /** @type {P} */(something), req) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export class C { + field = /** @type {P} */(something); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @optional */ optField = /** @type {P} */(something); // not a thing -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @readonly */ roFiled = /** @type {P} */(something); + ~~~~~~~~~~ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + method(p = /** @type {P} */(something)) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + /** @param {number} req */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + methodWithRequiredDefault(p = /** @type {P} */(something), req) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + constructor(ctorField = /** @type {P} */(something)) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + get x() { return /** @type {P} */(something) } -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + set x(v) { } + } + + export default /** @type {P} */(something); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + // allows `undefined` on the input side, thanks to the initializer + /** + * + * @param {P} x -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ -+ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. \ No newline at end of file ++ export function fnWithPartialAnnotationOnDefaultparam(x = /** @type {P} */(something), b) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.errors.txt.diff deleted file mode 100644 index 888b51d69d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassAccessorsJs1.errors.txt.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.declarationEmitClassAccessorsJs1.errors.txt -+++ new.declarationEmitClassAccessorsJs1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (2 errors) ==== -+ // https://github.com/microsoft/TypeScript/issues/58167 -+ -+ export class VFile { -+ /** -+ * @returns {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ get path() { -+ return '' -+ } -+ -+ /** -+ * @param {URL | string} path -+ ~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set path(path) { -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt.diff deleted file mode 100644 index e1269a7a0c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.declarationEmitClassSetAccessorParamNameInJs.errors.txt -+++ new.declarationEmitClassSetAccessorParamNameInJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+foo.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (1 errors) ==== -+ // https://github.com/microsoft/TypeScript/issues/55391 -+ -+ export class Foo { -+ /** -+ * Bar. -+ * -+ * @param {string} baz Baz. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set bar(baz) {} -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt.diff deleted file mode 100644 index 5383769db8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.declarationEmitClassSetAccessorParamNameInJs2.errors.txt -+++ new.declarationEmitClassSetAccessorParamNameInJs2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+foo.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (1 errors) ==== -+ export class Foo { -+ /** -+ * Bar. -+ * -+ * @param {{ prop: string }} baz Baz. -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set bar({}) {} -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt.diff deleted file mode 100644 index e5437ace1b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.declarationEmitClassSetAccessorParamNameInJs3.errors.txt -+++ new.declarationEmitClassSetAccessorParamNameInJs3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+foo.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (1 errors) ==== -+ export class Foo { -+ /** -+ * Bar. -+ * -+ * @param {{ prop: string | undefined }} baz Baz. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set bar({ prop = 'foo' }) {} -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.errors.txt.diff deleted file mode 100644 index e47fcba5c4..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitLateBoundJSAssignments.errors.txt.diff +++ /dev/null @@ -1,39 +0,0 @@ ---- old.declarationEmitLateBoundJSAssignments.errors.txt -+++ new.declarationEmitLateBoundJSAssignments.errors.txt -@@= skipped -0, +0 lines =@@ -- -+file.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== file.js (4 errors) ==== -+ export function foo() {} -+ foo.bar = 12; -+ const _private = Symbol(); -+ foo[_private] = "ok"; -+ const strMem = "strMemName"; -+ foo[strMem] = "ok"; -+ const dashStrMem = "dashed-str-mem"; -+ foo[dashStrMem] = "ok"; -+ const numMem = 42; -+ foo[numMem] = "ok"; -+ -+ /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const x = foo[_private]; -+ /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const y = foo[strMem]; -+ /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const z = foo[numMem]; -+ /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const a = foo[dashStrMem]; -+ \ No newline at end of file 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 0e5940f9ef..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitObjectLiteralAccessorsJs1.errors.txt.diff +++ /dev/null @@ -1,75 +0,0 @@ ---- old.declarationEmitObjectLiteralAccessorsJs1.errors.txt -+++ new.declarationEmitObjectLiteralAccessorsJs1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(21,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(28,14): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(36,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(46,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (6 errors) ==== -+ // same type accessors -+ export const obj1 = { -+ /** -+ * my awesome getter (first in source order) -+ * @returns {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ get x() { -+ return ""; -+ }, -+ /** -+ * my awesome setter (second in source order) -+ * @param {string} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set x(a) {}, -+ }; -+ -+ // divergent accessors -+ export const obj2 = { -+ /** -+ * my awesome getter -+ * @returns {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ get x() { -+ return ""; -+ }, -+ /** -+ * my awesome setter -+ * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set x(a) {}, -+ }; -+ -+ export const obj3 = { -+ /** -+ * my awesome getter -+ * @returns {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ get x() { -+ return ""; -+ }, -+ }; -+ -+ export const obj4 = { -+ /** -+ * my awesome setter -+ * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set x(a) {}, -+ }; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff index 28064adf35..6569dcf3a6 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff @@ -2,13 +2,10 @@ +++ new.expandoFunctionContextualTypesJs.errors.txt @@= skipped -0, +0 lines =@@ - -+input.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -+input.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. +input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== input.js (4 errors) ==== ++==== input.js (1 errors) ==== + /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ + + /** @@ -17,8 +14,6 @@ + + /** + * @type {StatelessComponent} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const MyComponent = () => /* @type {any} */(null); + @@ -37,16 +32,12 @@ + + /** + * @type {StatelessComponent} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const check = MyComponent2; + + /** + * + * @param {{ props: MyComponentProps }} p -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function expectLiteral(p) {} + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.errors.txt.diff deleted file mode 100644 index 828eec824e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionSymbolPropertyJs.errors.txt.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.expandoFunctionSymbolPropertyJs.errors.txt -+++ new.expandoFunctionSymbolPropertyJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /types.ts (0 errors) ==== -+ export const symb = Symbol(); -+ -+ export interface TestSymb { -+ (): void; -+ readonly [symb]: boolean; -+ } -+ -+==== /a.js (1 errors) ==== -+ import { symb } from "./types"; -+ -+ /** -+ * @returns {import("./types").TestSymb} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function test() { -+ function inner() {} -+ inner[symb] = true; -+ return inner; -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.errors.txt.diff deleted file mode 100644 index 0b5fc0d559..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.exportDefaultWithJSDoc2.errors.txt -+++ new.exportDefaultWithJSDoc2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(6,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -+ -+ -+==== a.js (1 errors) ==== -+ /** -+ * A number, or a string containing a number. -+ * @typedef {(number|string)} NumberLike -+ */ -+ -+ export default /** @type {NumberLike[]} */([ ]); -+ ~~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ -+==== b.ts (0 errors) ==== -+ import A from './a' -+ A[0] \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt.diff deleted file mode 100644 index 7863bc90bd..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/extendedUnicodePlaneIdentifiersJSDoc.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.extendedUnicodePlaneIdentifiersJSDoc.errors.txt -+++ new.extendedUnicodePlaneIdentifiersJSDoc.errors.txt -@@= skipped -0, +0 lines =@@ -- -+file.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== file.js (2 errors) ==== -+ /** -+ * Adds -+ * @param {number} 𝑚 -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {number} 𝑀 -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function foo(𝑚, 𝑀) { -+ console.log(𝑀 + 𝑚); -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.errors.txt.diff deleted file mode 100644 index 29aa38a8f2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/importTypeResolutionJSDocEOF.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.importTypeResolutionJSDocEOF.errors.txt -+++ new.importTypeResolutionJSDocEOF.errors.txt -@@= skipped -0, +0 lines =@@ -- -+usage.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== interfaces.d.ts (0 errors) ==== -+ export interface Bar { -+ prop: string -+ } -+ -+==== usage.js (1 errors) ==== -+ /** @type {Bar} */ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ export let bar; -+ -+ /** @typedef {import('./interfaces').Bar} Bar */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt.diff deleted file mode 100644 index c2b419eda0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.errors.txt.diff +++ /dev/null @@ -1,39 +0,0 @@ ---- old.jsDeclarationEmitDoesNotRenameImport.errors.txt -+++ new.jsDeclarationEmitDoesNotRenameImport.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(10,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== test/Test.js (0 errors) ==== -+ /** @module test/Test */ -+ class Test {} -+ export default Test; -+==== Test.js (0 errors) ==== -+ /** @module Test */ -+ class Test {} -+ export default Test; -+==== index.js (1 errors) ==== -+ import Test from './test/Test.js' -+ -+ /** -+ * @typedef {Object} Options -+ * @property {typeof import("./Test.js").default} [test] -+ */ -+ -+ class X extends Test { -+ /** -+ * @param {Options} options -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(options) { -+ super(); -+ if (options.test) { -+ this.test = new options.test(); -+ } -+ } -+ } -+ -+ export default X; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff deleted file mode 100644 index 92d08d3c0b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.jsDeclarationsInheritedTypes.errors.txt -+++ new.jsDeclarationsInheritedTypes.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(20,15): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(27,15): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (3 errors) ==== -+ /** -+ * @typedef A -+ * @property {string} a -+ */ -+ -+ /** -+ * @typedef B -+ * @property {number} b -+ */ -+ -+ class C1 { -+ /** -+ * @type {A} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ value; -+ } -+ -+ class C2 extends C1 { -+ /** -+ * @type {A} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ value; -+ } -+ -+ class C3 extends C1 { -+ /** -+ * @type {A & B} -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ value; -+ } -+ \ No newline at end of file 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 944994c296..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt.diff +++ /dev/null @@ -1,55 +0,0 @@ ---- old.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt -+++ new.jsDocDeclarationEmitDoesNotUseNodeModulesPathWithoutError.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(7,8): error TS8009: The '?' modifier can only be used in TypeScript files. -+index.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== 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 (2 errors) ==== -+ /** -+ * @typedef {import('@lion/ajax').LionRequestInit} LionRequestInit -+ */ -+ -+ export class NewAjax { -+ /** -+ * @param {LionRequestInit} [init] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ case5_unexpectedlyResolvesPathToNodeModules(init) {} -+ } -+ -+ /** -+ * @type {(init?: LionRequestInit) => void} -+ */ -+ // @ts-expect-error -+ NewAjax.prototype.case6_unexpectedlyResolvesPathToNodeModules; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff index 4f2298a1c7..aa131e44ee 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff @@ -3,13 +3,10 @@ @@= skipped -0, +0 lines =@@ - +enumDef.js(16,18): error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. -+index.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. +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(13,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(18,11): error TS2503: Cannot find namespace 'Host'. -+index.js(18,11): error TS8010: Type annotations can only be used in TypeScript files. + + +==== enumDef.js (1 errors) ==== @@ -33,13 +30,11 @@ +!!! error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. + x: 12 + } -+==== index.js (7 errors) ==== ++==== index.js (4 errors) ==== + var Other = {}; + Other.Cls = class { + /** + * @param {!Host.UserMetrics.Action} p -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ +!!! error TS2503: Cannot find namespace 'Host'. + */ @@ -55,8 +50,6 @@ + * @type {Host.UserMetrics.Bargh} + ~~~~ +!!! error TS2503: Cannot find namespace 'Host'. -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var x = "ok"; + @@ -64,8 +57,6 @@ + * @type {Host.UserMetrics.Blah} + ~~~~ +!!! error TS2503: Cannot find namespace 'Host'. -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var y = "ok"; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff index bb1a86e259..708fd18a67 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.errors.txt.diff @@ -3,13 +3,10 @@ @@= skipped -0, +0 lines =@@ - +index.js(10,12): error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? -+index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(17,16): error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? -+usage.js(12,16): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== usage.js (1 errors) ==== ++==== usage.js (0 errors) ==== + const { Thing, useThing, cbThing } = require("./index"); + + useThing(Thing.a); @@ -22,15 +19,13 @@ + + cbThing(type => { + /** @type {LogEntry} */ -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const logEntry = { + time: Date.now(), + type, + }; + }); + -+==== index.js (4 errors) ==== ++==== index.js (2 errors) ==== + /** @enum {string} */ + const Thing = Object.freeze({ + a: "thing", @@ -43,8 +38,6 @@ + * @param {Thing} x + ~~~~~ +!!! error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function useThing(x) {} + @@ -52,8 +45,6 @@ + + /** + * @param {(x: Thing) => void} x -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~ +!!! error TS2749: 'Thing' refers to a value, but is being used as a type here. Did you mean 'typeof Thing'? + */ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff index c468258a2b..4f27d9dc88 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsExportMemberMergedWithModuleAugmentation.errors.txt.diff @@ -2,24 +2,13 @@ +++ new.jsExportMemberMergedWithModuleAugmentation.errors.txt @@= skipped -0, +0 lines =@@ -/index.ts(11,7): error TS2741: Property 'x' is missing in type '{ b: string; }' but required in type 'Abcde'. -- -- --==== /test.js (0 errors) ==== +/index.ts(1,23): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. +/index.ts(3,16): error TS2671: Cannot augment module './test' because it resolves to a non-module entity. +/index.ts(11,10): error TS2749: 'Abcde' refers to a value, but is being used as a type here. Did you mean 'typeof Abcde'? -+/test.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /test.js (1 errors) ==== - class Abcde { - /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - x; - } - -@@= skipped -10, +15 lines =@@ + + + ==== /test.js (0 errors) ==== +@@= skipped -10, +12 lines =@@ Abcde }; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt.diff deleted file mode 100644 index b1e51af630..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileAlternativeUseOfOverloadTag.errors.txt.diff +++ /dev/null @@ -1,71 +0,0 @@ ---- old.jsFileAlternativeUseOfOverloadTag.errors.txt -+++ new.jsFileAlternativeUseOfOverloadTag.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsFileAlternativeUseOfOverloadTag.js(7,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileAlternativeUseOfOverloadTag.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileAlternativeUseOfOverloadTag.js(25,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileAlternativeUseOfOverloadTag.js(38,7): error TS8017: Signature declarations can only be used in TypeScript files. -+ -+ -+==== jsFileAlternativeUseOfOverloadTag.js (4 errors) ==== -+ // These are a few examples of existing alternative uses of @overload tag. -+ // They will not work as expected with our implementation, but we are -+ // trying to make sure that our changes do not result in any crashes here. -+ -+ const example1 = { -+ /** -+ * @overload Example1(value) -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. -+ * Creates Example1 -+ * @param value [String] -+ */ -+ constructor: function Example1(value, options) {}, -+ }; -+ -+ const example2 = { -+ /** -+ * Example 2 -+ * -+ * @overload Example2(value) -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. -+ * Creates Example2 -+ * @param value [String] -+ * @param secretAccessKey [String] -+ * @param sessionToken [String] -+ * @example Creates with string value -+ * const example = new Example(''); -+ * @overload Example2(options) -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. -+ * Creates Example2 -+ * @option options value [String] -+ * @example Creates with options object -+ * const example = new Example2({ -+ * value: '', -+ * }); -+ */ -+ constructor: function Example2() {}, -+ }; -+ -+ const example3 = { -+ /** -+ * @overload evaluate(options = {}, [callback]) -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. -+ * Evaluate something -+ * @note Something interesting -+ * @param options [map] -+ * @return [string] returns evaluation result -+ * @return [null] returns nothing if callback provided -+ * @callback callback function (error, result) -+ * If callback is provided it will be called with evaluation result -+ * @param error [Error] -+ * @param result [String] -+ * @see callback -+ */ -+ evaluate: function evaluate(options, callback) {}, -+ }; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.errors.txt.diff index cb5ca61282..4ab5110bb2 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationSyntaxError.errors.txt.diff @@ -8,14 +8,10 @@ -!!! error TS5055: Cannot write file 'a.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. -==== a.js (0 errors) ==== -+a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (1 errors) ==== - /** - * @type {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @type {string} - */ - var v; \ No newline at end of file +- /** +- * @type {number} +- * @type {string} +- */ +- var v; +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff index 903db52451..99642fd262 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff @@ -2,52 +2,28 @@ +++ new.jsFileFunctionOverloads.errors.txt @@= skipped -0, +0 lines =@@ - -+jsFileFunctionOverloads.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(12,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(27,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads.js(29,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(34,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(41,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(48,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(51,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads.js(54,31): error TS8016: Type assertion expressions can only be used in TypeScript files. + + -+==== jsFileFunctionOverloads.js (15 errors) ==== ++==== jsFileFunctionOverloads.js (1 errors) ==== + /** + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {number} x + * @returns {'number'} + */ + /** + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {string} x + * @returns {'string'} + */ + /** + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {boolean} x + * @returns {'boolean'} + */ + /** + * @param {unknown} x -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function getTypeName(x) { + return typeof x; @@ -56,11 +32,7 @@ + /** + * @template T + * @param {T} x -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const identity = x => x; + ~~~~~~~ @@ -70,8 +42,6 @@ + * @template T + * @template U + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {T[]} array + * @param {(x: T) => U[]} iterable + * @returns {U[]} @@ -79,31 +49,19 @@ + /** + * @template T + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {T[][]} array + * @returns {T[]} + */ + /** + * @param {unknown[]} array -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {(x: unknown) => unknown} iterable -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {unknown[]} -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function flatMap(array, iterable = identity) { + /** @type {unknown[]} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const result = []; + for (let i = 0; i < array.length; i += 1) { + result.push(.../** @type {unknown[]} */(iterable(array[i]))); -+ ~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + return result; + } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff index 5f9c151273..6291af636d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff @@ -2,50 +2,26 @@ +++ new.jsFileFunctionOverloads2.errors.txt @@= skipped -0, +0 lines =@@ - -+jsFileFunctionOverloads2.js(3,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(11,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(25,14): error TS8010: Type annotations can only be used in TypeScript files. +jsFileFunctionOverloads2.js(27,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(32,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(37,5): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(41,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(42,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(43,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(46,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileFunctionOverloads2.js(49,31): error TS8016: Type assertion expressions can only be used in TypeScript files. + + -+==== jsFileFunctionOverloads2.js (15 errors) ==== ++==== jsFileFunctionOverloads2.js (1 errors) ==== + // Also works if all @overload tags are combined in one comment. + /** + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {number} x + * @returns {'number'} + * + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {string} x + * @returns {'string'} + * + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {boolean} x + * @returns {'boolean'} + * + * @param {unknown} x -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function getTypeName(x) { + return typeof x; @@ -54,11 +30,7 @@ + /** + * @template T + * @param {T} x -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const identity = x => x; + ~~~~~~~ @@ -68,37 +40,23 @@ + * @template T + * @template U + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {T[]} array + * @param {(x: T) => U[]} iterable + * @returns {U[]} + * + * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {T[][]} array + * @returns {T[]} + * + * @param {unknown[]} array -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {(x: unknown) => unknown} iterable -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {unknown[]} -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function flatMap(array, iterable = identity) { + /** @type {unknown[]} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const result = []; + for (let i = 0; i < array.length; i += 1) { + result.push(.../** @type {unknown[]} */(iterable(array[i]))); -+ ~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + } + return result; + } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff deleted file mode 100644 index f092f3e52e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileImportPreservedWhenUsed.errors.txt.diff +++ /dev/null @@ -1,39 +0,0 @@ ---- old.jsFileImportPreservedWhenUsed.errors.txt -+++ new.jsFileImportPreservedWhenUsed.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(6,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== dash.d.ts (0 errors) ==== -+ type ObjectIterator = (value: TObject[keyof TObject], key: string, collection: TObject) => TResult; -+ -+ interface LoDashStatic { -+ mapValues(obj: T | null | undefined, callback: ObjectIterator): { [P in keyof T]: TResult }; -+ } -+ declare const _: LoDashStatic; -+ export = _; -+==== Consts.ts (0 errors) ==== -+ export const INDEX_FIELD = '__INDEX'; -+==== index.js (2 errors) ==== -+ import * as _ from './dash'; -+ import { INDEX_FIELD } from './Consts'; -+ -+ export class Test { -+ /** -+ * @param {object} obj -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {object} vm -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ test(obj, vm) { -+ let index = 0; -+ vm.objects = _.mapValues( -+ obj, -+ object => ({ ...object, [INDEX_FIELD]: index++ }), -+ ); -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff index 6cac563c55..9c210ea67f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff @@ -3,18 +3,9 @@ @@= skipped -0, +0 lines =@@ - +jsFileMethodOverloads.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+jsFileMethodOverloads.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileMethodOverloads.js(13,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileMethodOverloads.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileMethodOverloads.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileMethodOverloads.js(31,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileMethodOverloads.js(36,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileMethodOverloads.js(40,6): error TS8009: The '?' modifier can only be used in TypeScript files. -+jsFileMethodOverloads.js(40,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileMethodOverloads.js(41,16): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsFileMethodOverloads.js (10 errors) ==== ++==== jsFileMethodOverloads.js (1 errors) ==== + /** + ~~~ + * @template T @@ -27,8 +18,6 @@ + ~~~~~ + * @param {T} value + ~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + constructor(value) { @@ -43,8 +32,6 @@ + ~~~~~ + * @overload + ~~~~~~~~~~~~~~ -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {Example} this + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {'number'} @@ -55,8 +42,6 @@ + ~~~~~ + * @overload + ~~~~~~~~~~~~~~ -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {Example} this + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {'string'} @@ -67,8 +52,6 @@ + ~~~~~ + * @returns {string} + ~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + getTypeName() { @@ -85,8 +68,6 @@ + ~~~~~~~~~~~~~~~~ + * @overload + ~~~~~~~~~~~~~~ -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {(y: T) => U} fn + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {U} @@ -97,8 +78,6 @@ + ~~~~~ + * @overload + ~~~~~~~~~~~~~~ -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~~~ + */ @@ -107,15 +86,8 @@ + ~~~~~ + * @param {(y: T) => unknown} [fn] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {unknown} + ~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + transform(fn) { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff index 41f2b1c550..ef1903391d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff @@ -3,18 +3,9 @@ @@= skipped -0, +0 lines =@@ - +jsFileMethodOverloads2.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+jsFileMethodOverloads2.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileMethodOverloads2.js(14,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileMethodOverloads2.js(18,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileMethodOverloads2.js(22,16): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileMethodOverloads2.js(30,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileMethodOverloads2.js(34,7): error TS8017: Signature declarations can only be used in TypeScript files. -+jsFileMethodOverloads2.js(37,6): error TS8009: The '?' modifier can only be used in TypeScript files. -+jsFileMethodOverloads2.js(37,14): error TS8010: Type annotations can only be used in TypeScript files. -+jsFileMethodOverloads2.js(38,16): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsFileMethodOverloads2.js (10 errors) ==== ++==== jsFileMethodOverloads2.js (1 errors) ==== + // Also works if all @overload tags are combined in one comment. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** @@ -29,8 +20,6 @@ + ~~~~~ + * @param {T} value + ~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + constructor(value) { @@ -45,8 +34,6 @@ + ~~~~~ + * @overload + ~~~~~~~~~~~~~~ -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {Example} this + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {'number'} @@ -55,8 +42,6 @@ + ~~~~ + * @overload + ~~~~~~~~~~~~~~ -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {Example} this + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {'string'} @@ -65,8 +50,6 @@ + ~~~~ + * @returns {string} + ~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + getTypeName() { @@ -83,8 +66,6 @@ + ~~~~~~~~~~~~~~~~ + * @overload + ~~~~~~~~~~~~~~ -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @param {(y: T) => U} fn + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @returns {U} @@ -93,23 +74,14 @@ + ~~~~ + * @overload + ~~~~~~~~~~~~~~ -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~~~ + * + ~~~~ + * @param {(y: T) => unknown} [fn] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {unknown} + ~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~ + transform(fn) { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff deleted file mode 100644 index 3b6cb739f2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads3.errors.txt.diff +++ /dev/null @@ -1,43 +0,0 @@ ---- old.jsFileMethodOverloads3.errors.txt -+++ new.jsFileMethodOverloads3.errors.txt -@@= skipped -0, +0 lines =@@ - /a.js(2,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+/a.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. - /a.js(7,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -- -- --==== /a.js (2 errors) ==== -+/a.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. -+/a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (6 errors) ==== - /** - * @overload - ~~~~~~~~ - !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @param {number} x - */ - -@@= skipped -13, +19 lines =@@ - * @overload - ~~~~~~~~ - !!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @param {string} x - */ - - /** - * @param {string | number} x -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {string | number} -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function id(x) { - return x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.errors.txt.diff deleted file mode 100644 index b245659244..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads5.errors.txt.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.jsFileMethodOverloads5.errors.txt -+++ new.jsFileMethodOverloads5.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. -+/a.js(8,5): error TS8017: Signature declarations can only be used in TypeScript files. -+/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(16,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+/a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (5 errors) ==== -+ /** -+ * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. -+ * @param {string} a -+ * @return {void} -+ */ -+ -+ /** -+ * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. -+ * @param {number} a -+ * @param {number} [b] -+ * @return {void} -+ */ -+ -+ /** -+ * @param {string | number} a -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {number} [b] -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export const foo = function (a, b) { } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.errors.txt.diff deleted file mode 100644 index bed5e16aaa..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocAccessEnumType.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.jsdocAccessEnumType.errors.txt -+++ new.jsdocAccessEnumType.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/b.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.ts (0 errors) ==== -+ export enum E { A } -+ -+==== /b.js (1 errors) ==== -+ import { E } from "./a"; -+ /** @type {E} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const e = E.A; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff index cc3246ab33..7281d6f678 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseImplicitAny.errors.txt.diff @@ -2,70 +2,40 @@ +++ new.jsdocArrayObjectPromiseImplicitAny.errors.txt @@= skipped -0, +0 lines =@@ - -+jsdocArrayObjectPromiseImplicitAny.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(23,13): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. +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(32,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseImplicitAny.js(37,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocArrayObjectPromiseImplicitAny.js (14 errors) ==== ++==== jsdocArrayObjectPromiseImplicitAny.js (2 errors) ==== + /** @type {Array} */ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var anyArray = [5]; + + /** @type {Array} */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var numberArray = [5]; + + /** + * @param {Array} arr -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {Array} -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function returnAnyArray(arr) { + return arr; + } + + /** @type {Promise} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var anyPromise = Promise.resolve(5); + + /** @type {Promise} */ -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var numberPromise = Promise.resolve(5); + + /** + * @param {Promise} pr -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {Promise} -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function returnAnyPromise(pr) { + return pr; + } + + /** @type {Object} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var anyObject = {valueOf: 1}; // not an error since assigning to any. + ~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type '() => Object'. @@ -73,17 +43,11 @@ + /** @type {Object} */ + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var paramedObject = {valueOf: 1}; + + /** + * @param {Object} obj -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {Object} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function returnAnyObject(obj) { + return obj; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff index 25720fb184..9f407cd4d4 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocArrayObjectPromiseNoImplicitAny.errors.txt.diff @@ -1,108 +1,25 @@ --- old.jsdocArrayObjectPromiseNoImplicitAny.errors.txt +++ new.jsdocArrayObjectPromiseNoImplicitAny.errors.txt -@@= skipped -0, +0 lines =@@ - jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS2314: Generic type 'Array' requires 1 type argument(s). -+jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseNoImplicitAny.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. - jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS2314: Generic type 'Array' requires 1 type argument(s). -+jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. - jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS2314: Generic type 'Array' requires 1 type argument(s). -+jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. - jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). -+jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseNoImplicitAny.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -4, +4 lines =@@ jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS2314: Generic type 'Promise' requires 1 type argument(s). -+jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS2314: Generic type 'Promise' requires 1 type argument(s). -+jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseNoImplicitAny.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. jsdocArrayObjectPromiseNoImplicitAny.js(30,21): error TS2322: Type 'number' is not assignable to type '() => Object'. - - -==== jsdocArrayObjectPromiseNoImplicitAny.js (7 errors) ==== +jsdocArrayObjectPromiseNoImplicitAny.js(32,12): error TS2315: Type 'Object' is not generic. -+jsdocArrayObjectPromiseNoImplicitAny.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseNoImplicitAny.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocArrayObjectPromiseNoImplicitAny.js(37,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocArrayObjectPromiseNoImplicitAny.js (20 errors) ==== ++==== jsdocArrayObjectPromiseNoImplicitAny.js (8 errors) ==== /** @type {Array} */ ~~~~~ !!! error TS2314: Generic type 'Array' requires 1 type argument(s). -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var notAnyArray = [5]; - - /** @type {Array} */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var numberArray = [5]; - - /** - * @param {Array} arr - ~~~~~ - !!! error TS2314: Generic type 'Array' requires 1 type argument(s). -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {Array} - ~~~~~ - !!! error TS2314: Generic type 'Array' requires 1 type argument(s). -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function returnNotAnyArray(arr) { - return arr; -@@= skipped -30, +51 lines =@@ - /** @type {Promise} */ - ~~~~~~~ - !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var notAnyPromise = Promise.resolve(5); - - /** @type {Promise} */ -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var numberPromise = Promise.resolve(5); - - /** - * @param {Promise} pr - ~~~~~~~ - !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {Promise} - ~~~~~~~ - !!! error TS2314: Generic type 'Promise' requires 1 type argument(s). -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function returnNotAnyPromise(pr) { - return pr; - } - - /** @type {Object} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. - ~~~~~~~ +@@= skipped -49, +50 lines =@@ !!! error TS2322: Type 'number' is not assignable to type '() => Object'. /** @type {Object} */ + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var paramedObject = {valueOf: 1}; - /** - * @param {Object} obj -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {Object} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function returnNotAnyObject(obj) { - return obj; \ No newline at end of file + /** \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff index 1aa2da75f1..7c77099eea 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocBracelessTypeTag1.errors.txt.diff @@ -3,13 +3,10 @@ @@= skipped -0, +0 lines =@@ -index.js(3,3): error TS2322: Type 'number' is not assignable to type 'string'. +index.js(12,14): error TS7006: Parameter 'arg' implicitly has an 'any' type. -+index.js(16,11): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(20,16): error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. --==== index.js (2 errors) ==== -+==== index.js (4 errors) ==== +@@= skipped -5, +5 lines =@@ /** @type () => string */ function fn1() { return 42; @@ -18,7 +15,7 @@ } /** @type () => string */ -@@= skipped -16, +16 lines =@@ +@@= skipped -11, +9 lines =@@ /** @type (arg: string) => string */ function fn3(arg) { @@ -26,15 +23,4 @@ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. return arg; } - - /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const obj1 = { type: "foo", prop: 10 }; - - /** @type ({ type: 'foo' } | { type: 'bar' }) & { prop: number } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const obj2 = { type: "other", prop: 10 }; - ~~~~ - !!! error TS2322: Type '"other"' is not assignable to type '"bar" | "foo"'. \ No newline at end of file + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff deleted file mode 100644 index 0a96713e61..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.jsdocCallbackAndType.errors.txt -+++ new.jsdocCallbackAndType.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. - /a.js(8,3): error TS2554: Expected 0 arguments, but got 1. - - --==== /a.js (1 errors) ==== -+==== /a.js (2 errors) ==== - /** - * @template T - * @callback B - */ - /** @type {B} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - let b; - b(); - b(1); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff index 8ea24d9039..171fe2282b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff @@ -3,13 +3,10 @@ @@= skipped -0, +0 lines =@@ +/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. /a.js(4,13): error TS2314: Generic type 'C' requires 1 type argument(s). -- -- + + -==== /a.js (1 errors) ==== -+/a.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (3 errors) ==== ++==== /a.js (2 errors) ==== /** @template T */ + ~~~~~~~~~~~~~~~~~~ class C {} @@ -17,9 +14,4 @@ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @param {C} p */ - ~ - !!! error TS2314: Generic type 'C' requires 1 type argument(s). -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function f(p) {} - \ No newline at end of file + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff index 7d066588a5..829a61d7f4 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionClassPropertiesDeclaration.errors.txt.diff @@ -2,22 +2,16 @@ +++ new.jsdocFunctionClassPropertiesDeclaration.errors.txt @@= skipped -0, +0 lines =@@ - -+/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +/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 -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number | undefined} y -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function Foo(x, y) { + if (!(this instanceof Foo)) { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff index 2d137dc837..240506dd0b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocFunctionTypeFalsePositive.errors.txt.diff @@ -1,15 +1,15 @@ --- old.jsdocFunctionTypeFalsePositive.errors.txt +++ new.jsdocFunctionTypeFalsePositive.errors.txt @@= skipped -0, +0 lines =@@ -+/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. /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) ==== +- +- +-==== /a.js (2 errors) ==== ++ ++ ++==== /a.js (1 errors) ==== /** @param {<} x */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. ~~ !!! error TS1098: Type parameter list cannot be empty. - ~ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff index ff0d004b6e..625bcf12a2 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff @@ -5,13 +5,10 @@ +/a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. +/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) ==== -+/a.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (4 errors) ==== ++==== /a.js (3 errors) ==== class C { + /** @template T */ @@ -24,11 +21,4 @@ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. } class D { - /** @return {number} */ - ~~~~~~ - !!! error TS1093: Type annotation cannot appear on a constructor declaration. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() {} - } - \ No newline at end of file + /** @return {number} */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff index 7969e691dd..81bb094f22 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.errors.txt.diff @@ -2,22 +2,16 @@ +++ new.jsdocImportTypeNodeNamespace.errors.txt @@= 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. -+Main.js(2,21): error TS8016: Type assertion expressions can only be used in TypeScript files. +Main.js(2,49): error TS2694: Namespace '"GeometryType"' has no exported member 'default'. ==== GeometryType.d.ts (0 errors) ==== -@@= skipped -6, +7 lines =@@ - } - export default _default; - --==== Main.js (1 errors) ==== -+==== Main.js (2 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. -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~ +!!! error TS2694: Namespace '"GeometryType"' has no exported member 'default'. } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.errors.txt.diff deleted file mode 100644 index b31360f39c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeResolution.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsdocImportTypeResolution.errors.txt -+++ new.jsdocImportTypeResolution.errors.txt -@@= skipped -0, +0 lines =@@ -- -+usage.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== module.js (0 errors) ==== -+ export class MyClass { -+ } -+ -+==== usage.js (1 errors) ==== -+ /** -+ * @typedef {Object} options -+ * @property {import("./module").MyClass} option -+ */ -+ /** @type {options} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ let v; \ No newline at end of file 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 a0a3e3422b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParamTagOnPropertyInitializer.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsdocParamTagOnPropertyInitializer.errors.txt -+++ new.jsdocParamTagOnPropertyInitializer.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class Foo { -+ /**@param {string} x */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ m = x => x.toLowerCase(); -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff index eed51b4985..d1fab64b56 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocParameterParsingInfiniteLoop.errors.txt.diff @@ -8,10 +8,9 @@ - -==== example.js (3 errors) ==== +example.js(3,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+example.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== example.js (2 errors) ==== ++==== example.js (1 errors) ==== // @ts-check /** * @type {function(@foo)} @@ -24,7 +23,5 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ let x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff deleted file mode 100644 index e68cbd5c34..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsdocPropertyTagInvalid.errors.txt -+++ new.jsdocPropertyTagInvalid.errors.txt -@@= skipped -0, +0 lines =@@ - /a.js(3,15): error TS2552: Cannot find name 'sting'. Did you mean 'string'? -- -- --==== /a.js (1 errors) ==== -+/a.js(6,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (2 errors) ==== - /** - * @typedef MyType - * @property {sting} [x] -@@= skipped -9, +10 lines =@@ - */ - - /** @param {MyType} p */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - export function f(p) { } - - ==== /b.js (0 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt.diff deleted file mode 100644 index a3b9726c6f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocReferenceGlobalTypeInCommonJs.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsdocReferenceGlobalTypeInCommonJs.errors.txt -+++ new.jsdocReferenceGlobalTypeInCommonJs.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. - a.js(4,1): error TS2686: 'Puppeteer' refers to a UMD global, but the current file is a module. Consider adding an import instead. - - --==== a.js (1 errors) ==== -+==== a.js (2 errors) ==== - const other = require('./other'); - /** @type {Puppeteer.Keyboard} */ -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var ppk; - Puppeteer.connect; - ~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff deleted file mode 100644 index be237bb963..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocResolveNameFailureInTypedef.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsdocResolveNameFailureInTypedef.errors.txt -+++ new.jsdocResolveNameFailureInTypedef.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. - /a.js(7,14): error TS2304: Cannot find name 'CantResolveThis'. - - --==== /a.js (1 errors) ==== -+==== /a.js (2 errors) ==== - /** - * @param {Ty} x -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(x) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff index ffde564d76..92e18b3433 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter.errors.txt.diff @@ -3,21 +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 errors) ==== -+/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. +/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) ==== - /** @param {...number} a */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function f(a) { - 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_es6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff deleted file mode 100644 index 4f7a90eab8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocRestParameter_es6.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsdocRestParameter_es6.errors.txt -+++ new.jsdocRestParameter_es6.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ /** @param {...number} a */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ function f(...a) { -+ a; // number[] -+ } -+ \ No newline at end of file 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 4e5cb4164b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.errors.txt.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.jsdocTypeCast.errors.txt -+++ new.jsdocTypeCast.errors.txt -@@= skipped -0, +0 lines =@@ -+jsdocTypeCast.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocTypeCast.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. - jsdocTypeCast.js(6,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. -+jsdocTypeCast.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. - jsdocTypeCast.js(10,9): error TS2322: Type 'string' is not assignable to type '"a" | "b"'. -- -- --==== jsdocTypeCast.js (2 errors) ==== -+jsdocTypeCast.js(13,16): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocTypeCast.js(14,24): error TS8016: Type assertion expressions can only be used in TypeScript files. -+ -+ -+==== jsdocTypeCast.js (7 errors) ==== - /** - * @param {string} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(x) { - /** @type {'a' | 'b'} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - let a = (x); // Error - ~ - !!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. - a; - - /** @type {'a' | 'b'} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - let b = (((x))); // Error - ~ - !!! error TS2322: Type 'string' is not assignable to type '"a" | "b"'. - b; - - /** @type {'a' | 'b'} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - let c = /** @type {'a' | 'b'} */ (x); // Ok -+ ~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - c; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt.diff deleted file mode 100644 index 0b72457a71..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeGenericInstantiationAttempt.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.jsdocTypeGenericInstantiationAttempt.errors.txt -+++ new.jsdocTypeGenericInstantiationAttempt.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ /** -+ * @param {Array<*>} list -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function thing(list) { -+ return list; -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff index afb3e4561a..2122f5ce56 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeNongenericInstantiationAttempt.errors.txt.diff @@ -1,134 +1,53 @@ --- old.jsdocTypeNongenericInstantiationAttempt.errors.txt +++ new.jsdocTypeNongenericInstantiationAttempt.errors.txt @@= skipped -0, +0 lines =@@ -+index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. 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. -+index2.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +index2.js(2,19): error TS2304: Cannot find name 'Void'. -+index3.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +index3.js(2,19): error TS2304: Cannot find name 'Undefined'. -+index4.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index4.js(2,19): error TS2315: Type 'Function' is not generic. -+index5.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index5.js(2,19): error TS2315: Type 'String' is not generic. -+index6.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index6.js(2,19): error TS2315: Type 'Number' is not generic. -+index7.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. index7.js(2,19): error TS2315: Type 'Object' is not generic. +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,12): error TS8010: Type annotations can only be used in TypeScript files. index8.js(4,15): error TS2304: Cannot find name 'T'. --==== index.js (1 errors) ==== -+==== index.js (2 errors) ==== - /** - * @param {(m: Boolean) => string} somebody -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~~~~ - !!! error TS2315: Type 'Boolean' is not generic. - */ -@@= skipped -17, +28 lines =@@ - return 'Hello ' + somebody; - } - --==== index2.js (1 errors) ==== -+==== index2.js (2 errors) ==== +@@= skipped -20, +21 lines =@@ + ==== index2.js (1 errors) ==== /** * @param {(m: Void) => string} somebody - ~~~~~~~ -!!! error TS2315: Type 'Void' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ +!!! error TS2304: Cannot find name 'Void'. */ function sayHello2(somebody) { return 'Hello ' + somebody; - } - - --==== index3.js (1 errors) ==== -+==== index3.js (2 errors) ==== +@@= skipped -11, +11 lines =@@ + ==== index3.js (1 errors) ==== /** * @param {(m: Undefined) => string} somebody - ~~~~~~~~~~~~ -!!! error TS2315: Type 'Undefined' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'Undefined'. */ function sayHello3(somebody) { return 'Hello ' + somebody; - } - - --==== index4.js (1 errors) ==== -+==== index4.js (2 errors) ==== - /** - * @param {(m: Function) => string} somebody -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~~~~~ - !!! error TS2315: Type 'Function' is not generic. - */ -@@= skipped -33, +39 lines =@@ - } - - --==== index5.js (1 errors) ==== -+==== index5.js (2 errors) ==== - /** - * @param {(m: String) => string} somebody -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~~~ - !!! error TS2315: Type 'String' is not generic. - */ -@@= skipped -11, +13 lines =@@ - } - - --==== index6.js (1 errors) ==== -+==== index6.js (2 errors) ==== - /** - * @param {(m: Number) => string} somebody -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~~~ - !!! error TS2315: Type 'Number' is not generic. - */ -@@= skipped -11, +13 lines =@@ - } - - --==== index7.js (1 errors) ==== -+==== index7.js (2 errors) ==== - /** - * @param {(m: Object) => string} somebody -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~~~ - !!! error TS2315: Type 'Object' is not generic. - */ -@@= skipped -10, +12 lines =@@ +@@= skipped -51, +51 lines =@@ return 'Hello ' + somebody; } -==== index8.js (1 errors) ==== -+==== index8.js (3 errors) ==== ++==== 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 TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'T'. */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt.diff deleted file mode 100644 index da45ed1622..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefBeforeParenthesizedExpression.errors.txt.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.jsdocTypedefBeforeParenthesizedExpression.errors.txt -+++ new.jsdocTypedefBeforeParenthesizedExpression.errors.txt -@@= skipped -0, +0 lines =@@ -- -+test.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. -+test.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== test.js (2 errors) ==== -+ // @ts-check -+ /** @typedef {number} NotADuplicateIdentifier */ -+ -+ (2 * 2); -+ -+ /** @typedef {number} AlsoNotADuplicate */ -+ -+ (2 * 2) + 1; -+ -+ -+ /** -+ * -+ * @param a {NotADuplicateIdentifier} -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param b {AlsoNotADuplicate} -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function makeSureTypedefsAreStillRecognized(a, b) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff index e50cba3fb0..9f75443651 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefMissingType.errors.txt.diff @@ -2,22 +2,23 @@ +++ new.jsdocTypedefMissingType.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(2,14): error TS8021: JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags. -+/a.js(12,11): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== /a.js (1 errors) ==== - // Bad: missing a type - /** @typedef T */ +- +- +-==== /a.js (1 errors) ==== +- // Bad: missing a type +- /** @typedef T */ - ~ -!!! error TS8021: JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags. - - const t = 0; - -@@= skipped -15, +13 lines =@@ - */ - - /** @type Person */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const person = { name: "" }; - \ No newline at end of file +- +- const t = 0; +- +- // OK: missing a type, but have property tags. +- /** +- * @typedef Person +- * @property {string} name +- */ +- +- /** @type Person */ +- const person = { name: "" }; +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.errors.txt.diff deleted file mode 100644 index dd18112fc8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedef_propertyWithNoType.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.jsdocTypedef_propertyWithNoType.errors.txt -+++ new.jsdocTypedef_propertyWithNoType.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ /** -+ * @typedef Foo -+ * @property foo -+ */ -+ -+ /** @type {Foo} */ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const x = { foo: 0 }; -+ \ No newline at end of file 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 a5654f94dc..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.errors.txt.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.parenthesizedJSDocCastAtReturnStatement.errors.txt -+++ new.parenthesizedJSDocCastAtReturnStatement.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(10,23): error TS8016: Type assertion expressions can only be used in TypeScript files. -+ -+ -+==== index.js (4 errors) ==== -+ /** @type {Map>} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const cache = new Map() -+ -+ /** -+ * @param {string} key -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {() => string} -+ ~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const getStringGetter = (key) => { -+ return () => { -+ return /** @type {string} */ (cache.get(key)) -+ ~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ } -+ } -+ \ No newline at end of file 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 98af6fab20..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.parenthesizedJSDocCastDoesNotNarrow.errors.txt -+++ new.parenthesizedJSDocCastDoesNotNarrow.errors.txt -@@= skipped -0, +0 lines =@@ -+index.js(3,20): error TS8016: Type assertion expressions can only be used in TypeScript files. - index.js(12,8): error TS2678: Type '"invalid"' is not comparable to type '"bar" | "foo"'. - - --==== index.js (1 errors) ==== -+==== index.js (2 errors) ==== - let value = ""; - - switch (/** @type {"foo" | "bar"} */ (value)) { -+ ~~~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - case "bar": - value; - break; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.errors.txt.diff deleted file mode 100644 index 1ea0cfbc8b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/requireOfJsonFileInJsFile.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.requireOfJsonFileInJsFile.errors.txt -+++ new.requireOfJsonFileInJsFile.errors.txt -@@= skipped -0, +0 lines =@@ - /user.js(2,7): error TS2339: Property 'b' does not exist on type '{ a: number; }'. -+/user.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. - /user.js(5,7): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. - /user.js(9,7): error TS2339: Property 'b' does not exist on type '{ a: number; }'. -+/user.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. - /user.js(12,7): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. - - --==== /user.js (4 errors) ==== -+==== /user.js (6 errors) ==== - const json0 = require("./json.json"); - json0.b; // Error (good) - ~ - !!! error TS2339: Property 'b' does not exist on type '{ a: number; }'. - - /** @type {{ b: number }} */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const json1 = require("./json.json"); // No error (bad) - ~~~~~ - !!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. -@@= skipped -22, +26 lines =@@ - !!! error TS2339: Property 'b' does not exist on type '{ a: number; }'. - - /** @type {{ b: number }} */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const js1 = require("./js.js"); // Error (good) - ~~~ - !!! error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ b: number; }'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.errors.txt.diff deleted file mode 100644 index 9dc164b446..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.errors.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.returnConditionalExpressionJSDocCast.errors.txt -+++ new.returnConditionalExpressionJSDocCast.errors.txt -@@= skipped -0, +0 lines =@@ -- -+file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(10,23): error TS8016: Type assertion expressions can only be used in TypeScript files. -+ -+ -+==== file.js (4 errors) ==== -+ // Don't peek into conditional return expression if it's wrapped in a cast -+ /** @type {Map} */ -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const sources = new Map(); -+ /** -+ -+ * @param {string=} type the type of source that should be generated -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {String} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function source(type = "javascript") { -+ return /** @type {String} */ ( -+ ~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ type -+ ? sources.get(type) -+ : sources.get("some other thing") -+ ); -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff deleted file mode 100644 index c9e9bf5ab3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff +++ /dev/null @@ -1,35 +0,0 @@ ---- old.strictOptionalProperties3.errors.txt -+++ new.strictOptionalProperties3.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. - 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(13,12): error TS8010: Type annotations can only be used in TypeScript files. - a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. - Types of property 'value' are incompatible. - Type 'undefined' is not assignable to type 'number'. - - --==== a.js (2 errors) ==== -+==== a.js (4 errors) ==== - /** - * @typedef {object} A - * @property {number} [value] - */ - - /** @type {A} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - 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. -@@= skipped -23, +27 lines =@@ - */ - - /** @type {B} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - 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. \ No newline at end of file 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 25a463580c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.strictOptionalProperties4.errors.txt -+++ new.strictOptionalProperties4.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(6,22): error TS8016: Type assertion expressions can only be used in TypeScript files. -+a.js(9,22): error TS8016: Type assertion expressions can only be used in TypeScript files. -+ -+ -+==== a.js (2 errors) ==== -+ /** -+ * @typedef Foo -+ * @property {number} [foo] -+ */ -+ -+ const x = /** @type {Foo} */ ({}); -+ ~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ x.foo; // number | undefined -+ -+ const y = /** @type {Required} */ ({}); -+ ~~~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ y.foo; // number -+ \ No newline at end of file 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 4f58a67ca3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable01.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.subclassThisTypeAssignable01.errors.txt -+++ new.subclassThisTypeAssignable01.errors.txt -@@= skipped -0, +0 lines =@@ -+file1.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. - 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'. -@@= skipped -57, +58 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 (2 errors) ==== - /** @type {ClassComponent} */ -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const test9 = new C(); - ~~~~~ - !!! error TS2322: Type 'C' is not assignable to type 'ClassComponent'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.errors.txt.diff deleted file mode 100644 index 8ddee870c9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/subclassThisTypeAssignable02.errors.txt.diff +++ /dev/null @@ -1,42 +0,0 @@ ---- old.subclassThisTypeAssignable02.errors.txt -+++ new.subclassThisTypeAssignable02.errors.txt -@@= skipped -0, +0 lines =@@ -- -+file1.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== tile1.ts (0 errors) ==== -+ interface Lifecycle> { -+ oninit?(vnode: Vnode): number; -+ [_: number]: any; -+ } -+ -+ interface Vnode> { -+ tag: Component; -+ } -+ -+ interface Component> { -+ view(this: State, vnode: Vnode): number; -+ } -+ -+ interface ClassComponent extends Lifecycle> { -+ oninit?(vnode: Vnode): number; -+ view(vnode: Vnode): number; -+ } -+ -+ interface MyAttrs { id: number } -+ class C implements ClassComponent { -+ view(v: Vnode) { return 0; } -+ -+ // Must declare a compatible-ish index signature or else -+ // we won't correctly implement ClassComponent. -+ [_: number]: unknown; -+ } -+ -+ const test8: ClassComponent = new C(); -+==== file1.js (1 errors) ==== -+ /** @type {ClassComponent} */ -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const test9 = new C(); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff deleted file mode 100644 index 67f53ae10f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.thisInFunctionCallJs.errors.txt -+++ new.thisInFunctionCallJs.errors.txt -@@= skipped -0, +0 lines =@@ - /a.js(9,26): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. - /a.js(15,31): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -- -- --==== /a.js (2 errors) ==== -+/a.js(21,20): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(29,20): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (4 errors) ==== - class Test { - constructor() { - /** @type {number[]} */ -@@= skipped -29, +31 lines =@@ - forEacher() { - this.data.forEach( - /** @this {Test} */ -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function (d) { - console.log(d === this.data.length) - }, this) -@@= skipped -8, +10 lines =@@ - finder() { - this.data.find( - /** @this {Test} */ -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function (d) { - return d === this.data.length - }, this) \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.errors.txt.diff deleted file mode 100644 index f3c6207bd6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/topLevelBlockExpando.errors.txt.diff +++ /dev/null @@ -1,51 +0,0 @@ ---- old.topLevelBlockExpando.errors.txt -+++ new.topLevelBlockExpando.errors.txt -@@= skipped -0, +0 lines =@@ -- -+check.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== check.ts (0 errors) ==== -+ // https://github.com/microsoft/TypeScript/issues/31972 -+ interface Person { -+ first: string; -+ last: string; -+ } -+ -+ { -+ const dice = () => Math.floor(Math.random() * 6); -+ dice.first = 'Rando'; -+ dice.last = 'Calrissian'; -+ const diceP: Person = dice; -+ } -+ -+==== check.js (1 errors) ==== -+ // Creates a type { first:string, last: string } -+ /** -+ * @typedef {Object} Human - creates a new type named 'SpecialType' -+ * @property {string} first - a string property of SpecialType -+ * @property {string} last - a number property of SpecialType -+ */ -+ -+ /** -+ * @param {Human} param used as a validation tool -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function doHumanThings(param) {} -+ -+ const dice1 = () => Math.floor(Math.random() * 6); -+ // dice1.first = 'Rando'; -+ dice1.last = 'Calrissian'; -+ -+ // doHumanThings(dice) -+ -+ // but inside a block... you can't call a human -+ { -+ const dice2 = () => Math.floor(Math.random() * 6); -+ dice2.first = 'Rando'; -+ dice2.last = 'Calrissian'; -+ -+ doHumanThings(dice2) -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.errors.txt.diff deleted file mode 100644 index 05df9bfb8d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unicodeEscapesInJSDoc.errors.txt.diff +++ /dev/null @@ -1,35 +0,0 @@ ---- old.unicodeEscapesInJSDoc.errors.txt -+++ new.unicodeEscapesInJSDoc.errors.txt -@@= skipped -0, +0 lines =@@ -- -+file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== file.js (4 errors) ==== -+ /** -+ * @param {number} \u0061 -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {number} a\u0061 -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function foo(a, aa) { -+ console.log(a + aa); -+ } -+ -+ /** -+ * @param {number} \u{0061} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {number} a\u{0061} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function bar(a, aa) { -+ console.log(a + aa); -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/uniqueSymbolJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/uniqueSymbolJs.errors.txt.diff index ca6385bfcb..e97c2ce80f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/uniqueSymbolJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/uniqueSymbolJs.errors.txt.diff @@ -3,21 +3,12 @@ @@= skipped -0, +0 lines =@@ -a.js(5,18): error TS1337: An index signature parameter type cannot be a literal type or generic type. Consider using a mapped object type instead. -a.js(5,28): error TS1005: ';' expected. -- -- --==== a.js (2 errors) ==== -+a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(5,18): error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type. -+a.js(5,22): error TS8010: Type annotations can only be used in TypeScript files. +a.js(5,23): error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? -+ -+ -+==== a.js (4 errors) ==== - /** @type {unique symbol} */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const foo = Symbol(); - + + + ==== a.js (2 errors) ==== +@@= skipped -8, +8 lines =@@ /** @typedef {{ [foo]: boolean }} A */ /** @typedef {{ [key: foo] boolean }} B */ ~~~ @@ -25,8 +16,6 @@ - ~~~~~~~ -!!! error TS1005: ';' expected. +!!! error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type. -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt.diff deleted file mode 100644 index 1ebe130021..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/annotatedThisPropertyInitializerDoesntNarrow.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.annotatedThisPropertyInitializerDoesntNarrow.errors.txt -+++ new.annotatedThisPropertyInitializerDoesntNarrow.errors.txt -@@= skipped -0, +0 lines =@@ -- -+Compilation.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -+Compilation.js(7,33): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== Compilation.js (2 errors) ==== -+ // from webpack/lib/Compilation.js and filed at #26427 -+ /** @param {{ [s: string]: number }} map */ -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ function mappy(map) {} -+ -+ export class C { -+ constructor() { -+ /** @type {{ [assetName: string]: number}} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ this.assets = {}; -+ } -+ m() { -+ mappy(this.assets) -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff index 6c89461c88..dc36288ada 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.errors.txt.diff @@ -2,14 +2,10 @@ +++ new.assertionTypePredicates2.errors.txt @@= skipped -0, +0 lines =@@ - -+assertionTypePredicates2.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+assertionTypePredicates2.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. -+assertionTypePredicates2.js(14,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -+assertionTypePredicates2.js(19,16): error TS8010: Type annotations can only be used in TypeScript files. +assertionTypePredicates2.js(21,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. + + -+==== assertionTypePredicates2.js (5 errors) ==== ++==== assertionTypePredicates2.js (1 errors) ==== + /** + * @typedef {{ x: number }} A + */ @@ -20,23 +16,15 @@ + + /** + * @param {A} a -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns { asserts a is B } -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const foo = (a) => { + if (/** @type { B } */ (a).y !== 0) throw TypeError(); -+ ~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + return undefined; + }; + + export const main = () => { + /** @type { A } */ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const a = { x: 1 }; + foo(a); + ~~~ 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 634f66cde6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/assertionsAndNonReturningFunctions.errors.txt.diff +++ /dev/null @@ -1,65 +0,0 @@ ---- old.assertionsAndNonReturningFunctions.errors.txt -+++ new.assertionsAndNonReturningFunctions.errors.txt -@@= skipped -0, +0 lines =@@ -+assertionsAndNonReturningFunctions.js(1,22): error TS8010: Type annotations can only be used in TypeScript files. -+assertionsAndNonReturningFunctions.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+assertionsAndNonReturningFunctions.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -+assertionsAndNonReturningFunctions.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. -+assertionsAndNonReturningFunctions.js(22,14): error TS8010: Type annotations can only be used in TypeScript files. -+assertionsAndNonReturningFunctions.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. - assertionsAndNonReturningFunctions.js(46,9): error TS7027: Unreachable code detected. -+assertionsAndNonReturningFunctions.js(51,12): error TS8010: Type annotations can only be used in TypeScript files. - assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code detected. - - --==== assertionsAndNonReturningFunctions.js (2 errors) ==== -+==== assertionsAndNonReturningFunctions.js (9 errors) ==== - /** @typedef {(check: boolean) => asserts check} AssertFunc */ -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - - /** @type {AssertFunc} */ -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const assert = check => { - if (!check) throw new Error(); - } -@@= skipped -16, +27 lines =@@ - - /** - * @param {boolean} check -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {asserts check} -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function assert2(check) { - if (!check) throw new Error(); -@@= skipped -8, +12 lines =@@ - - /** - * @returns {never} -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function fail() { - throw new Error(); -@@= skipped -7, +9 lines =@@ - - /** - * @param {*} x -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f1(x) { - if (!!true) { -@@= skipped -24, +26 lines =@@ - - /** - * @param {boolean} b -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f2(b) { - switch (b) { \ No newline at end of file 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 edb5c095a2..ec3ffa5a3a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncArrowFunction_allowJs.errors.txt.diff @@ -13,25 +13,18 @@ - -==== file.js (7 errors) ==== +file.js(2,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(6,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+file.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+file.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+file.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== file.js (10 errors) ==== ++==== 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const a = () => 0 - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -43,8 +36,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const b = async () => 0 - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -56,8 +47,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const c = async () => { return 0 - ~~~~~~ @@ -71,8 +60,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const d = async () => { return "" } @@ -81,8 +68,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (p) => {} // Error (good) 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 474de3f39c..5a82cdee21 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff @@ -8,70 +8,34 @@ - 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'. -+/a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. +/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(21,14): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(28,7): error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. + Type 'Promise' is not assignable to type 'string'. -+/a.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(34,14): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.d.ts (0 errors) ==== declare class Thenable { then(): void; } -==== /a.js (3 errors) ==== -+==== /a.js (12 errors) ==== ++==== /a.js (2 errors) ==== /** * @callback T1 * @param {string} str -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {string} - */ - - /** - * @callback T2 - * @param {string} str -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {Promise} - */ - - /** - * @callback T3 - * @param {string} str -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {Thenable} - */ - - /** +@@= skipped -32, +28 lines =@@ * @param {string} str -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @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. +!!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ const f1 = async str => { return str; -@@= skipped -40, +56 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. -+!!! error TS8010: Type annotations can only be used in TypeScript files. const f2 = async str => { + ~~ +!!! error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. @@ -79,33 +43,16 @@ return str; } - /** - * @param {string} str -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {Promise} -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - const f3 = async str => { - return str; - } - - /** @type {T2} */ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const f4 = async str => { - return str; +@@= skipped -28, +28 lines =@@ } /** @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'. -+!!! error TS8010: Type annotations can only be used in TypeScript files. const f5 = async str => { return str; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff index c099b6df53..b3e507b55d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff @@ -2,17 +2,13 @@ +++ new.callbackCrossModule.errors.txt @@= skipped -0, +0 lines =@@ - -+mod1.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+use.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. +use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. + + -+==== mod1.js (2 errors) ==== ++==== mod1.js (1 errors) ==== + /** @callback Con - some kind of continuation + * @param {object | undefined} error -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {any} I don't even know what this should return + */ + module.exports = C @@ -22,10 +18,8 @@ + this.p = 1 + } + -+==== use.js (2 errors) ==== ++==== use.js (1 errors) ==== + /** @param {import('./mod1').Con} k */ -+ ~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace 'C' has no exported member 'Con'. + function f(k) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff index cbf709a09b..e019fdce7f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackOnConstructor.errors.txt.diff @@ -2,19 +2,15 @@ +++ new.callbackOnConstructor.errors.txt @@= skipped -0, +0 lines =@@ - -+callbackOnConstructor.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. +callbackOnConstructor.js(12,12): error TS2304: Cannot find name 'ValueGetter_2'. -+callbackOnConstructor.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== callbackOnConstructor.js (3 errors) ==== ++==== callbackOnConstructor.js (1 errors) ==== + export class Preferences { + assignability = "no" + /** + * @callback ValueGetter_2 + * @param {string} name -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {boolean|number|string|undefined} + */ + constructor() {} @@ -24,7 +20,5 @@ + /** @type {ValueGetter_2} */ + ~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'ValueGetter_2'. -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var ooscope2 = s => s.length > 0 + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff deleted file mode 100644 index 98ca8b6b1c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.callbackTag1.errors.txt -+++ new.callbackTag1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+cb.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== cb.js (4 errors) ==== -+ /** @callback Sid -+ * @param {string} s -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {string} What were you expecting -+ */ -+ var x = 1 -+ -+ /** @type {Sid} smallId */ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ var sid = s => s + "!"; -+ -+ -+ /** @type {NoReturn} */ -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ var noreturn = obj => void obj.title -+ -+ /** -+ * @callback NoReturn -+ * @param {{ e: number, m: number, title: string }} s - Knee deep, shores, etc -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff index cbfd600916..9d44d496ef 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff @@ -2,42 +2,11 @@ +++ new.callbackTag2.errors.txt @@= skipped -0, +0 lines =@@ -cb.js(18,29): error TS2304: Cannot find name 'S'. -- -- --==== cb.js (1 errors) ==== -+cb.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. -+cb.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== cb.js (9 errors) ==== - /** @template T - * @callback Id - * @param {T} t -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {T} Maybe just return 120 and cast it? - */ - var x = 1 - - /** @type {Id} I actually wanted to write `const "120"` */ -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var one_twenty = s => "120"; - - /** @template S - * @callback SharedId - * @param {S} ego -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {S} - */ + + + ==== cb.js (1 errors) ==== +@@= skipped -19, +19 lines =@@ class SharedClass { constructor() { /** @type {SharedId} */ @@ -48,28 +17,4 @@ +!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. } } - /** @type {SharedId} */ -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var outside = n => n + 1; - - /** @type {Final<{ fantasy }, { heroes }>} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var noreturn = (barts, tidus, noctis) => "cecil" - - /** - * @template V,X - * @callback Final - * @param {V} barts - "Barts" -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {X} tidus - Titus -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {X & V} noctis - "Prince Noctis Lucius Caelum" -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @return {"cecil" | "zidane"} - */ - \ No newline at end of file + /** @type {SharedId} */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff deleted file mode 100644 index 3791574a14..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.callbackTag3.errors.txt -+++ new.callbackTag3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+cb.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== cb.js (1 errors) ==== -+ /** @callback Miracle -+ * @returns {string} What were you expecting -+ */ -+ /** @type {Miracle} smallId */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ var sid = () => "!"; -+ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff deleted file mode 100644 index e6babd3e5c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.callbackTag4.errors.txt -+++ new.callbackTag4.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (4 errors) ==== -+ /** -+ * @callback C -+ * @this {{ a: string, b: number }} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {string} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {number} b -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {boolean} -+ */ -+ -+ /** @type {C} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const cb = function (a, b) { -+ this -+ return true -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNamespace.errors.txt.diff deleted file mode 100644 index 1d73615ec9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNamespace.errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.callbackTagNamespace.errors.txt -+++ new.callbackTagNamespace.errors.txt -@@= skipped -0, +0 lines =@@ -- -+namespaced.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+namespaced.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== namespaced.js (2 errors) ==== -+ /** -+ * @callback NS.Nested.Inner -+ * @param {Object} space - spaaaaaaaaace -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {Object} peace - peaaaaaaaaace -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @return {string | number} -+ */ -+ var x = 1; -+ /** @type {NS.Nested.Inner} */ -+ function f(space, peace) { -+ return '1' -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff deleted file mode 100644 index 198167dc08..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff +++ /dev/null @@ -1,35 +0,0 @@ ---- old.callbackTagNestedParameter.errors.txt -+++ new.callbackTagNestedParameter.errors.txt -@@= skipped -0, +0 lines =@@ -- -+cb_nested.js(4,4): error TS8010: Type annotations can only be used in TypeScript files. -+cb_nested.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+cb_nested.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== cb_nested.js (3 errors) ==== -+ /** -+ * @callback WorksWithPeopleCallback -+ * @param {Object} person -+ * @param {string} person.name -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @param {number} [person.age] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {void} -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * For each person, calls your callback. -+ * @param {WorksWithPeopleCallback} callback -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {void} -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function eachPerson(callback) { -+ callback({ name: "Empty" }); -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff index 6c52576c61..20cd34bc46 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff @@ -2,23 +2,17 @@ +++ new.callbackTagVariadicType.errors.txt @@= skipped -0, +0 lines =@@ - -+callbackTagVariadicType.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+callbackTagVariadicType.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +callbackTagVariadicType.js(9,18): error TS2554: Expected 1 arguments, but got 2. + + -+==== callbackTagVariadicType.js (3 errors) ==== ++==== callbackTagVariadicType.js (1 errors) ==== + /** + * @callback Foo + * @param {...string} args -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number} + */ + + /** @type {Foo} */ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + export const x = () => 1 + var res = x('a', 'b') + ~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/chainedPrototypeAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/chainedPrototypeAssignment.errors.txt.diff index 757dde1c6f..a22e977b2c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/chainedPrototypeAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/chainedPrototypeAssignment.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 lines =@@ -use.js(5,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -use.js(6,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -+mod.js(11,17): error TS8010: Type annotations can only be used in TypeScript files. +use.js(3,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. +use.js(4,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. @@ -25,19 +24,4 @@ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. ==== types.d.ts (0 errors) ==== - declare function require(name: string): any; - declare var exports: any; --==== mod.js (0 errors) ==== -+==== mod.js (1 errors) ==== - /// - var A = function A() { - this.a = 1 -@@= skipped -28, +29 lines =@@ - exports.B = B - A.prototype = B.prototype = { - /** @param {number} n */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - m(n) { - return n + 1 - } \ No newline at end of file + declare function require(name: string): any; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignProperty.errors.txt.diff index 37c12f34b9..4d70a6774c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignProperty.errors.txt.diff @@ -14,22 +14,18 @@ - - -==== validator.ts (10 errors) ==== -+index.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(4,19): error TS2306: File 'mod1.js' is not a module. -+index.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(9,19): error TS2306: File 'mod2.js' is not a module. +mod1.js(1,23): error TS2304: Cannot find name 'exports'. +mod1.js(2,23): error TS2304: Cannot find name 'exports'. +mod1.js(3,23): error TS2304: Cannot find name 'exports'. +mod1.js(4,23): error TS2304: Cannot find name 'exports'. +mod1.js(5,23): error TS2304: Cannot find name 'exports'. -+mod1.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. +mod2.js(1,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +mod2.js(2,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +mod2.js(3,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +mod2.js(4,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +mod2.js(5,23): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+mod2.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. +validator.ts(3,21): error TS2306: File 'mod1.js' is not a module. +validator.ts(23,21): error TS2306: File 'mod2.js' is not a module. + @@ -43,7 +39,7 @@ m1.thing; m1.readonlyProp; -@@= skipped -27, +37 lines =@@ +@@= skipped -27, +33 lines =@@ // disallowed assignments m1.readonlyProp = "name"; @@ -88,7 +84,7 @@ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -==== mod1.js (0 errors) ==== -+==== mod1.js (6 errors) ==== ++==== mod1.js (5 errors) ==== Object.defineProperty(exports, "thing", { value: 42, writable: true }); + ~~~~~~~ +!!! error TS2304: Cannot find name 'exports'. @@ -105,15 +101,13 @@ + ~~~~~~~ +!!! error TS2304: Cannot find name 'exports'. /** @param {string} str */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } }); -==== mod2.js (0 errors) ==== -+==== mod2.js (6 errors) ==== ++==== mod2.js (5 errors) ==== Object.defineProperty(module.exports, "thing", { value: "yes", writable: true }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -130,19 +124,15 @@ + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /** @param {string} str */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. set(str) { this.rwAccessors = Number(str) } }); -==== index.js (0 errors) ==== -+==== index.js (4 errors) ==== ++==== index.js (2 errors) ==== /** * @type {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ const q = require("./mod1").thing; + ~~~~~~~~ @@ -150,8 +140,6 @@ /** * @type {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ const u = require("./mod2").thing; + ~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt.diff index 5e23b33612..e79888a53e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkExportsObjectAssignPrototypeProperty.errors.txt.diff @@ -9,9 +9,7 @@ - - -==== validator.ts (5 errors) ==== -+mod1.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +mod1.js(6,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+mod1.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. +validator.ts(5,12): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. + + @@ -26,7 +24,7 @@ m1.thing; m1.readonlyProp; -@@= skipped -24, +25 lines =@@ +@@= skipped -24, +23 lines =@@ // disallowed assignments m1.readonlyProp = "name"; @@ -49,12 +47,10 @@ -==== mod1.js (0 errors) ==== + + -+==== mod1.js (3 errors) ==== ++==== mod1.js (1 errors) ==== /** * @constructor * @param {string} name -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ function Person(name) { this.name = name; @@ -62,13 +58,4 @@ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. } Person.prototype.describe = function () { - return "Person called " + this.name; -@@= skipped -33, +27 lines =@@ - Object.defineProperty(Person.prototype, "readonlyAccessor", { get() { return 21.75 } }); - Object.defineProperty(Person.prototype, "setonlyAccessor", { - /** @param {string} str */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - set(str) { - this.rwAccessors = Number(str) - } \ No newline at end of file + return "Person called " + this.name; \ No newline at end of file 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 4427020e7e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocOptionalParamOrder.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.checkJsdocOptionalParamOrder.errors.txt -+++ new.checkJsdocOptionalParamOrder.errors.txt -@@= skipped -0, +0 lines =@@ -+0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. - 0.js(7,20): error TS1016: A required parameter cannot follow an optional parameter. - - --==== 0.js (1 errors) ==== -+==== 0.js (5 errors) ==== - // @ts-check - /** - * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} [b] -+ ~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} c -+ ~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo(a, b, c) {} - ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt.diff index 55ed41719b..ff12ecfbcb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamOnVariableDeclaredFunctionExpression.errors.txt.diff @@ -5,38 +5,23 @@ - - -==== 0.js (1 errors) ==== -+0.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== 0.js (5 errors) ==== - // @ts-check - /** - * @param {number=} n -+ ~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} [s] -+ ~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - var x = function foo(n, s) {} - var y; -@@= skipped -15, +28 lines =@@ - - /** - * @param {string} s +- // @ts-check +- /** +- * @param {number=} n +- * @param {string} [s] +- */ +- var x = function foo(n, s) {} +- var y; +- /** +- * @param {boolean!} b +- */ +- y = function bar(b) {} +- +- /** +- * @param {string} s - ~ -!!! error TS8024: JSDoc '@param' tag has name 's', but there is no parameter with that name. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - var one = function (s) { }, two = function (untyped) { }; - \ No newline at end of file +- */ +- var one = function (s) { }, two = function (untyped) { }; +- ++ \ No newline at end of file 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 a923bbcb6e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocParamTag1.errors.txt.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.checkJsdocParamTag1.errors.txt -+++ new.checkJsdocParamTag1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+0.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== 0.js (4 errors) ==== -+ // @ts-check -+ /** -+ * @param {number=} n -+ ~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {string} [s] -+ ~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function foo(n, s) {} -+ -+ foo(); -+ foo(1); -+ foo(1, "hi"); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.errors.txt.diff deleted file mode 100644 index a95dc40e2d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag1.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.checkJsdocReturnTag1.errors.txt -+++ new.checkJsdocReturnTag1.errors.txt -@@= skipped -0, +0 lines =@@ -+returns.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. -+returns.js(10,14): error TS8010: Type annotations can only be used in TypeScript files. -+returns.js(17,14): error TS8010: Type annotations can only be used in TypeScript files. - returns.js(20,12): error TS2872: This kind of expression is always truthy. - - --==== returns.js (1 errors) ==== -+==== returns.js (4 errors) ==== - // @ts-check - /** - * @returns {string} This comment is not currently exposed -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f() { - return "hello"; -@@= skipped -11, +16 lines =@@ - - /** - * @returns {string=} This comment is not currently exposed -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f1() { - return "hello world"; -@@= skipped -7, +9 lines =@@ - - /** - * @returns {string|number} This comment is not currently exposed -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f2() { - return 5 || "hello"; \ No newline at end of file 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 0b664b3a2c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocReturnTag2.errors.txt.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.checkJsdocReturnTag2.errors.txt -+++ new.checkJsdocReturnTag2.errors.txt -@@= skipped -0, +0 lines =@@ -+returns.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. - returns.js(6,5): error TS2322: Type 'number' is not assignable to type 'string'. -+returns.js(10,14): error TS8010: Type annotations can only be used in TypeScript files. - 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 (5 errors) ==== - // @ts-check - /** - * @returns {string} This comment is not currently exposed -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f() { - return 5; -@@= skipped -16, +20 lines =@@ - - /** - * @returns {string | number} This comment is not currently exposed -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f1() { - return 5 || true; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff index 7f95c17eac..ade10090ef 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.errors.txt.diff @@ -1,47 +1,14 @@ --- old.checkJsdocSatisfiesTag1.errors.txt +++ new.checkJsdocSatisfiesTag1.errors.txt @@= skipped -0, +0 lines =@@ -+/a.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(20,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+/a.js(21,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(21,44): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. -/a.js(22,17): error TS1360: Type '{}' does not satisfy the expected type 'T1'. - Property 'a' is missing in type '{}' but required in type 'T1'. -+/a.js(22,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/a.js(22,38): error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. -+/a.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(25,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+/a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(28,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+/a.js(29,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+/a.js(30,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+/a.js(31,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. /a.js(31,49): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. --==== /a.js (3 errors) ==== -+==== /a.js (14 errors) ==== - /** - * @typedef {Object} T1 - * @property {number} a -@@= skipped -16, +26 lines =@@ - - /** - * @typedef {(x: string) => string} T3 -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - - /** -@@= skipped -8, +10 lines =@@ - */ - - const t1 = /** @satisfies {T1} */ ({ a: 1 }); -+ ~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); -+ ~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. +@@= skipped -28, +27 lines =@@ ~ !!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'. const t3 = /** @satisfies {T1} */ ({}); @@ -49,34 +16,9 @@ -!!! error TS1360: Type '{}' does not satisfy the expected type 'T1'. -!!! error TS1360: Property 'a' is missing in type '{}' but required in type 'T1'. -!!! related TS2728 /a.js:3:4: 'a' is declared here. -+ ~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + ~ +!!! error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'. +!!! related TS2728 /a.js:3:23: 'a' is declared here. /** @type {T2} */ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const t4 = /** @satisfies {T2} */ ({ a: "a" }); -+ ~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - - /** @type {(m: string) => string} */ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const t5 = /** @satisfies {T3} */((m) => m.substring(0)); -+ ~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - const t6 = /** @satisfies {[number, number]} */ ([1, 2]); -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - const t7 = /** @satisfies {T4} */ ({ a: 'test' }); -+ ~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); -+ ~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - ~ - !!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T4'. - \ No newline at end of file + const t4 = /** @satisfies {T2} */ ({ a: "a" }); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff deleted file mode 100644 index 552bbff342..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.checkJsdocSatisfiesTag10.errors.txt -+++ new.checkJsdocSatisfiesTag10.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. - /a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Partial>'. - /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. - - --==== /a.js (2 errors) ==== -+==== /a.js (3 errors) ==== - /** @typedef {"a" | "b" | "c" | "d"} Keys */ - - const p = /** @satisfies {Partial>} */ ({ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - a: 0, - b: "hello", - x: 8 // Should error, 'x' isn't in 'Keys' \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.errors.txt.diff index 437e623ed0..4d4c0fe983 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.errors.txt.diff @@ -6,28 +6,29 @@ - - -==== /a.js (2 errors) ==== -+/a.js(20,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== - /** - * @typedef {Object} T1 - * @property {number} a -@@= skipped -15, +14 lines =@@ - /** - * @satisfies {T1} - * @satisfies {T2} +- /** +- * @typedef {Object} T1 +- * @property {number} a +- */ +- +- /** +- * @typedef {Object} T2 +- * @property {number} a +- */ +- +- /** +- * @satisfies {T1} +- * @satisfies {T2} - ~~~~~~~~~ -!!! error TS1223: 'satisfies' tag already specified. - */ - const t1 = { a: 1 }; - - /** - * @satisfies {number} +- */ +- const t1 = { a: 1 }; +- +- /** +- * @satisfies {number} - ~~~~~~~~~ -!!! error TS1223: 'satisfies' tag already specified. - */ - const t2 = /** @satisfies {number} */ (1); -+ ~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - \ No newline at end of file +- */ +- const t2 = /** @satisfies {number} */ (1); +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.errors.txt.diff index a72f22e5e8..85c8c13099 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.errors.txt.diff @@ -8,27 +8,23 @@ - - -==== /a.js (4 errors) ==== -+/a.js(10,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== - /** - * @typedef {Object} T1 - * @property {number} a -@@= skipped -11, +8 lines =@@ - - /** - * @satisfies T1 +- /** +- * @typedef {Object} T1 +- * @property {number} a +- */ +- +- /** +- * @satisfies T1 - ~~ -!!! error TS1005: '{' expected. - */ +- */ - -!!! error TS1005: '}' expected. - const t1 = { a: 1 }; - const t2 = /** @satisfies T1 */ ({ a: 1 }); - ~~ +- const t1 = { a: 1 }; +- const t2 = /** @satisfies T1 */ ({ a: 1 }); +- ~~ -!!! error TS1005: '{' expected. - -!!! error TS1005: '}' expected. -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - \ No newline at end of file +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff index 4246c5e64a..2c074193e1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.errors.txt.diff @@ -4,22 +4,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(1,34): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + -+==== /a.js (4 errors) ==== ++==== /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. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + + const p = /** @satisfies {Predicates} */ ({ -+ ~~~~~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + 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 deleted file mode 100644 index 54be4714bc..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.checkJsdocSatisfiesTag3.errors.txt -+++ new.checkJsdocSatisfiesTag3.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(2,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. - /a.js(3,7): error TS7006: Parameter 's' implicitly has an 'any' type. -- -- --==== /a.js (1 errors) ==== -+/a.js(8,17): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+ -+ -+==== /a.js (4 errors) ==== - /** @type {{ f(s: string): void } & Record }} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - f(s) { }, // "incorrect" implicit any on 's' - ~ - !!! error TS7006: Parameter 's' implicitly has an 'any' type. -@@= skipped -11, +18 lines =@@ - - // This needs to not crash (outer node is not expression) - /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff index 4a61a052be..50185c3ada 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.errors.txt.diff @@ -3,17 +3,11 @@ @@= skipped -0, +0 lines =@@ -/a.js(5,21): error TS1360: Type '{}' does not satisfy the expected type 'Foo'. - Property 'a' is missing in type '{}' but required in type 'Foo'. -- -- --==== /a.js (1 errors) ==== -+/a.js(5,32): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/a.js(5,43): error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. -+/b.js(6,32): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+ -+ -+==== /a.js (2 errors) ==== - /** - * @typedef {Object} Foo + + + ==== /a.js (1 errors) ==== +@@= skipped -7, +6 lines =@@ * @property {number} a */ export default /** @satisfies {Foo} */ ({}); @@ -21,19 +15,9 @@ -!!! error TS1360: Type '{}' does not satisfy the expected type 'Foo'. -!!! error TS1360: Property 'a' is missing in type '{}' but required in type 'Foo'. -!!! related TS2728 /a.js:3:4: 'a' is declared here. -+ ~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. + ~ +!!! error TS2741: Property 'a' is missing in type '{}' but required in type 'Foo'. +!!! related TS2728 /a.js:3:23: 'a' is declared here. --==== /b.js (0 errors) ==== -+==== /b.js (1 errors) ==== - /** - * @typedef {Object} Foo - * @property {number} a - */ - - export default /** @satisfies {Foo} */ ({ a: 1 }); -+ ~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. \ No newline at end of file + ==== /b.js (0 errors) ==== + /** \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.errors.txt.diff deleted file mode 100644 index ea1d84e592..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.checkJsdocSatisfiesTag5.errors.txt -+++ new.checkJsdocSatisfiesTag5.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(1,31): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(3,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+ -+ -+==== /a.js (2 errors) ==== -+ /** @typedef {{ move(distance: number): void }} Movable */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ -+ const car = /** @satisfies {Movable & Record} */ ({ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+ start() { }, -+ move(d) { -+ // d should be number -+ }, -+ stop() { } -+ }) -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.errors.txt.diff deleted file mode 100644 index 2134c5aaed..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.checkJsdocSatisfiesTag6.errors.txt -+++ new.checkJsdocSatisfiesTag6.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(8,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. - /a.js(14,11): error TS2339: Property 'y' does not exist on type '{ x: number; }'. - - --==== /a.js (1 errors) ==== -+==== /a.js (2 errors) ==== - /** - * @typedef {Object} Point2d - * @property {number} x -@@= skipped -9, +10 lines =@@ - - // Undesirable behavior today with type annotation - const a = /** @satisfies {Partial} */ ({ x: 10 }); -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - - // Should OK - console.log(a.x.toFixed()); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff deleted file mode 100644 index dce7c70e7a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.checkJsdocSatisfiesTag7.errors.txt -+++ new.checkJsdocSatisfiesTag7.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(3,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. - /a.js(6,5): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type 'Record'. - /a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. - - --==== /a.js (2 errors) ==== -+==== /a.js (3 errors) ==== - /** @typedef {"a" | "b" | "c" | "d"} Keys */ - - const p = /** @satisfies {Record} */ ({ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - a: 0, - b: "hello", - x: 8 // Should error, 'x' isn't in 'Keys' \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff index 19e89d0d8f..f18376a34a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.errors.txt.diff @@ -7,10 +7,9 @@ -==== /a.js (1 errors) ==== +/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(4,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + -+==== /a.js (3 errors) ==== ++==== /a.js (2 errors) ==== /** @typedef {Object.} Facts */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. @@ -19,8 +18,6 @@ // Should be able to detect a failure here const x = /** @satisfies {Facts} */ ({ -+ ~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. m: true, s: "false" - ~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff deleted file mode 100644 index fec2ac3ee2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.checkJsdocSatisfiesTag9.errors.txt -+++ new.checkJsdocSatisfiesTag9.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(9,40): error TS8037: Type satisfaction expressions can only be used in TypeScript files. - /a.js(11,26): error TS2353: Object literal may only specify known properties, and 'd' does not exist in type 'Color'. - - --==== /a.js (1 errors) ==== -+==== /a.js (2 errors) ==== - /** - * @typedef {Object} Color - * @property {number} r -@@= skipped -10, +11 lines =@@ - - // All of these should be Colors, but I only use some of them here. - export const Palette = /** @satisfies {Record} */ ({ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - white: { r: 255, g: 255, b: 255 }, - black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' - ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff index 44250ba884..886d602488 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag1.errors.txt.diff @@ -5,58 +5,23 @@ - - -==== 0.js (1 errors) ==== -+0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(20,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+0.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(24,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+0.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(28,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+0.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(33,11): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(38,11): error TS8010: Type annotations can only be used in TypeScript files. +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 (14 errors) ==== ++==== 0.js (4 errors) ==== // @ts-check /** @type {String} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var S = "hello world"; - - /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var n = 10; - - /** @type {*} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var anyT = 2; - anyT = "hello"; - - /** @type {?} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var anyT1 = 2; - anyT1 = "hi"; - - /** @type {Function} */ -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const x = (a) => a + 1; +@@= skipped -21, +24 lines =@@ x(1); /** @type {function} */ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const y = (a) => a + 1; y(1); @@ -66,8 +31,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const x1 = (a) => a + 1; x1(0); @@ -75,22 +38,11 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const x2 = (a) => a + 1; x2(0); - /** - * @type {object} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - var props = {}; - - /** +@@= skipped -22, +29 lines =@@ * @type {Object} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ var props = {}; + ~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff index a1d9902555..6b72170b6d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag2.errors.txt.diff @@ -2,9 +2,7 @@ +++ new.checkJsdocTypeTag2.errors.txt @@= skipped -0, +0 lines =@@ -0.js(3,5): error TS2322: Type 'boolean' is not assignable to type 'string'. -+0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(3,5): error TS2322: Type 'boolean' is not assignable to type 'String'. -+0.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -15,31 +13,22 @@ - -==== 0.js (7 errors) ==== +0.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(12,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+0.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+0.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +0.js(23,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+0.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== 0.js (13 errors) ==== ++==== 0.js (6 errors) ==== // @ts-check /** @type {String} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var S = true; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. +!!! error TS2322: Type 'boolean' is not assignable to type 'String'. /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var n = "hello"; - ~ +@@= skipped -19, +18 lines =@@ !!! error TS2322: Type 'string' is not assignable to type 'number'. /** @type {function (number)} */ @@ -48,8 +37,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const x1 = (a) => a + 1; x1("string"); - ~~~~~~~~ @@ -59,13 +46,9 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const x2 = (a) => a + 1; /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var a; a = x2(0); - ~ @@ -75,8 +58,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const x3 = (a) => a.concat("hi"); - ~~~~~~ -!!! error TS2339: Property 'concat' does not exist on type 'number'. @@ -86,8 +67,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const x4 = (a) => a + 1; - ~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.errors.txt.diff deleted file mode 100644 index f9ebd17be1..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag3.errors.txt.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.checkJsdocTypeTag3.errors.txt -+++ new.checkJsdocTypeTag3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+test.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== test.js (1 errors) ==== -+ /** @type {Array} */ -+ ~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ var nns; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff deleted file mode 100644 index 34487090d5..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.checkJsdocTypeTag4.errors.txt -+++ new.checkJsdocTypeTag4.errors.txt -@@= skipped -0, +0 lines =@@ -+test.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. - test.js(5,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. -+test.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. - 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 (2 errors) ==== -+==== test.js (4 errors) ==== - /** Also should error for jsdoc typedefs - * @template {string} U - * @typedef {{ b: U }} B - */ - /** @type {A} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~ - !!! error TS2344: Type 'number' does not satisfy the constraint 'string'. - var a; - /** @type {B} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~ - !!! error TS2344: Type 'number' does not satisfy the constraint 'string'. - var b; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff index fddb797705..c6f159b314 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff @@ -2,47 +2,34 @@ +++ new.checkJsdocTypeTag5.errors.txt @@= skipped -0, +0 lines =@@ -test.js(3,17): error TS2322: Type 'number' is not assignable to type 'string'. -+test.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. 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(6,12): error TS8010: Type annotations can only be used in TypeScript files. +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(11,12): error TS8010: Type annotations can only be used in TypeScript files. 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(13,12): error TS8010: Type annotations can only be used in TypeScript files. +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(17,18): error TS8010: Type annotations can only be used in TypeScript files. -+test.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. +test.js(24,5): error TS2322: Type 'number' is not assignable to type '0 | 1 | 2'. -+test.js(26,19): error TS8010: Type annotations can only be used in TypeScript files. -+test.js(26,39): error TS8010: Type annotations can only be used in TypeScript files. -+test.js(33,12): error TS8010: Type annotations can only be used in TypeScript files. 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) ==== -+==== test.js (15 errors) ==== ++==== 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} */ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. 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} */ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var g = function (x) { return x } - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -55,15 +42,11 @@ - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. /** @type {{ (x: number): string }} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. 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 }} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var k = function (x) { return x } - ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -73,36 +56,18 @@ /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - /** @type {Argle} */ - function blargle(s) { - return 0; - } +@@= skipped -45, +45 lines =@@ /** @type {0 | 1 | 2} - assignment should not error */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. 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 */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. /** @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 */ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var twothree = monaLisa(false); - ~~~~~~~~ - !!! error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff index 363b590590..91b9e0af5b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag6.errors.txt.diff @@ -2,14 +2,11 @@ +++ new.checkJsdocTypeTag6.errors.txt @@= skipped -0, +0 lines =@@ -test.js(1,12): error TS8030: The type of a function declaration must match the function's signature. -+test.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. 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(26,12): error TS8010: Type annotations can only be used in TypeScript files. 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(29,12): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -19,20 +16,14 @@ -==== test.js (7 errors) ==== + + -+==== test.js (6 errors) ==== ++==== 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 }} */ -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var g = function (prop) { - ~ - !!! error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. +@@= skipped -24, +17 lines =@@ } /** @type {(a: number) => number} */ @@ -41,7 +32,7 @@ function add1(a, b) { return a + b; } /** @type {(a: number, b: number) => number} */ -@@= skipped -39, +35 lines =@@ +@@= skipped -15, +13 lines =@@ // They can't have more parameters than the type/context. /** @type {() => void} */ @@ -50,20 +41,7 @@ function funcWithMoreParameters(more) {} // error /** @type {() => void} */ -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - 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} */ -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const arrowWithMoreParameters = (more) => {}; // error - ~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'. -@@= skipped -19, +21 lines =@@ +@@= skipped -19, +17 lines =@@ ({ /** @type {() => void} */ methodWithMoreParameters(more) {}, // error diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag7.errors.txt.diff deleted file mode 100644 index eccb6bff5b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag7.errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.checkJsdocTypeTag7.errors.txt -+++ new.checkJsdocTypeTag7.errors.txt -@@= skipped -0, +0 lines =@@ -- -+test.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. -+test.js(2,28): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== test.js (2 errors) ==== -+ /** -+ * @typedef {(a: string, b: number) => void} Foo -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ -+ class C { -+ /** @type {Foo} */ -+ foo(a, b) {} -+ -+ /** @type {(optional?) => void} */ -+ methodWithOptionalParameters() {} -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag8.errors.txt.diff index b1d84581d6..0a81a4d39f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag8.errors.txt.diff @@ -2,17 +2,14 @@ +++ new.checkJsdocTypeTag8.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. +index.js(4,20): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. + + -+==== index.js (2 errors) ==== ++==== index.js (1 errors) ==== + // https://github.com/microsoft/TypeScript/issues/57953 + + /** + * @param {Number|BigInt} n -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later. + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff index 6c1cd30b36..b398e62b86 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTagOnObjectProperty2.errors.txt.diff @@ -14,15 +14,13 @@ -==== 0.js (8 errors) ==== +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(18,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== 0.js (5 errors) ==== ++==== 0.js (3 errors) ==== // @ts-check var lol; const obj = { -@@= skipped -18, +15 lines =@@ +@@= skipped -18, +13 lines =@@ /** @type {function(number): number} */ method1(n1) { return "42"; @@ -50,15 +48,11 @@ } lol = "string" /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var s = obj.method1(0); - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var s1 = obj.method2("0"); - ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff deleted file mode 100644 index a6506e9c14..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff +++ /dev/null @@ -1,59 +0,0 @@ ---- old.checkJsdocTypedefInParamTag1.errors.txt -+++ new.checkJsdocTypedefInParamTag1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+0.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== 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 -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function foo(opts) { -+ opts.x; -+ } -+ -+ foo({x: 'abc'}); -+ -+ /** -+ * @typedef {Object} AnotherOpts -+ * @property anotherX {string} -+ * @property anotherY {string=} -+ * -+ * @param {AnotherOpts} opts -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function foo1(opts) { -+ opts.anotherX; -+ } -+ -+ foo1({anotherX: "world"}); -+ -+ /** -+ * @typedef {object} Opts1 -+ * @property {string} x -+ * @property {string=} y -+ * @property {string} [z] -+ * @property {string} [w="hi"] -+ * -+ * @param {Opts1} opts -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function foo2(opts) { -+ opts.x; -+ } -+ foo2({x: 'abc'}); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff index fb4ab1bd6d..cfb3d23d1b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff @@ -8,10 +8,9 @@ +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(10,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== 0.js (4 errors) ==== ++==== 0.js (3 errors) ==== // @ts-check var exports = {}; @@ -30,7 +29,5 @@ -!!! error TS2694: Namespace 'exports' has no exported member 'SomeName'. + ~~~~~~~ +!!! error TS2503: Cannot find namespace 'exports'. -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const myString = 'str'; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkObjectDefineProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkObjectDefineProperty.errors.txt.diff index 55ae05059c..a3a773a7c6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkObjectDefineProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkObjectDefineProperty.errors.txt.diff @@ -8,16 +8,9 @@ - - -==== validate.ts (4 errors) ==== -+index.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,10): error TS2741: Property 'name' is missing in type '{}' but required in type '{ name: string; }'. -+index.js(21,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(23,11): error TS2339: Property 'zip' does not exist on type '{}'. -+index.js(26,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(28,11): error TS2339: Property 'houseNumber' does not exist on type '{}'. -+index.js(33,29): error TS8016: Type assertion expressions can only be used in TypeScript files. -+index.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(38,12): error TS8010: Type annotations can only be used in TypeScript files. +validate.ts(3,3): error TS2339: Property 'name' does not exist on type '{}'. +validate.ts(4,3): error TS2339: Property 'middleInit' does not exist on type '{}'. +validate.ts(5,3): error TS2339: Property 'lastName' does not exist on type '{}'. @@ -84,26 +77,11 @@ +!!! error TS2339: Property 'middleInit' does not exist on type '{}'. -==== index.js (0 errors) ==== -+==== index.js (10 errors) ==== ++==== index.js (3 errors) ==== const x = {}; Object.defineProperty(x, "name", { value: "Charles", writable: true }); Object.defineProperty(x, "middleInit", { value: "H" }); -@@= skipped -39, +76 lines =@@ - Object.defineProperty(x, "houseNumber", { get() { return 21.75 } }); - Object.defineProperty(x, "zipStr", { - /** @param {string} str */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - set(str) { - this.zip = Number(str) - } -@@= skipped -7, +9 lines =@@ - - /** - * @param {{name: string}} named -+ ~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ +@@= skipped -50, +80 lines =@@ function takeName(named) { return named.name; } takeName(x); @@ -112,8 +90,6 @@ +!!! related TS2728 index.js:15:13: 'name' is declared here. /** * @type {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ var a = x.zip; + ~~~ @@ -121,28 +97,10 @@ /** * @type {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ var b = x.houseNumber; + ~~~~~~~~~~~ +!!! error TS2339: Property 'houseNumber' does not exist on type '{}'. const returnExemplar = () => x; - const needsExemplar = (_ = x) => void 0; - - const expected = /** @type {{name: string, readonly middleInit: string, readonly lastName: string, zip: number, readonly houseNumber: number, zipStr: string}} */(/** @type {*} */(null)); -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - - /** - * - * @param {typeof returnExemplar} a -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {typeof needsExemplar} b -+ ~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function match(a, b) {} - \ No newline at end of file + const needsExemplar = (_ = x) => void 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkOtherObjectAssignProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkOtherObjectAssignProperty.errors.txt.diff index c18a09dde5..2ef436de9d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkOtherObjectAssignProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkOtherObjectAssignProperty.errors.txt.diff @@ -13,8 +13,6 @@ -==== importer.js (7 errors) ==== +importer.js(1,21): error TS2306: File 'mod1.js' is not a module. +mod1.js(2,23): error TS2304: Cannot find name 'exports'. -+mod1.js(5,11): error TS8010: Type annotations can only be used in TypeScript files. -+mod1.js(7,22): error TS8016: Type assertion expressions can only be used in TypeScript files. +mod1.js(8,23): error TS2304: Cannot find name 'exports'. +mod1.js(11,23): error TS2304: Cannot find name 'exports'. +mod1.js(14,23): error TS2304: Cannot find name 'exports'. @@ -36,7 +34,7 @@ mod.bad1; mod.bad2; mod.bad3; -@@= skipped -22, +22 lines =@@ +@@= skipped -22, +20 lines =@@ mod.thing = 0; mod.other = 0; @@ -56,7 +54,7 @@ -!!! error TS2540: Cannot assign to 'bad3' because it is a read-only property. -==== mod1.js (0 errors) ==== -+==== mod1.js (8 errors) ==== ++==== mod1.js (6 errors) ==== const obj = { value: 42, writable: true }; Object.defineProperty(exports, "thing", obj); + ~~~~~~~ @@ -64,12 +62,8 @@ /** * @type {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ let str = /** @type {string} */("other"); -+ ~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. Object.defineProperty(exports, str, { value: 42, writable: true }); + ~~~~~~~ +!!! error TS2304: Cannot find name 'exports'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff deleted file mode 100644 index 1173d12361..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkSpecialPropertyAssignments.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.checkSpecialPropertyAssignments.errors.txt -+++ new.checkSpecialPropertyAssignments.errors.txt -@@= skipped -0, +0 lines =@@ -+bug24252.js(4,20): error TS8010: Type annotations can only be used in TypeScript files. -+bug24252.js(6,20): error TS8010: Type annotations can only be used in TypeScript files. - 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 (3 errors) ==== - var A = {}; - A.B = class { - m() { - /** @type {string[]} */ -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var x = []; - /** @type {number[]} */ -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var y; - y = x; - ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff index 9d647489a4..beb795529b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff @@ -5,17 +5,13 @@ -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(3,12): error TS8010: Type annotations can only be used in TypeScript files. +first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. -+first.js(27,16): error TS8010: Type annotations can only be used in TypeScript files. +first.js(27,21): error TS8020: JSDoc types can only be used inside documentation comments. -+first.js(28,16): error TS8010: Type annotations can only be used in TypeScript files. +first.js(44,4): error TS2339: Property 'numberOxen' 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(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+generic.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +generic.js(9,22): error TS8011: Type arguments can only be used in TypeScript files. +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'. @@ -37,16 +33,11 @@ +second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. + + -+==== first.js (7 errors) ==== ++==== first.js (4 errors) ==== /** * @constructor * @param {number} numberOxen -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function Wagon(numberOxen) { - this.numberOxen = numberOxen -@@= skipped -36, +41 lines =@@ +@@= skipped -36, +35 lines =@@ } // ok class Sql extends Wagon { @@ -61,13 +52,9 @@ } /** * @param {Array.} files -+ ~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. * @param {"csv" | "json" | "xmlolololol"} format -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * This is not assignable, so should have a type error */ load(files, format) { @@ -78,7 +65,7 @@ if (format === "xmlolololol") { throw new Error("please do not use XML. It was a joke."); } -@@= skipped -30, +31 lines =@@ +@@= skipped -30, +27 lines =@@ } var db = new Sql(); db.numberOxen = db.foonly @@ -117,15 +104,13 @@ +!!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (2 errors) ==== -+==== generic.js (8 errors) ==== ++==== generic.js (7 errors) ==== /** + ~~~ * @template T + ~~~~~~~~~~~~~~ * @param {T} flavour + ~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function Soup(flavour) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.errors.txt.diff index 94269d68a6..18e8e7a09d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSAliasedExport.errors.txt.diff @@ -3,18 +3,15 @@ @@= skipped -0, +0 lines =@@ - +bug43713.js(1,9): error TS2305: Module '"./commonJSAliasedExport"' has no exported member 'funky'. -+bug43713.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +commonJSAliasedExport.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +commonJSAliasedExport.js(7,16): error TS2339: Property 'funky' does not exist on type '(ast: any) => any'. + + -+==== bug43713.js (2 errors) ==== ++==== bug43713.js (1 errors) ==== + const { funky } = require('./commonJSAliasedExport'); + ~~~~~ +!!! error TS2305: Module '"./commonJSAliasedExport"' has no exported member 'funky'. + /** @type {boolean} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var diddy + var diddy = funky(1) + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff index 6939ecfe0e..579c812e95 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportClassTypeReference.errors.txt.diff @@ -3,16 +3,13 @@ @@= skipped -0, +0 lines =@@ - +main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? -+main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== main.js (2 errors) ==== ++==== main.js (1 errors) ==== + const { K } = require("./mod1"); + /** @param {K} k */ + ~ +!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(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 33ec25a45e..0dd6edc42f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportExportedClassExpression.errors.txt.diff @@ -3,16 +3,13 @@ @@= skipped -0, +0 lines =@@ - +main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? -+main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== main.js (2 errors) ==== ++==== main.js (1 errors) ==== + const { K } = require("./mod1"); + /** @param {K} k */ + ~ +!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(k) { + k.values() + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff index 4bd4ec8085..ab343dc0e8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/commonJSImportNestedClassTypeReference.errors.txt.diff @@ -3,16 +3,13 @@ @@= skipped -0, +0 lines =@@ - +main.js(2,13): error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? -+main.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== main.js (2 errors) ==== ++==== main.js (1 errors) ==== + const { K } = require("./mod1"); + /** @param {K} k */ + ~ +!!! error TS2749: 'K' refers to a value, but is being used as a type here. Did you mean 'typeof K'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(k) { + k.values() + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff index ddb5570264..3565540763 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff @@ -3,24 +3,18 @@ @@= skipped -0, +0 lines =@@ - +constructorFunctionMethodTypeParameters.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+constructorFunctionMethodTypeParameters.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +constructorFunctionMethodTypeParameters.js(19,30): error TS8004: Type parameter declarations can only be used in TypeScript files. +constructorFunctionMethodTypeParameters.js(22,16): error TS2304: Cannot find name 'T'. -+constructorFunctionMethodTypeParameters.js(22,16): error TS8010: Type annotations can only be used in TypeScript files. -+constructorFunctionMethodTypeParameters.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. +constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find name 'T'. -+constructorFunctionMethodTypeParameters.js(24,17): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== constructorFunctionMethodTypeParameters.js (8 errors) ==== ++==== constructorFunctionMethodTypeParameters.js (4 errors) ==== + /** + ~~~ + * @template {string} T + ~~~~~~~~~~~~~~~~~~~~~~~ + * @param {T} t + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function Cls(t) { @@ -51,18 +45,12 @@ + ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} u + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T} + ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + function (t, u) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.errors.txt.diff index ee329c830c..3f9c9593a1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctions.errors.txt.diff @@ -11,12 +11,11 @@ +index.js(23,15): error TS2350: Only a void function can be called with the 'new' keyword. +index.js(27,39): error TS2350: Only a void function can be called with the 'new' keyword. +index.js(31,15): error TS2350: Only a void function can be called with the 'new' keyword. -+index.js(51,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(55,13): error TS2554: Expected 1 arguments, but got 0. -==== index.js (3 errors) ==== -+==== index.js (10 errors) ==== ++==== index.js (9 errors) ==== function C1() { if (!(this instanceof C1)) return new C1(); + ~~~~~~~~ @@ -70,13 +69,4 @@ +!!! error TS2350: Only a void function can be called with the 'new' keyword. var c5_v1; - c5_v1 = function f() { }; -@@= skipped -58, +77 lines =@@ - /** - * @constructor - * @param {number} num -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function C7(num) {} - \ No newline at end of file + c5_v1 = function f() { }; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff index d0c6be8cc6..866e73f31c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionsStrict.errors.txt.diff @@ -5,21 +5,16 @@ - - -==== a.js (1 errors) ==== -+a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. +a.js(8,9): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. -+a.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. +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 */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. function C(x) { this.x = x - } -@@= skipped -9, +15 lines =@@ +@@= skipped -9, +11 lines =@@ this.y = 12 } var c = new C(1) @@ -31,8 +26,6 @@ c.y = undefined // ok /** @param {number} x */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. function A(x) { if (!(this instanceof A)) { return new A(x) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.errors.txt.diff deleted file mode 100644 index 826803ecdd..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.constructorTagWithThisTag.errors.txt -+++ new.constructorTagWithThisTag.errors.txt -@@= skipped -0, +0 lines =@@ -- -+classthisboth.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== classthisboth.js (1 errors) ==== -+ /** -+ * @class -+ * @this {{ e: number, m: number }} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * this-tag should win, both 'e' and 'm' should be defined. -+ */ -+ function C() { -+ this.e = this.m + 1 -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.errors.txt.diff deleted file mode 100644 index ba9a0eaf4a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypeFromJSDoc.errors.txt.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.contextualTypeFromJSDoc.errors.txt -+++ new.contextualTypeFromJSDoc.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (3 errors) ==== -+ /** @type {Array<[string, {x?:number, y?:number}]>} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const arr = [ -+ ['a', { x: 1 }], -+ ['b', { y: 2 }] -+ ]; -+ -+ /** @return {Array<[string, {x?:number, y?:number}]>} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ function f() { -+ return [ -+ ['a', { x: 1 }], -+ ['b', { y: 2 }] -+ ]; -+ } -+ -+ class C { -+ /** @param {Array<[string, {x?:number, y?:number}]>} value */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ set x(value) { } -+ get x() { -+ return [ -+ ['a', { x: 1 }], -+ ['b', { y: 2 }] -+ ]; -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff index 75149ecf86..8ba6639782 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/contextualTypedSpecialAssignment.errors.txt.diff @@ -2,20 +2,16 @@ +++ new.contextualTypedSpecialAssignment.errors.txt @@= skipped -0, +0 lines =@@ - -+mod.js(2,34): error TS8010: Type annotations can only be used in TypeScript files. -+test.js(3,9): error TS8010: Type annotations can only be used in TypeScript files. +test.js(15,5): error TS2322: Type 'string' is not assignable to type '"done"'. +test.js(16,7): error TS7006: Parameter 'n' implicitly has an 'any' type. +test.js(57,17): error TS2339: Property 'x' does not exist on type 'Thing'. +test.js(61,17): error TS2339: Property 'x' does not exist on type 'Thing'. + + -+==== test.js (5 errors) ==== ++==== test.js (4 errors) ==== + /** @typedef {{ + status: 'done' + m(n: number): void -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + }} DoneStatus */ + + // property assignment @@ -93,11 +89,9 @@ + m(n) { } + } + -+==== mod.js (1 errors) ==== ++==== mod.js (0 errors) ==== + // module.exports assignment + /** @type {{ status: 'done', m(n: number): void }} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + module.exports = { + status: "done", + m(n) { } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).errors.txt.diff deleted file mode 100644 index 9faf9dc7fb..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).errors.txt.diff +++ /dev/null @@ -1,64 +0,0 @@ ---- old.destructuringParameterDeclaration9(strict=false).errors.txt -+++ new.destructuringParameterDeclaration9(strict=false).errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(3,4): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (4 errors) ==== -+ /** -+ * @param {Object} [config] -+ * @param {Partial>} [config.additionalFiles] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function prepareConfig({ -+ additionalFiles: { -+ json = [] -+ } = {} -+ } = {}) { -+ json // string[] -+ } -+ -+ export function prepareConfigWithoutAnnotation({ -+ additionalFiles: { -+ json = [] -+ } = {} -+ } = {}) { -+ json -+ } -+ -+ /** @type {(param: { -+ ~~~~~~~~~ -+ additionalFiles?: Partial>; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ }) => void} */ -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ export const prepareConfigWithContextualSignature = ({ -+ additionalFiles: { -+ json = [] -+ } = {} -+ } = {})=> { -+ json // string[] -+ } -+ -+ // Additional repros from https://github.com/microsoft/TypeScript/issues/59936 -+ -+ /** -+ * @param {{ a?: { json?: string[] }}} [config] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f1({ a: { json = [] } = {} } = {}) { return json } -+ -+ /** -+ * @param {[[string[]?]?]} [x] -+ ~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f2([[json = []] = []] = []) { return json } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).errors.txt.diff deleted file mode 100644 index 75da44d63c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).errors.txt.diff +++ /dev/null @@ -1,51 +0,0 @@ ---- old.destructuringParameterDeclaration9(strict=true).errors.txt -+++ new.destructuringParameterDeclaration9(strict=true).errors.txt -@@= skipped -0, +0 lines =@@ -+index.js(3,4): error TS8010: Type annotations can only be used in TypeScript files. - index.js(15,9): error TS7031: Binding element 'json' implicitly has an 'any[]' type. -- -- --==== index.js (1 errors) ==== -+index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (5 errors) ==== - /** - * @param {Object} [config] - * @param {Partial>} [config.additionalFiles] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function prepareConfig({ - additionalFiles: { -@@= skipped -24, +30 lines =@@ - } - - /** @type {(param: { -+ ~~~~~~~~~ - additionalFiles?: Partial>; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - }) => void} */ -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - export const prepareConfigWithContextualSignature = ({ - additionalFiles: { - json = [] -@@= skipped -14, +18 lines =@@ - - /** - * @param {{ a?: { json?: string[] }}} [config] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f1({ a: { json = [] } = {} } = {}) { return json } - - /** - * @param {[[string[]?]?]} [x] -+ ~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f2([[json = []] = []] = []) { return json } - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff index e3f7fbf4c4..4b31a93b36 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTag.errors.txt.diff @@ -4,24 +4,14 @@ -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(24,13): error TS8010: Type annotations can only be used in TypeScript files. +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(25,12): error TS8010: Type annotations can only be used in TypeScript files. +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(26,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(29,16): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(31,16): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(33,16): error TS8010: Type annotations can only be used in TypeScript files. +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(35,16): error TS8010: Type annotations can only be used in TypeScript files. 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(41,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (13 errors) ==== ++==== a.js (5 errors) ==== /** @enum {string} */ const Target = { START: "start", @@ -41,52 +31,27 @@ OK: 1, /** @type {number} */ FINE: 2, -@@= skipped -31, +37 lines =@@ +@@= 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'? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Second} s + ~~~~~~ +!!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Fs} f + ~~ +!!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ function consume(t,s,f) { /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var str = t - /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var num = s +@@= skipped -11, +17 lines =@@ /** @type {(n: number) => number} */ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. 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'? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var v = Target.START v = Target.UNKNOWN // error, can't find 'UNKNOWN' - ~~~~~~~ -@@= skipped -19, +41 lines =@@ - v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums - } - /** @param {string} s */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function ff(s) { - // element access with arbitrary string is an error only with noImplicitAny - if (!Target[s]) { \ No newline at end of file + ~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff index 0e114ebf91..cd516c8a20 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagImported.errors.txt.diff @@ -3,35 +3,26 @@ @@= skipped -0, +0 lines =@@ - +type.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. -+type.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+type.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +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'? -+value.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== type.js (4 errors) ==== ++==== type.js (2 errors) ==== + /** @typedef {import("./mod1").TestEnum} TE */ + ~~~~~~~~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. + /** @type {TE} */ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const test = 'add' + /** @type {import("./mod1").TestEnum} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'TestEnum'. + const tost = 'remove' + -+==== value.js (2 errors) ==== ++==== 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'? -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const tist = TestEnum.ADD + + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff index 9909a63130..69e6638c6f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/enumTagUseBeforeDefCrash.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 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(7,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== bug27134.js (2 errors) ==== ++==== bug27134.js (1 errors) ==== + /** + * @enum {number} + */ @@ -16,8 +15,6 @@ + * @type {foo} + ~~~ +!!! error TS2749: 'foo' refers to a value, but is being used as a type here. Did you mean 'typeof foo'? -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var s; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff index 9153e54284..edfe5ae50a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff @@ -14,19 +14,17 @@ - - -==== foo.js (10 errors) ==== -+foo.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(21,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. + Type 'void' is not assignable to type 'Promise'. -+foo.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. + Type 'void' is not assignable to type 'never'. + + -+==== foo.js (4 errors) ==== ++==== foo.js (2 errors) ==== /** * @callback FunctionReturningPromise * @returns {Promise} -@@= skipped -17, +13 lines =@@ +@@= skipped -17, +11 lines =@@ /** @type {FunctionReturningPromise} */ function testPromise1() { @@ -51,8 +49,6 @@ } /** @type {FunctionReturningPromise} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var testPromise4 = function() { - ~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. @@ -62,7 +58,7 @@ console.log("test") } -@@= skipped -34, +29 lines =@@ +@@= skipped -34, +27 lines =@@ /** @type {FunctionReturningNever} */ function testNever1() { @@ -88,8 +84,6 @@ } /** @type {FunctionReturningNever} */ -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var testNever4 = function() { - ~~~~~~~~ -!!! error TS2534: A function returning 'never' cannot have a reachable end point. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/esDecorators-classDeclaration-exportModifier.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/esDecorators-classDeclaration-exportModifier.errors.txt.diff index 4e0f4b1adf..611a6b4b71 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/esDecorators-classDeclaration-exportModifier.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/esDecorators-classDeclaration-exportModifier.errors.txt.diff @@ -7,46 +7,43 @@ - - -==== global.js (0 errors) ==== -+global.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== global.js (1 errors) ==== - /** @type {*} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var dec; - - ==== file1.js (0 errors) ==== -@@= skipped -14, +14 lines =@@ - // ok - @dec export default class C2 {} - +- /** @type {*} */ +- var dec; +- +-==== file1.js (0 errors) ==== +- // ok +- @dec export class C1 { } +- +-==== file2.js (0 errors) ==== +- // ok +- @dec export default class C2 {} +- -==== file3.js (1 errors) ==== -+==== file3.js (0 errors) ==== - // error - export @dec default class C3 {} +- // error +- export @dec default class C3 {} - ~~~~ -!!! error TS1206: Decorators are not valid here. - - ==== file4.js (0 errors) ==== - // ok -@@= skipped -14, +12 lines =@@ - // ok - export default @dec class C5 {} - +- +-==== file4.js (0 errors) ==== +- // ok +- export @dec class C4 {} +- +-==== file5.js (0 errors) ==== +- // ok +- export default @dec class C5 {} +- -==== file6.js (1 errors) ==== -+==== file6.js (0 errors) ==== - // error - @dec export @dec class C6 {} +- // error +- @dec export @dec class C6 {} - ~~~~ -!!! error TS8038: Decorators may not appear after 'export' or 'export default' if they also appear before 'export'. -!!! related TS1486 file6.js:2:1: Decorator used before 'export' here. - +- -==== file7.js (1 errors) ==== -+==== file7.js (0 errors) ==== - // error - @dec export default @dec class C7 {} +- // error +- @dec export default @dec class C7 {} - ~~~~ -!!! error TS8038: Decorators may not appear after 'export' or 'export default' if they also appear before 'export'. -!!! related TS1486 file7.js:2:1: Decorator used before 'export' here. - \ No newline at end of file +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff index 0a657910bc..a86c615df7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportNestedNamespaces.errors.txt.diff @@ -4,10 +4,8 @@ - +mod.js(2,11): error TS2339: Property 'K' does not exist on type '{}'. +use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. -+use.js(8,13): error TS8010: Type annotations can only be used in TypeScript files. +use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. +use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -+use.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== mod.js (1 errors) ==== @@ -23,7 +21,7 @@ + } + } + -+==== use.js (5 errors) ==== ++==== use.js (3 errors) ==== + import * as s from './mod' + + var k = new s.n.K() @@ -34,15 +32,11 @@ + + + /** @param {s.n.K} c -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2694: Namespace '"mod"' has no exported member 'n'. + @param {s.Classic} classic */ + ~~~~~~~~~ +!!! error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(c, classic) { + c.x + classic.p diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff index 34d9724e5b..f71a29aa27 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/exportedEnumTypeAndValue.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 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'? -+use.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== def.js (0 errors) ==== @@ -14,13 +13,11 @@ + }; + export default MyEnum; + -+==== use.js (2 errors) ==== ++==== 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'? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const v = MyEnum.b; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff index 85d5474d0b..77a86868b3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff @@ -2,7 +2,6 @@ +++ new.extendsTag5.errors.txt @@= skipped -0, +0 lines =@@ +/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+/a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(26,16): error TS8011: Type arguments can only be used in TypeScript files. /a.js(29,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. Types of property 'b' are incompatible. @@ -18,7 +17,7 @@ +/a.js(44,16): error TS8011: Type arguments can only be used in TypeScript files. + + -+==== /a.js (8 errors) ==== ++==== /a.js (7 errors) ==== /** + ~~~ * @typedef {{ @@ -45,8 +44,6 @@ + ~~~~~~ * @param {T} a + ~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~~~~ constructor(a) { @@ -61,7 +58,7 @@ /** * @extends {A<{ -@@= skipped -32, +59 lines =@@ +@@= skipped -32, +56 lines =@@ * }>} */ class B extends A {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff index 49b0d90f81..9a8bb6f9ff 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 lines =@@ - +genericSetterInClassTypeJsDoc.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+genericSetterInClassTypeJsDoc.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== genericSetterInClassTypeJsDoc.js (2 errors) ==== ++==== genericSetterInClassTypeJsDoc.js (1 errors) ==== + /** + ~~~ + * @template T @@ -21,8 +20,6 @@ + + /** @param {T} initialValue */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor(initialValue) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + this.#value = initialValue; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.errors.txt.diff deleted file mode 100644 index 1412b2d2a6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag1.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.importTag1.errors.txt -+++ new.importTag1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /types.ts (0 errors) ==== -+ export interface Foo { -+ a: number; -+ } -+ -+==== /foo.js (2 errors) ==== -+ /** -+ * @import { Foo } from "./types" -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param { Foo } foo -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(foo) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag11.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag11.errors.txt.diff index 66f92671e2..1d60c189e9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag11.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag11.errors.txt.diff @@ -6,17 +6,12 @@ - - -==== /foo.js (2 errors) ==== -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+ -+ -+==== /foo.js (1 errors) ==== - /** - * @import foo +- /** +- * @import foo - -!!! error TS1109: Expression expected. -+ ~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ +- */ - -!!! error TS1005: 'from' expected. - \ No newline at end of file +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag12.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag12.errors.txt.diff index b8ebdf34bc..3bcbbcf079 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag12.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag12.errors.txt.diff @@ -2,15 +2,13 @@ +++ new.importTag12.errors.txt @@= skipped -0, +0 lines =@@ -/foo.js(2,20): error TS1109: Expression expected. -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. - - - ==== /foo.js (1 errors) ==== - /** - * @import foo from +- +- +-==== /foo.js (1 errors) ==== +- /** +- * @import foo from - -!!! error TS1109: Expression expected. -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - \ No newline at end of file +- */ +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag13.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag13.errors.txt.diff index 71c3450d7e..a55a49f933 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag13.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag13.errors.txt.diff @@ -2,19 +2,13 @@ +++ new.importTag13.errors.txt @@= skipped -0, +0 lines =@@ -/foo.js(1,15): error TS1005: 'from' expected. -- -- --==== /foo.js (1 errors) ==== -+/foo.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(1,15): error TS1141: String literal expected. -+ -+ -+==== /foo.js (2 errors) ==== + + + ==== /foo.js (1 errors) ==== /** @import x = require("types") */ - ~ -!!! error TS1005: 'from' expected. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~ +!!! error TS1141: String literal expected. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag14.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag14.errors.txt.diff index 57f9ecee38..689b431d29 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag14.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag14.errors.txt.diff @@ -1,20 +1,14 @@ --- old.importTag14.errors.txt +++ new.importTag14.errors.txt @@= skipped -0, +0 lines =@@ -+/foo.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. +/foo.js(1,25): error TS2306: File '/foo.js' is not a module. /foo.js(1,33): error TS1464: Type import attributes should have exactly one key - 'resolution-mode' - with value 'import' or 'require'. /foo.js(1,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. -/foo.js(1,38): error TS1005: '{' expected. -- -- --==== /foo.js (3 errors) ==== -+ -+ -+==== /foo.js (4 errors) ==== + + + ==== /foo.js (3 errors) ==== /** @import * as f from "./foo" with */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. + ~~~~~~~ +!!! error TS2306: File '/foo.js' is not a module. ~~~~ 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 deleted file mode 100644 index a9a776ef2d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=es2015).errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.importTag15(module=es2015).errors.txt -+++ new.importTag15(module=es2015).errors.txt -@@= skipped -0, +0 lines =@@ -+1.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. - 1.js(1,30): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. -+1.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. - 1.js(2,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. -+1.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== 0.ts (0 errors) ==== - export interface I { } - --==== 1.js (2 errors) ==== -+==== 1.js (5 errors) ==== - /** @import { I } from './0' with { type: "json" } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~ - !!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. - /** @import * as foo from './0' with { type: "json" } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~ - !!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. - - /** @param {I} a */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function f(a) {} - \ No newline at end of file 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 deleted file mode 100644 index d81eee3ea8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag15(module=esnext).errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.importTag15(module=esnext).errors.txt -+++ new.importTag15(module=esnext).errors.txt -@@= skipped -0, +0 lines =@@ -+1.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. - 1.js(1,30): error TS2857: Import attributes cannot be used with type-only imports or exports. -+1.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. - 1.js(2,33): error TS2857: Import attributes cannot be used with type-only imports or exports. -+1.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== 0.ts (0 errors) ==== - export interface I { } - --==== 1.js (2 errors) ==== -+==== 1.js (5 errors) ==== - /** @import { I } from './0' with { type: "json" } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~ - !!! error TS2857: Import attributes cannot be used with type-only imports or exports. - /** @import * as foo from './0' with { type: "json" } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~ - !!! error TS2857: Import attributes cannot be used with type-only imports or exports. - - /** @param {I} a */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function f(a) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.errors.txt.diff deleted file mode 100644 index 08f0e2153f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag16.errors.txt.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.importTag16.errors.txt -+++ new.importTag16.errors.txt -@@= skipped -0, +0 lines =@@ -- -+b.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. -+b.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+b.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.ts (0 errors) ==== -+ export default interface Foo {} -+ export interface I {} -+ -+==== b.js (3 errors) ==== -+ /** @import Foo, { I } from "./a" */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ -+ /** -+ * @param {Foo} a -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {I} b -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function foo(a, b) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff index e00e290a77..1c6f910b5b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTag17.errors.txt.diff @@ -3,32 +3,15 @@ @@= 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"'. -+/a.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/a.js(2,5): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/a.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(5,15): error TS2749: 'Import' refers to a value, but is being used as a type here. Did you mean 'typeof Import'? -+/a.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(12,15): error TS2749: 'Require' refers to a value, but is being used as a type here. Did you mean 'typeof Require'? ==== /node_modules/@types/foo/package.json (0 errors) ==== -@@= skipped -19, +23 lines =@@ - ==== /node_modules/@types/foo/index.d.cts (0 errors) ==== - export declare const Require: "script"; - --==== /a.js (2 errors) ==== -+==== /a.js (6 errors) ==== - /** @import { Import } from 'foo' with { 'resolution-mode': 'import' } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - /** @import { Require } from 'foo' with { 'resolution-mode': 'require' } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. +@@= skipped -25, +25 lines =@@ /** * @returns { Import } -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2749: 'Import' refers to a value, but is being used as a type here. Did you mean 'typeof Import'? */ @@ -40,8 +23,6 @@ /** * @returns { Require } -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~ +!!! error TS2749: 'Require' refers to a value, but is being used as a type here. Did you mean 'typeof Require'? */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.errors.txt.diff deleted file mode 100644 index d9a8e02666..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag18.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.importTag18.errors.txt -+++ new.importTag18.errors.txt -@@= skipped -0, +0 lines =@@ -- -+b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+b.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.ts (0 errors) ==== -+ export interface Foo {} -+ -+==== b.js (2 errors) ==== -+ /** -+ * @import { -+ ~~~~~~~~~ -+ * Foo -+ ~~~~~~~~~ -+ * } from "./a" -+ ~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param {Foo} a -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function foo(a) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.errors.txt.diff deleted file mode 100644 index 5788185cac..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag19.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.importTag19.errors.txt -+++ new.importTag19.errors.txt -@@= skipped -0, +0 lines =@@ -- -+b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+b.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.ts (0 errors) ==== -+ export interface Foo {} -+ -+==== b.js (2 errors) ==== -+ /** -+ * @import { Foo } -+ ~~~~~~~~~~~~~~~ -+ * from "./a" -+ ~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param {Foo} a -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function foo(a) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.errors.txt.diff deleted file mode 100644 index fceb1047fe..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag2.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.importTag2.errors.txt -+++ new.importTag2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /types.ts (0 errors) ==== -+ export interface Foo { -+ a: number; -+ } -+ -+==== /foo.js (2 errors) ==== -+ /** -+ * @import * as types from "./types" -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param { types.Foo } foo -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function f(foo) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.errors.txt.diff deleted file mode 100644 index 5eecda83df..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag20.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.importTag20.errors.txt -+++ new.importTag20.errors.txt -@@= skipped -0, +0 lines =@@ -- -+b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+b.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.ts (0 errors) ==== -+ export interface Foo {} -+ -+==== b.js (2 errors) ==== -+ /** -+ * @import -+ ~~~~~~~ -+ * { Foo -+ ~~~~~~~~ -+ * } from './a' -+ ~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param {Foo} a -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function foo(a) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag21.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag21.errors.txt.diff deleted file mode 100644 index 51591f8d08..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag21.errors.txt.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.importTag21.errors.txt -+++ new.importTag21.errors.txt -@@= skipped -0, +0 lines =@@ -- -+test.js(1,5): error TS8006: 'import type' declarations can only be used in TypeScript files. -+ -+ -+==== node_modules/tslib/package.json (0 errors) ==== -+ { -+ "name": "tslib", -+ "exports": { -+ ".": { -+ "module": { -+ "types": "./modules/index.d.ts", -+ "default": "./tslib.es6.mjs" -+ }, -+ "import": { -+ "node": "./modules/index.js", -+ "default": { -+ "types": "./modules/index.d.ts", -+ "default": "./tslib.es6.mjs" -+ } -+ }, -+ "default": "./tslib.js" -+ }, -+ "./*": "./*", -+ "./": "./" -+ } -+ } -+ -+==== node_modules/tslib/modules/index.d.ts (0 errors) ==== -+ export {}; -+ -+==== node_modules/tslib/tslib.d.ts (0 errors) ==== -+ export {}; -+ -+==== test.js (1 errors) ==== -+ /** @import * as tslib from "tslib" */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ /** @type {typeof tslib} T */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff deleted file mode 100644 index 4cc94555c2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag23.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.importTag23.errors.txt -+++ new.importTag23.errors.txt -@@= skipped -0, +0 lines =@@ -+/b.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/b.js(5,18): error TS8005: 'implements' clauses can only be used in TypeScript files. - /b.js(6,14): error TS2420: Class 'C' incorrectly implements interface 'I'. - Property 'foo' is missing in type 'C' but required in type 'I'. - -@@= skipped -6, +8 lines =@@ - foo(): void; - } - --==== /b.js (1 errors) ==== -+==== /b.js (3 errors) ==== - /** - * @import * as NS from './a' -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - */ - - /** @implements {NS.I} */ -+ ~~~~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - export class C {} - ~ - !!! error TS2420: Class 'C' incorrectly implements interface 'I'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff deleted file mode 100644 index 9245a6672b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag3.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.importTag3.errors.txt -+++ new.importTag3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /types.ts (0 errors) ==== -+ export default interface Foo { -+ a: number; -+ } -+ -+==== /foo.js (2 errors) ==== -+ /** -+ * @import Foo from "./types" -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param { Foo } foo -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function f(foo) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff deleted file mode 100644 index 8bcf42a98a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag4.errors.txt.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.importTag4.errors.txt -+++ new.importTag4.errors.txt -@@= skipped -0, +0 lines =@@ -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. - /foo.js(2,14): error TS2300: Duplicate identifier 'Foo'. -+/foo.js(6,4): error TS8006: 'import type' declarations can only be used in TypeScript files. - /foo.js(6,14): error TS2300: Duplicate identifier 'Foo'. -+/foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== /types.ts (0 errors) ==== -@@= skipped -6, +9 lines =@@ - a: number; - } - --==== /foo.js (2 errors) ==== -+==== /foo.js (5 errors) ==== - /** - * @import { Foo } from "./types" -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - ~~~ - !!! error TS2300: Duplicate identifier 'Foo'. - */ - - /** - * @import { Foo } from "./types" -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. - ~~~ - !!! error TS2300: Duplicate identifier 'Foo'. - */ - - /** - * @param { Foo } foo -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(foo) {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.errors.txt.diff deleted file mode 100644 index 90833dc98c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag5.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.importTag5.errors.txt -+++ new.importTag5.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/foo.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /types.ts (0 errors) ==== -+ export interface Foo { -+ a: number; -+ } -+ -+==== /foo.js (2 errors) ==== -+ /** -+ * @import { Foo } from "./types" -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param { Foo } foo -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(foo) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.errors.txt.diff deleted file mode 100644 index 62cb42a496..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag6.errors.txt.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.importTag6.errors.txt -+++ new.importTag6.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+/foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /types.ts (0 errors) ==== -+ export interface A { -+ a: number; -+ } -+ export interface B { -+ a: number; -+ } -+ -+==== /foo.js (3 errors) ==== -+ /** -+ * @import { -+ ~~~~~~~~~ -+ * A, -+ ~~~~~~~~~ -+ * B, -+ ~~~~~~~~~ -+ * } from "./types" -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param { A } a -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param { B } b -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(a, b) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.errors.txt.diff deleted file mode 100644 index 933900508c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag7.errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.importTag7.errors.txt -+++ new.importTag7.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /types.ts (0 errors) ==== -+ export interface A { -+ a: number; -+ } -+ export interface B { -+ a: number; -+ } -+ -+==== /foo.js (3 errors) ==== -+ /** -+ * @import { -+ ~~~~~~~~~ -+ * A, -+ ~~~~~ -+ * B } from "./types" -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param { A } a -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param { B } b -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(a, b) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.errors.txt.diff deleted file mode 100644 index cca70041fa..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag8.errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.importTag8.errors.txt -+++ new.importTag8.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /types.ts (0 errors) ==== -+ export interface A { -+ a: number; -+ } -+ export interface B { -+ a: number; -+ } -+ -+==== /foo.js (3 errors) ==== -+ /** -+ * @import -+ ~~~~~~~ -+ * { A, B } -+ ~~~~~~~~~~~ -+ * from "./types" -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param { A } a -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param { B } b -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(a, b) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.errors.txt.diff deleted file mode 100644 index 0ccc93cd39..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTag9.errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.importTag9.errors.txt -+++ new.importTag9.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/foo.js(2,4): error TS8006: 'import type' declarations can only be used in TypeScript files. -+/foo.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+/foo.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /types.ts (0 errors) ==== -+ export interface A { -+ a: number; -+ } -+ export interface B { -+ a: number; -+ } -+ -+==== /foo.js (3 errors) ==== -+ /** -+ * @import -+ ~~~~~~~ -+ * * as types -+ ~~~~~~~~~~~~~ -+ * from "./types" -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ */ -+ -+ /** -+ * @param { types.A } a -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param { types.B } b -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(a, b) {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.errors.txt.diff deleted file mode 100644 index 8dadc95f72..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.errors.txt.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.importTypeInJSDoc.errors.txt -+++ new.importTypeInJSDoc.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(5,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -+index.js(7,22): error TS8016: Type assertion expressions can only be used in TypeScript files. -+index.js(8,22): error TS8016: Type assertion expressions can only be used in TypeScript files. -+ -+ -+==== externs.d.ts (0 errors) ==== -+ declare namespace MyClass { -+ export interface Bar { -+ doer: (x: string) => void; -+ } -+ } -+ declare class MyClass { -+ field: string; -+ static Bar: (x: string, y?: number) => void; -+ constructor(x: MyClass.Bar); -+ } -+ declare global { -+ const Foo: typeof MyClass; -+ } -+ export = MyClass; -+==== index.js (3 errors) ==== -+ /** -+ * @typedef {import("./externs")} Foo -+ */ -+ -+ let a = /** @type {Foo} */(/** @type {*} */(undefined)); -+ ~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ a = new Foo({doer: Foo.Bar}); -+ const q = /** @type {import("./externs").Bar} */({ doer: q => q }); -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ const r = /** @type {typeof import("./externs").Bar} */(r => r); -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff index 3973b36381..d581d2992d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff @@ -3,14 +3,10 @@ @@= skipped -0, +0 lines =@@ - +/a.js(1,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -+/a.js(4,15): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(9,6): error TS8004: Type parameter declarations can only be used in TypeScript files. -+/a.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(14,17): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== /a.js (6 errors) ==== ++==== /a.js (2 errors) ==== + export class C { + + /** @@ -19,12 +15,8 @@ + ~~~~~~~~~~~~~~~~~~ + * @this {T} + ~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T} + ~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static a() { @@ -43,12 +35,8 @@ + ~~~~~~~~~~~~~~~~~~ + * @this {T} + ~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T} + ~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + b() { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff index 1e319bc4c2..9bde4a39c9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff @@ -2,21 +2,14 @@ +++ new.instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt @@= skipped -0, +0 lines =@@ - -+instantiateTemplateTagTypeParameterOnVariableStatement.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+instantiateTemplateTagTypeParameterOnVariableStatement.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. +instantiateTemplateTagTypeParameterOnVariableStatement.js(6,12): error TS8004: Type parameter declarations can only be used in TypeScript files. -+instantiateTemplateTagTypeParameterOnVariableStatement.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== instantiateTemplateTagTypeParameterOnVariableStatement.js (4 errors) ==== ++==== instantiateTemplateTagTypeParameterOnVariableStatement.js (1 errors) ==== + /** + * @template T + * @param {T} a -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {(b: T) => T} -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const seq = a => b => b; + ~~~~~~~~~~~~ @@ -26,7 +19,5 @@ + const text2 = "world"; + + /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var text3 = seq(text1)(text2); + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff deleted file mode 100644 index 33ae5e5251..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- old.jsDeclarationsClassAccessor.errors.txt -+++ new.jsDeclarationsClassAccessor.errors.txt -@@= skipped -0, +0 lines =@@ -- -+argument.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. -+argument.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== supplement.d.ts (0 errors) ==== -+ export { }; -+ declare module "./argument.js" { -+ interface Argument { -+ idlType: any; -+ default: null; -+ } -+ } -+==== base.js (0 errors) ==== -+ export class Base { -+ constructor() { } -+ -+ toJSON() { -+ const json = { type: undefined, name: undefined, inheritance: undefined }; -+ return json; -+ } -+ } -+==== argument.js (2 errors) ==== -+ import { Base } from "./base.js"; -+ export class Argument extends Base { -+ /** -+ * @param {*} tokeniser -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ static parse(tokeniser) { -+ return; -+ } -+ -+ get type() { -+ return "argument"; -+ } -+ -+ /** -+ * @param {*} defs -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ *validate(defs) { } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff index b155cdd10d..5668162016 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff @@ -3,23 +3,19 @@ @@= skipped -0, +0 lines =@@ - +lib.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+lib.js(3,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -+lib.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. + + +==== interface.ts (0 errors) ==== + export interface Encoder { + encode(value: T): Uint8Array + } -+==== lib.js (3 errors) ==== ++==== lib.js (1 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + * @implements {IEncoder} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. + */ + ~~~ + export class Encoder { @@ -28,8 +24,6 @@ + ~~~~~~~ + * @param {T} value + ~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + encode(value) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff index 31ea574ff0..47035117e1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassMethod.errors.txt.diff @@ -8,9 +8,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(36,16): error TS8010: Type annotations can only be used in TypeScript files. -+jsDeclarationsClassMethod.js(37,16): error TS8010: Type annotations can only be used in TypeScript files. -+jsDeclarationsClassMethod.js(38,18): error TS8010: Type annotations can only be used in TypeScript files. +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. @@ -18,7 +15,7 @@ +jsDeclarationsClassMethod.js(61,30): error TS7006: Parameter 'y' implicitly has an 'any' type. + + -+==== jsDeclarationsClassMethod.js (14 errors) ==== ++==== jsDeclarationsClassMethod.js (11 errors) ==== + function C1() { + /** + * A comment prop @@ -67,14 +64,8 @@ + /** + * A comment method1 + * @param {number} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} y -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + method1(x, y) { + return 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 8ffd9670c5..172fe63117 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff @@ -2,43 +2,17 @@ +++ new.jsDeclarationsClasses.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(13,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(24,15): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(30,15): error TS8010: Type annotations can only be used in TypeScript files. +index.js(31,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+index.js(38,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(40,34): error TS8016: Type assertion expressions can only be used in TypeScript files. -+index.js(43,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(48,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(50,34): error TS8016: Type assertion expressions can only be used in TypeScript files. -+index.js(53,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(58,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(59,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(65,15): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(71,15): error TS8010: Type annotations can only be used in TypeScript files. +index.js(72,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+index.js(79,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(84,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(89,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(94,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(97,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(104,15): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(108,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(109,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(111,25): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(115,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(116,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(153,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(161,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(167,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(173,23): error TS8011: Type arguments can only be used in TypeScript files. -+index.js(175,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(183,20): error TS8016: Type assertion expressions can only be used in TypeScript files. + + -+==== index.js (34 errors) ==== ++==== index.js (8 errors) ==== + export class A {} + + export class B { @@ -52,11 +26,7 @@ + export class D { + /** + * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(a, b) {} + } @@ -75,8 +45,6 @@ + ~~~~~~~ + * @type {T & U} + ~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + field; @@ -89,8 +57,6 @@ + ~~~~~~~ + * @type {T & U} + ~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @readonly + ~~~~~~~~~~~~~~~~ + ~~~~~~~~~ @@ -110,22 +76,16 @@ + ~~~~~~~ + * @return {U} + ~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + get f1() { return /** @type {*} */(null); } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + + /** + ~~~~~~~ + * @param {U} _p + ~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + set f1(_p) {} @@ -136,22 +96,16 @@ + ~~~~~~~ + * @return {U} + ~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + get f2() { return /** @type {*} */(null); } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + + /** + ~~~~~~~ + * @param {U} _p + ~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + set f3(_p) {} @@ -162,12 +116,8 @@ + ~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(a, b) {} @@ -180,8 +130,6 @@ + ~~~~~~~ + * @type {string} + ~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static staticField; @@ -194,8 +142,6 @@ + ~~~~~~~ + * @type {string} + ~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @readonly + ~~~~~~~~~~~~~~~~ + ~~~~~~~~~ @@ -215,8 +161,6 @@ + ~~~~~~~ + * @return {string} + ~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static get s1() { return ""; } @@ -227,8 +171,6 @@ + ~~~~~~~ + * @param {string} _p + ~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static set s1(_p) {} @@ -239,8 +181,6 @@ + ~~~~~~~ + * @return {string} + ~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static get s2() { return ""; } @@ -251,8 +191,6 @@ + ~~~~~~~ + * @param {string} _p + ~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + static set s3(_p) {} @@ -275,8 +213,6 @@ + ~~~~~~~ + * @type {T & U} + ~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + field; @@ -285,12 +221,8 @@ + ~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(a, b) {} @@ -308,13 +240,9 @@ + * @param {A} a + ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {B} b + ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + ~~~~~~~ @@ -376,8 +304,6 @@ + ~~~~~~~ + * @param {T} param + ~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(param) { @@ -410,8 +336,6 @@ + ~~~~~~~ + * @param {U} param + ~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(param) { @@ -427,8 +351,6 @@ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + var x = /** @type {*} */(null); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + export class VariableBase extends x {} + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.errors.txt.diff deleted file mode 100644 index fe09bb76cb..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsComputedNames.errors.txt.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.jsDeclarationsComputedNames.errors.txt -+++ new.jsDeclarationsComputedNames.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index2.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (0 errors) ==== -+ const TopLevelSym = Symbol(); -+ const InnerSym = Symbol(); -+ module.exports = { -+ [TopLevelSym](x = 12) { -+ return x; -+ }, -+ items: { -+ [InnerSym]: (arg = {x: 12}) => arg.x -+ } -+ } -+ -+==== index2.js (1 errors) ==== -+ const TopLevelSym = Symbol(); -+ const InnerSym = Symbol(); -+ -+ export class MyClass { -+ static [TopLevelSym] = 12; -+ [InnerSym] = "ok"; -+ /** -+ * @param {typeof TopLevelSym | typeof InnerSym} _p -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(_p = InnerSym) { -+ // switch on _p -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff deleted file mode 100644 index 3187c4a675..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff +++ /dev/null @@ -1,50 +0,0 @@ ---- old.jsDeclarationsDefault.errors.txt -+++ new.jsDeclarationsDefault.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index3.js(2,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -+index4.js(3,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -+ -+ -+==== index1.js (0 errors) ==== -+ export default 12; -+ -+==== index2.js (0 errors) ==== -+ export default function foo() { -+ return foo; -+ } -+ export const x = foo; -+ export { foo as bar }; -+ -+==== index3.js (1 errors) ==== -+ export default class Foo { -+ a = /** @type {Foo} */(null); -+ ~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ }; -+ export const X = Foo; -+ export { Foo as Bar }; -+ -+==== index4.js (1 errors) ==== -+ import Fab from "./index3"; -+ class Bar extends Fab { -+ x = /** @type {Bar} */(null); -+ ~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ } -+ export default Bar; -+ -+==== index5.js (0 errors) ==== -+ // merge type alias and const (OK) -+ export default 12; -+ /** -+ * @typedef {string | number} default -+ */ -+ -+==== index6.js (0 errors) ==== -+ // merge type alias and function (OK) -+ export default function func() {}; -+ /** -+ * @typedef {string | number} default -+ */ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff index b454400a7d..665d647959 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnumTag.errors.txt.diff @@ -3,20 +3,12 @@ @@= skipped -0, +0 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(23,12): error TS8010: Type annotations can only be used in TypeScript files. +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(24,12): error TS8010: Type annotations can only be used in TypeScript files. +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(25,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(28,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(30,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(32,16): error TS8010: Type annotations can only be used in TypeScript files. +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(34,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(38,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (12 errors) ==== ++==== index.js (4 errors) ==== + /** @enum {string} */ + export const Target = { + START: "start", @@ -42,43 +34,27 @@ + * @param {Target} t + ~~~~~~ +!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {Second} s + ~~~~~~ +!!! error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {Fs} f + ~~ +!!! error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function consume(t,s,f) { + /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var str = t + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var num = s + /** @type {(n: number) => number} */ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + 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'? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var v = Target.START + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums + } + /** @param {string} s */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + export function ff(s) { + // element access with arbitrary string is an error only with noImplicitAny + if (!Target[s]) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt.diff deleted file mode 100644 index 6d25a966f3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpression.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.jsDeclarationsExportAssignedClassExpression.errors.txt -+++ new.jsDeclarationsExportAssignedClassExpression.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ module.exports = class Thing { -+ /** -+ * @param {number} p -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(p) { -+ this.t = 12 + p; -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt.diff deleted file mode 100644 index 016a56c4f7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt -+++ new.jsDeclarationsExportAssignedClassExpressionAnonymous.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ module.exports = class { -+ /** -+ * @param {number} p -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(p) { -+ this.t = 12 + p; -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt.diff index 7ca978669d..b6ab682031 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.errors.txt.diff @@ -3,19 +3,16 @@ @@= skipped -0, +0 lines =@@ - +index.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(9,16): error TS2339: Property 'Sub' does not exist on type 'typeof exports'. + + -+==== index.js (3 errors) ==== ++==== index.js (2 errors) ==== + module.exports = class { + ~~~~~~~~~~~~~~~~~~~~~~~~ + /** + ~~~~~~~ + * @param {number} p + ~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(p) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff index a73d15c21c..5e159e01b7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff @@ -5,28 +5,15 @@ +index.js(1,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(3,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(4,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(7,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(11,38): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(12,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(12,58): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(19,13): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(21,38): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(22,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(22,58): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. +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(35,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. +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(45,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. +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`. @@ -37,7 +24,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 (33 errors) ==== ++==== index.js (20 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`. @@ -51,18 +38,10 @@ + + /** + * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function d(a, b) { return /** @type {*} */(null); } -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + Object.defineProperty(module.exports, "d", { value: d }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -77,23 +56,15 @@ + ~~~~~~~~~~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T & U} + ~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function e(a, b) { return /** @type {*} */(null); } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + Object.defineProperty(module.exports, "e", { value: e }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -106,8 +77,6 @@ + ~~~~~~~~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f(a) { @@ -128,11 +97,7 @@ + + /** + * @param {{x: string}} a -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof module.exports.b}} b -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ @@ -146,11 +111,7 @@ + + /** + * @param {{x: string}} a -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof module.exports.b}} b -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff index 0db30bd19e..be95625d15 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff @@ -5,41 +5,28 @@ +context.js(4,14): error TS1340: Module './timer' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./timer')'? +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(6,31): error TS2694: Namespace 'Hook' has no exported member 'HookHandler'. -+context.js(29,12): error TS8010: Type annotations can only be used in TypeScript files. +context.js(34,14): error TS2350: Only a void function can be called with the 'new' keyword. -+context.js(40,16): error TS8010: Type annotations can only be used in TypeScript files. -+context.js(41,16): error TS8010: Type annotations can only be used in TypeScript files. -+context.js(42,18): error TS8010: Type annotations can only be used in TypeScript files. +context.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+hook.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. +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(5,12): error TS8010: Type annotations can only be used in TypeScript files. +hook.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+timer.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== timer.js (1 errors) ==== ++==== timer.js (0 errors) ==== + /** + * @param {number} timeout -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function Timer(timeout) { + this.timeout = timeout; + } + module.exports = Timer; -+==== hook.js (4 errors) ==== ++==== hook.js (2 errors) ==== + /** + * @typedef {(arg: import("./context")) => void} HookHandler -+ ~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~ +!!! 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 -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function Hook(handle) { + this.handle = handle; @@ -48,7 +35,7 @@ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== context.js (9 errors) ==== ++==== context.js (5 errors) ==== + /** + * Imports + * @@ -84,8 +71,6 @@ + * + * @class + * @param {Input} input -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + + function Context(input) { @@ -99,14 +84,8 @@ + Context.prototype = { + /** + * @param {Input} input -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {HookHandler=} handle -+ ~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {State} -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + construct(input, handle = () => void 0) { + return input; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.errors.txt.diff deleted file mode 100644 index 29658f0372..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionJSDoc.errors.txt.diff +++ /dev/null @@ -1,57 +0,0 @@ ---- old.jsDeclarationsFunctionJSDoc.errors.txt -+++ new.jsDeclarationsFunctionJSDoc.errors.txt -@@= skipped -0, +0 lines =@@ -- -+source.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+source.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+source.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. -+source.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. -+source.js(26,18): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== source.js (5 errors) ==== -+ /** -+ * Foos a bar together using an `a` and a `b` -+ * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {string} b -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function foo(a, b) {} -+ -+ /** -+ * Legacy - DO NOT USE -+ */ -+ export class Aleph { -+ /** -+ * Impossible to construct. -+ * @param {Aleph} a -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {null} b -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(a, b) { -+ /** -+ * Field is always null -+ */ -+ this.field = b; -+ } -+ -+ /** -+ * Doesn't actually do anything -+ * @returns {void} -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ doIt() {} -+ } -+ -+ /** -+ * Not the speed of light -+ */ -+ export const c = 12; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff index 6799e70522..ab7bce91b9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses.errors.txt.diff @@ -3,20 +3,13 @@ @@= skipped -0, +0 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'? -+referencer.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+source.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+source.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +source.js(7,16): error TS2350: Only a void function can be called with the 'new' keyword. + + -+==== source.js (3 errors) ==== ++==== source.js (1 errors) ==== + /** + * @param {number} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} y -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function Point(x, y) { + if (!(this instanceof Point)) { @@ -28,15 +21,13 @@ + this.y = y; + } + -+==== referencer.js (2 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'? -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function magnitude(p) { + return Math.sqrt(p.x ** 2 + p.y ** 2); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff index 12344ff2f7..553f356860 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionLikeClasses2.errors.txt.diff @@ -3,21 +3,13 @@ @@= skipped -0, +0 lines =@@ - +referencer.js(3,23): error TS2350: Only a void function can be called with the 'new' keyword. -+source.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +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(13,16): error TS8010: Type annotations can only be used in TypeScript files. -+source.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -+source.js(36,12): error TS8010: Type annotations can only be used in TypeScript files. +source.js(40,16): error TS2350: Only a void function can be called with the 'new' keyword. -+source.js(53,16): error TS8010: Type annotations can only be used in TypeScript files. -+source.js(62,16): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== source.js (8 errors) ==== ++==== source.js (2 errors) ==== + /** + * @param {number} len -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function Vec(len) { + /** @@ -31,8 +23,6 @@ + * @param {Vec} other + ~~~ +!!! error TS2749: 'Vec' refers to a value, but is being used as a type here. Did you mean 'typeof Vec'? -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + dot(other) { + if (other.storage.length !== this.storage.length) { @@ -55,11 +45,7 @@ + + /** + * @param {number} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} y -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function Point2D(x, y) { + if (!(this instanceof Point2D)) { @@ -79,8 +65,6 @@ + }, + /** + * @param {number} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set x(x) { + this.storage[0] = x; @@ -90,8 +74,6 @@ + }, + /** + * @param {number} y -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + set y(y) { + this.storage[1] = y; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff index 5862d1a7da..bf29d0665d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 lines =@@ - +source.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+source.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== source.js (2 errors) ==== ++==== source.js (1 errors) ==== + module.exports = MyClass; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -21,6 +20,4 @@ + * + * @callback DoneCB + * @param {number} failures - Number of failures that occurred. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff index 50cfcbec96..d2687c691a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff @@ -2,28 +2,15 @@ +++ new.jsDeclarationsFunctions.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(14,45): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(14,59): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(20,13): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(22,45): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(22,59): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(38,21): error TS2349: This expression is not callable. + Type '{ y: any; }' has no call signatures. -+index.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(48,21): error TS2349: This expression is not callable. + Type '{ y: any; }' has no call signatures. + + -+==== index.js (17 errors) ==== ++==== index.js (4 errors) ==== + export function a() {} + + export function b() {} @@ -34,18 +21,10 @@ + + /** + * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {number} b -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {string} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export function d(a, b) { return /** @type {*} */(null); } -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + + @@ -55,23 +34,15 @@ + ~~~~~~~~~~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {U} b + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @return {T & U} + ~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + export function e(a, b) { return /** @type {*} */(null); } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + + @@ -81,8 +52,6 @@ + ~~~~~~~~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + export function f(a) { @@ -96,11 +65,7 @@ + + /** + * @param {{x: string}} a -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof b}} b -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function g(a, b) { + return a.x && b.y(); @@ -113,11 +78,7 @@ + + /** + * @param {{x: string}} a -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof b}} b -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function hh(a, b) { + return a.x && b.y(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff index 943c257cf6..4d291444a9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.errors.txt.diff @@ -4,18 +4,12 @@ - +index.js(4,18): error TS2339: Property 'cat' does not exist on type '() => void'. +index.js(7,18): error TS2339: Property 'Cls' does not exist on type '() => void'. -+index.js(14,57): error TS8016: Type assertion expressions can only be used in TypeScript files. -+index.js(22,57): error TS8016: Type assertion expressions can only be used in TypeScript files. +index.js(31,18): error TS2339: Property 'self' does not exist on type '(a: any) => any'. -+index.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. +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(44,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. +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 (11 errors) ==== ++==== index.js (5 errors) ==== + module.exports.a = function a() {} + + module.exports.b = function b() {} @@ -34,8 +28,6 @@ + * @return {string} + */ + module.exports.d = function d(a, b) { return /** @type {*} */(null); } -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** + * @template T,U @@ -44,8 +36,6 @@ + * @return {T & U} + */ + module.exports.e = function e(a, b) { return /** @type {*} */(null); } -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + + /** + * @template T @@ -60,11 +50,7 @@ + + /** + * @param {{x: string}} a -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof module.exports.b}} b -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ @@ -76,11 +62,7 @@ + + /** + * @param {{x: string}} a -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{y: typeof module.exports.b}} b -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff deleted file mode 100644 index 7d2ac5d06e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff +++ /dev/null @@ -1,161 +0,0 @@ ---- old.jsDeclarationsGetterSetter.errors.txt -+++ new.jsDeclarationsGetterSetter.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(33,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(44,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(52,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(66,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(72,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(81,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(85,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(94,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(98,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(107,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(111,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (12 errors) ==== -+ export class A { -+ get x() { -+ return 12; -+ } -+ } -+ -+ export class B { -+ /** -+ * @param {number} _arg -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set x(_arg) { -+ } -+ } -+ -+ export class C { -+ get x() { -+ return 12; -+ } -+ set x(_arg) { -+ } -+ } -+ -+ export class D {} -+ Object.defineProperty(D.prototype, "x", { -+ get() { -+ return 12; -+ } -+ }); -+ -+ export class E {} -+ Object.defineProperty(E.prototype, "x", { -+ /** -+ * @param {number} _arg -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set(_arg) {} -+ }); -+ -+ export class F {} -+ Object.defineProperty(F.prototype, "x", { -+ get() { -+ return 12; -+ }, -+ /** -+ * @param {number} _arg -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set(_arg) {} -+ }); -+ -+ export class G {} -+ Object.defineProperty(G.prototype, "x", { -+ /** -+ * @param {number[]} args -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set(...args) {} -+ }); -+ -+ export class H {} -+ Object.defineProperty(H.prototype, "x", { -+ set() {} -+ }); -+ -+ -+ export class I {} -+ Object.defineProperty(I.prototype, "x", { -+ /** -+ * @param {number} v -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ set: (v) => {} -+ }); -+ -+ /** -+ * @param {number} v -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const jSetter = (v) => {} -+ export class J {} -+ Object.defineProperty(J.prototype, "x", { -+ set: jSetter -+ }); -+ -+ /** -+ * @param {number} v -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const kSetter1 = (v) => {} -+ /** -+ * @param {number} v -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const kSetter2 = (v) => {} -+ export class K {} -+ Object.defineProperty(K.prototype, "x", { -+ set: Math.random() ? kSetter1 : kSetter2 -+ }); -+ -+ /** -+ * @param {number} v -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const lSetter1 = (v) => {} -+ /** -+ * @param {string} v -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const lSetter2 = (v) => {} -+ export class L {} -+ Object.defineProperty(L.prototype, "x", { -+ set: Math.random() ? lSetter1 : lSetter2 -+ }); -+ -+ /** -+ * @param {number | boolean} v -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const mSetter1 = (v) => {} -+ /** -+ * @param {string | boolean} v -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const mSetter2 = (v) => {} -+ export class M {} -+ Object.defineProperty(M.prototype, "x", { -+ set: Math.random() ? mSetter1 : mSetter2 -+ }); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff index 543d0da424..44269de68f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff @@ -6,29 +6,23 @@ - -==== file.js (0 errors) ==== +file.js(4,11): error TS2315: Type 'Object' is not generic. -+file.js(4,11): error TS8010: Type annotations can only be used in TypeScript files. +file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. +file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. +file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +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(6,11): error TS8010: Type annotations can only be used in TypeScript files. +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. -+file2.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -+file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== file.js (7 errors) ==== ++==== file.js (6 errors) ==== /** * @namespace myTypes * @global * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ const myTypes = { // SOME PROPS HERE @@ -56,7 +50,7 @@ export {myTypes}; -==== file2.js (1 errors) ==== -+==== file2.js (6 errors) ==== ++==== 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. @@ -67,8 +61,6 @@ * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ const testFnTypes = { // SOME PROPS HERE @@ -84,11 +76,6 @@ * @param {testFnTypes.input} input - Input. + ~~~~~~~~~~~ +!!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {number|null} Result. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ - function testFn(input) { - if (typeof input === 'number') { \ No newline at end of file + function testFn(input) { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff index ef17a94160..516be88695 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff @@ -3,22 +3,18 @@ @@= skipped -0, +0 lines =@@ - +file.js(4,11): error TS2315: Type 'Object' is not generic. -+file.js(4,11): error TS8010: Type annotations can only be used in TypeScript files. +file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. +file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. +file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +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(6,11): error TS8010: Type annotations can only be used in TypeScript files. +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. -+file2.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -+file2.js(18,14): error TS8010: Type annotations can only be used in TypeScript files. +file2.js(28,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== file2.js (7 errors) ==== ++==== file2.js (4 errors) ==== + const {myTypes} = require('./file.js'); + + /** @@ -27,8 +23,6 @@ + * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const testFnTypes = { + // SOME PROPS HERE @@ -44,11 +38,7 @@ + * @param {testFnTypes.input} input - Input. + ~~~~~~~~~~~ +!!! error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {number|null} Result. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function testFn(input) { + if (typeof input === 'number') { @@ -61,15 +51,13 @@ + module.exports = {testFn, testFnTypes}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== file.js (7 errors) ==== ++==== file.js (6 errors) ==== + /** + * @namespace myTypes + * @global + * @type {Object} + ~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const myTypes = { + // SOME PROPS HERE diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff index fc0ba03484..3c6b8c3b2f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportNamespacedType.errors.txt.diff @@ -2,15 +2,12 @@ +++ new.jsDeclarationsImportNamespacedType.errors.txt @@= skipped -0, +0 lines =@@ - -+file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(2,29): error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. + + -+==== file.js (2 errors) ==== ++==== file.js (1 errors) ==== + import { dummy } from './mod1' + /** @type {import('./mod1').Dotted.Name} - should work */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'Dotted'. + var dot2 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff index 5bc136d0c9..d983ccd590 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsJSDocRedirectedLookups.errors.txt.diff @@ -2,114 +2,63 @@ +++ new.jsDeclarationsJSDocRedirectedLookups.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(5,12): error TS2304: Cannot find name 'Void'. -+index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(6,12): error TS2304: Cannot find name 'Undefined'. -+index.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(7,12): error TS2304: Cannot find name 'Null'. -+index.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(10,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(11,12): error TS2552: Cannot find name 'array'. Did you mean 'Array'? -+index.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(12,12): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? -+index.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(13,12): error TS2315: Type 'Object' is not generic. -+index.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. +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(30,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (25 errors) ==== ++==== index.js (8 errors) ==== + // these are recognized as TS concepts by the checker + /** @type {String} */const a = ""; -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Number} */const b = 0; -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Boolean} */const c = true; -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Void} */const d = undefined; + ~~~~ +!!! error TS2304: Cannot find name 'Void'. -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Undefined} */const e = undefined; + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'Undefined'. -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Null} */const f = null; + ~~~~ +!!! error TS2304: Cannot find name 'Null'. -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + + /** @type {Function} */const g = () => void 0; -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {array} */const i = []; + ~~~~~ +!!! error TS2552: Cannot find name 'array'. Did you mean 'Array'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Array' is declared here. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @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. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @type {Object} */const k = {x: "x"}; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + + + // 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; -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + // @ts-ignore + /** @type {bool} */const m = true; -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + // @ts-ignore + /** @type {int} */const n = true; -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + // @ts-ignore + /** @type {float} */const o = true; -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + // @ts-ignore + /** @type {integer} */const p = true; -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + + // 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'? -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file ++!!! 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/submoduleAccepted/conformance/jsDeclarationsMissingGenerics.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingGenerics.errors.txt.diff deleted file mode 100644 index 64df139f01..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingGenerics.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.jsDeclarationsMissingGenerics.errors.txt -+++ new.jsDeclarationsMissingGenerics.errors.txt -@@= skipped -0, +0 lines =@@ -- -+file.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== file.js (2 errors) ==== -+ /** -+ * @param {Array} x -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function x(x) {} -+ /** -+ * @param {Promise} x -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function y(x) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff index 7f1aaeea10..4740647901 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsMissingTypeParameters.errors.txt.diff @@ -2,23 +2,14 @@ +++ new.jsDeclarationsMissingTypeParameters.errors.txt @@= skipped -0, +0 lines =@@ - -+file.js(2,5): error TS8009: The '?' modifier can only be used in TypeScript files. -+file.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. +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,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== file.js (6 errors) ==== ++==== file.js (2 errors) ==== + /** + * @param {Array=} y desc -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ -+ ~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. + function x(y) { } + + // @ts-ignore @@ -28,8 +19,6 @@ + + /** + * @return {(Array.<> | null)} list of devices -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + ~~ @@ -40,7 +29,5 @@ + /** + * + * @return {?Promise} A promise -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function w() { return null; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff index 98a58766b9..6344763693 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsModuleReferenceHasEmit.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 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(9,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (2 errors) ==== ++==== index.js (1 errors) ==== + /** + * @module A + */ @@ -18,8 +17,6 @@ + * @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`. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + export let el = null; + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff index fec041d231..8ffe7e8556 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.errors.txt.diff @@ -2,28 +2,18 @@ +++ new.jsDeclarationsNestedParams.errors.txt @@= skipped -0, +0 lines =@@ - -+file.js(5,9): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(7,19): error TS8010: Type annotations can only be used in TypeScript files. +file.js(7,26): error TS8020: JSDoc types can only be used inside documentation comments. -+file.js(16,9): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(20,19): error TS8010: Type annotations can only be used in TypeScript files. +file.js(20,26): error TS8020: JSDoc types can only be used inside documentation comments. + + -+==== file.js (6 errors) ==== ++==== 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 TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + */ @@ -35,18 +25,10 @@ + * 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 TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt.diff deleted file mode 100644 index cffe859faa..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps1.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.jsDeclarationsOptionalTypeLiteralProps1.errors.txt -+++ new.jsDeclarationsOptionalTypeLiteralProps1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+foo.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (1 errors) ==== -+ /** -+ * foo -+ * -+ * @public -+ * @param {object} opts -+ * @param {number} opts.a -+ * @param {number} [opts.b] -+ * @param {number} [opts.c] -+ * @returns {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function foo({ a, b, c }) { -+ return a + b + c; -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt.diff index f97b9b3ebe..985ac34538 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsOptionalTypeLiteralProps2.errors.txt.diff @@ -2,13 +2,12 @@ +++ new.jsDeclarationsOptionalTypeLiteralProps2.errors.txt @@= skipped -0, +0 lines =@@ - -+foo.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(11,16): error TS7031: Binding element 'a' implicitly has an 'any' type. +foo.js(11,19): error TS7031: Binding element 'b' implicitly has an 'any' type. +foo.js(11,22): error TS7031: Binding element 'c' implicitly has an 'any' type. + + -+==== foo.js (4 errors) ==== ++==== foo.js (3 errors) ==== + /** + * foo + * @@ -18,8 +17,6 @@ + * @param {number} [opts.b] + * @param {number} [opts.c] + * @returns {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function foo({ a, b, c }) { + ~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff index a6dd054bd3..b2112d421b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff @@ -5,9 +5,6 @@ +base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +file.js(1,15): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? +file.js(4,12): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? -+file.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== base.js (1 errors) ==== @@ -25,7 +22,7 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + -+==== file.js (5 errors) ==== ++==== file.js (2 errors) ==== + /** @typedef {import('./base')} BaseFactory */ + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? @@ -34,8 +31,6 @@ + * @param {import('./base')} factory + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + /** @enum {import('./base')} */ + const couldntThinkOfAny = {} @@ -43,11 +38,7 @@ + /** + * + * @param {InstanceType} base -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {InstanceType} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const test = (base) => { + return base; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff index fef5b188fb..b007854e6e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit2.errors.txt.diff @@ -3,8 +3,6 @@ @@= skipped -0, +0 lines =@@ - +base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -+file.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. + + +==== base.js (1 errors) ==== @@ -22,17 +20,13 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + -+==== file.js (2 errors) ==== ++==== file.js (0 errors) ==== + /** @typedef {typeof import('./base')} BaseFactory */ + + /** + * + * @param {InstanceType} base -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {InstanceType} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const test = (base) => { + return base; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsPrivateFields01.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsPrivateFields01.errors.txt.diff deleted file mode 100644 index 94bb89dc58..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsPrivateFields01.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.jsDeclarationsPrivateFields01.errors.txt -+++ new.jsDeclarationsPrivateFields01.errors.txt -@@= skipped -0, +0 lines =@@ -- -+file.js(12,23): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== file.js (1 errors) ==== -+ export class C { -+ #hello = "hello"; -+ #world = 100; -+ -+ #calcHello() { -+ return this.#hello; -+ } -+ -+ get #screamingHello() { -+ return this.#hello.toUpperCase(); -+ } -+ /** @param value {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ set #screamingHello(value) { -+ throw "NO"; -+ } -+ -+ getWorld() { -+ return this.#world; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.errors.txt.diff deleted file mode 100644 index 5af197c8e5..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.errors.txt.diff +++ /dev/null @@ -1,106 +0,0 @@ ---- old.jsDeclarationsReactComponents.errors.txt -+++ new.jsDeclarationsReactComponents.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsDeclarationsReactComponents2.jsx(3,11): error TS8010: Type annotations can only be used in TypeScript files. -+jsDeclarationsReactComponents3.jsx(3,11): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== jsDeclarationsReactComponents1.jsx (0 errors) ==== -+ /// -+ import React from "react"; -+ import PropTypes from "prop-types" -+ -+ const TabbedShowLayout = ({ -+ }) => { -+ return ( -+
-+ ); -+ }; -+ -+ TabbedShowLayout.propTypes = { -+ version: PropTypes.number, -+ -+ }; -+ -+ TabbedShowLayout.defaultProps = { -+ tabs: undefined -+ }; -+ -+ export default TabbedShowLayout; -+ -+==== jsDeclarationsReactComponents2.jsx (1 errors) ==== -+ import React from "react"; -+ /** -+ * @type {React.SFC} -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const TabbedShowLayout = () => { -+ return ( -+
-+ ok -+
-+ ); -+ }; -+ -+ TabbedShowLayout.defaultProps = { -+ tabs: "default value" -+ }; -+ -+ export default TabbedShowLayout; -+ -+==== jsDeclarationsReactComponents3.jsx (1 errors) ==== -+ import React from "react"; -+ /** -+ * @type {{defaultProps: {tabs: string}} & ((props?: {elem: string}) => JSX.Element)} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const TabbedShowLayout = () => { -+ return ( -+
-+ ok -+
-+ ); -+ }; -+ -+ TabbedShowLayout.defaultProps = { -+ tabs: "default value" -+ }; -+ -+ export default TabbedShowLayout; -+ -+==== jsDeclarationsReactComponents4.jsx (0 errors) ==== -+ import React from "react"; -+ const TabbedShowLayout = (/** @type {{className: string}}*/prop) => { -+ return ( -+
-+ ok -+
-+ ); -+ }; -+ -+ TabbedShowLayout.defaultProps = { -+ tabs: "default value" -+ }; -+ -+ export default TabbedShowLayout; -+==== jsDeclarationsReactComponents5.jsx (0 errors) ==== -+ import React from 'react'; -+ import PropTypes from 'prop-types'; -+ -+ function Tree({ allowDropOnRoot }) { -+ return
-+ } -+ -+ Tree.propTypes = { -+ classes: PropTypes.object, -+ }; -+ -+ Tree.defaultProps = { -+ classes: {}, -+ parentSource: 'parent_id', -+ }; -+ -+ export default Tree; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReexportedCjsAlias.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReexportedCjsAlias.errors.txt.diff deleted file mode 100644 index 0587995303..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReexportedCjsAlias.errors.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.jsDeclarationsReexportedCjsAlias.errors.txt -+++ new.jsDeclarationsReexportedCjsAlias.errors.txt -@@= skipped -0, +0 lines =@@ -- -+lib.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== main.js (0 errors) ==== -+ const { SomeClass, SomeClass: Another } = require('./lib'); -+ -+ module.exports = { -+ SomeClass, -+ Another -+ } -+==== lib.js (1 errors) ==== -+ /** -+ * @param {string} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function bar(a) { -+ return a + a; -+ } -+ -+ class SomeClass { -+ a() { -+ return 1; -+ } -+ } -+ -+ module.exports = { -+ bar, -+ SomeClass -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt.diff index 99ec32649f..a4400a9598 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReferenceToClassInstanceCrossFile.errors.txt.diff @@ -4,7 +4,6 @@ - +index.js(7,19): error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? +index.js(14,18): error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? -+index.js(14,18): error TS8010: Type annotations can only be used in TypeScript files. + + +==== test.js (0 errors) ==== @@ -21,7 +20,7 @@ + } + + module.exports = { Rectangle }; -+==== index.js (3 errors) ==== ++==== index.js (2 errors) ==== + const {Rectangle} = require('./rectangle'); + + class Render { @@ -40,8 +39,6 @@ + * @returns {Rectangle} the rect + ~~~~~~~~~ +!!! error TS2749: 'Rectangle' refers to a value, but is being used as a type here. Did you mean 'typeof Rectangle'? -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + addRectangle() { + const obj = new Rectangle(); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff index e9f2ce081f..84a007210a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt.diff @@ -2,67 +2,43 @@ +++ new.jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+index.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+index.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(22,12): error TS2315: Type 'Object' is not generic. -+index.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(22,18): error TS8020: JSDoc types can only be used inside documentation comments. + + -+==== index.js (12 errors) ==== ++==== index.js (4 errors) ==== + /** @type {?} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + export const a = null; + + /** @type {*} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + export const b = null; + + /** @type {string?} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + export const c = null; + + /** @type {string=} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + export const d = null; + + /** @type {string!} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + export const g = null; + + /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. + 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 b97965ebc9..28c1441a5e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReusesExistingTypeAnnotations.errors.txt.diff @@ -2,44 +2,22 @@ +++ new.jsDeclarationsReusesExistingTypeAnnotations.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(11,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(44,9): error TS1051: A 'set' accessor cannot have an optional parameter. -+index.js(44,9): error TS8009: The '?' modifier can only be used in TypeScript files. -+index.js(44,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(54,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(64,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(74,17): error TS8010: Type annotations can only be used in TypeScript files. +index.js(82,9): error TS1051: A 'set' accessor cannot have an optional parameter. -+index.js(82,9): error TS8009: The '?' modifier can only be used in TypeScript files. -+index.js(82,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(87,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(92,17): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(97,17): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (16 errors) ==== ++==== index.js (2 errors) ==== + class С1 { + /** @type {string=} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + p1 = undefined; + + /** @type {string | undefined} */ -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + p2 = undefined; + + /** @type {?string} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + p3 = null; + + /** @type {string | null} */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + p4 = null; + } + @@ -75,10 +53,6 @@ + /** @param {string=} value */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1051: A 'set' accessor cannot have an optional parameter. -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + set p1(value) { + this.p1 = value; + } @@ -89,8 +63,6 @@ + } + + /** @param {string | undefined} value */ -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + set p2(value) { + this.p2 = value; + } @@ -101,8 +73,6 @@ + } + + /** @param {?string} value */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + set p3(value) { + this.p3 = value; + } @@ -113,8 +83,6 @@ + } + + /** @param {string | null} value */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + set p4(value) { + this.p4 = value; + } @@ -125,31 +93,21 @@ + /** @param {string=} value */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1051: A 'set' accessor cannot have an optional parameter. -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + set p1(value) { + this.p1 = value; + } + + /** @param {string | undefined} value */ -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + set p2(value) { + this.p2 = value; + } + + /** @param {?string} value */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + set p3(value) { + this.p3 = value; + } + + /** @param {string | null} value */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + set p4(value) { + this.p4 = value; + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff deleted file mode 100644 index 6a672cfc91..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt -+++ new.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (2 errors) ==== -+ export class Super { -+ /** -+ * @param {string} firstArg -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {string} secondArg -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ constructor(firstArg, secondArg) { } -+ } -+ -+ export class Sub extends Super { -+ constructor() { -+ super('first', 'second'); -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff deleted file mode 100644 index cd400cd8ef..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsDeclarationsThisTypes.errors.txt -+++ new.jsDeclarationsThisTypes.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ export class A { -+ /** @returns {this} */ -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ method() { -+ return this; -+ } -+ } -+ export default class Base extends A { -+ // This method is required to reproduce #35932 -+ verify() { } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff index a2e90f9e10..87be54e949 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff @@ -2,14 +2,10 @@ +++ new.jsDeclarationsTypeAliases.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. -+mixed.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+mixed.js(6,14): error TS8010: Type annotations can only be used in TypeScript files. +mixed.js(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== index.js (2 errors) ==== ++==== index.js (0 errors) ==== + export {}; // flag file as module + /** + * @typedef {string | number | symbol} PropName @@ -20,8 +16,6 @@ + * + * @callback NumberToStringCb + * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {string} + */ + @@ -36,22 +30,16 @@ + * @template T + * @callback Identity + * @param {T} x -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + */ + -+==== mixed.js (3 errors) ==== ++==== mixed.js (1 errors) ==== + /** + * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType + */ + /** + * @param {number} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {SomeType} -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + function doTheThing(x) { + return {x: ""+x}; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt.diff deleted file mode 100644 index b680283829..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReassignmentFromDeclaration.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.jsDeclarationsTypeReassignmentFromDeclaration.errors.txt -+++ new.jsDeclarationsTypeReassignmentFromDeclaration.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /some-mod.d.ts (0 errors) ==== -+ interface Item { -+ x: string; -+ } -+ declare const items: Item[]; -+ export = items; -+==== index.js (1 errors) ==== -+ /** @type {typeof import("/some-mod")} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const items = []; -+ module.exports = items; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff index 7f1e67e057..63315a780b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 lines =@@ - +conn.js(11,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+usage.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. +usage.js(11,37): error TS2694: Namespace 'Conn' has no exported member 'Whatever'. +usage.js(16,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + @@ -23,7 +22,7 @@ + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== usage.js (3 errors) ==== ++==== usage.js (2 errors) ==== + /** + * @typedef {import("./conn")} Conn + */ @@ -31,8 +30,6 @@ + class Wrap { + /** + * @param {Conn} c -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(c) { + this.connItem = c.item; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff index 1e7e95b275..cbea1dc733 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff @@ -2,22 +2,18 @@ +++ new.jsDeclarationsTypedefAndLatebound.errors.txt @@= skipped -0, +0 lines =@@ - -+LazySet.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. +LazySet.js(13,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (1 errors) ==== ++==== index.js (0 errors) ==== + const LazySet = require("./LazySet"); + + /** @type {LazySet} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + 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 @@ -25,8 +21,6 @@ + class LazySet { + /** + * @param {LazySet} iterable -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + addAll(iterable) {} + [Symbol.iterator]() {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.errors.txt.diff deleted file mode 100644 index c936fbdd96..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefFunction.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.jsDeclarationsTypedefFunction.errors.txt -+++ new.jsDeclarationsTypedefFunction.errors.txt -@@= skipped -0, +0 lines =@@ -- -+foo.js(3,10): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (3 errors) ==== -+ /** -+ * @typedef {{ -+ * [id: string]: [Function, Function]; -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * }} ResolveRejectMap -+ */ -+ -+ let id = 0 -+ -+ /** -+ * @param {ResolveRejectMap} handlers -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {Promise} -+ ~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const send = handlers => new Promise((resolve, reject) => { -+ handlers[++id] = [resolve, reject] -+ }) \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff index 22947afeb7..a95ad05e93 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff @@ -3,16 +3,12 @@ @@= skipped -0, +0 lines =@@ - +index.js(3,37): error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. -+index.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(16,16): error TS8010: Type annotations can only be used in TypeScript files. +index.js(21,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+module.js(11,11): error TS8010: Type annotations can only be used in TypeScript files. +module.js(24,12): error TS2315: Type 'Object' is not generic. -+module.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. +module.js(27,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== index.js (4 errors) ==== ++==== index.js (2 errors) ==== + const {taskGroups, taskNameToGroup} = require('./module.js'); + + /** @typedef {import('./module.js').TaskGroup} TaskGroup */ @@ -30,11 +26,7 @@ + class MainThreadTasks { + /** + * @param {TaskGroup} x -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {TaskNode} y -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(x, y){} + } @@ -42,7 +34,7 @@ + module.exports = MainThreadTasks; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== module.js (4 errors) ==== ++==== module.js (2 errors) ==== + /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ + + /** @@ -54,8 +46,6 @@ + + /** + * @type {{[P in TaskGroupIds]: {id: P, label: string}}} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const taskGroups = { + parseHTML: { @@ -71,8 +61,6 @@ + /** @type {Object} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const taskNameToGroup = {}; + + module.exports = { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt.diff deleted file mode 100644 index 82e983d6fc..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsUniqueSymbolUsage.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.jsDeclarationsUniqueSymbolUsage.errors.txt -+++ new.jsDeclarationsUniqueSymbolUsage.errors.txt -@@= skipped -0, +0 lines =@@ -- -+b.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. -+b.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (0 errors) ==== -+ export const kSymbol = Symbol("my-symbol"); -+ -+ /** -+ * @typedef {{[kSymbol]: true}} WithSymbol -+ */ -+==== b.js (2 errors) ==== -+ /** -+ * @returns {import('./a').WithSymbol} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {import('./a').WithSymbol} value -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function b(value) { -+ return value; -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.errors.txt.diff deleted file mode 100644 index 0a0b39828d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocBindingInUnreachableCode.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.jsdocBindingInUnreachableCode.errors.txt -+++ new.jsdocBindingInUnreachableCode.errors.txt -@@= skipped -0, +0 lines =@@ -- -+bug27341.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== bug27341.js (1 errors) ==== -+ if (false) { -+ /** -+ * @param {string} s -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ const x = function (s) { -+ }; -+ } -+ \ No newline at end of file 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 61f9e009ba..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocCatchClauseWithTypeAnnotation.errors.txt.diff +++ /dev/null @@ -1,146 +0,0 @@ ---- old.jsdocCatchClauseWithTypeAnnotation.errors.txt -+++ new.jsdocCatchClauseWithTypeAnnotation.errors.txt -@@= skipped -0, +0 lines =@@ -+foo.js(11,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(12,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(13,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(14,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(16,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(17,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(18,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(19,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(20,31): error TS8010: Type annotations can only be used in TypeScript files. - foo.js(20,54): error TS2339: Property 'foo' does not exist on type 'unknown'. -+foo.js(21,31): error TS8010: Type annotations can only be used in TypeScript files. - 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(22,31): error TS8010: Type annotations can only be used in TypeScript files. - foo.js(23,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. -+foo.js(23,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(27,23): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(34,14): error TS8010: Type annotations can only be used in TypeScript files. - foo.js(35,7): error TS2492: Cannot redeclare identifier 'err' in catch clause. -+foo.js(39,14): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(44,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(45,31): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(46,31): error TS8010: Type annotations can only be used in TypeScript files. - foo.js(46,45): error TS2339: Property 'x' does not exist on type '{}'. -+foo.js(47,31): error TS8010: Type annotations can only be used in TypeScript files. - 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(48,31): error TS8010: Type annotations can only be used in TypeScript files. - foo.js(49,31): error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. -- -- --==== foo.js (9 errors) ==== -+foo.js(49,31): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (30 errors) ==== - /** - * @typedef {any} Any - */ -@@= skipped -20, +41 lines =@@ - function fn() { - try { } catch (x) { } // should be OK - try { } catch (/** @type {any} */ err) { } // should be OK -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {Any} */ err) { } // should be OK -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {unknown} */ err) { } // should be OK -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {Unknown} */ err) { } // should be OK -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (err) { err.foo; } // should be OK - try { } catch (/** @type {any} */ err) { err.foo; } // should be OK -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {Any} */ err) { err.foo; } // should be OK -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {unknown} */ err) { console.log(err); } // should be OK -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {Unknown} */ err) { console.log(err); } // should be OK -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {unknown} */ err) { err.foo; } // error in the body -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~ - !!! error TS2339: Property 'foo' does not exist on type 'unknown'. - try { } catch (/** @type {Unknown} */ err) { err.foo; } // error in the body -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~ - !!! 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. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {object} */ err) { } // error in the type - ~~~~~~ - !!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - - try { console.log(); } - // @ts-ignore - catch (/** @type {number} */ err) { // e should not be a `number` -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - console.log(err.toLowerCase()); - } - -@@= skipped -31, +57 lines =@@ - try { } - catch (err) { - /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - let err; - ~~~ - !!! error TS2492: Cannot redeclare identifier 'err' in catch clause. -@@= skipped -7, +9 lines =@@ - try { } - catch (err) { - /** @type {boolean} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var err; - } - - try { } catch ({ x }) { } // should be OK - try { } catch (/** @type {any} */ { x }) { x.foo; } // should be OK -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {Any} */ { x }) { x.foo;} // should be OK -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {unknown} */ { x }) { console.log(x); } // error in the destructure -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ - !!! error TS2339: Property 'x' does not exist on type '{}'. - try { } catch (/** @type {Unknown} */ { x }) { console.log(x); } // error in the destructure -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ - !!! 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. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - try { } catch (/** @type {object} */ { x }) { } // error in the type - ~~~~~~ - !!! error TS1196: Catch clause variable type annotation must be 'any' or 'unknown' if specified. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff index 1542802ffa..1dd3554bc8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocConstructorFunctionTypeReference.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 lines =@@ - +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(8,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocConstructorFunctionTypeReference.js (2 errors) ==== ++==== jsdocConstructorFunctionTypeReference.js (1 errors) ==== + var Validator = function VFunc() { + this.flags = "gim" + }; @@ -17,8 +16,6 @@ + * @param {Validator} state + ~~~~~~~~~ +!!! error TS2749: 'Validator' refers to a value, but is being used as a type here. Did you mean 'typeof Validator'? -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var validateRegExpFlags = function(state) { + return state.flags diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff index 5e7e98203f..6b6ecc5911 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff @@ -7,34 +7,25 @@ - -==== functions.js (1 errors) ==== +functions.js(3,13): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+functions.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +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(13,13): error TS8010: Type annotations can only be used in TypeScript files. +functions.js(15,14): error TS7006: Parameter 'c' implicitly has an 'any' type. -+functions.js(20,17): error TS8010: Type annotations can only be used in TypeScript files. +functions.js(30,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+functions.js(30,12): error TS8010: Type annotations can only be used in TypeScript files. +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(36,12): error TS8010: Type annotations can only be used in TypeScript files. +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(49,13): error TS8010: Type annotations can only be used in TypeScript files. +functions.js(51,26): error TS7006: Parameter 'dref' implicitly has an 'any' type. -+functions.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. +functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type. + + -+==== functions.js (18 errors) ==== ++==== functions.js (11 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id1(c) { + ~ @@ -52,8 +43,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ function id2(c) { + ~ @@ -61,22 +50,13 @@ return c } - class C { - /** @param {number} n */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor(n) { - this.length = n; - } -@@= skipped -32, +66 lines =@@ +@@= skipped -32, +53 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var f = function (ab, onetwo) { return ab === "a" ? 3 : 4; } + ~~ +!!! error TS7006: Parameter 'ab' implicitly has an 'any' type. @@ -85,21 +65,12 @@ /** - * @constructor - * @param {number} n -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function D(n) { - this.length = n; -@@= skipped -19, +30 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'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ var construct = function(dref) { return new dref(33); } + ~~~~ @@ -107,16 +78,7 @@ var z3 = construct(D); z3.length; -@@= skipped -9, +15 lines =@@ - /** - * @constructor - * @param {number} n -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - var E = function(n) { - this.not_length_on_purpose = n; -@@= skipped -7, +9 lines =@@ +@@= skipped -16, +20 lines =@@ var y3 = id2(E); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplementsTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplementsTag.errors.txt.diff deleted file mode 100644 index d2b7121db0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplementsTag.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.jsdocImplementsTag.errors.txt -+++ new.jsdocImplementsTag.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(6,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ /** -+ * @typedef { { foo: string } } A -+ */ -+ -+ /** -+ * @implements { A } -+ ~~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. -+ */ -+ class B { -+ foo = '' -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.errors.txt.diff deleted file mode 100644 index 36de9321b4..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_class.errors.txt.diff +++ /dev/null @@ -1,49 +0,0 @@ ---- old.jsdocImplements_class.errors.txt -+++ new.jsdocImplements_class.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(2,18): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(5,18): error TS8005: 'implements' clauses can only be used in TypeScript files. -+/a.js(10,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -+/a.js(12,18): error TS8010: Type annotations can only be used in TypeScript files. - /a.js(13,5): error TS2416: Property 'method' in type 'B2' is not assignable to the same property in base type 'A'. - Type '() => string' is not assignable to type '() => number'. - Type 'string' is not assignable to type 'number'. -+/a.js(16,18): error TS8005: 'implements' clauses can only be used in TypeScript files. - /a.js(17,7): error TS2720: Class 'B3' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? - Property 'method' is missing in type 'B3' but required in type 'A'. - - --==== /a.js (2 errors) ==== -+==== /a.js (7 errors) ==== - class A { - /** @return {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - method() { throw new Error(); } - } - /** @implements {A} */ -+ ~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B { - method() { return 0 } - } - - /** @implements A */ -+ ~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B2 { - /** @return {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - method() { return "" } - ~~~~~~ - !!! error TS2416: Property 'method' in type 'B2' is not assignable to the same property in base type 'A'. -@@= skipped -25, +38 lines =@@ - } - - /** @implements {A} */ -+ ~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B3 { - ~~ - !!! error TS2720: Class 'B3' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface.errors.txt.diff deleted file mode 100644 index b185b93244..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface.errors.txt.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.jsdocImplements_interface.errors.txt -+++ new.jsdocImplements_interface.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(1,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -+/a.js(7,18): error TS8005: 'implements' clauses can only be used in TypeScript files. - /a.js(9,5): error TS2416: Property 'mNumber' in type 'B2' is not assignable to the same property in base type 'A'. - Type '() => string' is not assignable to type '() => number'. - Type 'string' is not assignable to type 'number'. -+/a.js(13,17): error TS8005: 'implements' clauses can only be used in TypeScript files. - /a.js(14,7): error TS2420: Class 'B3' incorrectly implements interface 'A'. - Property 'mNumber' is missing in type 'B3' but required in type 'A'. - -@@= skipped -8, +11 lines =@@ - interface A { - mNumber(): number; - } --==== /a.js (2 errors) ==== -+==== /a.js (5 errors) ==== - /** @implements A */ -+ ~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B { - mNumber() { - return 0; - } - } - /** @implements {A} */ -+ ~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B2 { - mNumber() { - ~~~~~~~ -@@= skipped -18, +22 lines =@@ - } - } - /** @implements A */ -+ ~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B3 { - ~~ - !!! error TS2420: Class 'B3' incorrectly implements interface 'A'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface_multiple.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface_multiple.errors.txt.diff deleted file mode 100644 index bddb4ec339..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_interface_multiple.errors.txt.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.jsdocImplements_interface_multiple.errors.txt -+++ new.jsdocImplements_interface_multiple.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(2,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -+/a.js(14,16): error TS8005: 'implements' clauses can only be used in TypeScript files. - /a.js(17,7): error TS2420: Class 'BadSquare' incorrectly implements interface 'Drawable'. - Property 'draw' is missing in type 'BadSquare' but required in type 'Drawable'. - -@@= skipped -8, +10 lines =@@ - interface Sizable { - size(): number; - } --==== /a.js (1 errors) ==== -+==== /a.js (3 errors) ==== - /** - * @implements {Drawable} -+ ~~~~~~~~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - * @implements Sizable - **/ - class Square { -@@= skipped -15, +17 lines =@@ - } - /** - * @implements Drawable -+ ~~~~~~~~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - * @implements {Sizable} - **/ - class BadSquare { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_missingType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_missingType.errors.txt.diff index 3d11cbb353..7a27f9d761 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_missingType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_missingType.errors.txt.diff @@ -2,15 +2,14 @@ +++ new.jsdocImplements_missingType.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(2,16): error TS1003: Identifier expected. -+/a.js(2,16): error TS8005: 'implements' clauses can only be used in TypeScript files. - - - ==== /a.js (1 errors) ==== - class A { constructor() { this.x = 0; } } - /** @implements */ - +- +- +-==== /a.js (1 errors) ==== +- class A { constructor() { this.x = 0; } } +- /** @implements */ +- -!!! error TS1003: Identifier expected. -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B { - } - \ No newline at end of file +- class B { +- } +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_namespacedInterface.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_namespacedInterface.errors.txt.diff deleted file mode 100644 index 3f0c5d1f6b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_namespacedInterface.errors.txt.diff +++ /dev/null @@ -1,35 +0,0 @@ ---- old.jsdocImplements_namespacedInterface.errors.txt -+++ new.jsdocImplements_namespacedInterface.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(1,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -+/a.js(7,18): error TS8005: 'implements' clauses can only be used in TypeScript files. -+ -+ -+==== /defs.d.ts (0 errors) ==== -+ declare namespace N { -+ interface A { -+ mNumber(): number; -+ } -+ interface AT { -+ gen(): T; -+ } -+ } -+==== /a.js (2 errors) ==== -+ /** @implements N.A */ -+ ~~~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. -+ class B { -+ mNumber() { -+ return 0; -+ } -+ } -+ /** @implements {N.AT} */ -+ ~~~~~~~~~~~~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. -+ class BAT { -+ gen() { -+ return ""; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_properties.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_properties.errors.txt.diff deleted file mode 100644 index 6f53e5c0c0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_properties.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.jsdocImplements_properties.errors.txt -+++ new.jsdocImplements_properties.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(2,17): error TS8005: 'implements' clauses can only be used in TypeScript files. - /a.js(3,7): error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? - Property 'x' is missing in type 'B' but required in type 'A'. -- -- --==== /a.js (1 errors) ==== -+/a.js(5,17): error TS8005: 'implements' clauses can only be used in TypeScript files. -+/a.js(10,18): error TS8005: 'implements' clauses can only be used in TypeScript files. -+ -+ -+==== /a.js (4 errors) ==== - class A { constructor() { this.x = 0; } } - /** @implements A*/ -+ ~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B {} - ~ - !!! error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass? -@@= skipped -11, +16 lines =@@ - !!! related TS2728 /a.js:1:27: 'x' is declared here. - - /** @implements A*/ -+ ~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B2 { - x = 10 - } - - /** @implements {A}*/ -+ ~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B3 { - constructor() { this.x = 10 } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_signatures.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_signatures.errors.txt.diff deleted file mode 100644 index 41a0bf7220..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImplements_signatures.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.jsdocImplements_signatures.errors.txt -+++ new.jsdocImplements_signatures.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(1,18): error TS8005: 'implements' clauses can only be used in TypeScript files. - /a.js(2,7): error TS2420: Class 'B' incorrectly implements interface 'Sig'. - Index signature for type 'string' is missing in type 'B'. - -@@= skipped -5, +6 lines =@@ - interface Sig { - [index: string]: string - } --==== /a.js (1 errors) ==== -+==== /a.js (2 errors) ==== - /** @implements {Sig} */ -+ ~~~ -+!!! error TS8005: 'implements' clauses can only be used in TypeScript files. - class B { - ~ - !!! error TS2420: Class 'B' incorrectly implements interface 'Sig'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.errors.txt.diff deleted file mode 100644 index bfea2f6c4d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.jsdocImportType.errors.txt -+++ new.jsdocImportType.errors.txt -@@= skipped -0, +0 lines =@@ -- -+use.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -+use.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== use.js (2 errors) ==== -+ /// -+ /** @typedef {import("./mod1")} C -+ * @type {C} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ var c; -+ c.chunk; -+ -+ const D = require("./mod1"); -+ /** @type {D} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ 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/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff deleted file mode 100644 index 4123c62a2a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportType2.errors.txt.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.jsdocImportType2.errors.txt -+++ new.jsdocImportType2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+use.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. -+use.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== use.js (2 errors) ==== -+ /// -+ /** @typedef {import("./mod1")} C -+ * @type {C} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ var c; -+ c.chunk; -+ -+ const D = require("./mod1"); -+ /** @type {D} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ 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/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff index d26a351f65..475e063877 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToClassAlias.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 lines =@@ - +test.js(1,32): error TS2694: Namespace '"mod1"' has no exported member 'C'. -+test.js(2,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== mod1.js (0 errors) ==== @@ -12,13 +11,11 @@ + } + module.exports.C = C + -+==== test.js (2 errors) ==== ++==== test.js (1 errors) ==== + /** @typedef {import('./mod1').C} X */ + ~ +!!! error TS2694: Namespace '"mod1"' has no exported member 'C'. + /** @param {X} c */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + 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 index c640d056d1..22c4d013c0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToCommonjsModule.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 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')'? -+test.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== ex.d.ts (0 errors) ==== @@ -12,12 +11,10 @@ + } + export = config; + -+==== test.js (2 errors) ==== ++==== 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')'? -+ ~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + 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 index cb091d9735..8f62d8a48b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToESModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToESModule.errors.txt.diff @@ -3,18 +3,15 @@ @@= skipped -0, +0 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')'? -+test.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== ex.d.ts (0 errors) ==== + export var config: {} + -+==== test.js (2 errors) ==== ++==== 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')'? -+ ~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + 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 index ef9721d179..2443dbe9b5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocImportTypeReferenceToStringLiteral.errors.txt.diff @@ -2,17 +2,14 @@ +++ new.jsdocImportTypeReferenceToStringLiteral.errors.txt @@= skipped -0, +0 lines =@@ - -+a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(1,26): error TS2694: Namespace '"b"' has no exported member 'FOO'. + + +==== b.js (0 errors) ==== + export const FOO = "foo"; + -+==== a.js (2 errors) ==== ++==== a.js (1 errors) ==== + /** @type {import('./b').FOO} */ -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! 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 073c878fec..50285f14a6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocIndexSignature.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocIndexSignature.errors.txt.diff @@ -6,49 +6,37 @@ - -==== indices.js (1 errors) ==== +indices.js(1,12): error TS2315: Type 'Object' is not generic. -+indices.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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,12): error TS8010: Type annotations can only be used in TypeScript files. +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,12): error TS8010: Type annotations can only be used in TypeScript files. +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,13): error TS8010: Type annotations can only be used in TypeScript files. +indices.js(7,19): error TS8020: JSDoc types can only be used inside documentation comments. + + -+==== indices.js (12 errors) ==== ++==== indices.js (8 errors) ==== /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. var o1; /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. var o2; /** @type {Object.} */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. var o3; /** @param {Object.} o */ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8020: JSDoc types can only be used inside documentation comments. function f(o) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.errors.txt.diff deleted file mode 100644 index d7a0750eb3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocLiteral.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.jsdocLiteral.errors.txt -+++ new.jsdocLiteral.errors.txt -@@= skipped -0, +0 lines =@@ -- -+in.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+in.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+in.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+in.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+in.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== in.js (5 errors) ==== -+ /** -+ * @param {'literal'} p1 -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {"literal"} p2 -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {'literal' | 'other'} p3 -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {'literal' | number} p4 -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {12 | true | 'str'} p5 -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(p1, p2, p3, p4, p5) { -+ return p1 + p2 + p3 + p4 + p5 + '.'; -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.errors.txt.diff deleted file mode 100644 index b76bf336f4..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocNeverUndefinedNull.errors.txt.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.jsdocNeverUndefinedNull.errors.txt -+++ new.jsdocNeverUndefinedNull.errors.txt -@@= skipped -0, +0 lines =@@ -- -+in.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+in.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+in.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+in.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== in.js (4 errors) ==== -+ /** -+ * @param {never} p1 -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {undefined} p2 -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {null} p3 -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {void} nothing -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(p1, p2, p3) { -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff index 85b9ef4d5f..dcc2f56e2b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters1.errors.txt.diff @@ -6,19 +6,16 @@ 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(1,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (4 errors) ==== -+==== jsdocOuterTypeParameters1.js (3 errors) ==== ++==== jsdocOuterTypeParameters1.js (2 errors) ==== /** @return {T} */ ~ !!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const dedupingMixin = function(mixin) {}; /** @template {T} */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff index e6c2813b41..da32259324 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOuterTypeParameters2.errors.txt.diff @@ -5,20 +5,16 @@ - 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(1,14): error TS8010: Type annotations can only be used in TypeScript files. 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 (3 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'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const dedupingMixin = function(mixin) {}; /** @template T */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff deleted file mode 100644 index 68db191e5d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff +++ /dev/null @@ -1,39 +0,0 @@ ---- old.jsdocOverrideTag1.errors.txt -+++ new.jsdocOverrideTag1.errors.txt -@@= skipped -0, +0 lines =@@ -+0.js(5,16): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(20,16): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(21,18): error TS8010: Type annotations can only be used in TypeScript files. - 0.js(27,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'A'. - 0.js(32,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. - 0.js(40,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. - - --==== 0.js (3 errors) ==== -+==== 0.js (7 errors) ==== - class A { - - /** - * @method - * @param {string | number} a -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {boolean} -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - foo (a) { - return typeof a === 'string' -@@= skipped -23, +31 lines =@@ - * @override - * @method - * @param {string | number} a -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {boolean} -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - foo (a) { - return super.foo(a) \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.errors.txt.diff index b4afeb938f..04a0106ed7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.errors.txt.diff @@ -3,141 +3,16 @@ @@= skipped -0, +0 lines =@@ -0.js(68,19): error TS2339: Property 'a' does not exist on type 'String'. -0.js(68,22): error TS2339: Property 'b' does not exist on type 'String'. -+0.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(26,4): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(33,4): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(36,4): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(41,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(43,4): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(50,4): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(56,12): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(66,12): error TS8010: Type annotations can only be used in TypeScript files. 0.js(70,20): error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name. -- -- + + -==== 0.js (3 errors) ==== -+0.js(71,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== 0.js (20 errors) ==== ++==== 0.js (1 errors) ==== // Object literal syntax /** * @param {{a: string, b: string}} obj -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -71, +69 lines =@@ * @param {string} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function good1({a, b}, x) {} - /** - * @param {{a: string, b: string}} obj -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {{c: number, d: number}} OBJECTION -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function good2({a, b}, {c, d}) {} - /** - * @param {number} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {{a: string, b: string}} obj -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} y -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function good3(x, {a, b}, y) {} - /** - * @param {{a: string, b: string}} obj -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function good4({a, b}) {} - -@@= skipped -29, +62 lines =@@ - /** - * @param {Object} obj - * @param {string} obj.a - this is like the saddest way to specify a type -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {string} obj.b - but it sure does allow a lot of documentation -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {string} x -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function good5({a, b}, x) {} - /** - * @param {Object} obj - * @param {string} obj.a -+ ~~~~~~~~~~~~~~~~~~~~~ - * @param {string} obj.b - but it sure does allow a lot of documentation -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {Object} OBJECTION - documentation here too -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} OBJECTION.c -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {string} OBJECTION.d - meh -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function good6({a, b}, {c, d}) {} - /** - * @param {number} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {Object} obj - * @param {string} obj.a -+ ~~~~~~~~~~~~~~~~~~~~~ - * @param {string} obj.b -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {string} y -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function good7(x, {a, b}, y) {} - /** - * @param {Object} obj - * @param {string} obj.a -+ ~~~~~~~~~~~~~~~~~~~~~ - * @param {string} obj.b -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function good8({a, b}) {} - - /** - * @param {{ a: string }} argument -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function good9({ a }) { - console.log(arguments, a); -@@= skipped -40, +68 lines =@@ - * @param {string} obj.a - * @param {string} obj.b - and x's type gets used for both parameters - * @param {string} x -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ function bad1(x, {a, b}) {} - ~ @@ -146,11 +21,4 @@ -!!! error TS2339: Property 'b' does not exist on type 'String'. /** * @param {string} y - here, y's type gets ignored but obj's is fine - ~ - !!! error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name. - * @param {{a: string, b: string}} obj -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function bad2(x, {a, b}) {} - \ No newline at end of file + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff deleted file mode 100644 index 94064170f3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.errors.txt.diff +++ /dev/null @@ -1,102 +0,0 @@ ---- old.jsdocParamTagTypeLiteral.errors.txt -+++ new.jsdocParamTagTypeLiteral.errors.txt -@@= skipped -0, +0 lines =@@ -+0.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. - 0.js(3,20): error TS8024: JSDoc '@param' tag has name 'unrelated', but there is no parameter with that name. -- -- --==== 0.js (1 errors) ==== -+0.js(12,4): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(25,4): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(36,4): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(45,4): error TS8010: Type annotations can only be used in TypeScript files. -+0.js(58,4): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== 0.js (7 errors) ==== - /** - * @param {Object} notSpecial -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @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. -@@= skipped -15, +23 lines =@@ - /** - * @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 -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function foo1(opts1) { - opts1.x; - } -@@= skipped -13, +19 lines =@@ - /** - * @param {Object[]} opts2 - * @param {string} opts2[].anotherX -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {string=} opts2[].anotherY -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function foo2(/** @param opts2 bad idea theatre! */opts2) { - opts2[0].anotherX; - } -@@= skipped -11, +15 lines =@@ - /** - * @param {object} opts3 - * @param {string} opts3.x -+ ~~~~~~~~~~~~~~~~~~~~~~~ - */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function foo3(opts3) { - opts3.x; - } -@@= skipped -9, +12 lines =@@ - /** - * @param {object[]} opts4 - * @param {string} opts4[].x -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {string=} opts4[].y -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {string} [opts4[].z] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {string} [opts4[].w="hi"] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function foo4(opts4) { - opts4[0].x; -@@= skipped -13, +18 lines =@@ - /** - * @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. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function foo5(opts5) { - opts5[0].what.bad[0].idea; - opts5[0].unnest; \ No newline at end of file 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 65e4562e4b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseBackquotedParamName.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.jsdocParseBackquotedParamName.errors.txt -+++ new.jsdocParseBackquotedParamName.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(2,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(3,20): error TS8010: Type annotations can only be used in TypeScript files. - a.js(5,18): error TS1016: A required parameter cannot follow an optional parameter. - - --==== a.js (1 errors) ==== -+==== a.js (4 errors) ==== - /** - * @param {string=} `args` -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param `bwarg` {?number?} -+ ~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(args, bwarg) { - ~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff index c0c5a4a7f3..0bed525624 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseDotDotDotInJSDocFunction.errors.txt.diff @@ -6,11 +6,10 @@ - -==== a.js (1 errors) ==== +a.js(3,12): error TS7006: Parameter 'callback' implicitly has an 'any' type. -+a.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(8,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? + + -+==== a.js (3 errors) ==== ++==== a.js (2 errors) ==== // from bcryptjs /** @param {function(...[*])} callback */ - ~~~~~~~~~~~~~~~~ @@ -23,8 +22,6 @@ /** * @type {!function(...number):string} -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff index 68c129cf48..0b43e0d1a6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseHigherOrderFunction.errors.txt.diff @@ -3,18 +3,15 @@ @@= skipped -0, +0 lines =@@ - +paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+paren.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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 (4 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var x = (s, id) => id(s) + ~ +!!! error TS7006: Parameter 's' implicitly has an 'any' type. 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 c6956778ae..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseMatchingBackticks.errors.txt.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.jsdocParseMatchingBackticks.errors.txt -+++ new.jsdocParseMatchingBackticks.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsdocParseMatchingBackticks.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocParseMatchingBackticks.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocParseMatchingBackticks.js(7,19): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocParseMatchingBackticks.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocParseMatchingBackticks.js(9,24): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocParseMatchingBackticks.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== jsdocParseMatchingBackticks.js (6 errors) ==== -+ /** -+ * `@param` initial at-param is OK in title comment -+ * @param {string} x hi there `@param` -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {string} y hi there `@ * param -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * this is the margin -+ * so we'll drop everything before it -+ `@param` @param {string} z hello??? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * `@param` @param {string} alpha hello??? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * `@ * param` @param {string} beta hello??? -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {string} gamma -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ export function f(x, y, z, alpha, beta, gamma) { -+ return x + y + z + alpha + beta + gamma -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff index a024c91ec4..a6dd8192ea 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseParenthesizedJSDocParameter.errors.txt.diff @@ -3,17 +3,14 @@ @@= skipped -0, +0 lines =@@ - +paren.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+paren.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +paren.js(2,9): error TS7006: Parameter 's' implicitly has an 'any' type. + + -+==== paren.js (3 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var x = s => s.toString() + ~ +!!! error TS7006: Parameter 's' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff index 320d6fc7e8..76fc71ede2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParseStarEquals.errors.txt.diff @@ -3,27 +3,16 @@ @@= skipped -0, +0 lines =@@ - +a.js(1,5): error TS1047: A rest parameter cannot be optional. -+a.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. -+a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(3,12): error TS2370: A rest parameter must be of an array type. -+a.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(12,14): error TS7006: Parameter 'f' implicitly has an 'any' type. + + -+==== a.js (7 errors) ==== ++==== a.js (3 errors) ==== + /** @param {...*=} args + ~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + @return {*=} */ + ~~~~ +!!! error TS1047: A rest parameter cannot be optional. -+ ~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(...args) { + ~~~~~~~ +!!! error TS2370: A rest parameter must be of an array type. @@ -31,8 +20,6 @@ + } + + /** @type *= */ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var x; + + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff deleted file mode 100644 index fcbd69c979..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPostfixEqualsAddsOptionality.errors.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.jsdocPostfixEqualsAddsOptionality.errors.txt -+++ new.jsdocPostfixEqualsAddsOptionality.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. -+a.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. - 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 errors) ==== -+a.js(12,5): error TS8009: The '?' modifier can only be used in TypeScript files. -+a.js(12,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (6 errors) ==== - /** @param {number=} a */ -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function f(a) { - a = 1 - a = null // should not be allowed -@@= skipped -18, +26 lines =@@ - f(1) - - /** @param {???!?number?=} a */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function g(a) { - a = 1 - a = null \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff index 9940ca857b..cd4ecc1839 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocPrefixPostfixParsing.errors.txt.diff @@ -12,82 +12,49 @@ -prefixPostfix.js(13,12): error TS1014: A rest parameter must be last in a parameter list. -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(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -+prefixPostfix.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. prefixPostfix.js(18,21): error TS7006: Parameter 'a' implicitly has an 'any' type. prefixPostfix.js(18,39): error TS7006: Parameter 'h' implicitly has an 'any' type. prefixPostfix.js(18,48): error TS7006: Parameter 'k' implicitly has an 'any' type. -==== prefixPostfix.js (14 errors) ==== -+==== prefixPostfix.js (15 errors) ==== ++==== prefixPostfix.js (3 errors) ==== /** * @param {number![]} x - number[] -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {!number[]} y - number[] -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(number[])!} z - number[] -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number?[]} a - parse error without parentheses - -!!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. - ~ -!!! error TS1005: '}' expected. * @param {?number[]} b - number[] | null -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {(number[])?} c - number[] | null -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...?number} e - (number | null)[] - ~~~~~~~~~~ +- ~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?} f - number[] | null - ~~~~~~~~~~ +- ~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number!?} g - number[] | null - ~~~~~~~~~~~ +- ~~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?!} h - parse error without parentheses (also nonsensical) - -!!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. - ~ -!!! error TS1005: '}' expected. * @param {...number[]} i - number[][] - ~~~~~~~~~~~ +- ~~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number![]?} j - number[][] | null - ~~~~~~~~~~~~~ +- ~~~~~~~~~~~~~ -!!! error TS1014: A rest parameter must be last in a parameter list. -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {...number?[]!} k - parse error without parentheses - -!!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. - ~ -!!! error TS1005: '}' expected. * @param {number extends number ? true : false} l - conditional types work -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {[number, number?]} m - [number, (number | undefined)?] -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f(x, y, z, a, b, c, e, f, g, h, i, j, k, l, m) { - ~ \ No newline at end of file + */ \ No newline at end of file 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 85496209ae..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, +0 lines =@@ -+jsdocPrivateName1.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. - jsdocPrivateName1.js(3,5): error TS2322: Type 'number' is not assignable to type 'boolean'. - - --==== jsdocPrivateName1.js (1 errors) ==== -+==== jsdocPrivateName1.js (2 errors) ==== - class A { - /** @type {boolean} some number value */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - #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/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff index aef7312b3f..d3cd22ef46 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff @@ -3,14 +3,13 @@ @@= skipped -0, +0 lines =@@ +jsdocReadonly.js(3,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +jsdocReadonly.js(4,8): error TS8009: The 'private' modifier can only be used in TypeScript files. -+jsdocReadonly.js(5,15): error TS8010: Type annotations can only be used in TypeScript files. +jsdocReadonly.js(9,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +jsdocReadonly.js(11,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. jsdocReadonly.js(23,3): error TS2540: Cannot assign to 'y' because it is a read-only property. -==== jsdocReadonly.js (1 errors) ==== -+==== jsdocReadonly.js (6 errors) ==== ++==== jsdocReadonly.js (5 errors) ==== class LOL { /** * @readonly @@ -22,8 +21,6 @@ * @type {number} + ~~~~~~~ +!!! error TS8009: The 'private' modifier can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * Order rules do not apply to JSDoc */ x = 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff deleted file mode 100644 index b0915af652..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReturnTag1.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.jsdocReturnTag1.errors.txt -+++ new.jsdocReturnTag1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+returns.js(2,14): error TS8010: Type annotations can only be used in TypeScript files. -+returns.js(9,14): error TS8010: Type annotations can only be used in TypeScript files. -+returns.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== returns.js (3 errors) ==== -+ /** -+ * @returns {string} This comment is not currently exposed -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f() { -+ return 5; -+ } -+ -+ /** -+ * @returns {string=} This comment is not currently exposed -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f1() { -+ return 5; -+ } -+ -+ /** -+ * @returns {string|number} This comment is not currently exposed -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f2() { -+ return 5 || "hello"; -+ } -+ \ No newline at end of file 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 790bc717d8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.errors.txt.diff +++ /dev/null @@ -1,67 +0,0 @@ ---- old.jsdocSignatureOnReturnedFunction.errors.txt -+++ new.jsdocSignatureOnReturnedFunction.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsdocSignatureOnReturnedFunction.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocSignatureOnReturnedFunction.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocSignatureOnReturnedFunction.js(5,18): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocSignatureOnReturnedFunction.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocSignatureOnReturnedFunction.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocSignatureOnReturnedFunction.js(16,18): error TS8010: Type annotations can only be used in TypeScript files. -+jsdocSignatureOnReturnedFunction.js(24,16): error TS8016: Type assertion expressions can only be used in TypeScript files. -+jsdocSignatureOnReturnedFunction.js(31,16): error TS8016: Type assertion expressions can only be used in TypeScript files. -+ -+ -+==== jsdocSignatureOnReturnedFunction.js (8 errors) ==== -+ function f1() { -+ /** -+ * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {number} b -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ return (a, b) => { -+ return a + b; -+ } -+ } -+ -+ function f2() { -+ /** -+ * @param {number} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {number} b -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ return function (a, b){ -+ return a + b; -+ } -+ } -+ -+ function f3() { -+ /** @type {(a: number, b: number) => number} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ return (a, b) => { -+ return a + b; -+ } -+ } -+ -+ function f4() { -+ /** @type {(a: number, b: number) => number} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. -+ return function (a, b){ -+ return a + b; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff index 2301ab4028..23ed49c09c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff @@ -2,26 +2,17 @@ +++ new.jsdocTemplateClass.errors.txt @@= skipped -0, +0 lines =@@ +templateTagOnClasses.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+templateTagOnClasses.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. -+templateTagOnClasses.js(7,22): error TS8010: Type annotations can only be used in TypeScript files. -+templateTagOnClasses.js(8,17): error TS8010: Type annotations can only be used in TypeScript files. -+templateTagOnClasses.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. -+templateTagOnClasses.js(15,16): error TS8010: Type annotations can only be used in TypeScript files. -+templateTagOnClasses.js(16,16): error TS8010: Type annotations can only be used in TypeScript files. -+templateTagOnClasses.js(17,17): error TS8010: Type annotations can only be used in TypeScript files. templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to type 'number'. -==== templateTagOnClasses.js (1 errors) ==== -+==== templateTagOnClasses.js (9 errors) ==== ++==== templateTagOnClasses.js (2 errors) ==== /** + ~~~ * @template T + ~~~~~~~~~~~~~~ * @typedef {(t: T) => T} Id + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ /** @template T */ @@ -30,12 +21,8 @@ + ~~~~~~~~~~~ /** @typedef {(t: T) => T} Id2 */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. /** @param {T} x */ + ~~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. constructor (x) { + ~~~~~~~~~~~~~~~~~~~~~ this.a = x @@ -48,20 +35,12 @@ + ~~~~~~~ * @param {T} x + ~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Id} y + ~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {Id2} alpha + ~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} + ~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~~~~~ foo(x, y, alpha) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff index 705a131408..3e302d5994 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff @@ -2,31 +2,22 @@ +++ new.jsdocTemplateConstructorFunction.errors.txt @@= skipped -0, +0 lines =@@ -templateTagOnConstructorFunctions.js(24,1): error TS2322: Type 'boolean' is not assignable to type 'number'. -- -- --==== templateTagOnConstructorFunctions.js (1 errors) ==== +templateTagOnConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+templateTagOnConstructorFunctions.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. -+templateTagOnConstructorFunctions.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== templateTagOnConstructorFunctions.js (3 errors) ==== + + + ==== templateTagOnConstructorFunctions.js (1 errors) ==== /** + ~~~ * @template U + ~~~~~~~~~~~~~~ * @typedef {(u: U) => U} Id + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ /** + ~~~ * @param {T} t + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T + ~~~~~~~~~~~~~~ */ @@ -45,7 +36,7 @@ /** * @param {T} v * @param {Id} id -@@= skipped -25, +45 lines =@@ +@@= skipped -25, +39 lines =@@ var z = new Zet(1) z.t = 2 z.u = false diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff index d521b8b3c9..579ae06c54 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff @@ -3,22 +3,14 @@ @@= skipped -0, +0 lines =@@ -templateTagWithNestedTypeLiteral.js(21,1): error TS2322: Type 'boolean' is not assignable to type 'number'. +templateTagWithNestedTypeLiteral.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+templateTagWithNestedTypeLiteral.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+templateTagWithNestedTypeLiteral.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. -- -- --==== templateTagWithNestedTypeLiteral.js (2 errors) ==== -+templateTagWithNestedTypeLiteral.js(30,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== templateTagWithNestedTypeLiteral.js (5 errors) ==== + + + ==== templateTagWithNestedTypeLiteral.js (2 errors) ==== /** + ~~~ * @param {T} t + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T + ~~~~~~~~~~~~~~ */ @@ -37,23 +29,12 @@ /** * @param {T} v * @param {object} o -@@= skipped -23, +38 lines =@@ +@@= skipped -23, +33 lines =@@ var z = new Zet(1) z.t = 2 z.u = false - ~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. let answer = z.add(3, { nested: 4 }) - - // lookup in typedef should not crash the compiler, even when the type is unknown -@@= skipped -13, +13 lines =@@ - !!! error TS2304: Cannot find name 'T'. - */ - /** @type {A} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const options = { value: null }; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff index 3e80aa4b69..21a8cf6da4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff @@ -3,23 +3,18 @@ @@= 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(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+forgot.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +forgot.js(8,15): error TS8004: Type parameter declarations can only be used in TypeScript files. -+forgot.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. +forgot.js(13,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+forgot.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. +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 (7 errors) ==== ++==== forgot.js (4 errors) ==== /** + ~~~ * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T + ~~~~~~~~~~~~~~ */ @@ -39,8 +34,6 @@ + ~~~ * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @template T + ~~~~~~~~~~~~~~ * @returns {function(): T} @@ -48,8 +41,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function g(a) { @@ -62,7 +53,7 @@ let s = g('hi')() /** -@@= skipped -26, +60 lines =@@ +@@= skipped -26, +51 lines =@@ */ Element.prototype.animate = function(keyframes) {}; ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff index 4a71c6ddd1..47cc69dacf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff @@ -2,21 +2,15 @@ +++ new.jsdocTemplateTag2.errors.txt @@= skipped -0, +0 lines =@@ - -+github17339.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. -+github17339.js(5,15): error TS8010: Type annotations can only be used in TypeScript files. +github17339.js(7,4): error TS8004: Type parameter declarations can only be used in TypeScript files. + + -+==== github17339.js (3 errors) ==== ++==== github17339.js (1 errors) ==== + var obj = { + /** + * @template T + * @param {T} a -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + x: function (a) { + ~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff index 5b21303c23..03f700f13c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff @@ -2,27 +2,17 @@ +++ new.jsdocTemplateTag3.errors.txt @@= skipped -0, +0 lines =@@ +a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(11,13): error TS8010: Type annotations can only be used in TypeScript files. 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 (5 errors) ==== +a.js(21,3): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. +a.js(21,50): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (12 errors) ==== + + + ==== a.js (5 errors) ==== /** + ~~~ * @template {{ a: number, b: string }} T,U A Comment @@ -35,28 +25,16 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} t + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} u + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {V} v + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {W} w + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {X} x + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {W | X} + ~~~~~~~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f(t, u, v, w, x) { @@ -99,8 +77,6 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} x + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function g(x) { } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff index 972801c289..26b326287b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff @@ -6,28 +6,22 @@ +a.js(8,16): error TS2315: Type 'Object' is not generic. +a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +a.js(14,16): error TS2304: Cannot find name 'K'. -+a.js(14,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(15,18): error TS2304: Cannot find name 'V'. -+a.js(15,18): error TS8010: Type annotations can only be used in TypeScript files. +a.js(18,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. +a.js(28,16): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(29,16): error TS2315: Type 'Object' is not generic. +a.js(30,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +a.js(35,16): error TS2304: Cannot find name 'K'. -+a.js(35,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(36,18): error TS2304: Cannot find name 'V'. -+a.js(36,18): error TS8010: Type annotations can only be used in TypeScript files. +a.js(39,21): error TS2339: Property '_map' does not exist on type '{ get: (key: K) => V; }'. +a.js(51,16): error TS2315: Type 'Object' is not generic. +a.js(52,10): error TS2339: Property '_map' does not exist on type '{ Multimap3: { (): void; prototype: { get(key: K): V; }; }; }'. +a.js(57,16): error TS2304: Cannot find name 'K'. -+a.js(57,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(58,18): error TS2304: Cannot find name 'V'. -+a.js(58,18): error TS8010: Type annotations can only be used in TypeScript files. +a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. + + -+==== a.js (23 errors) ==== ++==== a.js (17 errors) ==== + /** + ~~~ + * Should work for function declarations @@ -59,13 +53,9 @@ + * @param {K} key the key ok + ~ +!!! error TS2304: Cannot find name 'K'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {V} the value ok + ~ +!!! error TS2304: Cannot find name 'V'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get(key) { + return this._map[key + '']; @@ -99,13 +89,9 @@ + * @param {K} key the key ok + ~ +!!! error TS2304: Cannot find name 'K'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {V} the value ok + ~ +!!! error TS2304: Cannot find name 'V'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get: function(key) { + return this._map[key + '']; @@ -135,13 +121,9 @@ + * @param {K} key the key ok + ~ +!!! error TS2304: Cannot find name 'K'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {V} the value ok + ~ +!!! error TS2304: Cannot find name 'V'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + get(key) { + return this._map[key + '']; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff index 6ff53831f5..cb6d1b01d5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff @@ -3,42 +3,24 @@ @@= skipped -0, +0 lines =@@ - +a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(11,64): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(16,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(23,64): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(27,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(28,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(34,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(38,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(39,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(45,54): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(50,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(56,62): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(63,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(65,22): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(69,16): error TS8010: Type annotations can only be used in TypeScript files. +a.js(77,40): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(81,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(82,14): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (22 errors) ==== ++==== a.js (8 errors) ==== + /** + ~~~ + * @template const T + ~~~~~~~~~~~~~~~~~~~~ + * @param {T} x + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f1(x) { @@ -60,12 +42,8 @@ + ~~~~~~~~~~~~~~~~~~~~~~~ + * @param {T} x + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f2(x) { @@ -87,12 +65,8 @@ + ~~~~~~~~~~~~~~~~~~~~ + * @param {T} x + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T[]} + ~~~~~~~~~~~~~~~~~ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f3(x) { @@ -113,12 +87,8 @@ + ~~~~~~~~~~~~~~~~~~~~ + * @param {[T, T]} x + ~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f4(x) { @@ -139,12 +109,8 @@ + ~~~~~~~~~~~~~~~~~~~~ + * @param {{ x: T, y: T}} obj + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f5(obj) { @@ -171,8 +137,6 @@ + ~~~~~~~ + * @param {T} x + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor(x) {} @@ -190,8 +154,6 @@ + * @param {U} x + ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + ~~~~~~~ @@ -220,12 +182,8 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {T} args + ~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @returns {T} + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f6(...args) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff index 694d8980df..75ba667d47 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff @@ -5,14 +5,10 @@ a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(9,12): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter -- -- + + -==== a.js (2 errors) ==== -+a.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (6 errors) ==== ++==== a.js (4 errors) ==== /** + ~~~ * @template const T @@ -45,12 +41,8 @@ !!! error TS1273: 'private' modifier cannot appear on a type parameter * @param {T} x + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {T} + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f(x) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff index 4ed49a0454..821831507a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff @@ -2,36 +2,25 @@ +++ new.jsdocTemplateTag8.errors.txt @@= skipped -0, +0 lines =@@ +a.js(2,14): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias -+a.js(8,11): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. 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(23,18): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. 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(42,18): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(46,11): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(51,11): error TS8010: Type annotations can only be used in TypeScript files. 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'. -@@= skipped -9, +20 lines =@@ +@@= skipped -9, +12 lines =@@ 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(56,33): error TS8004: Type parameter declarations can only be used in TypeScript files. 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(60,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (18 errors) ==== ++==== a.js (9 errors) ==== /** * @template out T + ~~~ @@ -39,22 +28,7 @@ * @typedef {Object} Covariant * @property {T} x */ - - /** - * @type {Covariant} -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - let super_covariant = { x: 1 }; - - /** - * @type {Covariant} -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - let sub_covariant = { x: '' }; - -@@= skipped -28, +36 lines =@@ +@@= skipped -28, +31 lines =@@ /** * @template in T @@ -62,25 +36,8 @@ +!!! 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 -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ - - /** - * @type {Contravariant} -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - let super_contravariant = { f: (x) => {} }; - - /** - * @type {Contravariant} -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - let sub_contravariant = { f: (x) => {} }; - -@@= skipped -22, +30 lines =@@ +@@= skipped -22, +24 lines =@@ /** * @template in out T @@ -88,25 +45,8 @@ +!!! 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 -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - - /** - * @type {Invariant} -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ - let super_invariant = { f: (x) => {} }; - - /** - * @type {Invariant} -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - let sub_invariant = { f: (x) => { return "" } }; - -@@= skipped -26, +34 lines =@@ +@@= skipped -26, +28 lines =@@ !!! 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'. @@ -121,8 +61,6 @@ !!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @param {T} x + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f(x) {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff index b9dd315d22..7ed8e4f665 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff @@ -1,54 +1,26 @@ --- old.jsdocTemplateTagDefault.errors.txt +++ new.jsdocTemplateTagDefault.errors.txt @@= skipped -0, +0 lines =@@ -+file.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. 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(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(13,21): error TS8004: Type parameter declarations can only be used in TypeScript files. 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(46,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(49,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. -+file.js(54,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. +file.js(57,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. -- -- + + -==== file.js (7 errors) ==== -+file.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. -+file.js(63,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== file.js (18 errors) ==== ++==== file.js (8 errors) ==== /** * @template {string | number} [T=string] - ok: defaults are permitted * @typedef {[T]} A - */ - - /** @type {A} */ // ok, default for `T` in `A` is `string` -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const aDefault1 = [""]; - /** @type {A} */ // error: `number` is not assignable to string` -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const aDefault2 = [0]; - ~ - !!! error TS2322: Type 'number' is not assignable to type 'string'. - /** @type {A} */ // ok, `T` is provided for `A` -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -22, +23 lines =@@ const aString = [""]; /** @type {A} */ // ok, `T` is provided for `A` -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const aNumber = [0]; + + @@ -125,12 +97,8 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f1(a, b) {} @@ -149,12 +117,8 @@ !!! error TS2706: Required type parameters may not follow optional type parameters. * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f2(a, b) {} @@ -173,12 +137,8 @@ + ~~~~~~~~~~~~~~~~~~ * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {U} b + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f3(a, b) {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff deleted file mode 100644 index 8b1954bf29..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.jsdocTemplateTagNameResolution.errors.txt -+++ new.jsdocTemplateTagNameResolution.errors.txt -@@= skipped -0, +0 lines =@@ -+file.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. - file.js(10,7): error TS2322: Type 'string' is not assignable to type 'number'. - - --==== file.js (1 errors) ==== -+==== file.js (2 errors) ==== - /** - * @template T - * @template {keyof T} K -@@= skipped -10, +11 lines =@@ - const x = { a: 1 }; - - /** @type {Foo} */ -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const y = "a"; - ~ - !!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff index 0a319d5089..2475a703b5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocThisType.errors.txt.diff @@ -1,29 +1,26 @@ --- old.jsdocThisType.errors.txt +++ new.jsdocThisType.errors.txt @@= skipped -0, +0 lines =@@ -+/a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. /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(11,12): error TS8010: Type annotations can only be used in TypeScript files. /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'. +/a.js(21,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+/a.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. ==== /types.d.ts (0 errors) ==== -@@= skipped -14, +14 lines =@@ +@@= skipped -12, +9 lines =@@ - ==== /a.js (6 errors) ==== + export type M = (this: Foo) => void; + +-==== /a.js (6 errors) ==== ++==== /a.js (3 errors) ==== /** @type {import('./types').M} */ -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. export const f1 = function() { this.test(); - ~~~~ -@@= skipped -9, +11 lines =@@ +@@= skipped -11, +11 lines =@@ /** @type {import('./types').M} */ export function f2() { this.test(); @@ -32,12 +29,7 @@ } /** @type {(this: import('./types').Foo) => void} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - export const f3 = function() { - this.test(); - ~~~~ -@@= skipped -14, +14 lines =@@ +@@= skipped -14, +12 lines =@@ /** @type {(this: import('./types').Foo) => void} */ export function f4() { this.test(); @@ -49,8 +41,6 @@ + ~~~~~~~~ +!!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 lib.es5.d.ts:--:--: 'Function' is declared here. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. export const f5 = function() { this.test(); - ~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff index 83aecc8706..54ee845a3b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeDefAtStartOfFile.errors.txt.diff @@ -2,29 +2,20 @@ +++ new.jsdocTypeDefAtStartOfFile.errors.txt @@= skipped -0, +0 lines =@@ - -+dtsEquivalent.js(1,19): error TS8010: Type annotations can only be used in TypeScript files. +index.js(1,12): error TS2304: Cannot find name 'AnyEffect'. -+index.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(3,12): error TS2304: Cannot find name 'Third'. -+index.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== dtsEquivalent.js (1 errors) ==== ++==== dtsEquivalent.js (0 errors) ==== + /** @typedef {{[k: string]: any}} AnyEffect */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @typedef {number} Third */ -+==== index.js (4 errors) ==== ++==== index.js (2 errors) ==== + /** @type {AnyEffect} */ + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'AnyEffect'. -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + let b; + /** @type {Third} */ + ~~~~~ +!!! error TS2304: Cannot find name 'Third'. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + let c; + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff index b550d37076..ae65230ca2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceExports.errors.txt.diff @@ -3,17 +3,14 @@ @@= skipped -0, +0 lines =@@ - +bug27342.js(3,11): error TS2709: Cannot use namespace 'exports' as a type. -+bug27342.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== bug27342.js (2 errors) ==== ++==== bug27342.js (1 errors) ==== + module.exports = {} + /** + * @type {exports} + ~~~~~~~ +!!! error TS2709: Cannot use namespace 'exports' as a type. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + var x + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff index baf11528d5..f6aa14b029 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImport.errors.txt.diff @@ -3,19 +3,15 @@ @@= skipped -0, +0 lines =@@ - +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(3,12): error TS8010: Type annotations can only be used in TypeScript files. +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(8,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocTypeReferenceToImport.js (4 errors) ==== ++==== jsdocTypeReferenceToImport.js (2 errors) ==== + const C = require('./ex').C; + const D = require('./ex')?.C; + /** @type {C} c */ + ~ +!!! error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var c = new C() + c.start + c.end @@ -23,8 +19,6 @@ + /** @type {D} c */ + ~ +!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var d = new D() + d.start + d.end diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff index de02308829..9e66ced279 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 lines =@@ - +MC.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+MW.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. +MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + @@ -24,14 +23,12 @@ + ~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== MW.js (2 errors) ==== ++==== MW.js (1 errors) ==== + /** @typedef {import("./MC")} MC */ + + class MW { + /** + * @param {MC} compiler the compiler -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(compiler) { + this.compiler = compiler; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff index 1651a75fde..b9969a5cd3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff @@ -3,13 +3,11 @@ @@= skipped -0, +0 lines =@@ - +MC.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+MC.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. +MW.js(1,15): error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? -+MW.js(5,14): error TS8010: Type annotations can only be used in TypeScript files. +MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== MC.js (2 errors) ==== ++==== MC.js (1 errors) ==== + const MW = require("./MW"); + + /** @typedef {number} Meyerhauser */ @@ -19,8 +17,6 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** @type {any} */ + ~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var x = {} + ~~~~~~~~~~~~~~ + return new MW(x); @@ -29,7 +25,7 @@ + ~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== MW.js (3 errors) ==== ++==== MW.js (2 errors) ==== + /** @typedef {import("./MC")} MC */ + ~~~~~~~~~~~~~~ +!!! error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? @@ -37,8 +33,6 @@ + class MW { + /** + * @param {MC} compiler the compiler -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + constructor(compiler) { + this.compiler = compiler; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff index 87d9ab3922..6d5f9a870c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToMergedClass.errors.txt.diff @@ -3,16 +3,13 @@ @@= skipped -0, +0 lines =@@ - +jsdocTypeReferenceToMergedClass.js(2,12): error TS2503: Cannot find namespace 'Workspace'. -+jsdocTypeReferenceToMergedClass.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== jsdocTypeReferenceToMergedClass.js (2 errors) ==== ++==== jsdocTypeReferenceToMergedClass.js (1 errors) ==== + var Workspace = {} + /** @type {Workspace.Project} */ + ~~~~~~~~~ +!!! error TS2503: Cannot find namespace 'Workspace'. -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var p; + p.isServiceProject() + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff index 6c7b6895c1..b83f68328b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToValue.errors.txt.diff @@ -3,15 +3,12 @@ @@= skipped -0, +0 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,13): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== foo.js (2 errors) ==== ++==== 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'? -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function process(image) { + return new image(1, 1) + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt.diff deleted file mode 100644 index 48d969fcd7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceUseBeforeDef.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsdocTypeReferenceUseBeforeDef.errors.txt -+++ new.jsdocTypeReferenceUseBeforeDef.errors.txt -@@= skipped -0, +0 lines =@@ -- -+bug25097.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== bug25097.js (1 errors) ==== -+ /** @type {C | null} */ -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const c = null -+ class C { -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff index 5d66ad9d9e..d9f1f96033 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTag.errors.txt.diff @@ -2,30 +2,6 @@ +++ new.jsdocTypeTag.errors.txt @@= skipped -0, +0 lines =@@ - -+a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(22,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(28,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(34,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(37,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(40,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(46,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(52,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(61,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(67,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(70,12): error TS8010: Type annotations can only be used in TypeScript files. +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'. @@ -34,125 +10,77 @@ +b.ts(21,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 (24 errors) ==== ++==== a.js (0 errors) ==== + /** @type {String} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var S; + + /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var s; + + /** @type {Number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var N; + + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var n; + + /** @type {BigInt} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var BI; + + /** @type {bigint} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var bi; + + /** @type {Boolean} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var B; + + /** @type {boolean} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var b; + + /** @type {Void} */ -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var V; + + /** @type {void} */ -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var v; + + /** @type {Undefined} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var U; + + /** @type {undefined} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var u; + + /** @type {Null} */ -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var Nl; + + /** @type {null} */ -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var nl; + + /** @type {Array} */ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var A; + + /** @type {array} */ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var a; + + /** @type {Promise} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var P; + + /** @type {promise} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var p; + + /** @type {?number} */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var nullable; + + /** @type {Object} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var Obj; + + /** @type {object} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var obj; + + /** @type {Function} */ -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var Func; + + /** @type {(s: string) => number} */ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var f; + + /** @type {new (s: string) => { s: string }} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var ctor; + +==== b.ts (6 errors) ==== diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff index 4d0fa62b91..cb553f8687 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff @@ -14,127 +14,66 @@ - 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(2,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(4,20): error TS8016: Type assertion expressions can only be used in TypeScript files. +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(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+b.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+b.js(12,20): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(13,25): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(43,23): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(44,23): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(45,23): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. -+b.js(47,26): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(48,26): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(49,26): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x -+b.js(51,24): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. -+b.js(52,24): error TS8016: Type assertion expressions can only be used in TypeScript files. +b.js(52,38): error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. -+b.js(53,24): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(59,23): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. -+b.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. b.js(66,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. -+b.js(66,15): error TS8016: Type assertion expressions can only be used in TypeScript files. 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(71,27): error TS8016: Type assertion expressions can only be used in TypeScript files. -+b.js(72,27): error TS8016: Type assertion expressions can only be used in TypeScript files. - - +@@= skipped -20, +12 lines =@@ ==== a.ts (0 errors) ==== var W: string; -==== b.js (10 errors) ==== -+==== b.js (30 errors) ==== ++==== b.js (9 errors) ==== // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); -+ ~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. var W = /** @type {string} */(4); // Error - ~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. +- ~~~~~~ + ~ !!! 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 {*} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var a; - - /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var s; - - var a = /** @type {*} */("" + 4); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - var s = "" + /** @type {*} */(4); -+ ~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - - class SomeBase { - constructor() { -@@= skipped -66, +91 lines =@@ - var someFakeClass = new SomeFakeClass(); - +@@= skipped -48, +48 lines =@@ someBase = /** @type {SomeBase} */(someDerived); -+ ~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someBase = /** @type {SomeBase} */(someBase); -+ ~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someBase = /** @type {SomeBase} */(someOther); // Error - ~~~~~~~~ +- ~~~~~~~~ -!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeBase' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. !!! related TS2728 b.js:17:9: 'p' is declared here. someDerived = /** @type {SomeDerived} */(someDerived); -+ ~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someDerived = /** @type {SomeDerived} */(someBase); -+ ~~~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. someDerived = /** @type {SomeDerived} */(someOther); // Error - ~~~~~~~~~~~ +- ~~~~~~~~~~~ -!!! error TS2352: Conversion of type 'SomeOther' to type 'SomeDerived' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x someOther = /** @type {SomeOther} */(someDerived); // Error - ~~~~~~~~~ +- ~~~~~~~~~ -!!! error TS2352: Conversion of type 'SomeDerived' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~~~~ +!!! error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someBase); // Error - ~~~~~~~~~ +- ~~~~~~~~~ -!!! error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -!!! error TS2352: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. + ~~~~~~~~ +!!! error TS2741: Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. !!! related TS2728 b.js:28:9: 'q' is declared here. someOther = /** @type {SomeOther} */(someOther); -+ ~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - someFakeClass = someBase; +@@= skipped -28, +24 lines =@@ someFakeClass = someDerived; someBase = someFakeClass; // Error @@ -144,34 +83,5 @@ -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. someBase = /** @type {SomeBase} */(someFakeClass); -+ ~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - - // Type assertion cannot be a type-predicate type - /** @type {number | string} */ -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var numOrStr; - /** @type {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - 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 TS8016: Type assertion expressions can only be used in TypeScript files. - ~~~~~~~~ - !!! error TS2454: Variable 'numOrStr' is used before being assigned. - str = numOrStr; // Error, no narrowing occurred -@@= skipped -57, +74 lines =@@ - - var asConst1 = /** @type {const} */(1); -+ ~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - var asConst2 = /** @type {const} */({ -+ ~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - x: 1 - }); \ No newline at end of file + // Type assertion cannot be a type-predicate type \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff index 5925d243ed..0136365e68 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagParameterType.errors.txt.diff @@ -7,18 +7,15 @@ - -==== a.js (2 errors) ==== +a.js(1,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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 (4 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (value) => { + ~~~~~ +!!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff index 97f3dbed9e..28a1528267 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagRequiredParameters.errors.txt.diff @@ -3,7 +3,6 @@ @@= 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(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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. @@ -12,13 +11,11 @@ -==== a.js (3 errors) ==== -+==== a.js (7 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const f = (value) => { + ~~~~~ +!!! error TS7006: Parameter 'value' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt.diff deleted file mode 100644 index 8bd9d8b177..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariableDeclarationWithTypeAnnotation.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.jsdocVariableDeclarationWithTypeAnnotation.errors.txt -+++ new.jsdocVariableDeclarationWithTypeAnnotation.errors.txt -@@= skipped -0, +0 lines =@@ -- -+foo.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (2 errors) ==== -+ /** @type {boolean} */ -+ var /** @type {string} */ x, -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ /** @type {number} */ y; -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff index a0193041d4..a79f41e4ea 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocVariadicType.errors.txt.diff @@ -3,17 +3,14 @@ @@= skipped -0, +0 lines =@@ - +a.js(2,11): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -+a.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (2 errors) ==== ++==== 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. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + const foo = function (a, b, ...r) { }; + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.errors.txt.diff deleted file mode 100644 index 48b5ee2f9a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/linkTagEmit1.errors.txt.diff +++ /dev/null @@ -1,35 +0,0 @@ ---- old.linkTagEmit1.errors.txt -+++ new.linkTagEmit1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+linkTagEmit1.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== declarations.d.ts (0 errors) ==== -+ declare namespace NS { -+ type R = number -+ } -+==== linkTagEmit1.js (1 errors) ==== -+ /** @typedef {number} N */ -+ /** -+ * @typedef {Object} D1 -+ * @property {1} e Just link to {@link NS.R} this time -+ * @property {1} m Wyatt Earp loved {@link N integers} I bet. -+ */ -+ -+ /** @typedef {number} Z @see N {@link N} */ -+ -+ /** -+ * @param {number} integer {@link Z} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function computeCommonSourceDirectoryOfFilenames(integer) { -+ return integer + 1 // pls pls pls -+ } -+ -+ /** {@link https://hvad} */ -+ var see3 = true -+ -+ /** @typedef {number} Attempt {@link https://wat} {@linkcode I think lingcod is better} {@linkplain or lutefisk}*/ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.errors.txt.diff deleted file mode 100644 index a0e197fef1..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/malformedTags.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.malformedTags.errors.txt -+++ new.malformedTags.errors.txt -@@= skipped -0, +0 lines =@@ -- -+myFile02.js(4,10): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== myFile02.js (1 errors) ==== -+ /** -+ * Checks if `value` is classified as an `Array` object. -+ * -+ * @type Function -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ var isArray = Array.isArray; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment.errors.txt.diff index d3fe5e1316..9b02b363c3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment.errors.txt.diff @@ -2,7 +2,6 @@ +++ new.moduleExportAssignment.errors.txt @@= skipped -0, +0 lines =@@ - -+npmlog.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. +npmlog.js(5,14): error TS2741: Property 'y' is missing in type 'EE' but required in type 'typeof import("npmlog")'. +npmlog.js(8,16): error TS2339: Property 'on' does not exist on type 'typeof import("npmlog")'. +npmlog.js(10,8): error TS2339: Property 'x' does not exist on type 'EE'. @@ -21,11 +20,9 @@ + ~~ +!!! error TS2339: Property 'on' does not exist on type 'typeof import("npmlog")'. + -+==== npmlog.js (6 errors) ==== ++==== npmlog.js (5 errors) ==== + class EE { + /** @param {string} s */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + on(s) { } + } + var npmlog = module.exports = new EE() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.errors.txt.diff deleted file mode 100644 index 49d3b73dfb..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment6.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.moduleExportAssignment6.errors.txt -+++ new.moduleExportAssignment6.errors.txt -@@= skipped -0, +0 lines =@@ -- -+webpackLibNormalModule.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. -+webpackLibNormalModule.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== webpackLibNormalModule.js (2 errors) ==== -+ class C { -+ /** @param {number} x */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor(x) { -+ this.x = x -+ this.exports = [x] -+ } -+ /** @param {number} y */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ m(y) { -+ return this.x + y -+ } -+ } -+ function exec() { -+ const module = new C(12); -+ return module.exports; // should be fine because `module` is defined locally -+ } -+ -+ function tricky() { -+ // (a trickier variant of what webpack does) -+ const module = new C(12); -+ return () => { -+ return module.exports; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff index 304edb0ae4..db60a68388 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff @@ -7,31 +7,17 @@ +index.ts(7,24): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. 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(2,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(2,28): error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. -+main.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(3,28): error TS2694: Namespace '"mod".export=' has no exported member 'AnotherThing'. -+main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(4,28): error TS2694: Namespace '"mod".export=' has no exported member 'foo'. -+main.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(5,28): error TS2694: Namespace '"mod".export=' has no exported member 'qux'. -+main.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(6,28): error TS2694: Namespace '"mod".export=' has no exported member 'baz'. -+main.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(7,28): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. -+main.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +main.js(8,28): error TS2694: Namespace '"mod".export=' has no exported member 'literal'. -+main.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(16,12): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(18,12): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(20,12): error TS8010: Type annotations can only be used in TypeScript files. main.js(20,35): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. - - -==== mod.js (0 errors) ==== -+main.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. +mod.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + @@ -59,74 +45,33 @@ -==== main.js (1 errors) ==== + ~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== main.js (22 errors) ==== ++==== main.js (8 errors) ==== /** * @param {import("./mod").Thing} a -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. * @param {import("./mod").AnotherThing} b -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'AnotherThing'. * @param {import("./mod").foo} c -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'foo'. * @param {import("./mod").qux} d -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'qux'. * @param {import("./mod").baz} e -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. * @param {import("./mod").buz} f -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. * @param {import("./mod").literal} g -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~ +!!! error TS2694: Namespace '"mod".export=' 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 -35, +95 lines =@@ - - /** - * @param {typeof import("./mod").Thing} a -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {typeof import("./mod").AnotherThing} b -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {typeof import("./mod").foo} c -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {typeof import("./mod").qux} d -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {typeof import("./mod").baz} e -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {typeof import("./mod").buz} f -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~ - !!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. - * @param {typeof import("./mod").literal} g -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function jsvalues(a, b, c, d, e, f, g) { +@@= skipped -48, +80 lines =@@ return a.length + b.length + c() + d() + e() + f() + g.length } @@ -135,7 +80,7 @@ function types( a: import('./mod').Thing, ~~~~~ -@@= skipped -31, +45 lines =@@ +@@= skipped -18, +18 lines =@@ ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. f: import('./mod').buz, diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff index b0df2029c1..de6a3161fb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportNestedNamespaces.errors.txt.diff @@ -4,10 +4,8 @@ - +mod.js(2,18): error TS2339: Property 'K' does not exist on type '{}'. +use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. -+use.js(8,13): error TS8010: Type annotations can only be used in TypeScript files. +use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. +use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -+use.js(9,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== mod.js (1 errors) ==== @@ -23,7 +21,7 @@ + } + } + -+==== use.js (5 errors) ==== ++==== use.js (3 errors) ==== + import * as s from './mod' + + var k = new s.n.K() @@ -34,15 +32,11 @@ + + + /** @param {s.n.K} c -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2694: Namespace '"mod"' has no exported member 'n'. + @param {s.Classic} classic */ + ~~~~~~~~~ +!!! error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(c, classic) { + c.x + classic.p 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 77233abf4b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportsElementAccessAssignment2.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.moduleExportsElementAccessAssignment2.errors.txt -+++ new.moduleExportsElementAccessAssignment2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+file1.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+file1.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+file1.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== file1.js (3 errors) ==== -+ // this file _should_ be a global file -+ var GlobalThing = { x: 12 }; -+ -+ /** -+ * @param {*} type -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {*} ctor -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {*} exports -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(type, ctor, exports) { -+ 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/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff deleted file mode 100644 index 2f1796e4d9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.optionalBindingParameters3.errors.txt -+++ new.optionalBindingParameters3.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(7,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+/a.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. - /a.js(9,12): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. - - --==== /a.js (1 errors) ==== -+==== /a.js (3 errors) ==== - /** - * @typedef Foo - * @property {string} a -@@= skipped -8, +10 lines =@@ - - /** - * @param {Foo} [options] -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function f({ a = "a" }) {} - ~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff deleted file mode 100644 index 95029e087e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.optionalBindingParameters4.errors.txt -+++ new.optionalBindingParameters4.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(2,11): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ /** -+ * @param {{ cause?: string }} [options] -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function foo({ cause } = {}) { -+ return cause; -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff index a870d1e433..7a4ff7dab6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag1.errors.txt.diff @@ -15,47 +15,24 @@ - - -==== overloadTag1.js (3 errors) ==== -+overloadTag1.js(2,5): error TS8017: Signature declarations can only be used in TypeScript files. -+overloadTag1.js(7,5): error TS8017: Signature declarations can only be used in TypeScript files. -+overloadTag1.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -+overloadTag1.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -+overloadTag1.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. +overloadTag1.js(26,25): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. -+overloadTag1.js(29,5): error TS8017: Signature declarations can only be used in TypeScript files. -+overloadTag1.js(34,5): error TS8017: Signature declarations can only be used in TypeScript files. + + -+==== overloadTag1.js (8 errors) ==== ++==== overloadTag1.js (1 errors) ==== /** * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {number} a - * @param {number} b +@@= 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. -+!!! error TS8017: Signature declarations can only be used in TypeScript files. * @param {string} a * @param {boolean} b * @returns {string} - * - * @param {string | number} a -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string | number} b -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {string | number} -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - export function overloaded(a,b) { - if (typeof a === "string" && typeof b === "string") { -@@= skipped -39, +43 lines =@@ +@@= skipped -21, +18 lines =@@ } var o1 = overloaded(1,2) var o2 = overloaded("zero", "one") @@ -71,19 +48,7 @@ /** * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @param {number} a - * @param {number} b - * @returns {number} - * - * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @param {string} a - * @param {boolean} b - * @returns {string} -@@= skipped -24, +24 lines =@@ +@@= skipped -24, +20 lines =@@ } uncheckedInternally(1,2) uncheckedInternally("zero", "one") diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff deleted file mode 100644 index 53079f6ad4..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- old.overloadTag2.errors.txt -+++ new.overloadTag2.errors.txt -@@= skipped -0, +0 lines =@@ -+overloadTag2.js(8,9): error TS8017: Signature declarations can only be used in TypeScript files. - overloadTag2.js(14,9): error TS2394: This overload signature is not compatible with its implementation signature. -+overloadTag2.js(14,9): error TS8017: Signature declarations can only be used in TypeScript files. -+overloadTag2.js(19,9): error TS8017: Signature declarations can only be used in TypeScript files. -+overloadTag2.js(23,16): error TS8010: Type annotations can only be used in TypeScript files. - 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 (3 errors) ==== -+==== overloadTag2.js (7 errors) ==== - export class Foo { - #a = true ? 1 : "1" - #b -@@= skipped -11, +15 lines =@@ - * Should not have an implicit any error, because constructor's return type is always implicit - * @constructor - * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @param {string} a - * @param {number} b - */ -@@= skipped -9, +11 lines =@@ - ~~~~~~~~ - !!! error TS2394: This overload signature is not compatible with its implementation signature. - !!! related TS2750 overloadTag2.js:25:5: The implementation signature is declared here. -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @param {number} a - */ - /** - * @constructor - * @overload -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @param {string} a - *//** - * @constructor - * @param {number | string} a -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - constructor(a, b) { - ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff index 84401b5745..b695479d11 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff @@ -3,12 +3,9 @@ @@= skipped -0, +0 lines =@@ - +/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+/a.js(7,9): error TS8017: Signature declarations can only be used in TypeScript files. -+/a.js(12,16): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== /a.js (4 errors) ==== ++==== /a.js (1 errors) ==== + /** + ~~~ + * @template T @@ -23,8 +20,6 @@ + ~~~~~~~~~~~~~~~~~~~ + * @overload + ~~~~~~~~~~~~~~~~ -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. + */ + ~~~~~~~ + constructor() { } @@ -35,8 +30,6 @@ + ~~~~~~~ + * @param {T} value + ~~~~~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~~~~~ + bar(value) { } @@ -46,8 +39,6 @@ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** @type {Foo} */ -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + let foo; + foo = new Foo(); + \ No newline at end of file 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 fdce0d5294..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagBracketsAddOptionalUndefined.errors.txt.diff +++ /dev/null @@ -1,43 +0,0 @@ ---- old.paramTagBracketsAddOptionalUndefined.errors.txt -+++ new.paramTagBracketsAddOptionalUndefined.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(2,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(3,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(4,4): error TS8009: The '?' modifier can only be used in TypeScript files. -+a.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (6 errors) ==== -+ /** -+ * @param {number} [p] -+ ~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {number=} q -+ ~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {number} [r=101] -+ ~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(p, q, r) { -+ 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() -+ f(undefined, undefined, undefined) -+ f(1, 2, 3) -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff index fb05cc949f..920c07865c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagNestedWithoutTopLevelObject3.errors.txt.diff @@ -1,7 +1,6 @@ --- old.paramTagNestedWithoutTopLevelObject3.errors.txt +++ new.paramTagNestedWithoutTopLevelObject3.errors.txt @@= skipped -0, +0 lines =@@ -+paramTagNestedWithoutTopLevelObject3.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. paramTagNestedWithoutTopLevelObject3.js(3,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. - - @@ -9,14 +8,11 @@ +paramTagNestedWithoutTopLevelObject3.js(6,16): error TS2339: Property 'bar' does not exist on type 'object'. + + -+==== paramTagNestedWithoutTopLevelObject3.js (3 errors) ==== ++==== paramTagNestedWithoutTopLevelObject3.js (2 errors) ==== /** * @param {object} xyz -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} xyz.bar.p - ~~~~~~~~~ - !!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. +@@= skipped -9, +10 lines =@@ */ function g(xyz) { return xyz.bar.p; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff index f69ec7ac68..c6d8802f9e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff @@ -3,23 +3,17 @@ @@= skipped -0, +0 lines =@@ - +38572.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+38572.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+38572.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== 38572.js (3 errors) ==== ++==== 38572.js (1 errors) ==== + /** + ~~~ + * @template T + ~~~~~~~~~~~~~~ + * @param {T} a + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {{[K in keyof T]: (value: T[K]) => void }} b + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function f(a, b) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff index 24d1bc187c..c7b1b74daa 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagWrapping.errors.txt.diff @@ -9,31 +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 (0 errors) ==== -+good.js(3,5): error TS8010: Type annotations can only be used in TypeScript files. -+good.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+good.js(6,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== good.js (3 errors) ==== - /** - * @param - * {number} x Arg x. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * y Arg y. - * @param {number} z -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * Arg z. - */ - function good(x, y, z) { -@@= skipped -22, +26 lines =@@ +@@= skipped -22, +17 lines =@@ good(1, 2, 3) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff index 5e69107dd6..134ae7585e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff @@ -3,24 +3,11 @@ @@= skipped -0, +0 lines =@@ - +propertiesOfGenericConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. +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(14,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(19,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(23,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(25,12): error TS8010: Type annotations can only be used in TypeScript files. +propertiesOfGenericConstructorFunctions.js(26,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(31,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(45,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(47,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertiesOfGenericConstructorFunctions.js(49,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== propertiesOfGenericConstructorFunctions.js (16 errors) ==== ++==== propertiesOfGenericConstructorFunctions.js (3 errors) ==== + /** + ~~~ + * @template {string} K @@ -29,20 +16,14 @@ + ~~~~~~~~~~~~~~ + * @param {string} ik + ~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @param {V} iv + ~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function Multimap(ik, iv) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** @type {{ [s: string]: V }} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + this._map = {}; + ~~~~~~~~~~~~~~~~~~~ + // without type annotation @@ -56,27 +37,17 @@ + /** @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'? -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const map = new Multimap("a", 1); + // without type annotation + const map2 = new Multimap("m", 2); + + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = map._map['hi'] + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = map._map2['hi'] + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = map2._map['hi'] + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = map._map2['hi'] + + @@ -89,8 +60,6 @@ + ~~~~~~~~~~~~~~ + * @param {T} t + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function Cp(t) { @@ -109,20 +78,12 @@ + var cp = new Cp(1) + + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = cp.x + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = cp.y + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = cp.m1() + /** @type {number} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var n = cp.m2() + + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff index 83418e73a5..4a3a8a2346 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertyAssignmentUseParentType2.errors.txt.diff @@ -2,32 +2,12 @@ +++ new.propertyAssignmentUseParentType2.errors.txt @@= skipped -0, +0 lines =@@ -propertyAssignmentUseParentType2.js(11,14): error TS2322: Type '{ (): boolean; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. -+propertyAssignmentUseParentType2.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertyAssignmentUseParentType2.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+propertyAssignmentUseParentType2.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. +propertyAssignmentUseParentType2.js(11,14): error TS2322: Type '{ (): true; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. Types of property 'nuo' are incompatible. Type '1000' is not assignable to type '789'. - --==== propertyAssignmentUseParentType2.js (1 errors) ==== -+==== propertyAssignmentUseParentType2.js (4 errors) ==== - /** @type {{ (): boolean; nuo: 789 }} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - export const inlined = () => true - inlined.nuo = 789 - - /** @type {{ (): boolean; nuo: 789 }} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - export const duplicated = () => true - /** @type {789} */ - duplicated.nuo = 789 - +@@= skipped -15, +15 lines =@@ /** @type {{ (): boolean; nuo: 789 }} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. export const conflictingDuplicated = () => true ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ (): boolean; nuo: 1000; }' is not assignable to type '{ (): boolean; nuo: 789; }'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff index f83933fb6d..55aaf5a4fd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergeAcrossFiles2.errors.txt.diff @@ -4,24 +4,16 @@ -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(2,11): error TS8010: Type annotations can only be used in TypeScript files. +other.js(7,11): error TS2503: Cannot find namespace 'Ns'. -+other.js(7,11): error TS8010: Type annotations can only be used in TypeScript files. ==== prototypePropertyAssignmentMergeAcrossFiles2.js (0 errors) ==== -@@= skipped -12, +14 lines =@@ - Ns.Two.prototype = { - } - --==== other.js (2 errors) ==== -+==== other.js (4 errors) ==== +@@= skipped -15, +15 lines =@@ + ==== other.js (2 errors) ==== /** * @type {Ns.One} + ~~ +!!! error TS2503: Cannot find namespace 'Ns'. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ var one; one.wat; @@ -31,8 +23,6 @@ * @type {Ns.Two} + ~~ +!!! error TS2503: Cannot find namespace 'Ns'. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ var two; two.wat; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff index 570512ea78..cac29e7193 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/prototypePropertyAssignmentMergedTypeReference.errors.txt.diff @@ -2,13 +2,12 @@ +++ new.prototypePropertyAssignmentMergedTypeReference.errors.txt @@= skipped -0, +0 lines =@@ - -+prototypePropertyAssignmentMergedTypeReference.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. +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 (3 errors) ==== ++==== prototypePropertyAssignmentMergedTypeReference.js (2 errors) ==== + var f = function() { + return 12; + }; @@ -16,8 +15,6 @@ + f.prototype.a = "a"; + + /** @type {new () => f} */ -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2749: 'f' refers to a value, but is being used as a type here. Did you mean 'typeof f'? + var x = f; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff deleted file mode 100644 index 82bfb1ef52..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.recursiveTypeReferences2.errors.txt -+++ new.recursiveTypeReferences2.errors.txt -@@= skipped -0, +0 lines =@@ -+bug39372.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. -+bug39372.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. - bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. - Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O - - --==== bug39372.js (1 errors) ==== -+==== bug39372.js (3 errors) ==== - /** @typedef {ReadonlyArray} JsonArray */ - /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ - - /** -@@= skipped -26, +30 lines =@@ - }} XMLObject */ - - /** @type {XMLObject<{foo:string}>} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const p = {}; - ~ - !!! error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff deleted file mode 100644 index 24b7d9c8d8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff +++ /dev/null @@ -1,98 +0,0 @@ ---- old.returnTagTypeGuard.errors.txt -+++ new.returnTagTypeGuard.errors.txt -@@= skipped -0, +0 lines =@@ -- -+bug25127.js(6,16): error TS8010: Type annotations can only be used in TypeScript files. -+bug25127.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. -+bug25127.js(18,16): error TS8010: Type annotations can only be used in TypeScript files. -+bug25127.js(19,17): error TS8010: Type annotations can only be used in TypeScript files. -+bug25127.js(25,13): error TS8010: Type annotations can only be used in TypeScript files. -+bug25127.js(32,12): error TS8010: Type annotations can only be used in TypeScript files. -+bug25127.js(33,13): error TS8010: Type annotations can only be used in TypeScript files. -+bug25127.js(39,13): error TS8010: Type annotations can only be used in TypeScript files. -+bug25127.js(48,12): error TS8010: Type annotations can only be used in TypeScript files. -+bug25127.js(55,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== bug25127.js (10 errors) ==== -+ class Entry { -+ constructor() { -+ this.c = 1 -+ } -+ /** -+ * @param {any} x -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @return {this is Entry} -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ isInit(x) { -+ return true -+ } -+ } -+ class Group { -+ constructor() { -+ this.d = 'no' -+ } -+ /** -+ * @param {any} x -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @return {false} -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ isInit(x) { -+ return false -+ } -+ } -+ /** @param {Entry | Group} chunk */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ function f(chunk) { -+ let x = chunk.isInit(chunk) ? chunk.c : chunk.d -+ return x -+ } -+ -+ /** -+ * @param {any} value -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @return {value is boolean} -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function isBoolean(value) { -+ return typeof value === "boolean"; -+ } -+ -+ /** @param {boolean | number} val */ -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ function foo(val) { -+ if (isBoolean(val)) { -+ val; -+ } -+ } -+ -+ /** -+ * @callback Cb -+ * @param {unknown} x -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @return {x is number} -+ */ -+ -+ /** @type {Cb} */ -+ function isNumber(x) { return typeof x === "number" } -+ -+ /** @param {unknown} x */ -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ function g(x) { -+ if (isNumber(x)) { -+ x * 2; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.errors.txt.diff index 612215a628..f8301b5289 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/syntaxErrors.errors.txt.diff @@ -3,24 +3,23 @@ @@= skipped -0, +0 lines =@@ -badTypeArguments.js(1,15): error TS1099: Type argument list cannot be empty. -badTypeArguments.js(2,22): error TS1009: Trailing comma not allowed. -+badTypeArguments.js(4,13): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== dummyType.d.ts (0 errors) ==== - declare class C { t: T } - +- +- +-==== dummyType.d.ts (0 errors) ==== +- declare class C { t: T } +- -==== badTypeArguments.js (2 errors) ==== -+==== badTypeArguments.js (1 errors) ==== - /** @param {C.<>} x */ +- /** @param {C.<>} x */ - ~~ -!!! error TS1099: Type argument list cannot be empty. - /** @param {C.} y */ +- /** @param {C.} y */ - ~ -!!! error TS1009: Trailing comma not allowed. - // @ts-ignore - /** @param {C.} skipped */ -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - function f(x, y, skipped) { - return x.t + y.t; - } \ No newline at end of file +- // @ts-ignore +- /** @param {C.} skipped */ +- function f(x, y, skipped) { +- return x.t + y.t; +- } +- var x = f({ t: 1000 }, { t: 3000 }, { t: 5000 }); +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff index 7b9ba7bec4..228097651d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff @@ -6,7 +6,6 @@ -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 TS8010: Type annotations can only be used in TypeScript files. +templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. +templateInsideCallback.js(17,17): error TS8004: Type parameter declarations can only be used in TypeScript files. templateInsideCallback.js(17,18): error TS7006: Parameter 'x' implicitly has an 'any' type. @@ -24,17 +23,10 @@ -!!! 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(29,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+templateInsideCallback.js(29,5): error TS8017: Signature declarations can only be used in TypeScript files. +templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+templateInsideCallback.js(37,5): error TS8017: Signature declarations can only be used in TypeScript files. -+templateInsideCallback.js(43,12): error TS8010: Type annotations can only be used in TypeScript files. -+templateInsideCallback.js(44,12): error TS8010: Type annotations can only be used in TypeScript files. -+templateInsideCallback.js(45,14): error TS8010: Type annotations can only be used in TypeScript files. -+templateInsideCallback.js(48,14): error TS8010: Type annotations can only be used in TypeScript files. -+templateInsideCallback.js(51,31): error TS8016: Type assertion expressions can only be used in TypeScript files. + + -+==== templateInsideCallback.js (14 errors) ==== ++==== templateInsideCallback.js (6 errors) ==== /** * @typedef Oops - ~~~~ @@ -42,7 +34,7 @@ * @template T * @property {T} a * @property {T} b -@@= skipped -27, +23 lines =@@ +@@= skipped -27, +15 lines =@@ /** * @callback Call * @template T @@ -58,8 +50,6 @@ * @type {Call} ~~~~~~~ !!! error TS2315: Type 'Call' is not generic. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS2304: Cannot find name 'T'. */ @@ -69,7 +59,7 @@ ~ !!! error TS7006: Parameter 'x' implicitly has an 'any' type. -@@= skipped -10, +16 lines =@@ +@@= skipped -10, +14 lines =@@ * @property {Object} oh * @property {number} oh.no * @template T @@ -81,13 +71,11 @@ /** * @overload -+ ~~~~~~~~ -+!!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @template T -- ~~~~~~~~ +- * @template T + ~~~~~~~~ -!!! error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag ++!!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. ++ * @template T * @template U * @param {T[]} array - ~ @@ -99,38 +87,14 @@ */ /** * @overload -+ ~~~~~~~~ -+!!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -+ ~~~~~~~~ -+!!! error TS8017: Signature declarations can only be used in TypeScript files. - * @template T -- ~~~~~~~~ +- * @template T + ~~~~~~~~ -!!! error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag ++!!! error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. ++ * @template T * @param {T[][]} array - ~ -!!! error TS2304: Cannot find name 'T'. * @returns {T[]} */ - /** - * @param {unknown[]} array -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {(x: unknown) => unknown} iterable -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {unknown[]} -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function flatMap(array, iterable = identity) { - /** @type {unknown[]} */ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const result = []; - for (let i = 0; i < array.length; i += 1) { - result.push(.../** @type {unknown[]} */(iterable(array[i]))); -+ ~~~~~~~~~ -+!!! error TS8016: Type assertion expressions can only be used in TypeScript files. - } - return result; - } \ No newline at end of file + /** \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff deleted file mode 100644 index 66dfc3b899..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.thisPropertyAssignmentInherited.errors.txt -+++ new.thisPropertyAssignmentInherited.errors.txt -@@= skipped -0, +0 lines =@@ -- -+thisPropertyAssignmentInherited.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== thisPropertyAssignmentInherited.js (1 errors) ==== -+ export class Element { -+ /** -+ * @returns {String} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ get textContent() { -+ return '' -+ } -+ set textContent(x) {} -+ cloneNode() { return this} -+ } -+ export class HTMLElement extends Element {} -+ export class TextElement extends HTMLElement { -+ get innerHTML() { return this.textContent; } -+ set innerHTML(html) { this.textContent = html; } -+ toString() { -+ } -+ } -+ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff deleted file mode 100644 index 72e6cee565..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.thisTag1.errors.txt -+++ new.thisTag1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (3 errors) ==== -+ /** @this {{ n: number }} Mount Holyoke Preparatory School -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {string} s -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @return {number} -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(s) { -+ return this.n + s.length -+ } -+ -+ const o = { -+ f, -+ n: 1 -+ } -+ o.f('hi') -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.errors.txt.diff deleted file mode 100644 index 48e38e625d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.thisTag2.errors.txt -+++ new.thisTag2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(4,10): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (2 errors) ==== -+ /** @this {string} */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ export function f1() {} -+ -+ /** @this */ -+ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ export function f2() {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff deleted file mode 100644 index 94af5b959f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.thisTag3.errors.txt -+++ new.thisTag3.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(2,20): error TS8010: Type annotations can only be used in TypeScript files. - /a.js(7,9): error TS2730: An arrow function cannot have a 'this' parameter. -+/a.js(7,15): error TS8010: Type annotations can only be used in TypeScript files. -+/a.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. - /a.js(10,21): error TS2339: Property 'fn' does not exist on type 'C'. - - --==== /a.js (2 errors) ==== -+==== /a.js (5 errors) ==== - /** - * @typedef {{fn(a: string): void}} T -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - - class C { -@@= skipped -11, +16 lines =@@ - * @this {T} - ~~~~ - !!! error TS2730: An arrow function cannot have a 'this' parameter. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {string} a -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - p = (a) => this.fn("" + a); - ~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff index 2c98ff0a48..e951cbb01a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff @@ -3,20 +3,14 @@ @@= skipped -0, +0 lines =@@ - +thisTypeOfConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+thisTypeOfConstructorFunctions.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. +thisTypeOfConstructorFunctions.js(15,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -+thisTypeOfConstructorFunctions.js(15,18): error TS8010: Type annotations can only be used in TypeScript files. +thisTypeOfConstructorFunctions.js(19,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -+thisTypeOfConstructorFunctions.js(24,12): error TS8010: Type annotations can only be used in TypeScript files. +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(38,12): error TS8010: Type annotations can only be used in TypeScript files. +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(41,12): error TS8010: Type annotations can only be used in TypeScript files. +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(43,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== thisTypeOfConstructorFunctions.js (12 errors) ==== ++==== thisTypeOfConstructorFunctions.js (6 errors) ==== + /** + ~~~ + * @class @@ -25,8 +19,6 @@ + ~~~~~~~~~~~~~~ + * @param {T} t + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function Cp(t) { @@ -49,8 +41,6 @@ + /** @return {this} */ + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + m4() { + this.z = this.y; return this + } @@ -66,8 +56,6 @@ + ~~~~~~~~~~~~~~ + * @param {T} t + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + */ + ~~~ + function Cpp(t) { @@ -89,21 +77,15 @@ + /** @type {Cpp} */ + ~~~ +!!! error TS2749: 'Cpp' refers to a value, but is being used as a type here. Did you mean 'typeof Cpp'? -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + 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'? -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + 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'? -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var cpn = cp.m4() + + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff index 347c43a51a..547bf8d5a5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromContextualThisType.errors.txt.diff @@ -2,16 +2,12 @@ +++ new.typeFromContextualThisType.errors.txt @@= skipped -0, +0 lines =@@ - -+bug25926.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +bug25926.js(4,18): error TS7006: Parameter 'n' implicitly has an 'any' type. -+bug25926.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +bug25926.js(11,27): error TS7006: Parameter 'm' implicitly has an 'any' type. + + -+==== bug25926.js (4 errors) ==== ++==== bug25926.js (2 errors) ==== + /** @type {{ a(): void; b?(n: number): number; }} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const o1 = { + a() { + this.b = n => n; @@ -21,8 +17,6 @@ + }; + + /** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const o2 = { + d() { + this.e = this.f = m => this.g || m; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff index 5fbf5175d2..881af72565 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer.errors.txt.diff @@ -5,18 +5,15 @@ -a.js(4,5): error TS7008: Member 'unknowable' implicitly has an 'any' type. -a.js(5,5): error TS7008: Member 'empty' 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(21,12): error TS8010: Type annotations can only be used in TypeScript files. a.js(25,29): error TS7006: Parameter 'l' 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'. -@@= skipped -7, +6 lines =@@ - 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'. +@@= skipped -9, +7 lines =@@ a.js(37,5): error TS2322: Type 'string' is not assignable to type 'number'. -+a.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. - ==== a.js (10 errors) ==== +-==== a.js (10 errors) ==== ++==== a.js (8 errors) ==== function A () { // should get any on this-assignments in constructor this.unknown = null @@ -34,22 +31,4 @@ +!!! error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. a.unknown = 1 a.unknown = true - a.unknown = {} -@@= skipped -30, +27 lines =@@ - a.empty.push('hi') - - /** @type {number | undefined} */ -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var n; - - // should get any on parameter initialisers -@@= skipped -48, +50 lines =@@ - l.push('ok') - - /** @type {(v: unknown) => v is undefined} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const isUndef = v => v === undefined; - const e = [1, undefined]; - \ No newline at end of file + a.unknown = {} \ No newline at end of file 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 1a46a62fda..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromJSInitializer4.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.typeFromJSInitializer4.errors.txt -+++ new.typeFromJSInitializer4.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. - a.js(5,12): error TS7006: Parameter 'a' 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} */ -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var n; - - // should get any on parameter initialisers \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff index 88c186cd9b..cd5c4c1215 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromParamTagForFunction.errors.txt.diff @@ -3,19 +3,11 @@ @@= skipped -0, +0 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'? -+a.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +b.js(3,13): error TS2749: 'B' refers to a value, but is being used as a type here. Did you mean 'typeof B'? -+b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +c.js(3,13): error TS2749: 'C' refers to a value, but is being used as a type here. Did you mean 'typeof C'? -+c.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +d.js(3,13): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'? -+d.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. -+e.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. +f.js(5,13): error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? -+f.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. +g.js(5,13): error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? -+g.js(5,13): error TS8010: Type annotations can only be used in TypeScript files. -+h.js(7,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== node.d.ts (0 errors) ==== @@ -27,14 +19,12 @@ + this.x = 1; + }; + -+==== a.js (2 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'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function a(p) { p.x; } + +==== b-ext.js (0 errors) ==== @@ -44,14 +34,12 @@ + } + }; + -+==== b.js (2 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'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function b(p) { p.x; } + +==== c-ext.js (0 errors) ==== @@ -59,14 +47,12 @@ + this.x = 1; + } + -+==== c.js (2 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'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function c(p) { p.x; } + +==== d-ext.js (0 errors) ==== @@ -74,14 +60,12 @@ + this.x = 1; + }; + -+==== d.js (2 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'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function d(p) { p.x; } + +==== e-ext.js (0 errors) ==== @@ -91,15 +75,13 @@ + } + } + -+==== e.js (1 errors) ==== ++==== e.js (0 errors) ==== + const { E } = require("./e-ext"); + + /** @param {E} p */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function e(p) { p.x; } + -+==== f.js (2 errors) ==== ++==== f.js (1 errors) ==== + var F = function () { + this.x = 1; + }; @@ -107,11 +89,9 @@ + /** @param {F} p */ + ~ +!!! error TS2749: 'F' refers to a value, but is being used as a type here. Did you mean 'typeof F'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function f(p) { p.x; } + -+==== g.js (2 errors) ==== ++==== g.js (1 errors) ==== + function G() { + this.x = 1; + } @@ -119,11 +99,9 @@ + /** @param {G} p */ + ~ +!!! error TS2749: 'G' refers to a value, but is being used as a type here. Did you mean 'typeof G'? -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function g(p) { p.x; } + -+==== h.js (1 errors) ==== ++==== h.js (0 errors) ==== + class H { + constructor() { + this.x = 1; @@ -131,6 +109,4 @@ + } + + /** @param {H} p */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function h(p) { p.x; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt.diff deleted file mode 100644 index a495120e4a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrivatePropertyAssignmentJs.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.typeFromPrivatePropertyAssignmentJs.errors.txt -+++ new.typeFromPrivatePropertyAssignmentJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(2,16): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(4,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== typeFromPrivatePropertyAssignmentJs.js (0 errors) ==== -+ -+==== a.js (2 errors) ==== -+ class C { -+ /** @type {{ foo?: string } | undefined } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ #a; -+ /** @type {{ foo?: string } | undefined } */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ #b; -+ m() { -+ const a = this.#a || {}; -+ this.#b = this.#b || {}; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff index 866f105819..46f52a51ad 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment.errors.txt.diff @@ -3,12 +3,10 @@ @@= skipped -0, +0 lines =@@ - +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(8,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(11,12): error TS2503: Cannot find namespace 'Outer'. -+a.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (4 errors) ==== ++==== a.js (2 errors) ==== + var Outer = class O { + m(x, y) { } + } @@ -19,15 +17,11 @@ + /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var si + si.m + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var oi + oi.n + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff index 9dfd5dfbc3..50bfd6b072 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 lines =@@ - +main.js(4,12): error TS2503: Cannot find namespace 'Outer'. -+main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== module.js (0 errors) ==== @@ -42,15 +41,13 @@ + }; + return Application; + })(); -+==== main.js (2 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'. -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var x; + x.y; + 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 76a9b86416..4fcf12d543 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment10_1.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 lines =@@ - +main.js(4,12): error TS2503: Cannot find namespace 'Outer'. -+main.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== module.js (0 errors) ==== @@ -42,15 +41,13 @@ + }; + return Application; + })(); -+==== main.js (2 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'. -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var x; + x.y; + 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 8f6a79b070..3cf1ad4cce 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment14.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 lines =@@ - +use.js(1,12): error TS2503: Cannot find namespace 'Outer'. -+use.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +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 '{}'. @@ -23,12 +22,10 @@ + m() { } + } + -+==== use.js (3 errors) ==== ++==== use.js (2 errors) ==== + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var inner + inner.x + inner.m() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff index 7b9bea59fa..99d17f1f61 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment15.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 lines =@@ - +a.js(10,12): error TS2503: Cannot find namespace 'Outer'. -+a.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (2 errors) ==== ++==== a.js (1 errors) ==== + var Outer = {}; + + Outer.Inner = class { @@ -19,8 +18,6 @@ + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var inner + inner.x + inner.m() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff index 11a70d86c0..eaa4b7ab57 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment16.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 lines =@@ - +a.js(9,12): error TS2503: Cannot find namespace 'Outer'. -+a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (2 errors) ==== ++==== a.js (1 errors) ==== + var Outer = {}; + + Outer.Inner = function () {} @@ -18,8 +17,6 @@ + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var inner + inner.x + inner.m() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff index a5eae95386..ee3e704669 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment2.errors.txt.diff @@ -3,12 +3,10 @@ @@= skipped -0, +0 lines =@@ - +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(9,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(12,12): error TS2503: Cannot find namespace 'Outer'. -+a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (4 errors) ==== ++==== a.js (2 errors) ==== + function Outer() { + this.y = 2 + } @@ -20,15 +18,11 @@ + /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var ok + ok.y + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var oc + oc.x + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff index b80b1327f2..1d22ed67e3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment24.errors.txt.diff @@ -4,10 +4,9 @@ - +usage.js(2,13): error TS2339: Property 'Message' does not exist on type 'typeof Inner'. +usage.js(7,12): error TS2503: Cannot find namespace 'Outer'. -+usage.js(7,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== usage.js (3 errors) ==== ++==== usage.js (2 errors) ==== + // note that usage is first in the compilation + Outer.Inner.Message = function() { + ~~~~~~~ @@ -19,8 +18,6 @@ + /** @type {Outer.Inner} should be instance type, not static type */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var x; + x.name + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff index 37000fd1ec..8f97d07393 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment3.errors.txt.diff @@ -3,12 +3,10 @@ @@= skipped -0, +0 lines =@@ - +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(9,12): error TS8010: Type annotations can only be used in TypeScript files. +a.js(12,12): error TS2503: Cannot find namespace 'Outer'. -+a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (4 errors) ==== ++==== a.js (2 errors) ==== + var Outer = function O() { + this.y = 2 + } @@ -20,15 +18,11 @@ + /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var ja + ja.y + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var da + da.x + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff index e12df41181..1f444bc551 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment35.errors.txt.diff @@ -3,19 +3,16 @@ @@= skipped -0, +0 lines =@@ - +bug26877.js(1,13): error TS2503: Cannot find namespace 'Emu'. -+bug26877.js(1,13): error TS8010: Type annotations can only be used in TypeScript files. +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 '{}'. +second.js(3,5): error TS2339: Property 'D' does not exist on type '{}'. + + -+==== bug26877.js (5 errors) ==== ++==== bug26877.js (4 errors) ==== + /** @param {Emu.D} x */ + ~~~ +!!! error TS2503: Cannot find namespace 'Emu'. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function ollKorrect(x) { + x._model + const y = new Emu.D() diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff index 9ad605d215..f71a2bea68 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment4.errors.txt.diff @@ -4,17 +4,15 @@ - +a.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. +a.js(8,12): error TS2503: Cannot find namespace 'Outer'. -+a.js(8,12): error TS8010: Type annotations can only be used in TypeScript files. +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(1,12): error TS8010: Type annotations can only be used in TypeScript files. +b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. + + +==== def.js (0 errors) ==== + var Outer = {}; + -+==== a.js (4 errors) ==== ++==== a.js (3 errors) ==== + Outer.Inner = class { + ~~~~~ +!!! error TS2339: Property 'Inner' does not exist on type '{}'. @@ -27,8 +25,6 @@ + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var local + local.y + var inner = new Outer.Inner() @@ -36,12 +32,10 @@ +!!! error TS2339: Property 'Inner' does not exist on type '{}'. + inner.y + -+==== b.js (3 errors) ==== ++==== b.js (2 errors) ==== + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var x + x.y + 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 index b750247ee2..8d9ed29fb6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment40.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 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(5,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== typeFromPropertyAssignment40.js (2 errors) ==== ++==== typeFromPropertyAssignment40.js (1 errors) ==== + function Outer() { + var self = this + self.y = 2 @@ -14,8 +13,6 @@ + /** @type {Outer} */ + ~~~~~ +!!! error TS2749: 'Outer' refers to a value, but is being used as a type here. Did you mean 'typeof Outer'? -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var ok + ok.y + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff index ce1ce6f8b5..e96d0ee8b7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment5.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 lines =@@ - +b.js(3,12): error TS2503: Cannot find namespace 'MC'. -+b.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (0 errors) ==== @@ -13,13 +12,11 @@ + } + MyClass.bar + -+==== b.js (2 errors) ==== ++==== b.js (1 errors) ==== + import MC from './a' + MC.bar + /** @type {MC.bar} */ + ~~ +!!! error TS2503: Cannot find namespace 'MC'. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var x + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff index 1876bc4daf..af12eda3f3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment6.errors.txt.diff @@ -6,7 +6,6 @@ +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. -+b.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. + + +==== def.js (0 errors) ==== @@ -23,7 +22,7 @@ + ~ +!!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. + -+==== b.js (3 errors) ==== ++==== b.js (2 errors) ==== + var msgs = Outer.i.messages() + ~ +!!! error TS2339: Property 'i' does not exist on type 'typeof Outer'. @@ -31,8 +30,6 @@ + /** @param {Outer.Inner} inner */ + ~~~~~ +!!! error TS2702: 'Outer' only refers to a type, but is being used as a namespace here. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + function x(inner) { + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff index 517637524d..5dfed1d5ae 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff @@ -8,10 +8,9 @@ +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(6,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (7 errors) ==== ++==== index.js (6 errors) ==== + First.Item = class I {} + ~~~~ +!!! error TS2339: Property 'Item' does not exist on type '{}'. @@ -30,8 +29,6 @@ + /** @type {Workspace.Object} */ + ~~~~~~~~~ +!!! error TS2503: Cannot find namespace 'Workspace'. -+ ~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var am; + +==== roots.js (0 errors) ==== diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff index ea5de82244..943eb88deb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment3.errors.txt.diff @@ -7,15 +7,12 @@ - -==== bug26885.js (1 errors) ==== +bug26885.js(2,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+bug26885.js(7,16): error TS8010: Type annotations can only be used in TypeScript files. -+bug26885.js(8,18): error TS8010: Type annotations can only be used in TypeScript files. +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(15,12): error TS8010: Type annotations can only be used in TypeScript files. +bug26885.js(16,13): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. + + -+==== bug26885.js (7 errors) ==== ++==== bug26885.js (4 errors) ==== function Multimap3() { this._map = {}; + ~~~~ @@ -23,13 +20,7 @@ }; Multimap3.prototype = { - /** - * @param {string} key -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {number} the value ok -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -13, +17 lines =@@ */ get(key) { return this._map[key + '']; @@ -44,8 +35,6 @@ /** @type {Multimap3} */ + ~~~~~~~~~ +!!! error TS2749: 'Multimap3' refers to a value, but is being used as a type here. Did you mean 'typeof Multimap3'? -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. 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/typeFromPrototypeAssignment4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.errors.txt.diff deleted file mode 100644 index 453587eb1f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPrototypeAssignment4.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.typeFromPrototypeAssignment4.errors.txt -+++ new.typeFromPrototypeAssignment4.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(7,14): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(8,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (2 errors) ==== -+ function Multimap4() { -+ this._map = {}; -+ }; -+ -+ Multimap4["prototype"] = { -+ /** -+ * @param {string} key -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @returns {number} the value ok -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ get(key) { -+ return this._map[key + '']; -+ } -+ }; -+ -+ Multimap4["prototype"]["add-on"] = function() {}; -+ Multimap4["prototype"]["addon"] = function() {}; -+ Multimap4["prototype"]["__underscores__"] = function() {}; -+ -+ const map4 = new Multimap4(); -+ map4.get(""); -+ map4["add-on"](); -+ map4.addon(); -+ map4.__underscores__(); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff index 01b7451585..c7596d9208 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeLookupInIIFE.errors.txt.diff @@ -2,14 +2,10 @@ +++ new.typeLookupInIIFE.errors.txt @@= skipped -0, +0 lines =@@ -a.js(3,15): error TS2694: Namespace 'ns' has no exported member 'NotFound'. -- -- --==== a.js (1 errors) ==== +a.js(3,12): error TS2503: Cannot find namespace 'ns'. -+a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (2 errors) ==== + + + ==== a.js (1 errors) ==== // #22973 var ns = (function() {})(); /** @type {ns.NotFound} */ @@ -17,7 +13,5 @@ -!!! error TS2694: Namespace 'ns' has no exported member 'NotFound'. + ~~ +!!! error TS2503: Cannot find namespace 'ns'. -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var crash; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff deleted file mode 100644 index 103ab0bae0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.typeTagNoErasure.errors.txt -+++ new.typeTagNoErasure.errors.txt -@@= skipped -0, +0 lines =@@ -+typeTagNoErasure.js(1,47): error TS8010: Type annotations can only be used in TypeScript files. -+typeTagNoErasure.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. - typeTagNoErasure.js(7,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. - - --==== typeTagNoErasure.js (1 errors) ==== -+==== typeTagNoErasure.js (3 errors) ==== - /** @template T @typedef {(data: T1) => T1} Test */ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - - /** @type {Test} */ -+ ~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const test = dibbity => dibbity - - test(1) // ok, T=1 \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.errors.txt.diff deleted file mode 100644 index b1990ffa7d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagOnFunctionReferencesGeneric.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.typeTagOnFunctionReferencesGeneric.errors.txt -+++ new.typeTagOnFunctionReferencesGeneric.errors.txt -@@= skipped -0, +0 lines =@@ -- -+typeTagOnFunctionReferencesGeneric.js(2,21): error TS8010: Type annotations can only be used in TypeScript files. -+typeTagOnFunctionReferencesGeneric.js(11,11): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== typeTagOnFunctionReferencesGeneric.js (2 errors) ==== -+ /** -+ * @typedef {(m : T) => T} IFn -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ -+ /**@type {IFn}*/ -+ export function inJs(l) { -+ return l; -+ } -+ inJs(1); // lints error. Why? -+ -+ /**@type {IFn}*/ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const inJsArrow = (j) => { -+ return j; -+ } -+ inJsArrow(2); // no error gets linted as expected -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff index 25e5f4f22d..09af25bcff 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff @@ -3,10 +3,7 @@ @@= skipped -0, +0 lines =@@ - +mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+use.js(1,12): error TS8010: Type annotations can only be used in TypeScript files. +use.js(1,29): error TS2694: Namespace 'C' has no exported member 'Both'. -+use.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+use.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. + + +==== commonjs.d.ts (0 errors) ==== @@ -43,20 +40,14 @@ + this.p = 1 + } + -+==== use.js (4 errors) ==== ++==== use.js (1 errors) ==== + /** @type {import('./mod1').Both} */ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ +!!! error TS2694: Namespace 'C' has no exported member 'Both'. + var both1 = { type: 'a', x: 1 }; + /** @type {import('./mod2').Both} */ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var both2 = both1; + /** @type {import('./mod3').Both} */ -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var both3 = both2; + + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff index 638115260b..0a4e1b8385 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff @@ -16,25 +16,19 @@ +mod1.js(20,9): error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. +mod1.js(23,1): error TS2300: Duplicate identifier 'export='. +mod1.js(24,5): error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. -+use.js(2,12): error TS8010: Type annotations can only be used in TypeScript files. +use.js(2,32): error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. +use.js(4,12): error TS2503: Cannot find namespace 'mod'. -+use.js(4,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== use.js (4 errors) ==== ++==== use.js (2 errors) ==== var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ +!!! error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. var b; /** @type {mod.Baz} */ + ~~~ +!!! error TS2503: Cannot find namespace 'mod'. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. var bb; var bbb = new mod.Baz(); @@ -77,7 +71,7 @@ // ok -@@= skipped -42, +62 lines =@@ +@@= skipped -42, +56 lines =@@ /** @typedef {number} Quid */ exports.Quid = 2; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff index 9852bbf2b3..917202641a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff @@ -3,34 +3,17 @@ @@= 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(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. +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; }'. -- -- --==== a.js (2 errors) ==== -+a.js(15,12): error TS8010: Type annotations can only be used in TypeScript files. +test.ts(1,23): error TS2304: Cannot find name 'Everything'. -+ -+ -+==== a.js (5 errors) ==== - /** - * @template {{ a: number, b: string }} T,U A Comment - * @template {{ c: boolean }} V uh ... are comments even supported?? -@@= skipped -14, +15 lines =@@ - */ - - /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var tuvwx; + + + ==== a.js (2 errors) ==== +@@= skipped -18, +16 lines =@@ /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~~~~~~~~ -!!! 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; }'. @@ -38,12 +21,7 @@ !!! 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). -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - 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/typedefOnSemicolonClassElement.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnSemicolonClassElement.errors.txt.diff deleted file mode 100644 index dee130d325..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnSemicolonClassElement.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.typedefOnSemicolonClassElement.errors.txt -+++ new.typedefOnSemicolonClassElement.errors.txt -@@= skipped -0, +0 lines =@@ -- -+typedefOnSemicolonClassElement.js(4,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== typedefOnSemicolonClassElement.js (1 errors) ==== -+ export class Preferences { -+ /** @typedef {string} A */ -+ ; -+ /** @type {A} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ a = 'ok' -+ } -+ \ No newline at end of file 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 47b5fcc390..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefOnStatements.errors.txt.diff +++ /dev/null @@ -1,96 +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 (4 errors) ==== -+typedefOnStatements.js(53,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(54,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(55,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(56,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(57,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(58,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(59,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(60,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(61,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(62,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(63,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(64,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(65,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(66,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(67,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(68,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(69,12): error TS8010: Type annotations can only be used in TypeScript files. -+typedefOnStatements.js(73,16): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== typedefOnStatements.js (22 errors) ==== - /** @typedef {{a: string}} A */ - ; - /** @typedef {{ b: string }} B */ -@@= skipped -64, +82 lines =@@ - - /** - * @param {A} a -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {B} b -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {C} c -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {D} d -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {E} e -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {F} f -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {G} g -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {H} h -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {I} i -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {J} j -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {K} k -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {L} l -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {M} m -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {N} n -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {O} o -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {P} p -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @param {Q} q -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function proof (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,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) - /** @type {Alpha} */ -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var alpha = { alpha: "aleph" } - /** @typedef {{ alpha: string }} Alpha */ - return \ No newline at end of file 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 0db0a47968..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefScope1.errors.txt.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.typedefScope1.errors.txt -+++ new.typedefScope1.errors.txt -@@= skipped -0, +0 lines =@@ -+typedefScope1.js(3,16): error TS8010: Type annotations can only be used in TypeScript files. -+typedefScope1.js(9,16): error TS8010: Type annotations can only be used in TypeScript files. - typedefScope1.js(13,12): error TS2304: Cannot find name 'B'. -- -- --==== typedefScope1.js (1 errors) ==== -+typedefScope1.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== typedefScope1.js (4 errors) ==== - function B1() { - /** @typedef {number} B */ - /** @type {B} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var ok1 = 0; - } - - function B2() { - /** @typedef {string} B */ - /** @type {B} */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var ok2 = 'hi'; - } - - /** @type {B} */ - ~ - !!! error TS2304: Cannot find name 'B'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - var notOK = 0; - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff index 78974a81a4..53b9db8293 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagExtraneousProperty.errors.txt.diff @@ -4,10 +4,9 @@ - +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(5,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== typedefTagExtraneousProperty.js (3 errors) ==== ++==== typedefTagExtraneousProperty.js (2 errors) ==== + /** @typedef {Object.} Mmap + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. @@ -17,8 +16,6 @@ + */ + + /** @type {Mmap} */ -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + var y = { bye: "no" }; + y + y.ignoreMe = "ok but just because of the index signature" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.errors.txt.diff deleted file mode 100644 index a06342012d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.errors.txt.diff +++ /dev/null @@ -1,56 +0,0 @@ ---- old.typedefTagNested.errors.txt -+++ new.typedefTagNested.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(35,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (3 errors) ==== -+ /** @typedef {Object} App -+ * @property {string} name -+ * @property {Object} icons -+ * @property {string} icons.image32 -+ * @property {string} icons.image64 -+ */ -+ var ex; -+ -+ /** @type {App} */ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ const app = { -+ name: 'name', -+ icons: { -+ image32: 'x.png', -+ image64: 'y.png', -+ } -+ } -+ -+ /** @typedef {Object} Opp -+ * @property {string} name -+ * @property {Object} oops -+ * @property {string} horrible -+ * @type {string} idea -+ */ -+ var intercessor = 1 -+ -+ /** @type {Opp} */ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ var mistake; -+ -+ /** @typedef {Object} Upp -+ * @property {string} name -+ * @property {Object} not -+ * @property {string} nested -+ */ -+ -+ /** @type {Upp} */ -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ var sala = { name: 'uppsala', not: 0, nested: "ok" }; -+ sala.name -+ sala.not -+ sala.nested -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff index 7d98bcccd9..659cf8a78f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff @@ -3,20 +3,12 @@ @@= skipped -0, +0 lines =@@ +github20832.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. github20832.js(2,15): error TS2304: Cannot find name 'U'. -+github20832.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -+github20832.js(6,13): error TS8010: Type annotations can only be used in TypeScript files. -+github20832.js(12,11): error TS8010: Type annotations can only be used in TypeScript files. +github20832.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. github20832.js(17,12): error TS2304: Cannot find name 'V'. -- -- + + -==== github20832.js (2 errors) ==== -+github20832.js(17,12): error TS8010: Type annotations can only be used in TypeScript files. -+github20832.js(21,12): error TS8010: Type annotations can only be used in TypeScript files. -+github20832.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== github20832.js (10 errors) ==== ++==== github20832.js (4 errors) ==== // #20832 + ~~~~~~~~~ /** @typedef {U} T - should be "error, can't find type named 'U' */ @@ -29,12 +21,8 @@ + ~~~~~~~~~~~~~~ * @param {U} x + ~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @return {T} + ~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function f(x) { @@ -46,8 +34,6 @@ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type T - should be fine, since T will be any */ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. const x = 3; + + @@ -60,8 +46,6 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'V'. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ /** @@ -70,8 +54,6 @@ + ~~~~~~~~~~~~~~ * @param {V} vvvvv + ~~~~~~~~~~~~~~~~~~~ -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ + ~~~ function g(vvvvv) { @@ -81,7 +63,4 @@ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type {Cb} */ -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - const cb = x => {} - \ No newline at end of file + const cb = x => {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff index 2732fe6f60..eaa71cd329 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff @@ -8,32 +8,13 @@ -==== mod1.js (0 errors) ==== +mod1.js(2,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod1.js(9,12): error TS2304: Cannot find name 'Type1'. -+mod1.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod1.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod1.js(11,14): error TS8010: Type annotations can only be used in TypeScript files. -+mod2.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod2.js(12,14): error TS8010: Type annotations can only be used in TypeScript files. +mod3.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod3.js(10,12): error TS2304: Cannot find name 'StringOrNumber1'. -+mod3.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod3.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod3.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod3.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod3.js(14,14): error TS8010: Type annotations can only be used in TypeScript files. +mod4.js(4,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. -+mod4.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod4.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod4.js(13,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod4.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod4.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. -+mod5.js(14,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod5.js(15,14): error TS8010: Type annotations can only be used in TypeScript files. -+mod6.js(12,12): error TS8010: Type annotations can only be used in TypeScript files. -+mod6.js(13,14): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== mod1.js (5 errors) ==== ++==== mod1.js (2 errors) ==== /** * @typedef {function(string): boolean} + ~~~~~~~~ @@ -42,46 +23,21 @@ * Type1 */ -@@= skipped -11, +37 lines =@@ +@@= 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'. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} arg The argument to call it with. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @returns {boolean} The return. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function callIt(func, arg) { - return func(arg); - } - --==== mod2.js (0 errors) ==== -+==== mod2.js (2 errors) ==== - /** - * @typedef {{ - * num: number, -@@= skipped -19, +27 lines =@@ - /** - * Makes use of a type with a multiline type expression. - * @param {Type2} obj The object. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {string|number} The return. -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. */ - function check(obj) { +@@= skipped -25, +27 lines =@@ return obj.boo ? obj.num : obj.str; } -==== mod3.js (0 errors) ==== -+==== mod3.js (7 errors) ==== ++==== mod3.js (2 errors) ==== /** * A function whose signature is very long. * @@ -97,27 +53,15 @@ * @param {StringOrNumber1} func The function. + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'StringOrNumber1'. -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {boolean} bool The condition. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} str The string. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} num The number. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {string|number} The return. -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function use1(func, bool, str, num) { +@@= skipped -20, +25 lines =@@ return func(bool, str, num) } -==== mod4.js (0 errors) ==== -+==== mod4.js (7 errors) ==== ++==== mod4.js (2 errors) ==== /** * A function whose signature is very long. * @@ -128,67 +72,16 @@ * number): * (string|number)} StringOrNumber2 */ -@@= skipped -38, +60 lines =@@ +@@= 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'. -+ ~~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {boolean} bool The condition. -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {string} str The string. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @param {number} num The number. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {string|number} The return. -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function use2(func, bool, str, num) { - return func(bool, str, num) - } - --==== mod5.js (0 errors) ==== -+==== mod5.js (2 errors) ==== - /** - * @typedef {{ - * num: -@@= skipped -24, +36 lines =@@ - /** - * Makes use of a type with a multiline type expression. - * @param {Type5} obj The object. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {string|number} The return. -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function check5(obj) { - return obj.boo ? obj.num : obj.str; - } - --==== mod6.js (0 errors) ==== -+==== mod6.js (2 errors) ==== - /** - * @typedef {{ - * foo: -@@= skipped -19, +23 lines =@@ - /** - * Makes use of a type with a multiline type expression. - * @param {Type6} obj The object. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - * @returns {*} The return. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - function check6(obj) { - return obj.foo; +@@= skipped -50, +52 lines =@@ } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff index 8b24e13068..352902b28f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff @@ -3,15 +3,12 @@ @@= skipped -0, +0 lines =@@ - +uniqueSymbolsDeclarationsInJs.js(4,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+uniqueSymbolsDeclarationsInJs.js(8,15): error TS8010: Type annotations can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJs.js(9,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+uniqueSymbolsDeclarationsInJs.js(13,15): error TS8010: Type annotations can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJs.js(14,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJs.js(20,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+uniqueSymbolsDeclarationsInJs.js(26,12): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== uniqueSymbolsDeclarationsInJs.js (7 errors) ==== ++==== uniqueSymbolsDeclarationsInJs.js (4 errors) ==== + // classes + class C { + /** @@ -23,8 +20,6 @@ + static readonlyStaticCall = Symbol(); + /** + * @type {unique symbol} -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @readonly + ~~~~~~~~~ + */ @@ -33,8 +28,6 @@ + static readonlyStaticType; + /** + * @type {unique symbol} -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + * @readonly + ~~~~~~~~~ + */ @@ -54,7 +47,5 @@ + } + + /** @type {unique symbol} */ -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + const a = Symbol(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff index 503b991f2e..bf3547a2c9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff @@ -1,29 +1,19 @@ --- old.uniqueSymbolsDeclarationsInJsErrors.errors.txt +++ new.uniqueSymbolsDeclarationsInJsErrors.errors.txt @@= skipped -0, +0 lines =@@ -+uniqueSymbolsDeclarationsInJsErrors.js(3,15): error TS8010: Type annotations can only be used in TypeScript files. 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(7,15): error TS8010: Type annotations can only be used in TypeScript files. +uniqueSymbolsDeclarationsInJsErrors.js(8,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+uniqueSymbolsDeclarationsInJsErrors.js(12,15): error TS8010: Type annotations can only be used in TypeScript files. 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) ==== -+==== uniqueSymbolsDeclarationsInJsErrors.js (6 errors) ==== ++==== uniqueSymbolsDeclarationsInJsErrors.js (3 errors) ==== class C { /** * @type {unique symbol} -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - static readwriteStaticType; - ~~~~~~~~~~~~~~~~~~~ - !!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +@@= skipped -12, +13 lines =@@ /** * @type {unique symbol} -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. * @readonly + ~~~~~~~~~ */ @@ -31,9 +21,4 @@ +!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. static readonlyType; /** - * @type {unique symbol} -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - */ - static readwriteType; - ~~~~~~~~~~~~~ \ No newline at end of file + * @type {unique symbol} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff deleted file mode 100644 index fbad269c96..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromJavascript.errors.txt.diff +++ /dev/null @@ -1,39 +0,0 @@ ---- old.varRequireFromJavascript.errors.txt -+++ new.varRequireFromJavascript.errors.txt -@@= skipped -0, +0 lines =@@ -- -+ex.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. -+use.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== use.js (1 errors) ==== -+ var ex = require('./ex') -+ -+ // values work -+ var crunch = new ex.Crunch(1); -+ crunch.n -+ -+ -+ // types work -+ /** -+ * @param {ex.Crunch} wrap -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(wrap) { -+ wrap.n -+ } -+ -+==== ex.js (1 errors) ==== -+ export class Crunch { -+ /** @param {number} n */ -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor(n) { -+ this.n = n -+ } -+ m() { -+ return this.n -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff deleted file mode 100644 index ce435ef2b5..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/varRequireFromTypescript.errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.varRequireFromTypescript.errors.txt -+++ new.varRequireFromTypescript.errors.txt -@@= skipped -0, +0 lines =@@ -- -+use.js(10,12): error TS8010: Type annotations can only be used in TypeScript files. -+use.js(11,12): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== use.js (2 errors) ==== -+ var ex = require('./ex') -+ -+ // values work -+ var crunch = new ex.Crunch(1); -+ crunch.n -+ -+ -+ // types work -+ /** -+ * @param {ex.Greatest} greatest -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ * @param {ex.Crunch} wrap -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ */ -+ function f(greatest, wrap) { -+ greatest.day -+ wrap.n -+ } -+ -+==== ex.d.ts (0 errors) ==== -+ export type Greatest = { day: 1 } -+ export class Crunch { -+ n: number -+ m(): number -+ constructor(n: number) -+ } -+ \ No newline at end of file From bd6a76d9302c2100c71512c0c162c680a0957485 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 03:12:00 +0000 Subject: [PATCH 06/31] Move diagnostic calculation to ast package with thread-safe lazy evaluation Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ast/ast.go | 377 ++++++++++++++++++++++++++++++++++- internal/compiler/program.go | 359 --------------------------------- 2 files changed, 376 insertions(+), 360 deletions(-) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 69ce69758b..0c1db83f8a 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -9,6 +9,7 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -10086,6 +10087,10 @@ type SourceFile struct { lineMapMu sync.RWMutex lineMap []core.TextPos + // Fields set by AdditionalSyntacticDiagnostics + + additionalSyntacticDiagnosticsMu sync.RWMutex + // Fields set by language service tokenCacheMu sync.Mutex @@ -10148,7 +10153,19 @@ func (node *SourceFile) SetJSDocDiagnostics(diags []*Diagnostic) { } func (node *SourceFile) AdditionalSyntacticDiagnostics() []*Diagnostic { - return node.additionalSyntacticDiagnostics + node.additionalSyntacticDiagnosticsMu.RLock() + diagnostics := node.additionalSyntacticDiagnostics + node.additionalSyntacticDiagnosticsMu.RUnlock() + if diagnostics == nil { + node.additionalSyntacticDiagnosticsMu.Lock() + defer node.additionalSyntacticDiagnosticsMu.Unlock() + diagnostics = node.additionalSyntacticDiagnostics + if diagnostics == nil { + diagnostics = node.getJSSyntacticDiagnosticsForFile() + node.additionalSyntacticDiagnostics = diagnostics + } + } + return diagnostics } func (node *SourceFile) SetAdditionalSyntacticDiagnostics(diags []*Diagnostic) { @@ -10475,3 +10492,361 @@ type PragmaSpecification struct { func (spec *PragmaSpecification) IsTripleSlash() bool { return (spec.Kind & PragmaKindTripleSlashXML) > 0 } + +// JS syntactic diagnostics functions + +func (sourceFile *SourceFile) getJSSyntacticDiagnosticsForFile() []*Diagnostic { + var diagnostics []*Diagnostic + + // Walk the entire AST to find TypeScript-only constructs + sourceFile.walkNodeForJSDiagnostics(sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) + + return diagnostics +} + +func (sourceFile *SourceFile) walkNodeForJSDiagnostics(node *Node, parent *Node, diags *[]*Diagnostic) { + if node == nil { + return + } + + // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations + if node.Flags&NodeFlagsReparsed != 0 { + return + } + + // Handle specific parent-child relationships first + switch parent.Kind { + case KindParameter, KindPropertyDeclaration, KindMethodDeclaration: + // Check for question token (optional markers) - only parameters have question tokens + if parent.Kind == KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } + fallthrough + case KindMethodSignature, KindConstructor, KindGetAccessor, KindSetAccessor, + KindFunctionExpression, KindFunctionDeclaration, KindArrowFunction, KindVariableDeclaration: + // Check for type annotations + if sourceFile.isTypeAnnotation(parent, node) { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check node-specific constructs + switch node.Kind { + case KindImportClause: + if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { + *diags = append(*diags, sourceFile.createDiagnosticForNode(parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) + return + } + + case KindExportDeclaration: + if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) + return + } + + case KindImportSpecifier: + if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) + return + } + + case KindExportSpecifier: + if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) + return + } + + case KindImportEqualsDeclaration: + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) + return + + case KindExportAssignment: + if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) + return + } + + case KindHeritageClause: + if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == KindImplementsKeyword { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) + return + } + + case KindInterfaceDeclaration: + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) + return + + case KindModuleDeclaration: + moduleKeyword := "module" + // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) + return + + case KindTypeAliasDeclaration: + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) + return + + case KindEnumDeclaration: + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) + return + + case KindNonNullExpression: + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) + return + + case KindAsExpression: + if node.AsAsExpression() != nil { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case KindSatisfiesExpression: + if node.AsSatisfiesExpression() != nil { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case KindConstructor, KindMethodDeclaration, KindFunctionDeclaration: + // Check for signature declarations (functions without bodies) + if sourceFile.isSignatureDeclaration(node) { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check for type parameters, type arguments, and modifiers + sourceFile.checkTypeParametersAndModifiers(node, diags) + + // Recursively walk children + node.ForEachChild(func(child *Node) bool { + sourceFile.walkNodeForJSDiagnostics(child, node, diags) + return false + }) +} + +func (sourceFile *SourceFile) isTypeAnnotation(parent *Node, node *Node) bool { + switch parent.Kind { + case KindFunctionDeclaration: + return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node + case KindFunctionExpression: + return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node + case KindArrowFunction: + return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node + case KindMethodDeclaration: + return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node + case KindGetAccessor: + return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node + case KindSetAccessor: + return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node + case KindConstructor: + return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node + case KindVariableDeclaration: + return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node + case KindParameter: + return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node + case KindPropertyDeclaration: + return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node + } + return false +} + +func (sourceFile *SourceFile) isSignatureDeclaration(node *Node) bool { + switch node.Kind { + case KindFunctionDeclaration: + return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil + case KindMethodDeclaration: + return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil + case KindConstructor: + return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil + } + return false +} + +func (sourceFile *SourceFile) checkTypeParametersAndModifiers(node *Node, diags *[]*Diagnostic) { + // Check type parameters + if sourceFile.hasTypeParameters(node) { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) + } + + // Check type arguments + if sourceFile.hasTypeArguments(node) { + *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) + } + + // Check modifiers + sourceFile.checkModifiers(node, diags) +} + +func (sourceFile *SourceFile) hasTypeParameters(node *Node) bool { + switch node.Kind { + case KindClassDeclaration: + return node.AsClassDeclaration() != nil && node.AsClassDeclaration().TypeParameters != nil + case KindClassExpression: + return node.AsClassExpression() != nil && node.AsClassExpression().TypeParameters != nil + case KindMethodDeclaration: + return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().TypeParameters != nil + case KindConstructor: + return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().TypeParameters != nil + case KindGetAccessor: + return node.AsGetAccessorDeclaration() != nil && node.AsGetAccessorDeclaration().TypeParameters != nil + case KindSetAccessor: + return node.AsSetAccessorDeclaration() != nil && node.AsSetAccessorDeclaration().TypeParameters != nil + case KindFunctionExpression: + return node.AsFunctionExpression() != nil && node.AsFunctionExpression().TypeParameters != nil + case KindFunctionDeclaration: + return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().TypeParameters != nil + case KindArrowFunction: + return node.AsArrowFunction() != nil && node.AsArrowFunction().TypeParameters != nil + } + return false +} + +func (sourceFile *SourceFile) hasTypeArguments(node *Node) bool { + switch node.Kind { + case KindCallExpression: + return node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil + case KindNewExpression: + return node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil + case KindExpressionWithTypeArguments: + return node.AsExpressionWithTypeArguments() != nil && node.AsExpressionWithTypeArguments().TypeArguments != nil + case KindJsxSelfClosingElement: + return node.AsJsxSelfClosingElement() != nil && node.AsJsxSelfClosingElement().TypeArguments != nil + case KindJsxOpeningElement: + return node.AsJsxOpeningElement() != nil && node.AsJsxOpeningElement().TypeArguments != nil + case KindTaggedTemplateExpression: + return node.AsTaggedTemplateExpression() != nil && node.AsTaggedTemplateExpression().TypeArguments != nil + } + return false +} + +func (sourceFile *SourceFile) checkModifiers(node *Node, diags *[]*Diagnostic) { + // Check for TypeScript-only modifiers on various declaration types + switch node.Kind { + case KindVariableStatement: + if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { + sourceFile.checkModifierList(node.AsVariableStatement().Modifiers(), true, diags) + } + case KindPropertyDeclaration: + if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { + sourceFile.checkPropertyModifiers(node.AsPropertyDeclaration().Modifiers(), diags) + } + case KindParameter: + if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { + sourceFile.checkParameterModifiers(node.AsParameterDeclaration().Modifiers(), diags) + } + } +} + +func (sourceFile *SourceFile) checkModifierList(modifiers *ModifierList, isConstValid bool, diags *[]*Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + sourceFile.checkModifier(modifier, isConstValid, diags) + } +} + +func (sourceFile *SourceFile) checkPropertyModifiers(modifiers *ModifierList, diags *[]*Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Property modifiers allow static and accessor, but not other TypeScript modifiers + switch modifier.Kind { + case KindStaticKeyword, KindAccessorKeyword: + // These are valid in JavaScript + continue + default: + if sourceFile.isTypeScriptOnlyModifier(modifier) { + *diags = append(*diags, sourceFile.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, sourceFile.getTokenText(modifier))) + } + } + } +} + +func (sourceFile *SourceFile) checkParameterModifiers(modifiers *ModifierList, diags *[]*Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + if sourceFile.isTypeScriptOnlyModifier(modifier) { + *diags = append(*diags, sourceFile.createDiagnosticForNode(modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) + } + } +} + +func (sourceFile *SourceFile) checkModifier(modifier *Node, isConstValid bool, diags *[]*Diagnostic) { + switch modifier.Kind { + case KindConstKeyword: + if !isConstValid { + *diags = append(*diags, sourceFile.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "const")) + } + case KindPublicKeyword, KindPrivateKeyword, KindProtectedKeyword, KindReadonlyKeyword, + KindDeclareKeyword, KindAbstractKeyword, KindOverrideKeyword, KindInKeyword, KindOutKeyword: + *diags = append(*diags, sourceFile.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, sourceFile.getTokenText(modifier))) + case KindStaticKeyword, KindExportKeyword, KindDefaultKeyword, KindAccessorKeyword: + // These are valid in JavaScript + } +} + +func (sourceFile *SourceFile) isTypeScriptOnlyModifier(modifier *Node) bool { + switch modifier.Kind { + case KindPublicKeyword, KindPrivateKeyword, KindProtectedKeyword, KindReadonlyKeyword, + KindDeclareKeyword, KindAbstractKeyword, KindOverrideKeyword, KindInKeyword, KindOutKeyword: + return true + } + return false +} + +func (sourceFile *SourceFile) getTokenText(node *Node) string { + switch node.Kind { + case KindPublicKeyword: + return "public" + case KindPrivateKeyword: + return "private" + case KindProtectedKeyword: + return "protected" + case KindReadonlyKeyword: + return "readonly" + case KindDeclareKeyword: + return "declare" + case KindAbstractKeyword: + return "abstract" + case KindOverrideKeyword: + return "override" + case KindInKeyword: + return "in" + case KindOutKeyword: + return "out" + case KindConstKeyword: + return "const" + case KindStaticKeyword: + return "static" + case KindAccessorKeyword: + return "accessor" + default: + return "" + } +} + +func (sourceFile *SourceFile) createDiagnosticForNode(node *Node, message *diagnostics.Message, args ...any) *Diagnostic { + // Find the source file for this node + nodeSourceFile := GetSourceFileOfNode(node) + if nodeSourceFile == nil { + // Fallback to empty range if we can't find the source file + return NewDiagnostic(nil, core.TextRange{}, message, args...) + } + return NewDiagnostic(nodeSourceFile, sourceFile.getErrorRangeForNode(node), message, args...) +} + +func (sourceFile *SourceFile) getErrorRangeForNode(node *Node) core.TextRange { + if node == nil { + return core.TextRange{} + } + return core.NewTextRange(node.Pos(), node.End()) +} diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 9a2164f07e..a8010ad2e2 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -370,370 +370,11 @@ func (p *Program) getSyntacticDiagnosticsForFile(ctx context.Context, sourceFile // For JavaScript files, we report semantic errors for using TypeScript-only // constructs from within a JavaScript file as syntactic errors. if ast.IsSourceFileJS(sourceFile) { - if sourceFile.AdditionalSyntacticDiagnostics() == nil { - sourceFile.SetAdditionalSyntacticDiagnostics(p.getJSSyntacticDiagnosticsForFile(ctx, sourceFile)) - } return append(sourceFile.AdditionalSyntacticDiagnostics(), sourceFile.Diagnostics()...) } return sourceFile.Diagnostics() } -func (p *Program) getJSSyntacticDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { - var diagnostics []*ast.Diagnostic - - // Walk the entire AST to find TypeScript-only constructs - p.walkNodeForJSDiagnostics(sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) - - return diagnostics -} - -func (p *Program) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node, diags *[]*ast.Diagnostic) { - if node == nil { - return - } - - // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations - if node.Flags&ast.NodeFlagsReparsed != 0 { - return - } - - // Handle specific parent-child relationships first - switch parent.Kind { - case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: - // Check for question token (optional markers) - only parameters have question tokens - if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) - return - } - fallthrough - case ast.KindMethodSignature, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, - ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindVariableDeclaration: - // Check for type annotations - if p.isTypeAnnotation(parent, node) { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) - return - } - } - - // Check node-specific constructs - switch node.Kind { - case ast.KindImportClause: - if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { - *diags = append(*diags, p.createDiagnosticForNode(parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) - return - } - - case ast.KindExportDeclaration: - if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) - return - } - - case ast.KindImportSpecifier: - if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) - return - } - - case ast.KindExportSpecifier: - if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) - return - } - - case ast.KindImportEqualsDeclaration: - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) - return - - case ast.KindExportAssignment: - if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) - return - } - - case ast.KindHeritageClause: - if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == ast.KindImplementsKeyword { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) - return - } - - case ast.KindInterfaceDeclaration: - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) - return - - case ast.KindModuleDeclaration: - moduleKeyword := "module" - // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) - return - - case ast.KindTypeAliasDeclaration: - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) - return - - case ast.KindEnumDeclaration: - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) - return - - case ast.KindNonNullExpression: - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) - return - - case ast.KindAsExpression: - if node.AsAsExpression() != nil { - *diags = append(*diags, p.createDiagnosticForNode(node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) - return - } - - case ast.KindSatisfiesExpression: - if node.AsSatisfiesExpression() != nil { - *diags = append(*diags, p.createDiagnosticForNode(node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) - return - } - - case ast.KindConstructor, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: - // Check for signature declarations (functions without bodies) - if p.isSignatureDeclaration(node) { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) - return - } - } - - // Check for type parameters, type arguments, and modifiers - p.checkTypeParametersAndModifiers(node, diags) - - // Recursively walk children - node.ForEachChild(func(child *ast.Node) bool { - p.walkNodeForJSDiagnostics(child, node, diags) - return false - }) -} - -func (p *Program) isTypeAnnotation(parent *ast.Node, node *ast.Node) bool { - switch parent.Kind { - case ast.KindFunctionDeclaration: - return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node - case ast.KindFunctionExpression: - return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node - case ast.KindArrowFunction: - return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node - case ast.KindMethodDeclaration: - return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node - case ast.KindGetAccessor: - return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node - case ast.KindSetAccessor: - return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node - case ast.KindConstructor: - return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node - case ast.KindVariableDeclaration: - return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node - case ast.KindParameter: - return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node - case ast.KindPropertyDeclaration: - return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node - } - return false -} - -func (p *Program) isSignatureDeclaration(node *ast.Node) bool { - switch node.Kind { - case ast.KindFunctionDeclaration: - return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil - case ast.KindMethodDeclaration: - return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil - case ast.KindConstructor: - return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil - } - return false -} - -func (p *Program) checkTypeParametersAndModifiers(node *ast.Node, diags *[]*ast.Diagnostic) { - // Check type parameters - if p.hasTypeParameters(node) { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) - } - - // Check type arguments - if p.hasTypeArguments(node) { - *diags = append(*diags, p.createDiagnosticForNode(node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) - } - - // Check modifiers - p.checkModifiers(node, diags) -} - -func (p *Program) hasTypeParameters(node *ast.Node) bool { - switch node.Kind { - case ast.KindClassDeclaration: - return node.AsClassDeclaration() != nil && node.AsClassDeclaration().TypeParameters != nil - case ast.KindClassExpression: - return node.AsClassExpression() != nil && node.AsClassExpression().TypeParameters != nil - case ast.KindMethodDeclaration: - return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().TypeParameters != nil - case ast.KindConstructor: - return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().TypeParameters != nil - case ast.KindGetAccessor: - return node.AsGetAccessorDeclaration() != nil && node.AsGetAccessorDeclaration().TypeParameters != nil - case ast.KindSetAccessor: - return node.AsSetAccessorDeclaration() != nil && node.AsSetAccessorDeclaration().TypeParameters != nil - case ast.KindFunctionExpression: - return node.AsFunctionExpression() != nil && node.AsFunctionExpression().TypeParameters != nil - case ast.KindFunctionDeclaration: - return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().TypeParameters != nil - case ast.KindArrowFunction: - return node.AsArrowFunction() != nil && node.AsArrowFunction().TypeParameters != nil - } - return false -} - -func (p *Program) hasTypeArguments(node *ast.Node) bool { - switch node.Kind { - case ast.KindCallExpression: - return node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil - case ast.KindNewExpression: - return node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil - case ast.KindExpressionWithTypeArguments: - return node.AsExpressionWithTypeArguments() != nil && node.AsExpressionWithTypeArguments().TypeArguments != nil - case ast.KindJsxSelfClosingElement: - return node.AsJsxSelfClosingElement() != nil && node.AsJsxSelfClosingElement().TypeArguments != nil - case ast.KindJsxOpeningElement: - return node.AsJsxOpeningElement() != nil && node.AsJsxOpeningElement().TypeArguments != nil - case ast.KindTaggedTemplateExpression: - return node.AsTaggedTemplateExpression() != nil && node.AsTaggedTemplateExpression().TypeArguments != nil - } - return false -} - -func (p *Program) checkModifiers(node *ast.Node, diags *[]*ast.Diagnostic) { - // Check for TypeScript-only modifiers on various declaration types - switch node.Kind { - case ast.KindVariableStatement: - if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { - p.checkModifierList(node.AsVariableStatement().Modifiers(), true, diags) - } - case ast.KindPropertyDeclaration: - if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { - p.checkPropertyModifiers(node.AsPropertyDeclaration().Modifiers(), diags) - } - case ast.KindParameter: - if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { - p.checkParameterModifiers(node.AsParameterDeclaration().Modifiers(), diags) - } - } -} - -func (p *Program) checkModifierList(modifiers *ast.ModifierList, isConstValid bool, diags *[]*ast.Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - p.checkModifier(modifier, isConstValid, diags) - } -} - -func (p *Program) checkPropertyModifiers(modifiers *ast.ModifierList, diags *[]*ast.Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - // Property modifiers allow static and accessor, but not other TypeScript modifiers - switch modifier.Kind { - case ast.KindStaticKeyword, ast.KindAccessorKeyword: - // These are valid in JavaScript - continue - default: - if p.isTypeScriptOnlyModifier(modifier) { - *diags = append(*diags, p.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, p.getTokenText(modifier))) - } - } - } -} - -func (p *Program) checkParameterModifiers(modifiers *ast.ModifierList, diags *[]*ast.Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - if p.isTypeScriptOnlyModifier(modifier) { - *diags = append(*diags, p.createDiagnosticForNode(modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) - } - } -} - -func (p *Program) checkModifier(modifier *ast.Node, isConstValid bool, diags *[]*ast.Diagnostic) { - switch modifier.Kind { - case ast.KindConstKeyword: - if !isConstValid { - *diags = append(*diags, p.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "const")) - } - case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, - ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: - *diags = append(*diags, p.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, p.getTokenText(modifier))) - case ast.KindStaticKeyword, ast.KindExportKeyword, ast.KindDefaultKeyword, ast.KindAccessorKeyword: - // These are valid in JavaScript - } -} - -func (p *Program) isTypeScriptOnlyModifier(modifier *ast.Node) bool { - switch modifier.Kind { - case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, - ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: - return true - } - return false -} - -func (p *Program) getTokenText(node *ast.Node) string { - switch node.Kind { - case ast.KindPublicKeyword: - return "public" - case ast.KindPrivateKeyword: - return "private" - case ast.KindProtectedKeyword: - return "protected" - case ast.KindReadonlyKeyword: - return "readonly" - case ast.KindDeclareKeyword: - return "declare" - case ast.KindAbstractKeyword: - return "abstract" - case ast.KindOverrideKeyword: - return "override" - case ast.KindInKeyword: - return "in" - case ast.KindOutKeyword: - return "out" - case ast.KindConstKeyword: - return "const" - case ast.KindStaticKeyword: - return "static" - case ast.KindAccessorKeyword: - return "accessor" - default: - return "" - } -} - -func (p *Program) createDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { - // Find the source file for this node - sourceFile := ast.GetSourceFileOfNode(node) - if sourceFile == nil { - // Fallback to empty range if we can't find the source file - return ast.NewDiagnostic(nil, core.TextRange{}, message, args...) - } - return ast.NewDiagnostic(sourceFile, p.getErrorRangeForNode(node), message, args...) -} - -func (p *Program) getErrorRangeForNode(node *ast.Node) core.TextRange { - if node == nil { - return core.TextRange{} - } - return core.NewTextRange(node.Pos(), node.End()) -} - func (p *Program) getBindDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { // TODO: restore this; tsgo's main depends on this function binding all files for timing. // if checker.SkipTypeChecking(sourceFile, p.compilerOptions) { From 1e6c41e07b4d0f443ebd39f80e4b7187529b77ac Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 03:53:04 +0000 Subject: [PATCH 07/31] Refactor JS diagnostic functions: move field order and extract to separate file Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ast/ast.go | 365 +-------------------------------- internal/ast/js_diagnostics.go | 364 ++++++++++++++++++++++++++++++++ 2 files changed, 368 insertions(+), 361 deletions(-) create mode 100644 internal/ast/js_diagnostics.go diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 0c1db83f8a..a1ae149d89 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -9,7 +9,6 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -10047,9 +10046,8 @@ type SourceFile struct { EndOfFileToken *TokenNode // TokenNode[*EndOfFileToken] // Fields set by parser - diagnostics []*Diagnostic - jsdocDiagnostics []*Diagnostic - additionalSyntacticDiagnostics []*Diagnostic + diagnostics []*Diagnostic + jsdocDiagnostics []*Diagnostic LanguageVariant core.LanguageVariant ScriptKind core.ScriptKind IsDeclarationFile bool @@ -10090,6 +10088,7 @@ type SourceFile struct { // Fields set by AdditionalSyntacticDiagnostics additionalSyntacticDiagnosticsMu sync.RWMutex + additionalSyntacticDiagnostics []*Diagnostic // Fields set by language service @@ -10161,7 +10160,7 @@ func (node *SourceFile) AdditionalSyntacticDiagnostics() []*Diagnostic { defer node.additionalSyntacticDiagnosticsMu.Unlock() diagnostics = node.additionalSyntacticDiagnostics if diagnostics == nil { - diagnostics = node.getJSSyntacticDiagnosticsForFile() + diagnostics = getJSSyntacticDiagnosticsForFile(node) node.additionalSyntacticDiagnostics = diagnostics } } @@ -10493,360 +10492,4 @@ func (spec *PragmaSpecification) IsTripleSlash() bool { return (spec.Kind & PragmaKindTripleSlashXML) > 0 } -// JS syntactic diagnostics functions -func (sourceFile *SourceFile) getJSSyntacticDiagnosticsForFile() []*Diagnostic { - var diagnostics []*Diagnostic - - // Walk the entire AST to find TypeScript-only constructs - sourceFile.walkNodeForJSDiagnostics(sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) - - return diagnostics -} - -func (sourceFile *SourceFile) walkNodeForJSDiagnostics(node *Node, parent *Node, diags *[]*Diagnostic) { - if node == nil { - return - } - - // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations - if node.Flags&NodeFlagsReparsed != 0 { - return - } - - // Handle specific parent-child relationships first - switch parent.Kind { - case KindParameter, KindPropertyDeclaration, KindMethodDeclaration: - // Check for question token (optional markers) - only parameters have question tokens - if parent.Kind == KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) - return - } - fallthrough - case KindMethodSignature, KindConstructor, KindGetAccessor, KindSetAccessor, - KindFunctionExpression, KindFunctionDeclaration, KindArrowFunction, KindVariableDeclaration: - // Check for type annotations - if sourceFile.isTypeAnnotation(parent, node) { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) - return - } - } - - // Check node-specific constructs - switch node.Kind { - case KindImportClause: - if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { - *diags = append(*diags, sourceFile.createDiagnosticForNode(parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) - return - } - - case KindExportDeclaration: - if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) - return - } - - case KindImportSpecifier: - if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) - return - } - - case KindExportSpecifier: - if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) - return - } - - case KindImportEqualsDeclaration: - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) - return - - case KindExportAssignment: - if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) - return - } - - case KindHeritageClause: - if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == KindImplementsKeyword { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) - return - } - - case KindInterfaceDeclaration: - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) - return - - case KindModuleDeclaration: - moduleKeyword := "module" - // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) - return - - case KindTypeAliasDeclaration: - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) - return - - case KindEnumDeclaration: - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) - return - - case KindNonNullExpression: - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) - return - - case KindAsExpression: - if node.AsAsExpression() != nil { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) - return - } - - case KindSatisfiesExpression: - if node.AsSatisfiesExpression() != nil { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) - return - } - - case KindConstructor, KindMethodDeclaration, KindFunctionDeclaration: - // Check for signature declarations (functions without bodies) - if sourceFile.isSignatureDeclaration(node) { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) - return - } - } - - // Check for type parameters, type arguments, and modifiers - sourceFile.checkTypeParametersAndModifiers(node, diags) - - // Recursively walk children - node.ForEachChild(func(child *Node) bool { - sourceFile.walkNodeForJSDiagnostics(child, node, diags) - return false - }) -} - -func (sourceFile *SourceFile) isTypeAnnotation(parent *Node, node *Node) bool { - switch parent.Kind { - case KindFunctionDeclaration: - return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node - case KindFunctionExpression: - return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node - case KindArrowFunction: - return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node - case KindMethodDeclaration: - return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node - case KindGetAccessor: - return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node - case KindSetAccessor: - return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node - case KindConstructor: - return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node - case KindVariableDeclaration: - return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node - case KindParameter: - return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node - case KindPropertyDeclaration: - return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node - } - return false -} - -func (sourceFile *SourceFile) isSignatureDeclaration(node *Node) bool { - switch node.Kind { - case KindFunctionDeclaration: - return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil - case KindMethodDeclaration: - return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil - case KindConstructor: - return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil - } - return false -} - -func (sourceFile *SourceFile) checkTypeParametersAndModifiers(node *Node, diags *[]*Diagnostic) { - // Check type parameters - if sourceFile.hasTypeParameters(node) { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) - } - - // Check type arguments - if sourceFile.hasTypeArguments(node) { - *diags = append(*diags, sourceFile.createDiagnosticForNode(node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) - } - - // Check modifiers - sourceFile.checkModifiers(node, diags) -} - -func (sourceFile *SourceFile) hasTypeParameters(node *Node) bool { - switch node.Kind { - case KindClassDeclaration: - return node.AsClassDeclaration() != nil && node.AsClassDeclaration().TypeParameters != nil - case KindClassExpression: - return node.AsClassExpression() != nil && node.AsClassExpression().TypeParameters != nil - case KindMethodDeclaration: - return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().TypeParameters != nil - case KindConstructor: - return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().TypeParameters != nil - case KindGetAccessor: - return node.AsGetAccessorDeclaration() != nil && node.AsGetAccessorDeclaration().TypeParameters != nil - case KindSetAccessor: - return node.AsSetAccessorDeclaration() != nil && node.AsSetAccessorDeclaration().TypeParameters != nil - case KindFunctionExpression: - return node.AsFunctionExpression() != nil && node.AsFunctionExpression().TypeParameters != nil - case KindFunctionDeclaration: - return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().TypeParameters != nil - case KindArrowFunction: - return node.AsArrowFunction() != nil && node.AsArrowFunction().TypeParameters != nil - } - return false -} - -func (sourceFile *SourceFile) hasTypeArguments(node *Node) bool { - switch node.Kind { - case KindCallExpression: - return node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil - case KindNewExpression: - return node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil - case KindExpressionWithTypeArguments: - return node.AsExpressionWithTypeArguments() != nil && node.AsExpressionWithTypeArguments().TypeArguments != nil - case KindJsxSelfClosingElement: - return node.AsJsxSelfClosingElement() != nil && node.AsJsxSelfClosingElement().TypeArguments != nil - case KindJsxOpeningElement: - return node.AsJsxOpeningElement() != nil && node.AsJsxOpeningElement().TypeArguments != nil - case KindTaggedTemplateExpression: - return node.AsTaggedTemplateExpression() != nil && node.AsTaggedTemplateExpression().TypeArguments != nil - } - return false -} - -func (sourceFile *SourceFile) checkModifiers(node *Node, diags *[]*Diagnostic) { - // Check for TypeScript-only modifiers on various declaration types - switch node.Kind { - case KindVariableStatement: - if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { - sourceFile.checkModifierList(node.AsVariableStatement().Modifiers(), true, diags) - } - case KindPropertyDeclaration: - if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { - sourceFile.checkPropertyModifiers(node.AsPropertyDeclaration().Modifiers(), diags) - } - case KindParameter: - if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { - sourceFile.checkParameterModifiers(node.AsParameterDeclaration().Modifiers(), diags) - } - } -} - -func (sourceFile *SourceFile) checkModifierList(modifiers *ModifierList, isConstValid bool, diags *[]*Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - sourceFile.checkModifier(modifier, isConstValid, diags) - } -} - -func (sourceFile *SourceFile) checkPropertyModifiers(modifiers *ModifierList, diags *[]*Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - // Property modifiers allow static and accessor, but not other TypeScript modifiers - switch modifier.Kind { - case KindStaticKeyword, KindAccessorKeyword: - // These are valid in JavaScript - continue - default: - if sourceFile.isTypeScriptOnlyModifier(modifier) { - *diags = append(*diags, sourceFile.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, sourceFile.getTokenText(modifier))) - } - } - } -} - -func (sourceFile *SourceFile) checkParameterModifiers(modifiers *ModifierList, diags *[]*Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - if sourceFile.isTypeScriptOnlyModifier(modifier) { - *diags = append(*diags, sourceFile.createDiagnosticForNode(modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) - } - } -} - -func (sourceFile *SourceFile) checkModifier(modifier *Node, isConstValid bool, diags *[]*Diagnostic) { - switch modifier.Kind { - case KindConstKeyword: - if !isConstValid { - *diags = append(*diags, sourceFile.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "const")) - } - case KindPublicKeyword, KindPrivateKeyword, KindProtectedKeyword, KindReadonlyKeyword, - KindDeclareKeyword, KindAbstractKeyword, KindOverrideKeyword, KindInKeyword, KindOutKeyword: - *diags = append(*diags, sourceFile.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, sourceFile.getTokenText(modifier))) - case KindStaticKeyword, KindExportKeyword, KindDefaultKeyword, KindAccessorKeyword: - // These are valid in JavaScript - } -} - -func (sourceFile *SourceFile) isTypeScriptOnlyModifier(modifier *Node) bool { - switch modifier.Kind { - case KindPublicKeyword, KindPrivateKeyword, KindProtectedKeyword, KindReadonlyKeyword, - KindDeclareKeyword, KindAbstractKeyword, KindOverrideKeyword, KindInKeyword, KindOutKeyword: - return true - } - return false -} - -func (sourceFile *SourceFile) getTokenText(node *Node) string { - switch node.Kind { - case KindPublicKeyword: - return "public" - case KindPrivateKeyword: - return "private" - case KindProtectedKeyword: - return "protected" - case KindReadonlyKeyword: - return "readonly" - case KindDeclareKeyword: - return "declare" - case KindAbstractKeyword: - return "abstract" - case KindOverrideKeyword: - return "override" - case KindInKeyword: - return "in" - case KindOutKeyword: - return "out" - case KindConstKeyword: - return "const" - case KindStaticKeyword: - return "static" - case KindAccessorKeyword: - return "accessor" - default: - return "" - } -} - -func (sourceFile *SourceFile) createDiagnosticForNode(node *Node, message *diagnostics.Message, args ...any) *Diagnostic { - // Find the source file for this node - nodeSourceFile := GetSourceFileOfNode(node) - if nodeSourceFile == nil { - // Fallback to empty range if we can't find the source file - return NewDiagnostic(nil, core.TextRange{}, message, args...) - } - return NewDiagnostic(nodeSourceFile, sourceFile.getErrorRangeForNode(node), message, args...) -} - -func (sourceFile *SourceFile) getErrorRangeForNode(node *Node) core.TextRange { - if node == nil { - return core.TextRange{} - } - return core.NewTextRange(node.Pos(), node.End()) -} diff --git a/internal/ast/js_diagnostics.go b/internal/ast/js_diagnostics.go new file mode 100644 index 0000000000..b642df9c44 --- /dev/null +++ b/internal/ast/js_diagnostics.go @@ -0,0 +1,364 @@ +package ast + +import ( + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" +) + +// JS syntactic diagnostics functions + +func getJSSyntacticDiagnosticsForFile(sourceFile *SourceFile) []*Diagnostic { + var diagnostics []*Diagnostic + + // Walk the entire AST to find TypeScript-only constructs + walkNodeForJSDiagnostics(sourceFile, sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) + + return diagnostics +} + +func walkNodeForJSDiagnostics(sourceFile *SourceFile, node *Node, parent *Node, diags *[]*Diagnostic) { + if node == nil { + return + } + + // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations + if node.Flags&NodeFlagsReparsed != 0 { + return + } + + // Handle specific parent-child relationships first + switch parent.Kind { + case KindParameter, KindPropertyDeclaration, KindMethodDeclaration: + // Check for question token (optional markers) - only parameters have question tokens + if parent.Kind == KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } + fallthrough + case KindMethodSignature, KindConstructor, KindGetAccessor, KindSetAccessor, + KindFunctionExpression, KindFunctionDeclaration, KindArrowFunction, KindVariableDeclaration: + // Check for type annotations + if isTypeAnnotation(parent, node) { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check node-specific constructs + switch node.Kind { + case KindImportClause: + if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { + *diags = append(*diags, createDiagnosticForNode(sourceFile, parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) + return + } + + case KindExportDeclaration: + if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) + return + } + + case KindImportSpecifier: + if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) + return + } + + case KindExportSpecifier: + if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) + return + } + + case KindImportEqualsDeclaration: + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) + return + + case KindExportAssignment: + if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) + return + } + + case KindHeritageClause: + if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == KindImplementsKeyword { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) + return + } + + case KindInterfaceDeclaration: + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) + return + + case KindModuleDeclaration: + moduleKeyword := "module" + // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) + return + + case KindTypeAliasDeclaration: + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) + return + + case KindEnumDeclaration: + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) + return + + case KindNonNullExpression: + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) + return + + case KindAsExpression: + if node.AsAsExpression() != nil { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case KindSatisfiesExpression: + if node.AsSatisfiesExpression() != nil { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case KindConstructor, KindMethodDeclaration, KindFunctionDeclaration: + // Check for signature declarations (functions without bodies) + if isSignatureDeclaration(node) { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check for type parameters, type arguments, and modifiers + checkTypeParametersAndModifiers(sourceFile, node, diags) + + // Recursively walk children + node.ForEachChild(func(child *Node) bool { + walkNodeForJSDiagnostics(sourceFile, child, node, diags) + return false + }) +} + +func isTypeAnnotation(parent *Node, node *Node) bool { + switch parent.Kind { + case KindFunctionDeclaration: + return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node + case KindFunctionExpression: + return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node + case KindArrowFunction: + return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node + case KindMethodDeclaration: + return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node + case KindGetAccessor: + return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node + case KindSetAccessor: + return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node + case KindConstructor: + return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node + case KindVariableDeclaration: + return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node + case KindParameter: + return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node + case KindPropertyDeclaration: + return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node + } + return false +} + +func isSignatureDeclaration(node *Node) bool { + switch node.Kind { + case KindFunctionDeclaration: + return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil + case KindMethodDeclaration: + return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil + case KindConstructor: + return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil + } + return false +} + +func checkTypeParametersAndModifiers(sourceFile *SourceFile, node *Node, diags *[]*Diagnostic) { + // Check type parameters + if hasTypeParameters(node) { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) + } + + // Check type arguments + if hasTypeArguments(node) { + *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) + } + + // Check modifiers + checkModifiers(sourceFile, node, diags) +} + +func hasTypeParameters(node *Node) bool { + switch node.Kind { + case KindClassDeclaration: + return node.AsClassDeclaration() != nil && node.AsClassDeclaration().TypeParameters != nil + case KindClassExpression: + return node.AsClassExpression() != nil && node.AsClassExpression().TypeParameters != nil + case KindMethodDeclaration: + return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().TypeParameters != nil + case KindConstructor: + return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().TypeParameters != nil + case KindGetAccessor: + return node.AsGetAccessorDeclaration() != nil && node.AsGetAccessorDeclaration().TypeParameters != nil + case KindSetAccessor: + return node.AsSetAccessorDeclaration() != nil && node.AsSetAccessorDeclaration().TypeParameters != nil + case KindFunctionExpression: + return node.AsFunctionExpression() != nil && node.AsFunctionExpression().TypeParameters != nil + case KindFunctionDeclaration: + return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().TypeParameters != nil + case KindArrowFunction: + return node.AsArrowFunction() != nil && node.AsArrowFunction().TypeParameters != nil + } + return false +} + +func hasTypeArguments(node *Node) bool { + switch node.Kind { + case KindCallExpression: + return node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil + case KindNewExpression: + return node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil + case KindExpressionWithTypeArguments: + return node.AsExpressionWithTypeArguments() != nil && node.AsExpressionWithTypeArguments().TypeArguments != nil + case KindJsxSelfClosingElement: + return node.AsJsxSelfClosingElement() != nil && node.AsJsxSelfClosingElement().TypeArguments != nil + case KindJsxOpeningElement: + return node.AsJsxOpeningElement() != nil && node.AsJsxOpeningElement().TypeArguments != nil + case KindTaggedTemplateExpression: + return node.AsTaggedTemplateExpression() != nil && node.AsTaggedTemplateExpression().TypeArguments != nil + } + return false +} + +func checkModifiers(sourceFile *SourceFile, node *Node, diags *[]*Diagnostic) { + // Check for TypeScript-only modifiers on various declaration types + switch node.Kind { + case KindVariableStatement: + if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { + checkModifierList(sourceFile, node.AsVariableStatement().Modifiers(), true, diags) + } + case KindPropertyDeclaration: + if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { + checkPropertyModifiers(sourceFile, node.AsPropertyDeclaration().Modifiers(), diags) + } + case KindParameter: + if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { + checkParameterModifiers(sourceFile, node.AsParameterDeclaration().Modifiers(), diags) + } + } +} + +func checkModifierList(sourceFile *SourceFile, modifiers *ModifierList, isConstValid bool, diags *[]*Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + checkModifier(sourceFile, modifier, isConstValid, diags) + } +} + +func checkPropertyModifiers(sourceFile *SourceFile, modifiers *ModifierList, diags *[]*Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Property modifiers allow static and accessor, but not other TypeScript modifiers + switch modifier.Kind { + case KindStaticKeyword, KindAccessorKeyword: + // These are valid in JavaScript + continue + default: + if isTypeScriptOnlyModifier(modifier) { + *diags = append(*diags, createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, getTokenText(modifier))) + } + } + } +} + +func checkParameterModifiers(sourceFile *SourceFile, modifiers *ModifierList, diags *[]*Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + if isTypeScriptOnlyModifier(modifier) { + *diags = append(*diags, createDiagnosticForNode(sourceFile, modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) + } + } +} + +func checkModifier(sourceFile *SourceFile, modifier *Node, isConstValid bool, diags *[]*Diagnostic) { + switch modifier.Kind { + case KindConstKeyword: + if !isConstValid { + *diags = append(*diags, createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "const")) + } + case KindPublicKeyword, KindPrivateKeyword, KindProtectedKeyword, KindReadonlyKeyword, + KindDeclareKeyword, KindAbstractKeyword, KindOverrideKeyword, KindInKeyword, KindOutKeyword: + *diags = append(*diags, createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, getTokenText(modifier))) + case KindStaticKeyword, KindExportKeyword, KindDefaultKeyword, KindAccessorKeyword: + // These are valid in JavaScript + } +} + +func isTypeScriptOnlyModifier(modifier *Node) bool { + switch modifier.Kind { + case KindPublicKeyword, KindPrivateKeyword, KindProtectedKeyword, KindReadonlyKeyword, + KindDeclareKeyword, KindAbstractKeyword, KindOverrideKeyword, KindInKeyword, KindOutKeyword: + return true + } + return false +} + +func getTokenText(node *Node) string { + switch node.Kind { + case KindPublicKeyword: + return "public" + case KindPrivateKeyword: + return "private" + case KindProtectedKeyword: + return "protected" + case KindReadonlyKeyword: + return "readonly" + case KindDeclareKeyword: + return "declare" + case KindAbstractKeyword: + return "abstract" + case KindOverrideKeyword: + return "override" + case KindInKeyword: + return "in" + case KindOutKeyword: + return "out" + case KindConstKeyword: + return "const" + case KindStaticKeyword: + return "static" + case KindAccessorKeyword: + return "accessor" + default: + return "" + } +} + +func createDiagnosticForNode(sourceFile *SourceFile, node *Node, message *diagnostics.Message, args ...any) *Diagnostic { + // Find the source file for this node + nodeSourceFile := GetSourceFileOfNode(node) + if nodeSourceFile == nil { + // Fallback to empty range if we can't find the source file + return NewDiagnostic(nil, core.TextRange{}, message, args...) + } + return NewDiagnostic(nodeSourceFile, getErrorRangeForNode(node), message, args...) +} + +func getErrorRangeForNode(node *Node) core.TextRange { + if node == nil { + return core.TextRange{} + } + return core.NewTextRange(node.Pos(), node.End()) +} \ No newline at end of file From 84ece9d2ad3023dcf4f78b53b44ddf78d1d9834c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 04:23:42 +0000 Subject: [PATCH 08/31] Address review feedback: format code, fix diagnostics initialization, remove unused function, and use slices.Concat Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ast/ast.go | 50 +++++++++++++++------------------- internal/ast/js_diagnostics.go | 4 +-- internal/compiler/program.go | 2 +- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index a1ae149d89..be98f4963b 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -10046,28 +10046,28 @@ type SourceFile struct { EndOfFileToken *TokenNode // TokenNode[*EndOfFileToken] // Fields set by parser - diagnostics []*Diagnostic - jsdocDiagnostics []*Diagnostic - LanguageVariant core.LanguageVariant - ScriptKind core.ScriptKind - IsDeclarationFile bool - UsesUriStyleNodeCoreModules core.Tristate - Identifiers map[string]string - IdentifierCount int - imports []*LiteralLikeNode // []LiteralLikeNode - ModuleAugmentations []*ModuleName // []ModuleName - AmbientModuleNames []string - CommentDirectives []CommentDirective - jsdocCache map[*Node][]*Node - Pragmas []Pragma - ReferencedFiles []*FileReference - TypeReferenceDirectives []*FileReference - LibReferenceDirectives []*FileReference - CheckJsDirective *CheckJsDirective - NodeCount int - TextCount int - CommonJSModuleIndicator *Node - ExternalModuleIndicator *Node + diagnostics []*Diagnostic + jsdocDiagnostics []*Diagnostic + LanguageVariant core.LanguageVariant + ScriptKind core.ScriptKind + IsDeclarationFile bool + UsesUriStyleNodeCoreModules core.Tristate + Identifiers map[string]string + IdentifierCount int + imports []*LiteralLikeNode // []LiteralLikeNode + ModuleAugmentations []*ModuleName // []ModuleName + AmbientModuleNames []string + CommentDirectives []CommentDirective + jsdocCache map[*Node][]*Node + Pragmas []Pragma + ReferencedFiles []*FileReference + TypeReferenceDirectives []*FileReference + LibReferenceDirectives []*FileReference + CheckJsDirective *CheckJsDirective + NodeCount int + TextCount int + CommonJSModuleIndicator *Node + ExternalModuleIndicator *Node // Fields set by binder @@ -10167,10 +10167,6 @@ func (node *SourceFile) AdditionalSyntacticDiagnostics() []*Diagnostic { return diagnostics } -func (node *SourceFile) SetAdditionalSyntacticDiagnostics(diags []*Diagnostic) { - node.additionalSyntacticDiagnostics = diags -} - func (node *SourceFile) JSDocCache() map[*Node][]*Node { return node.jsdocCache } @@ -10491,5 +10487,3 @@ type PragmaSpecification struct { func (spec *PragmaSpecification) IsTripleSlash() bool { return (spec.Kind & PragmaKindTripleSlashXML) > 0 } - - diff --git a/internal/ast/js_diagnostics.go b/internal/ast/js_diagnostics.go index b642df9c44..c292044051 100644 --- a/internal/ast/js_diagnostics.go +++ b/internal/ast/js_diagnostics.go @@ -8,7 +8,7 @@ import ( // JS syntactic diagnostics functions func getJSSyntacticDiagnosticsForFile(sourceFile *SourceFile) []*Diagnostic { - var diagnostics []*Diagnostic + diagnostics := []*Diagnostic{} // Walk the entire AST to find TypeScript-only constructs walkNodeForJSDiagnostics(sourceFile, sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) @@ -361,4 +361,4 @@ func getErrorRangeForNode(node *Node) core.TextRange { return core.TextRange{} } return core.NewTextRange(node.Pos(), node.End()) -} \ No newline at end of file +} diff --git a/internal/compiler/program.go b/internal/compiler/program.go index a8010ad2e2..2e77d5aa6c 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -370,7 +370,7 @@ func (p *Program) getSyntacticDiagnosticsForFile(ctx context.Context, sourceFile // For JavaScript files, we report semantic errors for using TypeScript-only // constructs from within a JavaScript file as syntactic errors. if ast.IsSourceFileJS(sourceFile) { - return append(sourceFile.AdditionalSyntacticDiagnostics(), sourceFile.Diagnostics()...) + return slices.Concat(sourceFile.AdditionalSyntacticDiagnostics(), sourceFile.Diagnostics()) } return sourceFile.Diagnostics() } From 617d7acc456158c89942ac849d1187ea50d74f36 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 05:23:36 +0000 Subject: [PATCH 09/31] Add NodeFlagsReparsed checks to fix false positives on JSDoc type annotations Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ast/js_diagnostics.go | 85 +++++++- .../arrowExpressionBodyJSDoc.errors.txt | 8 +- .../compiler/arrowExpressionJs.errors.txt | 12 -- ...nferenceFromAnnotatedFunctionJs.errors.txt | 19 +- ...ithAnnotatedOptionalParameterJs.errors.txt | 37 ---- ...peNode4(strictnullchecks=false).errors.txt | 43 ---- ...ypeNode4(strictnullchecks=true).errors.txt | 43 ---- .../jsFileFunctionOverloads.errors.txt | 64 ------ .../jsFileFunctionOverloads2.errors.txt | 59 ------ .../compiler/jsFileFunctionOverloads2.js | 26 +++ .../compiler/jsFileFunctionOverloads2.js.diff | 28 ++- .../compiler/jsFileMethodOverloads.errors.txt | 98 --------- .../jsFileMethodOverloads2.errors.txt | 92 -------- .../jsdocClassMissingTypeArguments.errors.txt | 6 +- .../compiler/jsdocIllegalTags.errors.txt | 7 +- ...nusedTypeParameters_templateTag.errors.txt | 6 +- ...usedTypeParameters_templateTag2.errors.txt | 39 +--- ...assCanExtendConstructorFunction.errors.txt | 11 +- ...torFunctionMethodTypeParameters.errors.txt | 23 +- .../conformance/extendsTag1.errors.txt | 9 +- .../conformance/extendsTag5.errors.txt | 22 +- .../genericSetterInClassTypeJsDoc.errors.txt | 48 ----- .../conformance/inferThis.errors.txt | 53 ----- ...ypeParameterOnVariableStatement.errors.txt | 19 -- ...ImplementsGenericsSerialization.errors.txt | 39 ---- .../jsDeclarationsClasses.errors.txt | 162 +------------- ...rationsExportDefinePropertyEmit.errors.txt | 25 +-- .../jsDeclarationsFunctions.errors.txt | 24 +-- .../jsdocAccessibilityTags.errors.txt | 14 +- .../conformance/jsdocReadonly.errors.txt | 16 +- .../jsdocReadonlyDeclarations.errors.txt | 5 +- .../conformance/jsdocTemplateClass.errors.txt | 26 +-- ...sdocTemplateConstructorFunction.errors.txt | 43 ---- ...docTemplateConstructorFunction2.errors.txt | 13 +- .../conformance/jsdocTemplateTag.errors.txt | 23 +- .../conformance/jsdocTemplateTag2.errors.txt | 19 -- .../conformance/jsdocTemplateTag3.errors.txt | 32 +-- .../conformance/jsdocTemplateTag4.errors.txt | 20 +- .../conformance/jsdocTemplateTag5.errors.txt | 20 +- .../conformance/jsdocTemplateTag6.errors.txt | 193 ----------------- .../conformance/jsdocTemplateTag7.errors.txt | 25 +-- .../conformance/jsdocTemplateTag8.errors.txt | 11 +- .../jsdocTemplateTagDefault.errors.txt | 63 +----- .../conformance/overloadTag3.errors.txt | 40 ---- .../paramTagTypeResolution2.errors.txt | 22 -- ...ateNamesIncompatibleModifiersJs.errors.txt | 14 +- ...esOfGenericConstructorFunctions.errors.txt | 29 +-- .../templateInsideCallback.errors.txt | 5 +- .../thisTypeOfConstructorFunctions.errors.txt | 28 +-- .../typedefTagTypeResolution.errors.txt | 28 +-- .../uniqueSymbolsDeclarationsInJs.errors.txt | 47 ----- ...ueSymbolsDeclarationsInJsErrors.errors.txt | 6 +- .../arrowExpressionBodyJSDoc.errors.txt.diff | 28 +-- .../arrowExpressionJs.errors.txt.diff | 16 -- ...nceFromAnnotatedFunctionJs.errors.txt.diff | 19 +- ...notatedOptionalParameterJs.errors.txt.diff | 41 ---- ...e4(strictnullchecks=false).errors.txt.diff | 47 ----- ...de4(strictnullchecks=true).errors.txt.diff | 47 ----- .../jsFileFunctionOverloads.errors.txt.diff | 68 ------ .../jsFileFunctionOverloads2.errors.txt.diff | 63 ------ .../jsFileMethodOverloads.errors.txt.diff | 102 --------- .../jsFileMethodOverloads2.errors.txt.diff | 96 --------- ...cClassMissingTypeArguments.errors.txt.diff | 17 -- .../compiler/jsdocIllegalTags.errors.txt.diff | 12 +- ...TypeParameters_templateTag.errors.txt.diff | 13 +- ...ypeParameters_templateTag2.errors.txt.diff | 41 +--- ...nExtendConstructorFunction.errors.txt.diff | 17 +- ...nctionMethodTypeParameters.errors.txt.diff | 23 +- .../conformance/extendsTag1.errors.txt.diff | 9 +- .../conformance/extendsTag5.errors.txt.diff | 42 +--- ...ericSetterInClassTypeJsDoc.errors.txt.diff | 52 ----- .../conformance/inferThis.errors.txt.diff | 57 ----- ...rameterOnVariableStatement.errors.txt.diff | 23 -- ...mentsGenericsSerialization.errors.txt.diff | 43 ---- .../jsDeclarationsClasses.errors.txt.diff | 162 +------------- ...nsExportDefinePropertyEmit.errors.txt.diff | 25 +-- .../jsDeclarationsFunctions.errors.txt.diff | 24 +-- .../jsdocAccessibilityTags.errors.txt.diff | 45 ---- .../conformance/jsdocReadonly.errors.txt.diff | 36 ---- .../jsdocReadonlyDeclarations.errors.txt.diff | 5 +- .../jsdocTemplateClass.errors.txt.diff | 57 ----- ...emplateConstructorFunction.errors.txt.diff | 68 +++--- ...mplateConstructorFunction2.errors.txt.diff | 25 +-- .../jsdocTemplateTag.errors.txt.diff | 37 +--- .../jsdocTemplateTag2.errors.txt.diff | 23 -- .../jsdocTemplateTag3.errors.txt.diff | 64 +----- .../jsdocTemplateTag4.errors.txt.diff | 20 +- .../jsdocTemplateTag5.errors.txt.diff | 20 +- .../jsdocTemplateTag6.errors.txt.diff | 197 ------------------ .../jsdocTemplateTag7.errors.txt.diff | 55 ----- .../jsdocTemplateTag8.errors.txt.diff | 33 +-- .../jsdocTemplateTagDefault.errors.txt.diff | 118 +---------- .../conformance/overloadTag3.errors.txt.diff | 44 ---- .../paramTagTypeResolution2.errors.txt.diff | 26 --- ...mesIncompatibleModifiersJs.errors.txt.diff | 50 ----- ...enericConstructorFunctions.errors.txt.diff | 29 +-- .../templateInsideCallback.errors.txt.diff | 11 +- ...TypeOfConstructorFunctions.errors.txt.diff | 28 +-- .../typedefTagTypeResolution.errors.txt.diff | 66 ------ ...queSymbolsDeclarationsInJs.errors.txt.diff | 51 ----- ...bolsDeclarationsInJsErrors.errors.txt.diff | 24 --- 101 files changed, 243 insertions(+), 3825 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/inferThis.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff diff --git a/internal/ast/js_diagnostics.go b/internal/ast/js_diagnostics.go index c292044051..2584808012 100644 --- a/internal/ast/js_diagnostics.go +++ b/internal/ast/js_diagnostics.go @@ -177,6 +177,11 @@ func isSignatureDeclaration(node *Node) bool { } func checkTypeParametersAndModifiers(sourceFile *SourceFile, node *Node, diags *[]*Diagnostic) { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&NodeFlagsReparsed != 0 { + return + } + // Check type parameters if hasTypeParameters(node) { *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) @@ -192,30 +197,73 @@ func checkTypeParametersAndModifiers(sourceFile *SourceFile, node *Node, diags * } func hasTypeParameters(node *Node) bool { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&NodeFlagsReparsed != 0 { + return false + } + + var typeParameters *NodeList switch node.Kind { case KindClassDeclaration: - return node.AsClassDeclaration() != nil && node.AsClassDeclaration().TypeParameters != nil + if node.AsClassDeclaration() != nil { + typeParameters = node.AsClassDeclaration().TypeParameters + } case KindClassExpression: - return node.AsClassExpression() != nil && node.AsClassExpression().TypeParameters != nil + if node.AsClassExpression() != nil { + typeParameters = node.AsClassExpression().TypeParameters + } case KindMethodDeclaration: - return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().TypeParameters != nil + if node.AsMethodDeclaration() != nil { + typeParameters = node.AsMethodDeclaration().TypeParameters + } case KindConstructor: - return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().TypeParameters != nil + if node.AsConstructorDeclaration() != nil { + typeParameters = node.AsConstructorDeclaration().TypeParameters + } case KindGetAccessor: - return node.AsGetAccessorDeclaration() != nil && node.AsGetAccessorDeclaration().TypeParameters != nil + if node.AsGetAccessorDeclaration() != nil { + typeParameters = node.AsGetAccessorDeclaration().TypeParameters + } case KindSetAccessor: - return node.AsSetAccessorDeclaration() != nil && node.AsSetAccessorDeclaration().TypeParameters != nil + if node.AsSetAccessorDeclaration() != nil { + typeParameters = node.AsSetAccessorDeclaration().TypeParameters + } case KindFunctionExpression: - return node.AsFunctionExpression() != nil && node.AsFunctionExpression().TypeParameters != nil + if node.AsFunctionExpression() != nil { + typeParameters = node.AsFunctionExpression().TypeParameters + } case KindFunctionDeclaration: - return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().TypeParameters != nil + if node.AsFunctionDeclaration() != nil { + typeParameters = node.AsFunctionDeclaration().TypeParameters + } case KindArrowFunction: - return node.AsArrowFunction() != nil && node.AsArrowFunction().TypeParameters != nil + if node.AsArrowFunction() != nil { + typeParameters = node.AsArrowFunction().TypeParameters + } + default: + return false } - return false + + if typeParameters == nil { + return false + } + + // Check if all type parameters are reparsed (JSDoc originated) + for _, tp := range typeParameters.Nodes { + if tp.Flags&NodeFlagsReparsed == 0 { + return true // Found a non-reparsed type parameter, so this is a TypeScript-only construct + } + } + + return false // All type parameters are reparsed (JSDoc originated), so this is valid in JS } func hasTypeArguments(node *Node) bool { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&NodeFlagsReparsed != 0 { + return false + } + switch node.Kind { case KindCallExpression: return node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil @@ -234,6 +282,11 @@ func hasTypeArguments(node *Node) bool { } func checkModifiers(sourceFile *SourceFile, node *Node, diags *[]*Diagnostic) { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&NodeFlagsReparsed != 0 { + return + } + // Check for TypeScript-only modifiers on various declaration types switch node.Kind { case KindVariableStatement: @@ -257,6 +310,10 @@ func checkModifierList(sourceFile *SourceFile, modifiers *ModifierList, isConstV } for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&NodeFlagsReparsed != 0 { + continue + } checkModifier(sourceFile, modifier, isConstValid, diags) } } @@ -267,6 +324,10 @@ func checkPropertyModifiers(sourceFile *SourceFile, modifiers *ModifierList, dia } for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&NodeFlagsReparsed != 0 { + continue + } // Property modifiers allow static and accessor, but not other TypeScript modifiers switch modifier.Kind { case KindStaticKeyword, KindAccessorKeyword: @@ -286,6 +347,10 @@ func checkParameterModifiers(sourceFile *SourceFile, modifiers *ModifierList, di } for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&NodeFlagsReparsed != 0 { + continue + } if isTypeScriptOnlyModifier(modifier) { *diags = append(*diags, createDiagnosticForNode(sourceFile, modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) } diff --git a/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt b/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt index d541cfc7e3..ff0349247e 100644 --- a/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.errors.txt @@ -1,20 +1,16 @@ -mytest.js(6,13): error TS8004: Type parameter declarations can only be used in TypeScript files. mytest.js(6,45): error TS2322: Type 'string' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -mytest.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. mytest.js(13,61): error TS2322: Type 'string' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -==== mytest.js (4 errors) ==== +==== mytest.js (2 errors) ==== /** * @template T * @param {T|undefined} value value or not * @returns {T} result value */ const foo1 = value => /** @type {string} */({ ...value }); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. @@ -25,8 +21,6 @@ mytest.js(13,61): error TS2322: Type 'string' is not assignable to type 'T'. * @returns {T} result value */ const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt b/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt deleted file mode 100644 index 93ae5e06a3..0000000000 --- a/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -mytest.js(6,24): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== mytest.js (1 errors) ==== - /** - * @template T - * @param {T|undefined} value value or not - * @returns {T} result value - */ - const cloneObjectGood = value => /** @type {T} */({ ...value }); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt index bc73f48bc1..b812e341fb 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt @@ -1,4 +1,3 @@ -index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(2,28): error TS2304: Cannot find name 'B'. index.js(2,42): error TS2304: Cannot find name 'A'. index.js(2,48): error TS2304: Cannot find name 'B'. @@ -6,11 +5,9 @@ index.js(2,67): error TS2304: Cannot find name 'B'. index.js(10,12): error TS2315: Type 'Funcs' is not generic. -==== index.js (6 errors) ==== +==== index.js (5 errors) ==== /** - ~~~ * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'B'. ~ @@ -20,34 +17,20 @@ index.js(10,12): error TS2315: Type 'Funcs' is not generic. ~ !!! error TS2304: Cannot find name 'B'. * @template A - ~~~~~~~~~~~~~~ * @template {Record} B - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~ - /** - ~~~ * @template A - ~~~~~~~~~~~~~~ * @template {Record} B - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {Funcs} fns - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS2315: Type 'Funcs' is not generic. * @returns {[A, B]} - ~~~~~~~~~~~~~~~~~~~~ */ - ~~~ function foo(fns) { - ~~~~~~~~~~~~~~~~~~~ return /** @type {any} */ (null); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. const result = foo({ bar: { 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 adb56c7b62..0000000000 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt +++ /dev/null @@ -1,37 +0,0 @@ -index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - /** - ~~~ - * @template T - ~~~~~~~~~~~~~~ - * @param {(value: T, index: number) => boolean} predicate - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {T} - ~~~~~~~~~~~~~~~ - */ - ~~~ - function filter(predicate) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - return /** @type {any} */ (null); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - const a = filter( - /** - * @param {number} [pose] - */ - (pose) => true - ); - - const b = filter( - /** - * @param {number} [pose] - * @param {number} [_] - */ - (pose, _) => true - ); - \ No newline at end of file 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 4399f211f5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt +++ /dev/null @@ -1,43 +0,0 @@ -input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. - - -==== input.js (1 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) {} - - export class C { - field = /** @type {P} */(something); - /** @optional */ optField = /** @type {P} */(something); // not a thing - /** @readonly */ roFiled = /** @type {P} */(something); - ~~~~~~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - method(p = /** @type {P} */(something)) {} - /** @param {number} req */ - methodWithRequiredDefault(p = /** @type {P} */(something), req) {} - - 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) {} \ 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 4399f211f5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt +++ /dev/null @@ -1,43 +0,0 @@ -input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. - - -==== input.js (1 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) {} - - export class C { - field = /** @type {P} */(something); - /** @optional */ optField = /** @type {P} */(something); // not a thing - /** @readonly */ roFiled = /** @type {P} */(something); - ~~~~~~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - method(p = /** @type {P} */(something)) {} - /** @param {number} req */ - methodWithRequiredDefault(p = /** @type {P} */(something), req) {} - - 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) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt deleted file mode 100644 index 7bb8e3c33b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.errors.txt +++ /dev/null @@ -1,64 +0,0 @@ -jsFileFunctionOverloads.js(29,17): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== jsFileFunctionOverloads.js (1 errors) ==== - /** - * @overload - * @param {number} x - * @returns {'number'} - */ - /** - * @overload - * @param {string} x - * @returns {'string'} - */ - /** - * @overload - * @param {boolean} x - * @returns {'boolean'} - */ - /** - * @param {unknown} x - * @returns {string} - */ - function getTypeName(x) { - return typeof x; - } - - /** - * @template T - * @param {T} x - * @returns {T} - */ - const identity = x => x; - ~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - * @template T - * @template U - * @overload - * @param {T[]} array - * @param {(x: T) => U[]} iterable - * @returns {U[]} - */ - /** - * @template T - * @overload - * @param {T[][]} array - * @returns {T[]} - */ - /** - * @param {unknown[]} array - * @param {(x: unknown) => unknown} iterable - * @returns {unknown[]} - */ - function flatMap(array, iterable = identity) { - /** @type {unknown[]} */ - const result = []; - for (let i = 0; i < array.length; i += 1) { - result.push(.../** @type {unknown[]} */(iterable(array[i]))); - } - return result; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt deleted file mode 100644 index 5c79ce98e6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.errors.txt +++ /dev/null @@ -1,59 +0,0 @@ -jsFileFunctionOverloads2.js(27,17): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== jsFileFunctionOverloads2.js (1 errors) ==== - // Also works if all @overload tags are combined in one comment. - /** - * @overload - * @param {number} x - * @returns {'number'} - * - * @overload - * @param {string} x - * @returns {'string'} - * - * @overload - * @param {boolean} x - * @returns {'boolean'} - * - * @param {unknown} x - * @returns {string} - */ - function getTypeName(x) { - return typeof x; - } - - /** - * @template T - * @param {T} x - * @returns {T} - */ - const identity = x => x; - ~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - * @template T - * @template U - * @overload - * @param {T[]} array - * @param {(x: T) => U[]} iterable - * @returns {U[]} - * - * @overload - * @param {T[][]} array - * @returns {T[]} - * - * @param {unknown[]} array - * @param {(x: unknown) => unknown} iterable - * @returns {unknown[]} - */ - function flatMap(array, iterable = identity) { - /** @type {unknown[]} */ - const result = []; - for (let i = 0; i < array.length; i += 1) { - result.push(.../** @type {unknown[]} */(iterable(array[i]))); - } - return result; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js index 335d3bf65f..91b2848fb0 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js @@ -120,3 +120,29 @@ declare function getTypeName(x: boolean): 'boolean'; declare const identity: (x: T) => T; declare function flatMap(array: T[], iterable: (x: T) => U[]): U[]; declare function flatMap(array: T[][]): T[]; + + +//// [DtsFileErrors] + + +dist/jsFileFunctionOverloads2.d.ts(11,33): error TS2304: Cannot find name 'T'. +dist/jsFileFunctionOverloads2.d.ts(11,41): error TS2304: Cannot find name 'T'. + + +==== dist/jsFileFunctionOverloads2.d.ts (2 errors) ==== + declare function getTypeName(x: number): 'number'; + declare function getTypeName(x: string): 'string'; + declare function getTypeName(x: boolean): 'boolean'; + /** + * @template T + * @param {T} x + * @returns {T} + */ + declare const identity: (x: T) => T; + declare function flatMap(array: T[], iterable: (x: T) => U[]): U[]; + declare function flatMap(array: T[][]): T[]; + ~ +!!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS2304: Cannot find name 'T'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js.diff b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js.diff index 3ed214f8c8..9356c66d0d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.js.diff @@ -108,4 +108,30 @@ -declare function identity(x: T): T; +declare const identity: (x: T) => T; +declare function flatMap(array: T[], iterable: (x: T) => U[]): U[]; -+declare function flatMap(array: T[][]): T[]; \ No newline at end of file ++declare function flatMap(array: T[][]): T[]; ++ ++ ++//// [DtsFileErrors] ++ ++ ++dist/jsFileFunctionOverloads2.d.ts(11,33): error TS2304: Cannot find name 'T'. ++dist/jsFileFunctionOverloads2.d.ts(11,41): error TS2304: Cannot find name 'T'. ++ ++ ++==== dist/jsFileFunctionOverloads2.d.ts (2 errors) ==== ++ declare function getTypeName(x: number): 'number'; ++ declare function getTypeName(x: string): 'string'; ++ declare function getTypeName(x: boolean): 'boolean'; ++ /** ++ * @template T ++ * @param {T} x ++ * @returns {T} ++ */ ++ declare const identity: (x: T) => T; ++ declare function flatMap(array: T[], iterable: (x: T) => U[]): U[]; ++ declare function flatMap(array: T[][]): T[]; ++ ~ ++!!! error TS2304: Cannot find name 'T'. ++ ~ ++!!! error TS2304: Cannot find name 'T'. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt deleted file mode 100644 index 90be28a763..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt +++ /dev/null @@ -1,98 +0,0 @@ -jsFileMethodOverloads.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== jsFileMethodOverloads.js (1 errors) ==== - /** - ~~~ - * @template T - ~~~~~~~~~~~~~~ - */ - ~~~ - class Example { - ~~~~~~~~~~~~~~~~ - /** - ~~~~~ - * @param {T} value - ~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - constructor(value) { - ~~~~~~~~~~~~~~~~~~~~~~ - this.value = value; - ~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~ - - - /** - ~~~~~ - * @overload - ~~~~~~~~~~~~~~ - * @param {Example} this - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {'number'} - ~~~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - /** - ~~~~~ - * @overload - ~~~~~~~~~~~~~~ - * @param {Example} this - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {'string'} - ~~~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - /** - ~~~~~ - * @returns {string} - ~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - getTypeName() { - ~~~~~~~~~~~~~~~~~ - return typeof this.value; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~ - - - /** - ~~~~~ - * @template U - ~~~~~~~~~~~~~~~~ - * @overload - ~~~~~~~~~~~~~~ - * @param {(y: T) => U} fn - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {U} - ~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - /** - ~~~~~ - * @overload - ~~~~~~~~~~~~~~ - * @returns {T} - ~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - /** - ~~~~~ - * @param {(y: T) => unknown} [fn] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {unknown} - ~~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - transform(fn) { - ~~~~~~~~~~~~~~~~~ - return fn ? fn(this.value) : this.value; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt deleted file mode 100644 index 63e598a9a7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt +++ /dev/null @@ -1,92 +0,0 @@ -jsFileMethodOverloads2.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== jsFileMethodOverloads2.js (1 errors) ==== - // Also works if all @overload tags are combined in one comment. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~ - * @template T - ~~~~~~~~~~~~~~ - */ - ~~~ - class Example { - ~~~~~~~~~~~~~~~~ - /** - ~~~~~ - * @param {T} value - ~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - constructor(value) { - ~~~~~~~~~~~~~~~~~~~~~~ - this.value = value; - ~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~ - - - /** - ~~~~~ - * @overload - ~~~~~~~~~~~~~~ - * @param {Example} this - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {'number'} - ~~~~~~~~~~~~~~~~~~~~~~~~ - * - ~~~~ - * @overload - ~~~~~~~~~~~~~~ - * @param {Example} this - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {'string'} - ~~~~~~~~~~~~~~~~~~~~~~~~ - * - ~~~~ - * @returns {string} - ~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - getTypeName() { - ~~~~~~~~~~~~~~~~~ - return typeof this.value; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~ - - - /** - ~~~~~ - * @template U - ~~~~~~~~~~~~~~~~ - * @overload - ~~~~~~~~~~~~~~ - * @param {(y: T) => U} fn - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {U} - ~~~~~~~~~~~~~~~~~ - * - ~~~~ - * @overload - ~~~~~~~~~~~~~~ - * @returns {T} - ~~~~~~~~~~~~~~~~~ - * - ~~~~ - * @param {(y: T) => unknown} [fn] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @returns {unknown} - ~~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~ - transform(fn) { - ~~~~~~~~~~~~~~~~~ - return fn ? fn(this.value) : this.value; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt index d5f6e77370..ae966c3990 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocClassMissingTypeArguments.errors.txt @@ -1,13 +1,9 @@ -/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. /a.js(4,13): error TS2314: Generic type 'C' requires 1 type argument(s). -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** @template T */ - ~~~~~~~~~~~~~~~~~~ class C {} - ~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @param {C} p */ ~ diff --git a/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt index 959e2ee1c0..018ec07e52 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocIllegalTags.errors.txt @@ -1,18 +1,13 @@ -/a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. /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 (3 errors) ==== +==== /a.js (2 errors) ==== class C { - /** @template T */ - ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor() { } - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. } class D { /** @return {number} */ diff --git a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.errors.txt b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.errors.txt index b9aa9cb689..cfd276ebcd 100644 --- a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag.errors.txt @@ -1,13 +1,9 @@ -/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. /a.js(1,15): error TS6196: 'T' is declared but never used. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== /** @template T */ - ~~~~~~~~~~~~~~~~~~ ~ !!! error TS6196: 'T' is declared but never used. function f() {} - ~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt index 1238a6c296..941b063cbf 100644 --- a/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/unusedTypeParameters_templateTag2.errors.txt @@ -1,84 +1,49 @@ -/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. /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(10,2): error TS8004: Type parameter declarations can only be used in TypeScript files. /a.js(13,3): error TS6205: All type parameters are unused. -/a.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. /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 (8 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 TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - ~~~ * @template T,V - ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ */ - ~~~ ~~ !!! error TS6205: All type parameters are unused. class C2 { - ~~~~~~~~~~ constructor() { } - ~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - ~~~ * @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 TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt index 193de9fab6..022d12234b 100644 --- a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt @@ -2,7 +2,6 @@ first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wago 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(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. -generic.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. generic.js(9,22): error TS8011: Type arguments can only be used in TypeScript files. 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'. @@ -107,22 +106,14 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con ~~~~~~~~~~ !!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (7 errors) ==== +==== generic.js (6 errors) ==== /** - ~~~ * @template T - ~~~~~~~~~~~~~~ * @param {T} flavour - ~~~~~~~~~~~~~~~~~~~~~ */ - ~~~ function Soup(flavour) { - ~~~~~~~~~~~~~~~~~~~~~~~~ this.flavour = flavour - ~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { ~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt index b4eefc5d4f..051cf5113e 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/constructorFunctionMethodTypeParameters.errors.txt @@ -1,25 +1,15 @@ -constructorFunctionMethodTypeParameters.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -constructorFunctionMethodTypeParameters.js(19,30): error TS8004: Type parameter declarations can only be used in TypeScript files. constructorFunctionMethodTypeParameters.js(22,16): error TS2304: Cannot find name 'T'. constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find name 'T'. -==== constructorFunctionMethodTypeParameters.js (4 errors) ==== +==== constructorFunctionMethodTypeParameters.js (2 errors) ==== /** - ~~~ * @template {string} T - ~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} t - ~~~~~~~~~~~~~~~ */ - ~~~ function Cls(t) { - ~~~~~~~~~~~~~~~~~ this.t = t; - ~~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @template {string} V @@ -32,30 +22,19 @@ constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find nam }; 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 - ~~~~~~~~~~~~~~~~ }; - ~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. var c = new Cls('a'); const s = c.topLevelComment('a', 'b'); diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt index 272456d93e..2d4912d227 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt @@ -1,19 +1,12 @@ -bug25101.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. bug25101.js(5,17): error TS8011: Type arguments can only be used in TypeScript files. -==== bug25101.js (2 errors) ==== +==== bug25101.js (1 errors) ==== /** - ~~~ * @template T - ~~~~~~~~~~~~~~ * @extends {Set} Should prefer this Set, not the Set in the heritage clause - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~ class My extends Set {} - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt index cd19b650c7..b0960272ab 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt @@ -1,4 +1,3 @@ -/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. /a.js(26,16): error TS8011: Type arguments can only be used in TypeScript files. /a.js(29,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. Types of property 'b' are incompatible. @@ -11,44 +10,25 @@ /a.js(44,16): error TS8011: Type arguments can only be used in TypeScript files. -==== /a.js (7 errors) ==== +==== /a.js (6 errors) ==== /** - ~~~ * @typedef {{ - ~~~~~~~~~~~~~~ * a: number | string; - ~~~~~~~~~~~~~~~~~~~~~~~~~ * b: boolean | string[]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * }} Foo - ~~~~~~~~ */ - ~~ - /** - ~~~ * @template {Foo} T - ~~~~~~~~~~~~~~~~~~~ */ - ~~ class A { - ~~~~~~~~~ /** - ~~~~~~ * @param {T} a - ~~~~~~~~~~~~~~~~~~ */ - ~~~~~~ constructor(a) { - ~~~~~~~~~~~~~~~~~~~ return a - ~~~~~~~~~~~~~~~ } - ~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @extends {A<{ diff --git a/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt b/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt deleted file mode 100644 index 1b263f9b6c..0000000000 --- a/testdata/baselines/reference/submodule/conformance/genericSetterInClassTypeJsDoc.errors.txt +++ /dev/null @@ -1,48 +0,0 @@ -genericSetterInClassTypeJsDoc.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== genericSetterInClassTypeJsDoc.js (1 errors) ==== - /** - ~~~ - * @template T - ~~~~~~~~~~~~~~ - */ - ~~~ - class Box { - ~~~~~~~~~~~~ - #value; - ~~~~~~~~~~~ - - - /** @param {T} initialValue */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - constructor(initialValue) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - this.#value = initialValue; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ - - ~~~~ - /** @type {T} */ - ~~~~~~~~~~~~~~~~~~~~ - get value() { - ~~~~~~~~~~~~~~~~~ - return this.#value; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ - - - set value(value) { - ~~~~~~~~~~~~~~~~~~~~~~ - this.#value = value; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - new Box(3).value = 3; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt b/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt deleted file mode 100644 index 9e255670bb..0000000000 --- a/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt +++ /dev/null @@ -1,53 +0,0 @@ -/a.js(1,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -/a.js(9,6): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== /a.js (2 errors) ==== - export class C { - - /** - ~~~~~~~ - * @template T - ~~~~~~~~~~~~~~~~~~ - * @this {T} - ~~~~~~~~~~~~~~~~ - * @return {T} - ~~~~~~~~~~~~~~~~~~ - */ - ~~~~~~~ - static a() { - ~~~~~~~~~~~~~~~~ - return this; - ~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - - - /** - ~~~~~~~ - * @template T - ~~~~~~~~~~~~~~~~~~ - * @this {T} - ~~~~~~~~~~~~~~~~ - * @return {T} - ~~~~~~~~~~~~~~~~~~ - */ - ~~~~~~~ - b() { - ~~~~~~~~~ - return this; - ~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - } - - 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/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt deleted file mode 100644 index 81c4e9569e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -instantiateTemplateTagTypeParameterOnVariableStatement.js(6,12): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== instantiateTemplateTagTypeParameterOnVariableStatement.js (1 errors) ==== - /** - * @template T - * @param {T} a - * @returns {(b: T) => T} - */ - const seq = a => b => b; - ~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - const text1 = "hello"; - const text2 = "world"; - - /** @type {string} */ - var text3 = seq(text1)(text2); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt deleted file mode 100644 index 399be9da33..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -lib.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== interface.ts (0 errors) ==== - export interface Encoder { - encode(value: T): Uint8Array - } -==== lib.js (1 errors) ==== - /** - ~~~ - * @template T - ~~~~~~~~~~~~~~ - * @implements {IEncoder} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~ - export class Encoder { - ~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ - * @param {T} value - ~~~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~~~ - encode(value) { - ~~~~~~~~~~~~~~~~~~~ - return new Uint8Array(0) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - - /** - * @template T - * @typedef {import('./interface').Encoder} IEncoder - */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt index 2cc0898d34..56139fa173 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt @@ -1,14 +1,7 @@ -index.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(31,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -index.js(72,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -index.js(97,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(111,25): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(153,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(167,2): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(173,23): error TS8011: Type arguments can only be used in TypeScript files. -==== index.js (8 errors) ==== +==== index.js (1 errors) ==== export class A {} export class B { @@ -26,229 +19,108 @@ index.js(173,23): error TS8011: Type arguments can only be used in TypeScript fi */ constructor(a, b) {} } - - /** - ~~~ * @template T,U - ~~~~~~~~~~~~~~~~ */ - ~~~ export class E { - ~~~~~~~~~~~~~~~~ /** - ~~~~~~~ * @type {T & U} - ~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ field; - ~~~~~~~~~~ - // @readonly is currently unsupported, it seems - included here just in case that changes - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** - ~~~~~~~ * @type {T & U} - ~~~~~~~~~~~~~~~~~~~~ * @readonly - ~~~~~~~~~~~~~~~~ - ~~~~~~~~~ */ - ~~~~~~~ - ~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. readonlyField; - ~~~~~~~~~~~~~~~~~~ - initializedField = 12; - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ * @return {U} - ~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ get f1() { return /** @type {*} */(null); } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ * @param {U} _p - ~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ set f1(_p) {} - ~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ * @return {U} - ~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ get f2() { return /** @type {*} */(null); } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ * @param {U} _p - ~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ set f3(_p) {} - ~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ * @param {T} a - ~~~~~~~~~~~~~~~~~~~ * @param {U} b - ~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ constructor(a, b) {} - ~~~~~~~~~~~~~~~~~~~~~~~~ - - /** - ~~~~~~~ * @type {string} - ~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ static staticField; - ~~~~~~~~~~~~~~~~~~~~~~~ - // @readonly is currently unsupported, it seems - included here just in case that changes - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** - ~~~~~~~ * @type {string} - ~~~~~~~~~~~~~~~~~~~~~ * @readonly - ~~~~~~~~~~~~~~~~ - ~~~~~~~~~ */ - ~~~~~~~ - ~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. static staticReadonlyField; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - static staticInitializedField = 12; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ * @return {string} - ~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ static get s1() { return ""; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ * @param {string} _p - ~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ static set s1(_p) {} - ~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ * @return {string} - ~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ static get s2() { return ""; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ * @param {string} _p - ~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ static set s3(_p) {} - ~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - ~~~ * @template T,U - ~~~~~~~~~~~~~~~~ */ - ~~~ export class F { - ~~~~~~~~~~~~~~~~ /** - ~~~~~~~ * @type {T & U} - ~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ field; - ~~~~~~~~~~ /** - ~~~~~~~ * @param {T} a - ~~~~~~~~~~~~~~~~~~~ * @param {U} b - ~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ constructor(a, b) {} - ~~~~~~~~~~~~~~~~~~~~~~~~ - - - /** - ~~~~~~~ - ~~~~~~~ * @template A,B - ~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~ * @param {A} a - ~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~ * @param {B} b - ~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ - ~~~~~~~ static create(a, b) { return new F(a, b); } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. class G {} @@ -283,68 +155,36 @@ index.js(173,23): error TS8011: Type arguments can only be used in TypeScript fi this.prop = 12; } } - - - /** - ~~~ * @template T - ~~~~~~~~~~~~~~ */ - ~~~ export class N extends L { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ /** - ~~~~~~~ * @param {T} param - ~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ constructor(param) { - ~~~~~~~~~~~~~~~~~~~~~~~~ super(); - ~~~~~~~~~~~~~~~~ this.another = param; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - ~~~ * @template U - ~~~~~~~~~~~~~~ * @extends {N} - ~~~~~~~~~~~~~~~~~~ */ - ~~~ export class O extends N { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ !!! error TS8011: Type arguments can only be used in TypeScript files. /** - ~~~~~~~ * @param {U} param - ~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ constructor(param) { - ~~~~~~~~~~~~~~~~~~~~~~~~ super(param); - ~~~~~~~~~~~~~~~~~~~~~ this.another2 = param; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. var x = /** @type {*} */(null); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt index 03fad2748c..fbb512e76b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt @@ -2,9 +2,7 @@ index.js(1,23): error TS2580: Cannot find name 'module'. Do you need to install index.js(3,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(4,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(12,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(12,58): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(22,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(22,58): error TS8004: Type parameter declarations can only be used in TypeScript files. 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`. @@ -20,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 (20 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`. @@ -41,47 +39,26 @@ index.js(58,23): error TS2580: Cannot find name 'module'. Do you need to install Object.defineProperty(module.exports, "d", { value: d }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. - - - /** - ~~~ * @template T,U - ~~~~~~~~~~~~~~~~ * @param {T} a - ~~~~~~~~~~~~~~~ * @param {U} b - ~~~~~~~~~~~~~~~ * @return {T & U} - ~~~~~~~~~~~~~~~~~~~ */ - ~~~ function e(a, b) { return /** @type {*} */(null); } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Object.defineProperty(module.exports, "e", { value: e }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. - - /** - ~~~ * @template T - ~~~~~~~~~~~~~~ * @param {T} a - ~~~~~~~~~~~~~~~ */ - ~~~ function f(a) { - ~~~~~~~~~~~~~~~ return a; - ~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Object.defineProperty(module.exports, "f", { value: f }); ~~~~~~ !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt index 499a3260d4..237c0f2e6f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.errors.txt @@ -1,12 +1,10 @@ -index.js(14,59): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(22,59): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(38,21): error TS2349: This expression is not callable. Type '{ y: any; }' has no call signatures. index.js(48,21): error TS2349: This expression is not callable. Type '{ y: any; }' has no call signatures. -==== index.js (4 errors) ==== +==== index.js (2 errors) ==== export function a() {} export function b() {} @@ -21,42 +19,22 @@ index.js(48,21): error TS2349: This expression is not callable. * @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); } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - ~~~ * @template T - ~~~~~~~~~~~~~~ * @param {T} a - ~~~~~~~~~~~~~~~ */ - ~~~ export function f(a) { - ~~~~~~~~~~~~~~~~~~~~~~ return a; - ~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. f.self = f; /** diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt index fda9e046de..6386334b80 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt @@ -1,6 +1,3 @@ -jsdocAccessibilityTag.js(5,8): error TS8009: The 'private' modifier can only be used in TypeScript files. -jsdocAccessibilityTag.js(11,8): error TS8009: The 'protected' modifier can only be used in TypeScript files. -jsdocAccessibilityTag.js(17,8): error TS8009: The 'public' modifier can only be used in TypeScript files. jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. @@ -13,34 +10,25 @@ jsdocAccessibilityTag.js(61,9): error TS2341: Property 'priv2' is private and on jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. -==== jsdocAccessibilityTag.js (13 errors) ==== +==== jsdocAccessibilityTag.js (10 errors) ==== class A { /** * Ap docs * * @private - ~~~~~~~~ */ - ~~~~~ -!!! error TS8009: The 'private' modifier can only be used in TypeScript files. priv = 4; /** * Aq docs * * @protected - ~~~~~~~~~~ */ - ~~~~~ -!!! error TS8009: The 'protected' modifier can only be used in TypeScript files. prot = 5; /** * Ar docs * * @public - ~~~~~~~ */ - ~~~~~ -!!! error TS8009: The 'public' modifier can only be used in TypeScript files. pub = 6; /** @public */ get ack() { return this.priv } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt index 43fe18d5d5..3cce555727 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt @@ -1,32 +1,18 @@ -jsdocReadonly.js(3,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -jsdocReadonly.js(4,8): error TS8009: The 'private' modifier can only be used in TypeScript files. -jsdocReadonly.js(9,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -jsdocReadonly.js(11,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. jsdocReadonly.js(23,3): error TS2540: Cannot assign to 'y' because it is a read-only property. -==== jsdocReadonly.js (5 errors) ==== +==== jsdocReadonly.js (1 errors) ==== class LOL { /** * @readonly - ~~~~~~~~~ * @private - ~~~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - ~~~~~~~~ * @type {number} - ~~~~~~~ -!!! error TS8009: The 'private' modifier can only be used in TypeScript files. * Order rules do not apply to JSDoc */ x = 1 /** @readonly */ - ~~~~~~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. y = 2 /** @readonly Definitely not here */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. static z = 3 /** @readonly This is OK too */ constructor() { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.errors.txt index 7da3ec1063..fcceb47726 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.errors.txt @@ -1,12 +1,9 @@ -jsdocReadonlyDeclarations.js(2,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. jsdocReadonlyDeclarations.js(14,1): error TS2554: Expected 1 arguments, but got 0. -==== jsdocReadonlyDeclarations.js (2 errors) ==== +==== jsdocReadonlyDeclarations.js (1 errors) ==== class C { /** @readonly */ - ~~~~~~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. x = 6 /** @readonly */ constructor(n) { diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt index 2ca7b00aaf..75303c2689 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateClass.errors.txt @@ -1,53 +1,29 @@ -templateTagOnClasses.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to type 'number'. -==== templateTagOnClasses.js (2 errors) ==== +==== templateTagOnClasses.js (1 errors) ==== /** - ~~~ * @template T - ~~~~~~~~~~~~~~ * @typedef {(t: T) => T} Id - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - ~~~ /** @template T */ - ~~~~~~~~~~~~~~~~~~ class Foo { - ~~~~~~~~~~~ /** @typedef {(t: T) => T} Id2 */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** @param {T} x */ - ~~~~~~~~~~~~~~~~~~~~~~~ constructor (x) { - ~~~~~~~~~~~~~~~~~~~~~ this.a = x - ~~~~~~~~~~~~~~~~~~ } - ~~~~~ /** - ~~~~~~~ * - ~~~~~~~ * @param {T} x - ~~~~~~~~~~~~~~~~~~~~ * @param {Id} y - ~~~~~~~~~~~~~~~~~~~~~~~ * @param {Id2} alpha - ~~~~~~~~~~~~~~~~~~~~~~~~~ * @return {T} - ~~~~~~~~~~~~~~~~~~ */ - ~~~~~~~ foo(x, y, alpha) { - ~~~~~~~~~~~~~~~~~~~~~~ return alpha(y(x)) - ~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. var f = new Foo(1) var g = new Foo(false) f.a = g.a diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt deleted file mode 100644 index 258b41f69c..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt +++ /dev/null @@ -1,43 +0,0 @@ -templateTagOnConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== templateTagOnConstructorFunctions.js (1 errors) ==== - /** - ~~~ - * @template U - ~~~~~~~~~~~~~~ - * @typedef {(u: U) => U} Id - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~ - /** - ~~~ - * @param {T} t - ~~~~~~~~~~~~~~~ - * @template T - ~~~~~~~~~~~~~~ - */ - ~~~ - function Zet(t) { - ~~~~~~~~~~~~~~~~~ - /** @type {T} */ - ~~~~~~~~~~~~~~~~~~~~ - this.u - ~~~~~~~~~~ - this.t = t - ~~~~~~~~~~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - /** - * @param {T} v - * @param {Id} id - */ - Zet.prototype.add = function(v, id) { - this.u = v || this.t - return id(this.u) - } - var z = new Zet(1) - z.t = 2 - z.u = false - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt index 88d214edd0..db4a9a3064 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt @@ -1,27 +1,16 @@ -templateTagWithNestedTypeLiteral.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. -==== templateTagWithNestedTypeLiteral.js (2 errors) ==== +==== templateTagWithNestedTypeLiteral.js (1 errors) ==== /** - ~~~ * @param {T} t - ~~~~~~~~~~~~~~~ * @template T - ~~~~~~~~~~~~~~ */ - ~~~ function Zet(t) { - ~~~~~~~~~~~~~~~~~ /** @type {T} */ - ~~~~~~~~~~~~~~~~~~~~ this.u - ~~~~~~~~~~ this.t = t - ~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @param {T} v * @param {object} o diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt index a28b08944c..b60487ba5b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag.errors.txt @@ -1,50 +1,29 @@ -forgot.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -forgot.js(8,15): error TS8004: Type parameter declarations can only be used in TypeScript files. 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 (4 errors) ==== +==== forgot.js (2 errors) ==== /** - ~~~ * @param {T} a - ~~~~~~~~~~~~~~~ * @template T - ~~~~~~~~~~~~~~ */ - ~~~ function f(a) { - ~~~~~~~~~~~~~~~ return () => a - ~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. let n = f(1)() - - /** - ~~~ * @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 - ~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. let s = g('hi')() /** diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt deleted file mode 100644 index efab5bd351..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag2.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -github17339.js(7,4): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== github17339.js (1 errors) ==== - var obj = { - /** - * @template T - * @param {T} a - * @returns {T} - */ - x: function (a) { - ~~~~~~~~~~~~~~~ - return a; - ~~~~~~~~~~~ - }, - ~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt index 81a8913437..acd63b1e17 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt @@ -1,73 +1,43 @@ -a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. 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 TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. -a.js(21,50): error TS8004: Type parameter declarations can only be used in TypeScript files. -==== a.js (5 errors) ==== +==== a.js (3 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) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2339: Property 'a' does not exist on type 'U'. ~ !!! error TS2339: Property 'b' does not exist on type 'U'. return w; - ~~~~~~~~~~~~~~~~~ } - ~~~~~ return x; - ~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. 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) { } - ~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt index f4bf25c322..b365cc2208 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag4.errors.txt @@ -1,8 +1,6 @@ -a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(8,16): error TS2315: Type 'Object' is not generic. a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. a.js(16,36): error TS7006: Parameter 'key' implicitly has an 'any' type. -a.js(26,16): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(27,16): error TS2315: Type 'Object' is not generic. a.js(28,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. a.js(35,37): error TS7006: Parameter 'key' implicitly has an 'any' type. @@ -11,32 +9,21 @@ a.js(48,10): error TS2339: Property '_map' does not exist on type '{ Multimap3: a.js(55,40): error TS7006: Parameter 'key' implicitly has an 'any' type. -==== a.js (11 errors) ==== +==== a.js (9 errors) ==== /** - ~~~ * Should work for function declarations - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @constructor - ~~~~~~~~~~~~~~~ * @template {string} K - ~~~~~~~~~~~~~~~~~~~~~~~ * @template V - ~~~~~~~~~~~~~~ */ - ~~~ function Multimap() { - ~~~~~~~~~~~~~~~~~~~~~ /** @type {Object} TODO: Remove the prototype from the fresh object */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. this._map = {}; - ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. }; - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @param {K} key the key ok @@ -55,18 +42,13 @@ a.js(55,40): error TS7006: Parameter 'key' implicitly has an 'any' type. * @template V */ var Multimap2 = function() { - ~~~~~~~~~~~~~ /** @type {Object} TODO: Remove the prototype from the fresh object */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. this._map = {}; - ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. }; - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** * @param {K} key the key ok diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt index bf5d19e95c..1c664fdd19 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag5.errors.txt @@ -1,10 +1,8 @@ -a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(8,16): error TS2315: Type 'Object' is not generic. a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. 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(28,16): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(29,16): error TS2315: Type 'Object' is not generic. a.js(30,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. a.js(35,16): error TS2304: Cannot find name 'K'. @@ -17,32 +15,21 @@ a.js(58,18): error TS2304: Cannot find name 'V'. a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. -==== a.js (17 errors) ==== +==== a.js (15 errors) ==== /** - ~~~ * Should work for function declarations - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @constructor - ~~~~~~~~~~~~~~~ * @template {string} K - ~~~~~~~~~~~~~~~~~~~~~~~ * @template V - ~~~~~~~~~~~~~~ */ - ~~~ function Multimap() { - ~~~~~~~~~~~~~~~~~~~~~ /** @type {Object} TODO: Remove the prototype from the fresh object */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. this._map = {}; - ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. }; - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Multimap.prototype = { /** @@ -67,18 +54,13 @@ a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K) * @template V */ var Multimap2 = function() { - ~~~~~~~~~~~~~ /** @type {Object} TODO: Remove the prototype from the fresh object */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ !!! error TS2315: Type 'Object' is not generic. this._map = {}; - ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. }; - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Multimap2.prototype = { /** 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 fef8fdb70c..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt +++ /dev/null @@ -1,193 +0,0 @@ -a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(11,64): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(23,64): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(34,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(45,54): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(56,62): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(65,22): error TS8004: Type parameter declarations can only be used in TypeScript files. -a.js(77,40): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== a.js (8 errors) ==== - /** - ~~~ - * @template const T - ~~~~~~~~~~~~~~~~~~~~ - * @param {T} x - ~~~~~~~~~~~~~~~ - * @returns {T} - ~~~~~~~~~~~~~~~ - */ - ~~~ - function f1(x) { - ~~~~~~~~~~~~~~~~ - return x; - ~~~~~~~~~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - 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) { - ~~~~~~~~~~~~~~~~ - return x; - ~~~~~~~~~~~~~ - }; - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - 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) { - ~~~~~~~~~~~~~~~~ - return [x]; - ~~~~~~~~~~~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - const t7 = f3("hello"); - const t8 = f3("hello"); - - - - /** - ~~~ - * @template const T - ~~~~~~~~~~~~~~~~~~~~ - * @param {[T, T]} x - ~~~~~~~~~~~~~~~~~~~~ - * @returns {T} - ~~~~~~~~~~~~~~~ - */ - ~~~ - function f4(x) { - ~~~~~~~~~~~~~~~~ - return x[0]; - ~~~~~~~~~~~~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - 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) { - ~~~~~~~~~~~~~~~~~~ - return obj.x; - ~~~~~~~~~~~~~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - 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) {} - ~~~~~~~~~~~~~~~~~~~~~ - - - - - /** - ~~~~~~~ - ~~~~~~~ - * @template const U - ~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {U} x - ~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~~~ - ~~~~~~~ - foo(x) { - ~~~~~~~~~~~~ - ~~~~~~~~~~~~ - return x; - ~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~ - } - ~~~~~ - ~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); - const t14 = t13.foo(["a", ["b", "c"]]); - - - - /** - ~~~ - * @template {readonly unknown[]} const T - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * @param {T} args - ~~~~~~~~~~~~~~~~~~ - * @returns {T} - ~~~~~~~~~~~~~~~ - */ - ~~~ - function f6(...args) { - ~~~~~~~~~~~~~~~~~~~~~~ - return args; - ~~~~~~~~~~~~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - const t15 = f6(1, 'b', { a: 1, b: 'x' }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt index e1c76679e3..6d5770242e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt @@ -1,51 +1,28 @@ -a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -a.js(9,12): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter -==== a.js (4 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 - ~~~~~~~~~~~~~~~~~~~ */ - ~~~ - /** - ~~~ * @template const T - ~~~~~~~~~~~~~~~~~~~~ */ - ~~~ class C { } - ~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - ~~~ * @template private T - ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~ !!! error TS1273: 'private' modifier cannot appear on a type parameter * @param {T} x - ~~~~~~~~~~~~~~~ * @returns {T} - ~~~~~~~~~~~~~~~ */ - ~~~ function f(x) { - ~~~~~~~~~~~~~~~ return x; - ~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt index 35e879af8b..5c9e0ed33d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt @@ -13,11 +13,10 @@ a.js(55,1): error TS2322: Type 'Invariant' is not assignable to type 'In 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(56,33): error TS8004: Type parameter declarations can only be used in TypeScript files. a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias -==== a.js (9 errors) ==== +==== a.js (8 errors) ==== /** * @template out T ~~~ @@ -96,20 +95,12 @@ a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of !!! 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'. - ~~~~~~~~~~ - /** - ~~~ * @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 TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt index 222236d979..6ad768a099 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt @@ -1,14 +1,11 @@ file.js(9,20): error TS2322: Type 'number' is not assignable to type 'string'. -file.js(13,21): error TS8004: Type parameter declarations can only be used in TypeScript files. 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(49,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. -file.js(57,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. -==== file.js (8 errors) ==== +==== file.js (5 errors) ==== /** * @template {string | number} [T=string] - ok: defaults are permitted * @typedef {[T]} A @@ -24,122 +21,64 @@ file.js(60,17): error TS2744: Type parameter defaults can only reference previou 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 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @param {T} a - ~~~~~~~~~~~~~~~ * @param {U} b - ~~~~~~~~~~~~~~~ */ - ~~~ function f1(a, b) {} - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - ~~~~ * @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) {} - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - ~~~ * @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) {} - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file 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 f916c78085..0000000000 --- a/testdata/baselines/reference/submodule/conformance/overloadTag3.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - /** - ~~~ - * @template T - ~~~~~~~~~~~~~~ - */ - ~~~ - export class Foo { - ~~~~~~~~~~~~~~~~~~ - /** - ~~~~~~~ - * @constructor - ~~~~~~~~~~~~~~~~~~~ - * @overload - ~~~~~~~~~~~~~~~~ - */ - ~~~~~~~ - constructor() { } - ~~~~~~~~~~~~~~~~~~~~~ - - - /** - ~~~~~~~ - * @param {T} value - ~~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~~~~~ - bar(value) { } - ~~~~~~~~~~~~~~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** @type {Foo} */ - let foo; - foo = new Foo(); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt b/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt deleted file mode 100644 index 1c28c99665..0000000000 --- a/testdata/baselines/reference/submodule/conformance/paramTagTypeResolution2.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -38572.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - - -==== 38572.js (1 errors) ==== - /** - ~~~ - * @template T - ~~~~~~~~~~~~~~ - * @param {T} a - ~~~~~~~~~~~~~~~ - * @param {{[K in keyof T]: (value: T[K]) => void }} b - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ - ~~~ - function f(a, b) { - ~~~~~~~~~~~~~~~~~~ - } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - f({ x: 42 }, { x(param) { param.toFixed() } }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt b/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt index f3c6dfb553..267ad3982c 100644 --- a/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt @@ -1,8 +1,5 @@ -privateNamesIncompatibleModifiersJs.js(3,8): error TS8009: The 'public' modifier can only be used in TypeScript files. privateNamesIncompatibleModifiersJs.js(3,8): error TS18010: An accessibility modifier cannot be used with a private identifier. -privateNamesIncompatibleModifiersJs.js(8,8): error TS8009: The 'private' modifier can only be used in TypeScript files. privateNamesIncompatibleModifiersJs.js(8,8): error TS18010: An accessibility modifier cannot be used with a private identifier. -privateNamesIncompatibleModifiersJs.js(13,8): error TS8009: The 'protected' modifier can only be used in TypeScript files. privateNamesIncompatibleModifiersJs.js(13,8): error TS18010: An accessibility modifier cannot be used with a private identifier. privateNamesIncompatibleModifiersJs.js(18,8): error TS18010: An accessibility modifier cannot be used with a private identifier. privateNamesIncompatibleModifiersJs.js(23,8): error TS18010: An accessibility modifier cannot be used with a private identifier. @@ -15,38 +12,29 @@ privateNamesIncompatibleModifiersJs.js(51,7): error TS18010: An accessibility mo privateNamesIncompatibleModifiersJs.js(55,8): error TS18010: An accessibility modifier cannot be used with a private identifier. -==== privateNamesIncompatibleModifiersJs.js (15 errors) ==== +==== privateNamesIncompatibleModifiersJs.js (12 errors) ==== class A { /** * @public ~~~~~~~ - ~~~~~~~ */ ~~~~~ -!!! error TS8009: The 'public' modifier can only be used in TypeScript files. - ~~~~~ !!! error TS18010: An accessibility modifier cannot be used with a private identifier. #a = 1; /** * @private ~~~~~~~~ - ~~~~~~~~ */ ~~~~~ -!!! error TS8009: The 'private' modifier can only be used in TypeScript files. - ~~~~~ !!! error TS18010: An accessibility modifier cannot be used with a private identifier. #b = 1; /** * @protected ~~~~~~~~~~ - ~~~~~~~~~~ */ ~~~~~ -!!! error TS8009: The 'protected' modifier can only be used in TypeScript files. - ~~~~~ !!! error TS18010: An accessibility modifier cannot be used with a private identifier. #c = 1; diff --git a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt index b929519474..ccc2bc954c 100644 --- a/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/propertiesOfGenericConstructorFunctions.errors.txt @@ -1,34 +1,19 @@ -propertiesOfGenericConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. 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(26,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -==== propertiesOfGenericConstructorFunctions.js (3 errors) ==== +==== 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 }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type {Multimap<"a" | "b", number>} with type annotation */ ~~~~~~~~ @@ -45,28 +30,16 @@ propertiesOfGenericConstructorFunctions.js(26,24): error TS8004: Type parameter 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 - ~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Cp.prototype = { m1() { return this.x }, m2() { this.z = this.x + 1; return this.y } diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt index 891191db93..48940af384 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt @@ -1,12 +1,11 @@ templateInsideCallback.js(15,11): error TS2315: Type 'Call' is not generic. templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. -templateInsideCallback.js(17,17): error TS8004: Type parameter declarations can only be used in TypeScript files. templateInsideCallback.js(17,18): error TS7006: Parameter 'x' implicitly has an 'any' type. templateInsideCallback.js(29,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. -==== templateInsideCallback.js (6 errors) ==== +==== templateInsideCallback.js (5 errors) ==== /** * @typedef Oops * @template T @@ -28,8 +27,6 @@ templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns !!! error TS2304: Cannot find name 'T'. */ const identity = x => x; - ~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ !!! error TS7006: Parameter 'x' implicitly has an 'any' type. diff --git a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt index 54f8e76591..0961be452d 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/thisTypeOfConstructorFunctions.errors.txt @@ -1,37 +1,22 @@ -thisTypeOfConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. thisTypeOfConstructorFunctions.js(15,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -thisTypeOfConstructorFunctions.js(19,2): error TS8004: Type parameter declarations can only be used in TypeScript files. 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 (6 errors) ==== +==== 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 - ~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. Cp.prototype = { /** @return {this} */ @@ -41,26 +26,15 @@ thisTypeOfConstructorFunctions.js(43,12): error TS2749: 'Cp' refers to a value, this.z = this.y; return this } } - - /** - ~~~ * @class - ~~~~~~~~~ * @template T - ~~~~~~~~~~~~~~ * @param {T} t - ~~~~~~~~~~~~~~~ */ - ~~~ function Cpp(t) { - ~~~~~~~~~~~~~~~~~ this.y = t - ~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @return {this} */ Cpp.prototype.m2 = function () { this.z = this.y; return this diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt index f3e513e45b..3372ce2456 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt @@ -1,62 +1,36 @@ -github20832.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. github20832.js(2,15): error TS2304: Cannot find name 'U'. -github20832.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. github20832.js(17,12): error TS2304: Cannot find name 'V'. -==== github20832.js (4 errors) ==== +==== 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; - ~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type T - should be fine, since T will be any */ const x = 3; - - /** - ~~~ * @callback Cb - ~~~~~~~~~~~~~~~ * @param {V} firstParam - ~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS2304: Cannot find name 'V'. */ - ~~~ /** - ~~~ * @template V - ~~~~~~~~~~~~~~ * @param {V} vvvvv - ~~~~~~~~~~~~~~~~~~~ */ - ~~~ function g(vvvvv) { - ~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @type {Cb} */ const cb = x => {} diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt deleted file mode 100644 index 9018979fea..0000000000 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt +++ /dev/null @@ -1,47 +0,0 @@ -uniqueSymbolsDeclarationsInJs.js(4,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -uniqueSymbolsDeclarationsInJs.js(9,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -uniqueSymbolsDeclarationsInJs.js(14,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -uniqueSymbolsDeclarationsInJs.js(20,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. - - -==== uniqueSymbolsDeclarationsInJs.js (4 errors) ==== - // classes - class C { - /** - * @readonly - ~~~~~~~~~ - */ - ~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - static readonlyStaticCall = Symbol(); - /** - * @type {unique symbol} - * @readonly - ~~~~~~~~~ - */ - ~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - static readonlyStaticType; - /** - * @type {unique symbol} - * @readonly - ~~~~~~~~~ - */ - ~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - static readonlyStaticTypeAndCall = Symbol(); - static readwriteStaticCall = Symbol(); - - /** - * @readonly - ~~~~~~~~~ - */ - ~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - readonlyCall = Symbol(); - readwriteCall = Symbol(); - } - - /** @type {unique symbol} */ - const a = Symbol(); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt index 8aa86600fd..681f7c5f3e 100644 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt @@ -1,9 +1,8 @@ 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(8,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. 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) ==== +==== uniqueSymbolsDeclarationsInJsErrors.js (2 errors) ==== class C { /** * @type {unique symbol} @@ -14,10 +13,7 @@ uniqueSymbolsDeclarationsInJsErrors.js(14,12): error TS1331: A property of a cla /** * @type {unique symbol} * @readonly - ~~~~~~~~~ */ - ~~~~~ -!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. static readonlyType; /** * @type {unique symbol} diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff index 4a9a7795da..4810a1e796 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.errors.txt.diff @@ -2,41 +2,27 @@ +++ new.arrowExpressionBodyJSDoc.errors.txt @@= skipped -0, +0 lines =@@ -mytest.js(6,44): error TS2322: Type 'string' is not assignable to type 'T'. -- 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. --mytest.js(13,44): error TS2322: Type 'string' is not assignable to type 'T'. -- 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -- -- --==== mytest.js (2 errors) ==== -+mytest.js(6,13): error TS8004: Type parameter declarations can only be used in TypeScript files. +mytest.js(6,45): error TS2322: Type 'string' is not assignable to type 'T'. -+ 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -+mytest.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. +-mytest.js(13,44): error TS2322: Type 'string' is not assignable to type 'T'. +mytest.js(13,61): error TS2322: Type 'string' is not assignable to type 'T'. -+ 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -+ -+ -+==== mytest.js (4 errors) ==== - /** - * @template T - * @param {T|undefined} value value or not + 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. + + +@@= skipped -10, +10 lines =@@ * @returns {T} result value */ const foo1 = value => /** @type {string} */({ ...value }); - ~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -@@= skipped -20, +24 lines =@@ +@@= skipped -10, +10 lines =@@ * @returns {T} result value */ const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff deleted file mode 100644 index 70fd2ab097..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.arrowExpressionJs.errors.txt -+++ new.arrowExpressionJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+mytest.js(6,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== mytest.js (1 errors) ==== -+ /** -+ * @template T -+ * @param {T|undefined} value value or not -+ * @returns {T} result value -+ */ -+ const cloneObjectGood = value => /** @type {T} */({ ...value }); -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff index d461cd3e25..24a1d9bbd3 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff @@ -2,7 +2,6 @@ +++ new.contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(2,28): error TS2304: Cannot find name 'B'. +index.js(2,42): error TS2304: Cannot find name 'A'. +index.js(2,48): error TS2304: Cannot find name 'B'. @@ -10,11 +9,9 @@ +index.js(10,12): error TS2315: Type 'Funcs' is not generic. + + -+==== index.js (6 errors) ==== ++==== index.js (5 errors) ==== + /** -+ ~~~ + * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS2304: Cannot find name 'B'. + ~ @@ -24,34 +21,20 @@ + ~ +!!! error TS2304: Cannot find name 'B'. + * @template A -+ ~~~~~~~~~~~~~~ + * @template {Record} B -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~ -+ + + /** -+ ~~~ + * @template A -+ ~~~~~~~~~~~~~~ + * @template {Record} B -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @param {Funcs} fns -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~ +!!! error TS2315: Type 'Funcs' is not generic. + * @returns {[A, B]} -+ ~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~ + function foo(fns) { -+ ~~~~~~~~~~~~~~~~~~~ + return /** @type {any} */ (null); -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + const result = foo({ + bar: { 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 f9fcccb0b7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt -+++ new.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ /** -+ ~~~ -+ * @template T -+ ~~~~~~~~~~~~~~ -+ * @param {(value: T, index: number) => boolean} predicate -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {T} -+ ~~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ function filter(predicate) { -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ return /** @type {any} */ (null); -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ const a = filter( -+ /** -+ * @param {number} [pose] -+ */ -+ (pose) => true -+ ); -+ -+ const b = filter( -+ /** -+ * @param {number} [pose] -+ * @param {number} [_] -+ */ -+ (pose, _) => true -+ ); -+ \ No newline at end of file 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 be2c0f1f43..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt -+++ new.declarationEmitCastReusesTypeNode4(strictnullchecks=false).errors.txt -@@= skipped -0, +0 lines =@@ -- -+input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ -+ -+==== input.js (1 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) {} -+ -+ export class C { -+ field = /** @type {P} */(something); -+ /** @optional */ optField = /** @type {P} */(something); // not a thing -+ /** @readonly */ roFiled = /** @type {P} */(something); -+ ~~~~~~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ method(p = /** @type {P} */(something)) {} -+ /** @param {number} req */ -+ methodWithRequiredDefault(p = /** @type {P} */(something), req) {} -+ -+ 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) {} \ No newline at end of file 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 b0ef4e3123..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt -+++ new.declarationEmitCastReusesTypeNode4(strictnullchecks=true).errors.txt -@@= skipped -0, +0 lines =@@ -- -+input.js(18,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ -+ -+==== input.js (1 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) {} -+ -+ export class C { -+ field = /** @type {P} */(something); -+ /** @optional */ optField = /** @type {P} */(something); // not a thing -+ /** @readonly */ roFiled = /** @type {P} */(something); -+ ~~~~~~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ method(p = /** @type {P} */(something)) {} -+ /** @param {number} req */ -+ methodWithRequiredDefault(p = /** @type {P} */(something), req) {} -+ -+ 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) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff deleted file mode 100644 index 99642fd262..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.errors.txt.diff +++ /dev/null @@ -1,68 +0,0 @@ ---- old.jsFileFunctionOverloads.errors.txt -+++ new.jsFileFunctionOverloads.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsFileFunctionOverloads.js(29,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== jsFileFunctionOverloads.js (1 errors) ==== -+ /** -+ * @overload -+ * @param {number} x -+ * @returns {'number'} -+ */ -+ /** -+ * @overload -+ * @param {string} x -+ * @returns {'string'} -+ */ -+ /** -+ * @overload -+ * @param {boolean} x -+ * @returns {'boolean'} -+ */ -+ /** -+ * @param {unknown} x -+ * @returns {string} -+ */ -+ function getTypeName(x) { -+ return typeof x; -+ } -+ -+ /** -+ * @template T -+ * @param {T} x -+ * @returns {T} -+ */ -+ const identity = x => x; -+ ~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ /** -+ * @template T -+ * @template U -+ * @overload -+ * @param {T[]} array -+ * @param {(x: T) => U[]} iterable -+ * @returns {U[]} -+ */ -+ /** -+ * @template T -+ * @overload -+ * @param {T[][]} array -+ * @returns {T[]} -+ */ -+ /** -+ * @param {unknown[]} array -+ * @param {(x: unknown) => unknown} iterable -+ * @returns {unknown[]} -+ */ -+ function flatMap(array, iterable = identity) { -+ /** @type {unknown[]} */ -+ const result = []; -+ for (let i = 0; i < array.length; i += 1) { -+ result.push(.../** @type {unknown[]} */(iterable(array[i]))); -+ } -+ return result; -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff deleted file mode 100644 index 6291af636d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.errors.txt.diff +++ /dev/null @@ -1,63 +0,0 @@ ---- old.jsFileFunctionOverloads2.errors.txt -+++ new.jsFileFunctionOverloads2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsFileFunctionOverloads2.js(27,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== jsFileFunctionOverloads2.js (1 errors) ==== -+ // Also works if all @overload tags are combined in one comment. -+ /** -+ * @overload -+ * @param {number} x -+ * @returns {'number'} -+ * -+ * @overload -+ * @param {string} x -+ * @returns {'string'} -+ * -+ * @overload -+ * @param {boolean} x -+ * @returns {'boolean'} -+ * -+ * @param {unknown} x -+ * @returns {string} -+ */ -+ function getTypeName(x) { -+ return typeof x; -+ } -+ -+ /** -+ * @template T -+ * @param {T} x -+ * @returns {T} -+ */ -+ const identity = x => x; -+ ~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ /** -+ * @template T -+ * @template U -+ * @overload -+ * @param {T[]} array -+ * @param {(x: T) => U[]} iterable -+ * @returns {U[]} -+ * -+ * @overload -+ * @param {T[][]} array -+ * @returns {T[]} -+ * -+ * @param {unknown[]} array -+ * @param {(x: unknown) => unknown} iterable -+ * @returns {unknown[]} -+ */ -+ function flatMap(array, iterable = identity) { -+ /** @type {unknown[]} */ -+ const result = []; -+ for (let i = 0; i < array.length; i += 1) { -+ result.push(.../** @type {unknown[]} */(iterable(array[i]))); -+ } -+ return result; -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff deleted file mode 100644 index 9c210ea67f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff +++ /dev/null @@ -1,102 +0,0 @@ ---- old.jsFileMethodOverloads.errors.txt -+++ new.jsFileMethodOverloads.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsFileMethodOverloads.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== jsFileMethodOverloads.js (1 errors) ==== -+ /** -+ ~~~ -+ * @template T -+ ~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ class Example { -+ ~~~~~~~~~~~~~~~~ -+ /** -+ ~~~~~ -+ * @param {T} value -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ constructor(value) { -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ this.value = value; -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~ -+ -+ -+ /** -+ ~~~~~ -+ * @overload -+ ~~~~~~~~~~~~~~ -+ * @param {Example} this -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {'number'} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ /** -+ ~~~~~ -+ * @overload -+ ~~~~~~~~~~~~~~ -+ * @param {Example} this -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {'string'} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ /** -+ ~~~~~ -+ * @returns {string} -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ getTypeName() { -+ ~~~~~~~~~~~~~~~~~ -+ return typeof this.value; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~ -+ -+ -+ /** -+ ~~~~~ -+ * @template U -+ ~~~~~~~~~~~~~~~~ -+ * @overload -+ ~~~~~~~~~~~~~~ -+ * @param {(y: T) => U} fn -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {U} -+ ~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ /** -+ ~~~~~ -+ * @overload -+ ~~~~~~~~~~~~~~ -+ * @returns {T} -+ ~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ /** -+ ~~~~~ -+ * @param {(y: T) => unknown} [fn] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {unknown} -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ transform(fn) { -+ ~~~~~~~~~~~~~~~~~ -+ return fn ? fn(this.value) : this.value; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff deleted file mode 100644 index ef1903391d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff +++ /dev/null @@ -1,96 +0,0 @@ ---- old.jsFileMethodOverloads2.errors.txt -+++ new.jsFileMethodOverloads2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsFileMethodOverloads2.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== jsFileMethodOverloads2.js (1 errors) ==== -+ // Also works if all @overload tags are combined in one comment. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ /** -+ ~~~ -+ * @template T -+ ~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ class Example { -+ ~~~~~~~~~~~~~~~~ -+ /** -+ ~~~~~ -+ * @param {T} value -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ constructor(value) { -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ this.value = value; -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~ -+ -+ -+ /** -+ ~~~~~ -+ * @overload -+ ~~~~~~~~~~~~~~ -+ * @param {Example} this -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {'number'} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ * -+ ~~~~ -+ * @overload -+ ~~~~~~~~~~~~~~ -+ * @param {Example} this -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {'string'} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ * -+ ~~~~ -+ * @returns {string} -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ getTypeName() { -+ ~~~~~~~~~~~~~~~~~ -+ return typeof this.value; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~ -+ -+ -+ /** -+ ~~~~~ -+ * @template U -+ ~~~~~~~~~~~~~~~~ -+ * @overload -+ ~~~~~~~~~~~~~~ -+ * @param {(y: T) => U} fn -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {U} -+ ~~~~~~~~~~~~~~~~~ -+ * -+ ~~~~ -+ * @overload -+ ~~~~~~~~~~~~~~ -+ * @returns {T} -+ ~~~~~~~~~~~~~~~~~ -+ * -+ ~~~~ -+ * @param {(y: T) => unknown} [fn] -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @returns {unknown} -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~ -+ transform(fn) { -+ ~~~~~~~~~~~~~~~~~ -+ return fn ? fn(this.value) : this.value; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ \ No newline at end of file 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 171fe2282b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocClassMissingTypeArguments.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.jsdocClassMissingTypeArguments.errors.txt -+++ new.jsdocClassMissingTypeArguments.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - /a.js(4,13): error TS2314: Generic type 'C' requires 1 type argument(s). - - --==== /a.js (1 errors) ==== -+==== /a.js (2 errors) ==== - /** @template T */ -+ ~~~~~~~~~~~~~~~~~~ - class C {} -+ ~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** @param {C} p */ - ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff index 625bcf12a2..546850ee3c 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocIllegalTags.errors.txt.diff @@ -2,23 +2,15 @@ +++ new.jsdocIllegalTags.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(2,19): error TS1092: Type parameters cannot appear on a constructor declaration. -+/a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. +/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) ==== -+==== /a.js (3 errors) ==== + ==== /a.js (2 errors) ==== class C { -+ /** @template T */ - ~ -+ ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~ !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor() { } -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - } - class D { - /** @return {number} */ \ No newline at end of file + } \ No newline at end of file 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 43bec4ecda..d468294256 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag.errors.txt.diff @@ -2,21 +2,14 @@ +++ new.unusedTypeParameters_templateTag.errors.txt @@= skipped -0, +0 lines =@@ -/a.js(1,5): error TS6133: 'T' is declared but its value is never read. -- -- --==== /a.js (1 errors) ==== -+/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +/a.js(1,15): error TS6196: 'T' is declared but never used. -+ -+ -+==== /a.js (2 errors) ==== + + + ==== /a.js (1 errors) ==== /** @template T */ - ~~~~~~~~~~~~ -!!! error TS6133: 'T' is declared but its value is never read. -+ ~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS6196: 'T' is declared but never used. function f() {} -+ ~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file 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 63757e8c80..d46e56aaf4 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unusedTypeParameters_templateTag2.errors.txt.diff @@ -8,96 +8,61 @@ - - -==== /a.js (4 errors) ==== -+/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +/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(10,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +/a.js(13,3): error TS6205: All type parameters are unused. -+/a.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +/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 (8 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 TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ /** -+ ~~~ * @template T,V - ~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ */ - ~ -+ ~~~ + ~~ !!! error TS6205: All type parameters are unused. class C2 { -+ ~~~~~~~~~~ constructor() { } -+ ~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ +@@= skipped -30, +34 lines =@@ /** -+ ~~~ * @template T,V,X - ~ -!!! 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 TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff index beb795529b..95850d24be 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff @@ -11,7 +11,6 @@ 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(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +generic.js(9,22): error TS8011: Type arguments can only be used in TypeScript files. +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'. @@ -37,7 +36,7 @@ /** * @constructor * @param {number} numberOxen -@@= skipped -36, +35 lines =@@ +@@= skipped -36, +34 lines =@@ } // ok class Sql extends Wagon { @@ -104,22 +103,12 @@ +!!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (2 errors) ==== -+==== generic.js (7 errors) ==== ++==== generic.js (6 errors) ==== /** -+ ~~~ * @template T -+ ~~~~~~~~~~~~~~ * @param {T} flavour -+ ~~~~~~~~~~~~~~~~~~~~~ - */ -+ ~~~ - function Soup(flavour) { -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - this.flavour = flavour -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ +@@= skipped -11, +13 lines =@@ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { + ~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff index 3565540763..0ba61e4376 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorFunctionMethodTypeParameters.errors.txt.diff @@ -2,28 +2,18 @@ +++ new.constructorFunctionMethodTypeParameters.errors.txt @@= skipped -0, +0 lines =@@ - -+constructorFunctionMethodTypeParameters.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+constructorFunctionMethodTypeParameters.js(19,30): error TS8004: Type parameter declarations can only be used in TypeScript files. +constructorFunctionMethodTypeParameters.js(22,16): error TS2304: Cannot find name 'T'. +constructorFunctionMethodTypeParameters.js(24,17): error TS2304: Cannot find name 'T'. + + -+==== constructorFunctionMethodTypeParameters.js (4 errors) ==== ++==== constructorFunctionMethodTypeParameters.js (2 errors) ==== + /** -+ ~~~ + * @template {string} T -+ ~~~~~~~~~~~~~~~~~~~~~~~ + * @param {T} t -+ ~~~~~~~~~~~~~~~ + */ -+ ~~~ + function Cls(t) { -+ ~~~~~~~~~~~~~~~~~ + this.t = t; -+ ~~~~~~~~~~~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + * @template {string} V @@ -36,30 +26,19 @@ + }; + + 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 -+ ~~~~~~~~~~~~~~~~ + }; -+ ~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + var c = new Cls('a'); + const s = c.topLevelComment('a', 'b'); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff index d631e8a152..675c69e18e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff @@ -2,22 +2,15 @@ +++ new.extendsTag1.errors.txt @@= skipped -0, +0 lines =@@ - -+bug25101.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +bug25101.js(5,17): error TS8011: Type arguments can only be used in TypeScript files. + + -+==== bug25101.js (2 errors) ==== ++==== bug25101.js (1 errors) ==== + /** -+ ~~~ + * @template T -+ ~~~~~~~~~~~~~~ + * @extends {Set} Should prefer this Set, not the Set in the heritage clause -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~ + class My extends Set {} -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff index 77a86868b3..231b1e98a7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff @@ -1,7 +1,6 @@ --- old.extendsTag5.errors.txt +++ new.extendsTag5.errors.txt @@= skipped -0, +0 lines =@@ -+/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +/a.js(26,16): error TS8011: Type arguments can only be used in TypeScript files. /a.js(29,16): error TS2344: Type '{ a: string; b: string; }' does not satisfy the constraint 'Foo'. Types of property 'b' are incompatible. @@ -17,48 +16,11 @@ +/a.js(44,16): error TS8011: Type arguments can only be used in TypeScript files. + + -+==== /a.js (7 errors) ==== ++==== /a.js (6 errors) ==== /** -+ ~~~ * @typedef {{ -+ ~~~~~~~~~~~~~~ * a: number | string; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ - * b: boolean | string[]; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * }} Foo -+ ~~~~~~~~ - */ -+ ~~ -+ - - /** -+ ~~~ - * @template {Foo} T -+ ~~~~~~~~~~~~~~~~~~~ - */ -+ ~~ - class A { -+ ~~~~~~~~~ - /** -+ ~~~~~~ - * @param {T} a -+ ~~~~~~~~~~~~~~~~~~ - */ -+ ~~~~~~ - constructor(a) { -+ ~~~~~~~~~~~~~~~~~~~ - return a -+ ~~~~~~~~~~~~~~~ - } -+ ~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** - * @extends {A<{ -@@= skipped -32, +56 lines =@@ +@@= skipped -32, +36 lines =@@ * }>} */ class B extends A {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff deleted file mode 100644 index 9a8bb6f9ff..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/genericSetterInClassTypeJsDoc.errors.txt.diff +++ /dev/null @@ -1,52 +0,0 @@ ---- old.genericSetterInClassTypeJsDoc.errors.txt -+++ new.genericSetterInClassTypeJsDoc.errors.txt -@@= skipped -0, +0 lines =@@ -- -+genericSetterInClassTypeJsDoc.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== genericSetterInClassTypeJsDoc.js (1 errors) ==== -+ /** -+ ~~~ -+ * @template T -+ ~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ class Box { -+ ~~~~~~~~~~~~ -+ #value; -+ ~~~~~~~~~~~ -+ -+ -+ /** @param {T} initialValue */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ constructor(initialValue) { -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ this.#value = initialValue; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~~~ -+ -+ ~~~~ -+ /** @type {T} */ -+ ~~~~~~~~~~~~~~~~~~~~ -+ get value() { -+ ~~~~~~~~~~~~~~~~~ -+ return this.#value; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~~~ -+ -+ -+ set value(value) { -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ this.#value = value; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ new Box(3).value = 3; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff deleted file mode 100644 index d581d2992d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff +++ /dev/null @@ -1,57 +0,0 @@ ---- old.inferThis.errors.txt -+++ new.inferThis.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(1,17): error TS8004: Type parameter declarations can only be used in TypeScript files. -+/a.js(9,6): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== /a.js (2 errors) ==== -+ export class C { -+ -+ /** -+ ~~~~~~~ -+ * @template T -+ ~~~~~~~~~~~~~~~~~~ -+ * @this {T} -+ ~~~~~~~~~~~~~~~~ -+ * @return {T} -+ ~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~~~ -+ static a() { -+ ~~~~~~~~~~~~~~~~ -+ return this; -+ ~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+ -+ /** -+ ~~~~~~~ -+ * @template T -+ ~~~~~~~~~~~~~~~~~~ -+ * @this {T} -+ ~~~~~~~~~~~~~~~~ -+ * @return {T} -+ ~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~~~ -+ b() { -+ ~~~~~~~~~ -+ return this; -+ ~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ } -+ -+ 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/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff deleted file mode 100644 index 9bde4a39c9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt -+++ new.instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt -@@= skipped -0, +0 lines =@@ -- -+instantiateTemplateTagTypeParameterOnVariableStatement.js(6,12): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== instantiateTemplateTagTypeParameterOnVariableStatement.js (1 errors) ==== -+ /** -+ * @template T -+ * @param {T} a -+ * @returns {(b: T) => T} -+ */ -+ const seq = a => b => b; -+ ~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ const text1 = "hello"; -+ const text2 = "world"; -+ -+ /** @type {string} */ -+ var text3 = seq(text1)(text2); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff deleted file mode 100644 index 5668162016..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassImplementsGenericsSerialization.errors.txt.diff +++ /dev/null @@ -1,43 +0,0 @@ ---- old.jsDeclarationsClassImplementsGenericsSerialization.errors.txt -+++ new.jsDeclarationsClassImplementsGenericsSerialization.errors.txt -@@= skipped -0, +0 lines =@@ -- -+lib.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== interface.ts (0 errors) ==== -+ export interface Encoder { -+ encode(value: T): Uint8Array -+ } -+==== lib.js (1 errors) ==== -+ /** -+ ~~~ -+ * @template T -+ ~~~~~~~~~~~~~~ -+ * @implements {IEncoder} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ export class Encoder { -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ /** -+ ~~~~~~~ -+ * @param {T} value -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~~~ -+ encode(value) { -+ ~~~~~~~~~~~~~~~~~~~ -+ return new Uint8Array(0) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+ /** -+ * @template T -+ * @typedef {import('./interface').Encoder} IEncoder -+ */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff index 172fe63117..1879cc7b19 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff @@ -2,17 +2,10 @@ +++ new.jsDeclarationsClasses.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(17,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(31,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+index.js(72,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+index.js(97,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(111,25): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(153,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(167,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(173,23): error TS8011: Type arguments can only be used in TypeScript files. + + -+==== index.js (8 errors) ==== ++==== index.js (1 errors) ==== + export class A {} + + export class B { @@ -30,229 +23,108 @@ + */ + constructor(a, b) {} + } -+ -+ + + /** -+ ~~~ + * @template T,U -+ ~~~~~~~~~~~~~~~~ + */ -+ ~~~ + export class E { -+ ~~~~~~~~~~~~~~~~ + /** -+ ~~~~~~~ + * @type {T & U} -+ ~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + field; -+ ~~~~~~~~~~ -+ + + // @readonly is currently unsupported, it seems - included here just in case that changes -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** -+ ~~~~~~~ + * @type {T & U} -+ ~~~~~~~~~~~~~~~~~~~~ + * @readonly -+ ~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~ + */ -+ ~~~~~~~ -+ ~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + readonlyField; -+ ~~~~~~~~~~~~~~~~~~ -+ + + initializedField = 12; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ + + /** -+ ~~~~~~~ + * @return {U} -+ ~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + get f1() { return /** @type {*} */(null); } -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ + + /** -+ ~~~~~~~ + * @param {U} _p -+ ~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + set f1(_p) {} -+ ~~~~~~~~~~~~~~~~~ -+ + + /** -+ ~~~~~~~ + * @return {U} -+ ~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + get f2() { return /** @type {*} */(null); } -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ + + /** -+ ~~~~~~~ + * @param {U} _p -+ ~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + set f3(_p) {} -+ ~~~~~~~~~~~~~~~~~ -+ + + /** -+ ~~~~~~~ + * @param {T} a -+ ~~~~~~~~~~~~~~~~~~~ + * @param {U} b -+ ~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + constructor(a, b) {} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ -+ + + + /** -+ ~~~~~~~ + * @type {string} -+ ~~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + static staticField; -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+ + + // @readonly is currently unsupported, it seems - included here just in case that changes -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** -+ ~~~~~~~ + * @type {string} -+ ~~~~~~~~~~~~~~~~~~~~~ + * @readonly -+ ~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~ + */ -+ ~~~~~~~ -+ ~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + static staticReadonlyField; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ + + static staticInitializedField = 12; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ + + /** -+ ~~~~~~~ + * @return {string} -+ ~~~~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + static get s1() { return ""; } -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ + + /** -+ ~~~~~~~ + * @param {string} _p -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + static set s1(_p) {} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ + + /** -+ ~~~~~~~ + * @return {string} -+ ~~~~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + static get s2() { return ""; } -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ + + /** -+ ~~~~~~~ + * @param {string} _p -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + static set s3(_p) {} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ + + /** -+ ~~~ + * @template T,U -+ ~~~~~~~~~~~~~~~~ + */ -+ ~~~ + export class F { -+ ~~~~~~~~~~~~~~~~ + /** -+ ~~~~~~~ + * @type {T & U} -+ ~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + field; -+ ~~~~~~~~~~ + /** -+ ~~~~~~~ + * @param {T} a -+ ~~~~~~~~~~~~~~~~~~~ + * @param {U} b -+ ~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + constructor(a, b) {} -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ -+ -+ + + /** -+ ~~~~~~~ -+ ~~~~~~~ + * @template A,B -+ ~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~~ + * @param {A} a -+ ~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~ + * @param {B} b -+ ~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ -+ ~~~~~~~ + static create(a, b) { return new F(a, b); } -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + class G {} + @@ -287,68 +159,36 @@ + this.prop = 12; + } + } -+ -+ -+ + + + /** -+ ~~~ + * @template T -+ ~~~~~~~~~~~~~~ + */ -+ ~~~ + export class N extends L { -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** -+ ~~~~~~~ + * @param {T} param -+ ~~~~~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + constructor(param) { -+ ~~~~~~~~~~~~~~~~~~~~~~~~ + super(); -+ ~~~~~~~~~~~~~~~~ + this.another = param; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } -+ ~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ + + /** -+ ~~~ + * @template U -+ ~~~~~~~~~~~~~~ + * @extends {N} -+ ~~~~~~~~~~~~~~~~~~ + */ -+ ~~~ + export class O extends N { -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. + /** -+ ~~~~~~~ + * @param {U} param -+ ~~~~~~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~~~~~ + constructor(param) { -+ ~~~~~~~~~~~~~~~~~~~~~~~~ + super(param); -+ ~~~~~~~~~~~~~~~~~~~~~ + this.another2 = param; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } -+ ~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + var x = /** @type {*} */(null); + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff index 5e159e01b7..e09c802428 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.errors.txt.diff @@ -6,9 +6,7 @@ +index.js(3,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(4,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(12,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(12,58): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(22,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(22,58): error TS8004: Type parameter declarations can only be used in TypeScript files. +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`. @@ -24,7 +22,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 (20 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`. @@ -45,47 +43,26 @@ + Object.defineProperty(module.exports, "d", { value: d }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+ -+ -+ + + + /** -+ ~~~ + * @template T,U -+ ~~~~~~~~~~~~~~~~ + * @param {T} a -+ ~~~~~~~~~~~~~~~ + * @param {U} b -+ ~~~~~~~~~~~~~~~ + * @return {T & U} -+ ~~~~~~~~~~~~~~~~~~~ + */ -+ ~~~ + function e(a, b) { return /** @type {*} */(null); } -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + Object.defineProperty(module.exports, "e", { value: e }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+ -+ + + /** -+ ~~~ + * @template T -+ ~~~~~~~~~~~~~~ + * @param {T} a -+ ~~~~~~~~~~~~~~~ + */ -+ ~~~ + function f(a) { -+ ~~~~~~~~~~~~~~~ + return a; -+ ~~~~~~~~~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + Object.defineProperty(module.exports, "f", { value: f }); + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff index d2687c691a..303a737360 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.errors.txt.diff @@ -2,15 +2,13 @@ +++ new.jsDeclarationsFunctions.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(14,59): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(22,59): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(38,21): error TS2349: This expression is not callable. + Type '{ y: any; }' has no call signatures. +index.js(48,21): error TS2349: This expression is not callable. + Type '{ y: any; }' has no call signatures. + + -+==== index.js (4 errors) ==== ++==== index.js (2 errors) ==== + export function a() {} + + export function b() {} @@ -25,42 +23,22 @@ + * @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); } -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ + + /** -+ ~~~ + * @template T -+ ~~~~~~~~~~~~~~ + * @param {T} a -+ ~~~~~~~~~~~~~~~ + */ -+ ~~~ + export function f(a) { -+ ~~~~~~~~~~~~~~~~~~~~~~ + return a; -+ ~~~~~~~~~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + f.self = f; + + /** diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff deleted file mode 100644 index f0c93aa0b0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff +++ /dev/null @@ -1,45 +0,0 @@ ---- old.jsdocAccessibilityTags.errors.txt -+++ new.jsdocAccessibilityTags.errors.txt -@@= skipped -0, +0 lines =@@ -+jsdocAccessibilityTag.js(5,8): error TS8009: The 'private' modifier can only be used in TypeScript files. -+jsdocAccessibilityTag.js(11,8): error TS8009: The 'protected' modifier can only be used in TypeScript files. -+jsdocAccessibilityTag.js(17,8): error TS8009: The 'public' modifier can only be used in TypeScript files. - jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. - jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. - jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. -@@= skipped -9, +12 lines =@@ - jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. - - --==== jsdocAccessibilityTag.js (10 errors) ==== -+==== jsdocAccessibilityTag.js (13 errors) ==== - class A { - /** - * Ap docs - * - * @private -+ ~~~~~~~~ - */ -+ ~~~~~ -+!!! error TS8009: The 'private' modifier can only be used in TypeScript files. - priv = 4; - /** - * Aq docs - * - * @protected -+ ~~~~~~~~~~ - */ -+ ~~~~~ -+!!! error TS8009: The 'protected' modifier can only be used in TypeScript files. - prot = 5; - /** - * Ar docs - * - * @public -+ ~~~~~~~ - */ -+ ~~~~~ -+!!! error TS8009: The 'public' modifier can only be used in TypeScript files. - pub = 6; - /** @public */ - get ack() { return this.priv } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff deleted file mode 100644 index d3cd22ef46..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.jsdocReadonly.errors.txt -+++ new.jsdocReadonly.errors.txt -@@= skipped -0, +0 lines =@@ -+jsdocReadonly.js(3,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+jsdocReadonly.js(4,8): error TS8009: The 'private' modifier can only be used in TypeScript files. -+jsdocReadonly.js(9,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+jsdocReadonly.js(11,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. - jsdocReadonly.js(23,3): error TS2540: Cannot assign to 'y' because it is a read-only property. - - --==== jsdocReadonly.js (1 errors) ==== -+==== jsdocReadonly.js (5 errors) ==== - class LOL { - /** - * @readonly -+ ~~~~~~~~~ - * @private -+ ~~~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ ~~~~~~~~ - * @type {number} -+ ~~~~~~~ -+!!! error TS8009: The 'private' modifier can only be used in TypeScript files. - * Order rules do not apply to JSDoc - */ - x = 1 - /** @readonly */ -+ ~~~~~~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - y = 2 - /** @readonly Definitely not here */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - static z = 3 - /** @readonly This is OK too */ - constructor() { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.errors.txt.diff index de84cbc0c6..6c46f1071b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.errors.txt.diff @@ -2,15 +2,12 @@ +++ new.jsdocReadonlyDeclarations.errors.txt @@= skipped -0, +0 lines =@@ - -+jsdocReadonlyDeclarations.js(2,9): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +jsdocReadonlyDeclarations.js(14,1): error TS2554: Expected 1 arguments, but got 0. + + -+==== jsdocReadonlyDeclarations.js (2 errors) ==== ++==== jsdocReadonlyDeclarations.js (1 errors) ==== + class C { + /** @readonly */ -+ ~~~~~~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. + x = 6 + /** @readonly */ + constructor(n) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff deleted file mode 100644 index 23ed49c09c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateClass.errors.txt.diff +++ /dev/null @@ -1,57 +0,0 @@ ---- old.jsdocTemplateClass.errors.txt -+++ new.jsdocTemplateClass.errors.txt -@@= skipped -0, +0 lines =@@ -+templateTagOnClasses.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to type 'number'. - - --==== templateTagOnClasses.js (1 errors) ==== -+==== templateTagOnClasses.js (2 errors) ==== - /** -+ ~~~ - * @template T -+ ~~~~~~~~~~~~~~ - * @typedef {(t: T) => T} Id -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ -+ ~~~ - /** @template T */ -+ ~~~~~~~~~~~~~~~~~~ - class Foo { -+ ~~~~~~~~~~~ - /** @typedef {(t: T) => T} Id2 */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** @param {T} x */ -+ ~~~~~~~~~~~~~~~~~~~~~~~ - constructor (x) { -+ ~~~~~~~~~~~~~~~~~~~~~ - this.a = x -+ ~~~~~~~~~~~~~~~~~~ - } -+ ~~~~~ - /** -+ ~~~~~~~ - * -+ ~~~~~~~ - * @param {T} x -+ ~~~~~~~~~~~~~~~~~~~~ - * @param {Id} y -+ ~~~~~~~~~~~~~~~~~~~~~~~ - * @param {Id2} alpha -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ - * @return {T} -+ ~~~~~~~~~~~~~~~~~~ - */ -+ ~~~~~~~ - foo(x, y, alpha) { -+ ~~~~~~~~~~~~~~~~~~~~~~ - return alpha(y(x)) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - var f = new Foo(1) - var g = new Foo(false) - f.a = g.a \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff index 3e302d5994..fd8c906846 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff @@ -2,44 +2,34 @@ +++ new.jsdocTemplateConstructorFunction.errors.txt @@= skipped -0, +0 lines =@@ -templateTagOnConstructorFunctions.js(24,1): error TS2322: Type 'boolean' is not assignable to type 'number'. -+templateTagOnConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - - - ==== templateTagOnConstructorFunctions.js (1 errors) ==== - /** -+ ~~~ - * @template U -+ ~~~~~~~~~~~~~~ - * @typedef {(u: U) => U} Id -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ -+ ~~~ - /** -+ ~~~ - * @param {T} t -+ ~~~~~~~~~~~~~~~ - * @template T -+ ~~~~~~~~~~~~~~ - */ -+ ~~~ - function Zet(t) { -+ ~~~~~~~~~~~~~~~~~ - /** @type {T} */ -+ ~~~~~~~~~~~~~~~~~~~~ - this.u -+ ~~~~~~~~~~ - this.t = t -+ ~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - /** - * @param {T} v - * @param {Id} id -@@= skipped -25, +39 lines =@@ - var z = new Zet(1) - z.t = 2 - z.u = false +- +- +-==== templateTagOnConstructorFunctions.js (1 errors) ==== +- /** +- * @template U +- * @typedef {(u: U) => U} Id +- */ +- /** +- * @param {T} t +- * @template T +- */ +- function Zet(t) { +- /** @type {T} */ +- this.u +- this.t = t +- } +- /** +- * @param {T} v +- * @param {Id} id +- */ +- Zet.prototype.add = function(v, id) { +- this.u = v || this.t +- return id(this.u) +- } +- var z = new Zet(1) +- z.t = 2 +- z.u = false - ~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. - \ No newline at end of file +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff index 579ae06c54..1de308f13e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff @@ -2,34 +2,15 @@ +++ new.jsdocTemplateConstructorFunction2.errors.txt @@= skipped -0, +0 lines =@@ -templateTagWithNestedTypeLiteral.js(21,1): error TS2322: Type 'boolean' is not assignable to type 'number'. -+templateTagWithNestedTypeLiteral.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. - ==== templateTagWithNestedTypeLiteral.js (2 errors) ==== +-==== templateTagWithNestedTypeLiteral.js (2 errors) ==== ++==== templateTagWithNestedTypeLiteral.js (1 errors) ==== /** -+ ~~~ * @param {T} t -+ ~~~~~~~~~~~~~~~ * @template T -+ ~~~~~~~~~~~~~~ - */ -+ ~~~ - function Zet(t) { -+ ~~~~~~~~~~~~~~~~~ - /** @type {T} */ -+ ~~~~~~~~~~~~~~~~~~~~ - this.u -+ ~~~~~~~~~~ - this.t = t -+ ~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - /** - * @param {T} v - * @param {object} o -@@= skipped -23, +33 lines =@@ +@@= skipped -23, +22 lines =@@ var z = new Zet(1) z.t = 2 z.u = false diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff index 21a8cf6da4..716047469c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag.errors.txt.diff @@ -2,58 +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(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+forgot.js(8,15): error TS8004: Type parameter declarations can only be used in TypeScript files. +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 (4 errors) ==== ++==== forgot.js (2 errors) ==== /** -+ ~~~ * @param {T} a -+ ~~~~~~~~~~~~~~~ * @template T -+ ~~~~~~~~~~~~~~ - */ -+ ~~~ - function f(a) { -+ ~~~~~~~~~~~~~~~ - return () => a -+ ~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - let n = f(1)() -+ -+ - - /** -+ ~~~ +@@= 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 -+ ~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - let s = g('hi')() - - /** -@@= skipped -26, +51 lines =@@ +@@= skipped -11, +14 lines =@@ */ Element.prototype.animate = function(keyframes) {}; ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff deleted file mode 100644 index 47cc69dacf..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag2.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsdocTemplateTag2.errors.txt -+++ new.jsdocTemplateTag2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+github17339.js(7,4): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== github17339.js (1 errors) ==== -+ var obj = { -+ /** -+ * @template T -+ * @param {T} a -+ * @returns {T} -+ */ -+ x: function (a) { -+ ~~~~~~~~~~~~~~~ -+ return a; -+ ~~~~~~~~~~~ -+ }, -+ ~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ }; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff index 03f700f13c..a30dd9f14c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff @@ -1,60 +1,23 @@ --- old.jsdocTemplateTag3.errors.txt +++ new.jsdocTemplateTag3.errors.txt @@= skipped -0, +0 lines =@@ -+a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. 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 (5 errors) ==== +a.js(21,3): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. -+a.js(21,50): error TS8004: Type parameter declarations can only be used in TypeScript files. - - - ==== a.js (5 errors) ==== ++ ++ ++==== a.js (3 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) { -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ - !!! error TS2339: Property 'a' does not exist on type 'U'. - ~ - !!! error TS2339: Property 'b' does not exist on type 'U'. - return w; -+ ~~~~~~~~~~~~~~~~~ - } -+ ~~~~~ - return x; -+ ~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - +@@= skipped -32, +29 lines =@@ f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); f({ a: 12 }, undefined, undefined, 101, 'nope'); ~~~~~~~~~~ @@ -62,25 +25,14 @@ -!!! error TS2345: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: 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. -+ -+ /** -+ ~~~ * @template {NoLongerAllowed} - ~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'NoLongerAllowed'. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @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) { } -+ ~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - \ No newline at end of file + function g(x) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff index 401888dde3..0f87797d38 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag4.errors.txt.diff @@ -2,11 +2,9 @@ +++ new.jsdocTemplateTag4.errors.txt @@= skipped -0, +0 lines =@@ - -+a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(8,16): error TS2315: Type 'Object' is not generic. +a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +a.js(16,36): error TS7006: Parameter 'key' implicitly has an 'any' type. -+a.js(26,16): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(27,16): error TS2315: Type 'Object' is not generic. +a.js(28,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +a.js(35,37): error TS7006: Parameter 'key' implicitly has an 'any' type. @@ -15,32 +13,21 @@ +a.js(55,40): error TS7006: Parameter 'key' implicitly has an 'any' type. + + -+==== a.js (11 errors) ==== ++==== a.js (9 errors) ==== + /** -+ ~~~ + * Should work for function declarations -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @constructor -+ ~~~~~~~~~~~~~~~ + * @template {string} K -+ ~~~~~~~~~~~~~~~~~~~~~~~ + * @template V -+ ~~~~~~~~~~~~~~ + */ -+ ~~~ + function Multimap() { -+ ~~~~~~~~~~~~~~~~~~~~~ + /** @type {Object} TODO: Remove the prototype from the fresh object */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + this._map = {}; -+ ~~~~~~~~~~~~~~~~~~~ + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }; -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + * @param {K} key the key ok @@ -59,18 +46,13 @@ + * @template V + */ + var Multimap2 = function() { -+ ~~~~~~~~~~~~~ + /** @type {Object} TODO: Remove the prototype from the fresh object */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + this._map = {}; -+ ~~~~~~~~~~~~~~~~~~~ + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }; -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** + * @param {K} key the key ok diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff index 26b326287b..4b8b9d6040 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag5.errors.txt.diff @@ -2,13 +2,11 @@ +++ new.jsdocTemplateTag5.errors.txt @@= skipped -0, +0 lines =@@ - -+a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(8,16): error TS2315: Type 'Object' is not generic. +a.js(9,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +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(28,16): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(29,16): error TS2315: Type 'Object' is not generic. +a.js(30,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. +a.js(35,16): error TS2304: Cannot find name 'K'. @@ -21,32 +19,21 @@ +a.js(61,21): error TS2339: Property '_map' does not exist on type '{ get(key: K): V; }'. + + -+==== a.js (17 errors) ==== ++==== a.js (15 errors) ==== + /** -+ ~~~ + * Should work for function declarations -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * @constructor -+ ~~~~~~~~~~~~~~~ + * @template {string} K -+ ~~~~~~~~~~~~~~~~~~~~~~~ + * @template V -+ ~~~~~~~~~~~~~~ + */ -+ ~~~ + function Multimap() { -+ ~~~~~~~~~~~~~~~~~~~~~ + /** @type {Object} TODO: Remove the prototype from the fresh object */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + this._map = {}; -+ ~~~~~~~~~~~~~~~~~~~ + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }; -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + Multimap.prototype = { + /** @@ -71,18 +58,13 @@ + * @template V + */ + var Multimap2 = function() { -+ ~~~~~~~~~~~~~ + /** @type {Object} TODO: Remove the prototype from the fresh object */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ +!!! error TS2315: Type 'Object' is not generic. + this._map = {}; -+ ~~~~~~~~~~~~~~~~~~~ + ~~~~ +!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. + }; -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + Multimap2.prototype = { + /** 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 cb6d1b01d5..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff +++ /dev/null @@ -1,197 +0,0 @@ ---- old.jsdocTemplateTag6.errors.txt -+++ new.jsdocTemplateTag6.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(11,64): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(23,64): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(34,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(45,54): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(56,62): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(65,22): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(77,40): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== a.js (8 errors) ==== -+ /** -+ ~~~ -+ * @template const T -+ ~~~~~~~~~~~~~~~~~~~~ -+ * @param {T} x -+ ~~~~~~~~~~~~~~~ -+ * @returns {T} -+ ~~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ function f1(x) { -+ ~~~~~~~~~~~~~~~~ -+ return x; -+ ~~~~~~~~~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ 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) { -+ ~~~~~~~~~~~~~~~~ -+ return x; -+ ~~~~~~~~~~~~~ -+ }; -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ 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) { -+ ~~~~~~~~~~~~~~~~ -+ return [x]; -+ ~~~~~~~~~~~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ const t7 = f3("hello"); -+ const t8 = f3("hello"); -+ -+ -+ -+ /** -+ ~~~ -+ * @template const T -+ ~~~~~~~~~~~~~~~~~~~~ -+ * @param {[T, T]} x -+ ~~~~~~~~~~~~~~~~~~~~ -+ * @returns {T} -+ ~~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ function f4(x) { -+ ~~~~~~~~~~~~~~~~ -+ return x[0]; -+ ~~~~~~~~~~~~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ 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) { -+ ~~~~~~~~~~~~~~~~~~ -+ return obj.x; -+ ~~~~~~~~~~~~~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ 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) {} -+ ~~~~~~~~~~~~~~~~~~~~~ -+ -+ -+ -+ -+ /** -+ ~~~~~~~ -+ ~~~~~~~ -+ * @template const U -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @param {U} x -+ ~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~~~ -+ ~~~~~~~ -+ foo(x) { -+ ~~~~~~~~~~~~ -+ ~~~~~~~~~~~~ -+ return x; -+ ~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~~ -+ } -+ ~~~~~ -+ ~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); -+ const t14 = t13.foo(["a", ["b", "c"]]); -+ -+ -+ -+ /** -+ ~~~ -+ * @template {readonly unknown[]} const T -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ * @param {T} args -+ ~~~~~~~~~~~~~~~~~~ -+ * @returns {T} -+ ~~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ function f6(...args) { -+ ~~~~~~~~~~~~~~~~~~~~~~ -+ return args; -+ ~~~~~~~~~~~~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ const t15 = f6(1, 'b', { a: 1, b: 'x' }); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff deleted file mode 100644 index 75ba667d47..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff +++ /dev/null @@ -1,55 +0,0 @@ ---- old.jsdocTemplateTag7.errors.txt -+++ new.jsdocTemplateTag7.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class -+a.js(9,12): error TS8004: Type parameter declarations can only be used in TypeScript files. - a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter - - --==== a.js (2 errors) ==== -+==== a.js (4 errors) ==== - /** -+ ~~~ - * @template const T -+ ~~~~~~~~~~~~~~~~~~~~ - ~~~~~ - !!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class - * @typedef {[T]} X -+ ~~~~~~~~~~~~~~~~~~~ - */ -+ ~~~ -+ - - /** -+ ~~~ - * @template const T -+ ~~~~~~~~~~~~~~~~~~~~ - */ -+ ~~~ - class C { } -+ ~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ - - /** -+ ~~~ - * @template private T -+ ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~ - !!! error TS1273: 'private' modifier cannot appear on a type parameter - * @param {T} x -+ ~~~~~~~~~~~~~~~ - * @returns {T} -+ ~~~~~~~~~~~~~~~ - */ -+ ~~~ - function f(x) { -+ ~~~~~~~~~~~~~~~ - return x; -+ ~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff index 821831507a..8b2d7d7f0b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff @@ -11,16 +11,12 @@ 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'. -@@= skipped -9, +12 lines =@@ - 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(56,33): error TS8004: Type parameter declarations can only be used in TypeScript files. +@@= skipped -12, +15 lines =@@ 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 (9 errors) ==== ++==== a.js (8 errors) ==== /** * @template out T + ~~~ @@ -28,7 +24,7 @@ * @typedef {Object} Covariant * @property {T} x */ -@@= skipped -28, +31 lines =@@ +@@= skipped -25, +27 lines =@@ /** * @template in T @@ -45,25 +41,4 @@ +!!! 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 -26, +28 lines =@@ - !!! 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'. -+ ~~~~~~~~~~ -+ - - /** -+ ~~~ - * @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 TS8004: Type parameter declarations can only be used in TypeScript files. - \ No newline at end of file + */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff index 7ed8e4f665..31ea3f1da6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff @@ -4,144 +4,30 @@ 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(13,21): error TS8004: Type parameter declarations can only be used in TypeScript files. 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(49,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. -+file.js(57,21): error TS8004: Type parameter declarations can only be used in TypeScript files. file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. -==== file.js (7 errors) ==== -+==== file.js (8 errors) ==== ++==== file.js (5 errors) ==== /** * @template {string | number} [T=string] - ok: defaults are permitted * @typedef {[T]} A -@@= skipped -22, +23 lines =@@ - const aString = [""]; - /** @type {A} */ // ok, `T` is provided for `A` - const aNumber = [0]; -+ -+ +@@= skipped -31, +29 lines =@@ /** -+ ~~~ - * @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` - ~ -!!! error TS1005: '=' expected. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * @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. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ - !!! 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) {} -+ ~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ - - /** -+ ~~~~ - * @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) {} -+ ~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ - - /** -+ ~~~ - * @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) {} -+ ~~~~~~~~~~~~~~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file 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 b695479d11..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag3.errors.txt.diff +++ /dev/null @@ -1,44 +0,0 @@ ---- old.overloadTag3.errors.txt -+++ new.overloadTag3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ /** -+ ~~~ -+ * @template T -+ ~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ export class Foo { -+ ~~~~~~~~~~~~~~~~~~ -+ /** -+ ~~~~~~~ -+ * @constructor -+ ~~~~~~~~~~~~~~~~~~~ -+ * @overload -+ ~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~~~ -+ constructor() { } -+ ~~~~~~~~~~~~~~~~~~~~~ -+ -+ -+ /** -+ ~~~~~~~ -+ * @param {T} value -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~~~~~ -+ bar(value) { } -+ ~~~~~~~~~~~~~~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ /** @type {Foo} */ -+ let foo; -+ foo = new Foo(); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff deleted file mode 100644 index c6d8802f9e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/paramTagTypeResolution2.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.paramTagTypeResolution2.errors.txt -+++ new.paramTagTypeResolution2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+38572.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ -+==== 38572.js (1 errors) ==== -+ /** -+ ~~~ -+ * @template T -+ ~~~~~~~~~~~~~~ -+ * @param {T} a -+ ~~~~~~~~~~~~~~~ -+ * @param {{[K in keyof T]: (value: T[K]) => void }} b -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ */ -+ ~~~ -+ function f(a, b) { -+ ~~~~~~~~~~~~~~~~~~ -+ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ f({ x: 42 }, { x(param) { param.toFixed() } }); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff deleted file mode 100644 index 30831764d7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff +++ /dev/null @@ -1,50 +0,0 @@ ---- old.privateNamesIncompatibleModifiersJs.errors.txt -+++ new.privateNamesIncompatibleModifiersJs.errors.txt -@@= skipped -0, +0 lines =@@ -+privateNamesIncompatibleModifiersJs.js(3,8): error TS8009: The 'public' modifier can only be used in TypeScript files. - privateNamesIncompatibleModifiersJs.js(3,8): error TS18010: An accessibility modifier cannot be used with a private identifier. -+privateNamesIncompatibleModifiersJs.js(8,8): error TS8009: The 'private' modifier can only be used in TypeScript files. - privateNamesIncompatibleModifiersJs.js(8,8): error TS18010: An accessibility modifier cannot be used with a private identifier. -+privateNamesIncompatibleModifiersJs.js(13,8): error TS8009: The 'protected' modifier can only be used in TypeScript files. - privateNamesIncompatibleModifiersJs.js(13,8): error TS18010: An accessibility modifier cannot be used with a private identifier. - privateNamesIncompatibleModifiersJs.js(18,8): error TS18010: An accessibility modifier cannot be used with a private identifier. - privateNamesIncompatibleModifiersJs.js(23,8): error TS18010: An accessibility modifier cannot be used with a private identifier. -@@= skipped -11, +14 lines =@@ - privateNamesIncompatibleModifiersJs.js(55,8): error TS18010: An accessibility modifier cannot be used with a private identifier. - - --==== privateNamesIncompatibleModifiersJs.js (12 errors) ==== -+==== privateNamesIncompatibleModifiersJs.js (15 errors) ==== - class A { - /** - * @public - ~~~~~~~ -+ ~~~~~~~ - */ -+ ~~~~~ -+!!! error TS8009: The 'public' modifier can only be used in TypeScript files. - ~~~~~ - !!! error TS18010: An accessibility modifier cannot be used with a private identifier. - #a = 1; -@@= skipped -13, +16 lines =@@ - /** - * @private - ~~~~~~~~ -+ ~~~~~~~~ - */ -+ ~~~~~ -+!!! error TS8009: The 'private' modifier can only be used in TypeScript files. - ~~~~~ - !!! error TS18010: An accessibility modifier cannot be used with a private identifier. - #b = 1; -@@= skipped -8, +11 lines =@@ - /** - * @protected - ~~~~~~~~~~ -+ ~~~~~~~~~~ - */ -+ ~~~~~ -+!!! error TS8009: The 'protected' modifier can only be used in TypeScript files. - ~~~~~ - !!! error TS18010: An accessibility modifier cannot be used with a private identifier. - #c = 1; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff index 134ae7585e..90eb34fe82 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/propertiesOfGenericConstructorFunctions.errors.txt.diff @@ -2,37 +2,22 @@ +++ new.propertiesOfGenericConstructorFunctions.errors.txt @@= skipped -0, +0 lines =@@ - -+propertiesOfGenericConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +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(26,24): error TS8004: Type parameter declarations can only be used in TypeScript files. + + -+==== propertiesOfGenericConstructorFunctions.js (3 errors) ==== ++==== 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 }; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + }; -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + /** @type {Multimap<"a" | "b", number>} with type annotation */ + ~~~~~~~~ @@ -49,28 +34,16 @@ + 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 -+ ~~~~~~~~~~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + Cp.prototype = { + m1() { return this.x }, + m2() { this.z = this.x + 1; return this.y } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff index 228097651d..2164c25069 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff @@ -7,7 +7,6 @@ -templateInsideCallback.js(10,12): error TS2304: Cannot find name 'T'. templateInsideCallback.js(15,11): error TS2315: Type 'Call' is not generic. +templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. -+templateInsideCallback.js(17,17): error TS8004: Type parameter declarations can only be used in TypeScript files. 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 @@ -26,7 +25,7 @@ +templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. + + -+==== templateInsideCallback.js (6 errors) ==== ++==== templateInsideCallback.js (5 errors) ==== /** * @typedef Oops - ~~~~ @@ -34,7 +33,7 @@ * @template T * @property {T} a * @property {T} b -@@= skipped -27, +15 lines =@@ +@@= skipped -27, +14 lines =@@ /** * @callback Call * @template T @@ -54,12 +53,8 @@ +!!! error TS2304: Cannot find name 'T'. */ const identity = x => x; -+ ~~~~~~~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ - !!! error TS7006: Parameter 'x' implicitly has an 'any' type. - -@@= skipped -10, +14 lines =@@ +@@= skipped -10, +12 lines =@@ * @property {Object} oh * @property {number} oh.no * @template T diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff index e951cbb01a..0d0f4cee34 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTypeOfConstructorFunctions.errors.txt.diff @@ -2,40 +2,25 @@ +++ new.thisTypeOfConstructorFunctions.errors.txt @@= skipped -0, +0 lines =@@ - -+thisTypeOfConstructorFunctions.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +thisTypeOfConstructorFunctions.js(15,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -+thisTypeOfConstructorFunctions.js(19,2): error TS8004: Type parameter declarations can only be used in TypeScript files. +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 (6 errors) ==== ++==== 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 -+ ~~~~~~~~~~~~~~~~~~~~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + + Cp.prototype = { + /** @return {this} */ @@ -45,26 +30,15 @@ + this.z = this.y; return this + } + } -+ -+ + + /** -+ ~~~ + * @class -+ ~~~~~~~~~ + * @template T -+ ~~~~~~~~~~~~~~ + * @param {T} t -+ ~~~~~~~~~~~~~~~ + */ -+ ~~~ + function Cpp(t) { -+ ~~~~~~~~~~~~~~~~~ + this.y = t -+ ~~~~~~~~~~~~~~ + } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + /** @return {this} */ + Cpp.prototype.m2 = function () { + this.z = this.y; return this diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff deleted file mode 100644 index 659cf8a78f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff +++ /dev/null @@ -1,66 +0,0 @@ ---- old.typedefTagTypeResolution.errors.txt -+++ new.typedefTagTypeResolution.errors.txt -@@= skipped -0, +0 lines =@@ -+github20832.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. - github20832.js(2,15): error TS2304: Cannot find name 'U'. -+github20832.js(13,13): error TS8004: Type parameter declarations can only be used in TypeScript files. - github20832.js(17,12): error TS2304: Cannot find name 'V'. - - --==== github20832.js (2 errors) ==== -+==== github20832.js (4 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; -+ ~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** @type T - should be fine, since T will be any */ - const x = 3; -+ -+ - - /** -+ ~~~ - * @callback Cb -+ ~~~~~~~~~~~~~~~ - * @param {V} firstParam -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - ~ - !!! error TS2304: Cannot find name 'V'. - */ -+ ~~~ - /** -+ ~~~ - * @template V -+ ~~~~~~~~~~~~~~ - * @param {V} vvvvv -+ ~~~~~~~~~~~~~~~~~~~ - */ -+ ~~~ - function g(vvvvv) { -+ ~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - /** @type {Cb} */ - const cb = x => {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff deleted file mode 100644 index 352902b28f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff +++ /dev/null @@ -1,51 +0,0 @@ ---- old.uniqueSymbolsDeclarationsInJs.errors.txt -+++ new.uniqueSymbolsDeclarationsInJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+uniqueSymbolsDeclarationsInJs.js(4,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+uniqueSymbolsDeclarationsInJs.js(9,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+uniqueSymbolsDeclarationsInJs.js(14,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+uniqueSymbolsDeclarationsInJs.js(20,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ -+ -+==== uniqueSymbolsDeclarationsInJs.js (4 errors) ==== -+ // classes -+ class C { -+ /** -+ * @readonly -+ ~~~~~~~~~ -+ */ -+ ~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ static readonlyStaticCall = Symbol(); -+ /** -+ * @type {unique symbol} -+ * @readonly -+ ~~~~~~~~~ -+ */ -+ ~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ static readonlyStaticType; -+ /** -+ * @type {unique symbol} -+ * @readonly -+ ~~~~~~~~~ -+ */ -+ ~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ static readonlyStaticTypeAndCall = Symbol(); -+ static readwriteStaticCall = Symbol(); -+ -+ /** -+ * @readonly -+ ~~~~~~~~~ -+ */ -+ ~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. -+ readonlyCall = Symbol(); -+ readwriteCall = Symbol(); -+ } -+ -+ /** @type {unique symbol} */ -+ const a = Symbol(); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff deleted file mode 100644 index bf3547a2c9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.uniqueSymbolsDeclarationsInJsErrors.errors.txt -+++ new.uniqueSymbolsDeclarationsInJsErrors.errors.txt -@@= 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(8,8): error TS8009: The 'readonly' modifier can only be used in TypeScript files. - 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) ==== -+==== uniqueSymbolsDeclarationsInJsErrors.js (3 errors) ==== - class C { - /** - * @type {unique symbol} -@@= skipped -12, +13 lines =@@ - /** - * @type {unique symbol} - * @readonly -+ ~~~~~~~~~ - */ -+ ~~~~~ -+!!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - static readonlyType; - /** - * @type {unique symbol} \ No newline at end of file From 2f7b583864fbe48a46efe8e5e3b92c4bf314a573 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 11:57:31 +0000 Subject: [PATCH 10/31] Move JS diagnostics from ast to compiler package and use SyncMap for caching Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ast/ast.go | 21 - internal/ast/js_diagnostics.go | 429 ------------------ internal/compiler/program.go | 428 ++++++++++++++++- .../jsSyntacticDiagnostics.errors.txt | 151 +++--- .../ambientPropertyDeclarationInJs.errors.txt | 10 +- ...entPropertyDeclarationInJs.errors.txt.diff | 27 -- 6 files changed, 487 insertions(+), 579 deletions(-) delete mode 100644 internal/ast/js_diagnostics.go delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff diff --git a/internal/ast/ast.go b/internal/ast/ast.go index be98f4963b..726796500a 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -10085,11 +10085,6 @@ type SourceFile struct { lineMapMu sync.RWMutex lineMap []core.TextPos - // Fields set by AdditionalSyntacticDiagnostics - - additionalSyntacticDiagnosticsMu sync.RWMutex - additionalSyntacticDiagnostics []*Diagnostic - // Fields set by language service tokenCacheMu sync.Mutex @@ -10151,22 +10146,6 @@ func (node *SourceFile) SetJSDocDiagnostics(diags []*Diagnostic) { node.jsdocDiagnostics = diags } -func (node *SourceFile) AdditionalSyntacticDiagnostics() []*Diagnostic { - node.additionalSyntacticDiagnosticsMu.RLock() - diagnostics := node.additionalSyntacticDiagnostics - node.additionalSyntacticDiagnosticsMu.RUnlock() - if diagnostics == nil { - node.additionalSyntacticDiagnosticsMu.Lock() - defer node.additionalSyntacticDiagnosticsMu.Unlock() - diagnostics = node.additionalSyntacticDiagnostics - if diagnostics == nil { - diagnostics = getJSSyntacticDiagnosticsForFile(node) - node.additionalSyntacticDiagnostics = diagnostics - } - } - return diagnostics -} - func (node *SourceFile) JSDocCache() map[*Node][]*Node { return node.jsdocCache } diff --git a/internal/ast/js_diagnostics.go b/internal/ast/js_diagnostics.go deleted file mode 100644 index 2584808012..0000000000 --- a/internal/ast/js_diagnostics.go +++ /dev/null @@ -1,429 +0,0 @@ -package ast - -import ( - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/diagnostics" -) - -// JS syntactic diagnostics functions - -func getJSSyntacticDiagnosticsForFile(sourceFile *SourceFile) []*Diagnostic { - diagnostics := []*Diagnostic{} - - // Walk the entire AST to find TypeScript-only constructs - walkNodeForJSDiagnostics(sourceFile, sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) - - return diagnostics -} - -func walkNodeForJSDiagnostics(sourceFile *SourceFile, node *Node, parent *Node, diags *[]*Diagnostic) { - if node == nil { - return - } - - // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations - if node.Flags&NodeFlagsReparsed != 0 { - return - } - - // Handle specific parent-child relationships first - switch parent.Kind { - case KindParameter, KindPropertyDeclaration, KindMethodDeclaration: - // Check for question token (optional markers) - only parameters have question tokens - if parent.Kind == KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) - return - } - fallthrough - case KindMethodSignature, KindConstructor, KindGetAccessor, KindSetAccessor, - KindFunctionExpression, KindFunctionDeclaration, KindArrowFunction, KindVariableDeclaration: - // Check for type annotations - if isTypeAnnotation(parent, node) { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) - return - } - } - - // Check node-specific constructs - switch node.Kind { - case KindImportClause: - if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { - *diags = append(*diags, createDiagnosticForNode(sourceFile, parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) - return - } - - case KindExportDeclaration: - if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) - return - } - - case KindImportSpecifier: - if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) - return - } - - case KindExportSpecifier: - if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) - return - } - - case KindImportEqualsDeclaration: - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) - return - - case KindExportAssignment: - if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) - return - } - - case KindHeritageClause: - if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == KindImplementsKeyword { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) - return - } - - case KindInterfaceDeclaration: - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) - return - - case KindModuleDeclaration: - moduleKeyword := "module" - // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) - return - - case KindTypeAliasDeclaration: - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) - return - - case KindEnumDeclaration: - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) - return - - case KindNonNullExpression: - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) - return - - case KindAsExpression: - if node.AsAsExpression() != nil { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) - return - } - - case KindSatisfiesExpression: - if node.AsSatisfiesExpression() != nil { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) - return - } - - case KindConstructor, KindMethodDeclaration, KindFunctionDeclaration: - // Check for signature declarations (functions without bodies) - if isSignatureDeclaration(node) { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) - return - } - } - - // Check for type parameters, type arguments, and modifiers - checkTypeParametersAndModifiers(sourceFile, node, diags) - - // Recursively walk children - node.ForEachChild(func(child *Node) bool { - walkNodeForJSDiagnostics(sourceFile, child, node, diags) - return false - }) -} - -func isTypeAnnotation(parent *Node, node *Node) bool { - switch parent.Kind { - case KindFunctionDeclaration: - return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node - case KindFunctionExpression: - return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node - case KindArrowFunction: - return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node - case KindMethodDeclaration: - return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node - case KindGetAccessor: - return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node - case KindSetAccessor: - return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node - case KindConstructor: - return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node - case KindVariableDeclaration: - return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node - case KindParameter: - return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node - case KindPropertyDeclaration: - return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node - } - return false -} - -func isSignatureDeclaration(node *Node) bool { - switch node.Kind { - case KindFunctionDeclaration: - return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil - case KindMethodDeclaration: - return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil - case KindConstructor: - return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil - } - return false -} - -func checkTypeParametersAndModifiers(sourceFile *SourceFile, node *Node, diags *[]*Diagnostic) { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&NodeFlagsReparsed != 0 { - return - } - - // Check type parameters - if hasTypeParameters(node) { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) - } - - // Check type arguments - if hasTypeArguments(node) { - *diags = append(*diags, createDiagnosticForNode(sourceFile, node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) - } - - // Check modifiers - checkModifiers(sourceFile, node, diags) -} - -func hasTypeParameters(node *Node) bool { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&NodeFlagsReparsed != 0 { - return false - } - - var typeParameters *NodeList - switch node.Kind { - case KindClassDeclaration: - if node.AsClassDeclaration() != nil { - typeParameters = node.AsClassDeclaration().TypeParameters - } - case KindClassExpression: - if node.AsClassExpression() != nil { - typeParameters = node.AsClassExpression().TypeParameters - } - case KindMethodDeclaration: - if node.AsMethodDeclaration() != nil { - typeParameters = node.AsMethodDeclaration().TypeParameters - } - case KindConstructor: - if node.AsConstructorDeclaration() != nil { - typeParameters = node.AsConstructorDeclaration().TypeParameters - } - case KindGetAccessor: - if node.AsGetAccessorDeclaration() != nil { - typeParameters = node.AsGetAccessorDeclaration().TypeParameters - } - case KindSetAccessor: - if node.AsSetAccessorDeclaration() != nil { - typeParameters = node.AsSetAccessorDeclaration().TypeParameters - } - case KindFunctionExpression: - if node.AsFunctionExpression() != nil { - typeParameters = node.AsFunctionExpression().TypeParameters - } - case KindFunctionDeclaration: - if node.AsFunctionDeclaration() != nil { - typeParameters = node.AsFunctionDeclaration().TypeParameters - } - case KindArrowFunction: - if node.AsArrowFunction() != nil { - typeParameters = node.AsArrowFunction().TypeParameters - } - default: - return false - } - - if typeParameters == nil { - return false - } - - // Check if all type parameters are reparsed (JSDoc originated) - for _, tp := range typeParameters.Nodes { - if tp.Flags&NodeFlagsReparsed == 0 { - return true // Found a non-reparsed type parameter, so this is a TypeScript-only construct - } - } - - return false // All type parameters are reparsed (JSDoc originated), so this is valid in JS -} - -func hasTypeArguments(node *Node) bool { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&NodeFlagsReparsed != 0 { - return false - } - - switch node.Kind { - case KindCallExpression: - return node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil - case KindNewExpression: - return node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil - case KindExpressionWithTypeArguments: - return node.AsExpressionWithTypeArguments() != nil && node.AsExpressionWithTypeArguments().TypeArguments != nil - case KindJsxSelfClosingElement: - return node.AsJsxSelfClosingElement() != nil && node.AsJsxSelfClosingElement().TypeArguments != nil - case KindJsxOpeningElement: - return node.AsJsxOpeningElement() != nil && node.AsJsxOpeningElement().TypeArguments != nil - case KindTaggedTemplateExpression: - return node.AsTaggedTemplateExpression() != nil && node.AsTaggedTemplateExpression().TypeArguments != nil - } - return false -} - -func checkModifiers(sourceFile *SourceFile, node *Node, diags *[]*Diagnostic) { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&NodeFlagsReparsed != 0 { - return - } - - // Check for TypeScript-only modifiers on various declaration types - switch node.Kind { - case KindVariableStatement: - if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { - checkModifierList(sourceFile, node.AsVariableStatement().Modifiers(), true, diags) - } - case KindPropertyDeclaration: - if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { - checkPropertyModifiers(sourceFile, node.AsPropertyDeclaration().Modifiers(), diags) - } - case KindParameter: - if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { - checkParameterModifiers(sourceFile, node.AsParameterDeclaration().Modifiers(), diags) - } - } -} - -func checkModifierList(sourceFile *SourceFile, modifiers *ModifierList, isConstValid bool, diags *[]*Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - // Bail out early if this modifier has NodeFlagsReparsed - if modifier.Flags&NodeFlagsReparsed != 0 { - continue - } - checkModifier(sourceFile, modifier, isConstValid, diags) - } -} - -func checkPropertyModifiers(sourceFile *SourceFile, modifiers *ModifierList, diags *[]*Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - // Bail out early if this modifier has NodeFlagsReparsed - if modifier.Flags&NodeFlagsReparsed != 0 { - continue - } - // Property modifiers allow static and accessor, but not other TypeScript modifiers - switch modifier.Kind { - case KindStaticKeyword, KindAccessorKeyword: - // These are valid in JavaScript - continue - default: - if isTypeScriptOnlyModifier(modifier) { - *diags = append(*diags, createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, getTokenText(modifier))) - } - } - } -} - -func checkParameterModifiers(sourceFile *SourceFile, modifiers *ModifierList, diags *[]*Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - // Bail out early if this modifier has NodeFlagsReparsed - if modifier.Flags&NodeFlagsReparsed != 0 { - continue - } - if isTypeScriptOnlyModifier(modifier) { - *diags = append(*diags, createDiagnosticForNode(sourceFile, modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) - } - } -} - -func checkModifier(sourceFile *SourceFile, modifier *Node, isConstValid bool, diags *[]*Diagnostic) { - switch modifier.Kind { - case KindConstKeyword: - if !isConstValid { - *diags = append(*diags, createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "const")) - } - case KindPublicKeyword, KindPrivateKeyword, KindProtectedKeyword, KindReadonlyKeyword, - KindDeclareKeyword, KindAbstractKeyword, KindOverrideKeyword, KindInKeyword, KindOutKeyword: - *diags = append(*diags, createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, getTokenText(modifier))) - case KindStaticKeyword, KindExportKeyword, KindDefaultKeyword, KindAccessorKeyword: - // These are valid in JavaScript - } -} - -func isTypeScriptOnlyModifier(modifier *Node) bool { - switch modifier.Kind { - case KindPublicKeyword, KindPrivateKeyword, KindProtectedKeyword, KindReadonlyKeyword, - KindDeclareKeyword, KindAbstractKeyword, KindOverrideKeyword, KindInKeyword, KindOutKeyword: - return true - } - return false -} - -func getTokenText(node *Node) string { - switch node.Kind { - case KindPublicKeyword: - return "public" - case KindPrivateKeyword: - return "private" - case KindProtectedKeyword: - return "protected" - case KindReadonlyKeyword: - return "readonly" - case KindDeclareKeyword: - return "declare" - case KindAbstractKeyword: - return "abstract" - case KindOverrideKeyword: - return "override" - case KindInKeyword: - return "in" - case KindOutKeyword: - return "out" - case KindConstKeyword: - return "const" - case KindStaticKeyword: - return "static" - case KindAccessorKeyword: - return "accessor" - default: - return "" - } -} - -func createDiagnosticForNode(sourceFile *SourceFile, node *Node, message *diagnostics.Message, args ...any) *Diagnostic { - // Find the source file for this node - nodeSourceFile := GetSourceFileOfNode(node) - if nodeSourceFile == nil { - // Fallback to empty range if we can't find the source file - return NewDiagnostic(nil, core.TextRange{}, message, args...) - } - return NewDiagnostic(nodeSourceFile, getErrorRangeForNode(node), message, args...) -} - -func getErrorRangeForNode(node *Node) core.TextRange { - if node == nil { - return core.TextRange{} - } - return core.NewTextRange(node.Pos(), node.End()) -} diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 2e77d5aa6c..cf57e0c968 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -52,6 +52,7 @@ type Program struct { commonSourceDirectoryOnce sync.Once declarationDiagnosticCache collections.SyncMap[*ast.SourceFile, []*ast.Diagnostic] + jsDiagnosticCache collections.SyncMap[*ast.SourceFile, []*ast.Diagnostic] } // FileExists implements checker.Program. @@ -370,7 +371,7 @@ func (p *Program) getSyntacticDiagnosticsForFile(ctx context.Context, sourceFile // For JavaScript files, we report semantic errors for using TypeScript-only // constructs from within a JavaScript file as syntactic errors. if ast.IsSourceFileJS(sourceFile) { - return slices.Concat(sourceFile.AdditionalSyntacticDiagnostics(), sourceFile.Diagnostics()) + return slices.Concat(p.getJSSyntacticDiagnosticsForFile(sourceFile), sourceFile.Diagnostics()) } return sourceFile.Diagnostics() } @@ -954,3 +955,428 @@ var plainJSErrors = collections.NewSetFromItems( // Type errors diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value.Code(), ) + +// JS syntactic diagnostics functions + +func (p *Program) getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { + if result, ok := p.jsDiagnosticCache.Load(sourceFile); ok { + return result + } + + diagnostics := []*ast.Diagnostic{} + + // Walk the entire AST to find TypeScript-only constructs + p.walkNodeForJSDiagnostics(sourceFile, sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) + + p.jsDiagnosticCache.Store(sourceFile, diagnostics) + return diagnostics +} + +func (p *Program) walkNodeForJSDiagnostics(sourceFile *ast.SourceFile, node *ast.Node, parent *ast.Node, diags *[]*ast.Diagnostic) { + if node == nil { + return + } + + // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations + if node.Flags&ast.NodeFlagsReparsed != 0 { + return + } + + // Handle specific parent-child relationships first + switch parent.Kind { + case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: + // Check for question token (optional markers) - only parameters have question tokens + if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } + fallthrough + case ast.KindMethodSignature, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, + ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindVariableDeclaration: + // Check for type annotations + if p.isTypeAnnotation(parent, node) { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check node-specific constructs + switch node.Kind { + case ast.KindImportClause: + if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) + return + } + + case ast.KindExportDeclaration: + if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) + return + } + + case ast.KindImportSpecifier: + if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) + return + } + + case ast.KindExportSpecifier: + if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) + return + } + + case ast.KindImportEqualsDeclaration: + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) + return + + case ast.KindExportAssignment: + if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindHeritageClause: + if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == ast.KindImplementsKeyword { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindInterfaceDeclaration: + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) + return + + case ast.KindModuleDeclaration: + moduleKeyword := "module" + // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) + return + + case ast.KindTypeAliasDeclaration: + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) + return + + case ast.KindEnumDeclaration: + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) + return + + case ast.KindNonNullExpression: + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) + return + + case ast.KindAsExpression: + if node.AsAsExpression() != nil { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindSatisfiesExpression: + if node.AsSatisfiesExpression() != nil { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindConstructor, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: + // Check for signature declarations (functions without bodies) + if p.isSignatureDeclaration(node) { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check for type parameters, type arguments, and modifiers + p.checkTypeParametersAndModifiers(sourceFile, node, diags) + + // Recursively walk children + node.ForEachChild(func(child *ast.Node) bool { + p.walkNodeForJSDiagnostics(sourceFile, child, node, diags) + return false + }) +} + +func (p *Program) isTypeAnnotation(parent *ast.Node, node *ast.Node) bool { + switch parent.Kind { + case ast.KindFunctionDeclaration: + return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node + case ast.KindFunctionExpression: + return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node + case ast.KindArrowFunction: + return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node + case ast.KindMethodDeclaration: + return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node + case ast.KindGetAccessor: + return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node + case ast.KindSetAccessor: + return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node + case ast.KindConstructor: + return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node + case ast.KindVariableDeclaration: + return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node + case ast.KindParameter: + return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node + case ast.KindPropertyDeclaration: + return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node + } + return false +} + +func (p *Program) isSignatureDeclaration(node *ast.Node) bool { + switch node.Kind { + case ast.KindFunctionDeclaration: + return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil + case ast.KindMethodDeclaration: + return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil + case ast.KindConstructor: + return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil + } + return false +} + +func (p *Program) checkTypeParametersAndModifiers(sourceFile *ast.SourceFile, node *ast.Node, diags *[]*ast.Diagnostic) { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return + } + + // Check type parameters + if p.hasTypeParameters(node) { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) + } + + // Check type arguments + if p.hasTypeArguments(node) { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) + } + + // Check modifiers + p.checkModifiers(sourceFile, node, diags) +} + +func (p *Program) hasTypeParameters(node *ast.Node) bool { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return false + } + + var typeParameters *ast.NodeList + switch node.Kind { + case ast.KindClassDeclaration: + if node.AsClassDeclaration() != nil { + typeParameters = node.AsClassDeclaration().TypeParameters + } + case ast.KindClassExpression: + if node.AsClassExpression() != nil { + typeParameters = node.AsClassExpression().TypeParameters + } + case ast.KindMethodDeclaration: + if node.AsMethodDeclaration() != nil { + typeParameters = node.AsMethodDeclaration().TypeParameters + } + case ast.KindConstructor: + if node.AsConstructorDeclaration() != nil { + typeParameters = node.AsConstructorDeclaration().TypeParameters + } + case ast.KindGetAccessor: + if node.AsGetAccessorDeclaration() != nil { + typeParameters = node.AsGetAccessorDeclaration().TypeParameters + } + case ast.KindSetAccessor: + if node.AsSetAccessorDeclaration() != nil { + typeParameters = node.AsSetAccessorDeclaration().TypeParameters + } + case ast.KindFunctionExpression: + if node.AsFunctionExpression() != nil { + typeParameters = node.AsFunctionExpression().TypeParameters + } + case ast.KindFunctionDeclaration: + if node.AsFunctionDeclaration() != nil { + typeParameters = node.AsFunctionDeclaration().TypeParameters + } + case ast.KindArrowFunction: + if node.AsArrowFunction() != nil { + typeParameters = node.AsArrowFunction().TypeParameters + } + default: + return false + } + + if typeParameters == nil { + return false + } + + // Check if all type parameters are reparsed (JSDoc originated) + for _, tp := range typeParameters.Nodes { + if tp.Flags&ast.NodeFlagsReparsed == 0 { + return true // Found a non-reparsed type parameter, so this is a TypeScript-only construct + } + } + + return false // All type parameters are reparsed (JSDoc originated), so this is valid in JS +} + +func (p *Program) hasTypeArguments(node *ast.Node) bool { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return false + } + + switch node.Kind { + case ast.KindCallExpression: + return node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil + case ast.KindNewExpression: + return node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil + case ast.KindExpressionWithTypeArguments: + return node.AsExpressionWithTypeArguments() != nil && node.AsExpressionWithTypeArguments().TypeArguments != nil + case ast.KindJsxSelfClosingElement: + return node.AsJsxSelfClosingElement() != nil && node.AsJsxSelfClosingElement().TypeArguments != nil + case ast.KindJsxOpeningElement: + return node.AsJsxOpeningElement() != nil && node.AsJsxOpeningElement().TypeArguments != nil + case ast.KindTaggedTemplateExpression: + return node.AsTaggedTemplateExpression() != nil && node.AsTaggedTemplateExpression().TypeArguments != nil + } + return false +} + +func (p *Program) checkModifiers(sourceFile *ast.SourceFile, node *ast.Node, diags *[]*ast.Diagnostic) { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return + } + + // Check for TypeScript-only modifiers on various declaration types + switch node.Kind { + case ast.KindVariableStatement: + if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { + p.checkModifierList(sourceFile, node.AsVariableStatement().Modifiers(), true, diags) + } + case ast.KindPropertyDeclaration: + if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { + p.checkPropertyModifiers(sourceFile, node.AsPropertyDeclaration().Modifiers(), diags) + } + case ast.KindParameter: + if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { + p.checkParameterModifiers(sourceFile, node.AsParameterDeclaration().Modifiers(), diags) + } + } +} + +func (p *Program) checkModifierList(sourceFile *ast.SourceFile, modifiers *ast.ModifierList, isConstValid bool, diags *[]*ast.Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + p.checkModifier(sourceFile, modifier, isConstValid, diags) + } +} + +func (p *Program) checkPropertyModifiers(sourceFile *ast.SourceFile, modifiers *ast.ModifierList, diags *[]*ast.Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + // Property modifiers allow static and accessor, but not other TypeScript modifiers + switch modifier.Kind { + case ast.KindStaticKeyword, ast.KindAccessorKeyword: + // These are valid in JavaScript + continue + default: + if p.isTypeScriptOnlyModifier(modifier) { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, p.getTokenText(modifier))) + } + } + } +} + +func (p *Program) checkParameterModifiers(sourceFile *ast.SourceFile, modifiers *ast.ModifierList, diags *[]*ast.Diagnostic) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + if p.isTypeScriptOnlyModifier(modifier) { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) + } + } +} + +func (p *Program) checkModifier(sourceFile *ast.SourceFile, modifier *ast.Node, isConstValid bool, diags *[]*ast.Diagnostic) { + switch modifier.Kind { + case ast.KindConstKeyword: + if !isConstValid { + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "const")) + } + case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, + ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: + *diags = append(*diags, p.createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, p.getTokenText(modifier))) + case ast.KindStaticKeyword, ast.KindExportKeyword, ast.KindDefaultKeyword, ast.KindAccessorKeyword: + // These are valid in JavaScript + } +} + +func (p *Program) isTypeScriptOnlyModifier(modifier *ast.Node) bool { + switch modifier.Kind { + case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, + ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: + return true + } + return false +} + +func (p *Program) getTokenText(node *ast.Node) string { + switch node.Kind { + case ast.KindPublicKeyword: + return "public" + case ast.KindPrivateKeyword: + return "private" + case ast.KindProtectedKeyword: + return "protected" + case ast.KindReadonlyKeyword: + return "readonly" + case ast.KindDeclareKeyword: + return "declare" + case ast.KindAbstractKeyword: + return "abstract" + case ast.KindOverrideKeyword: + return "override" + case ast.KindInKeyword: + return "in" + case ast.KindOutKeyword: + return "out" + case ast.KindConstKeyword: + return "const" + case ast.KindStaticKeyword: + return "static" + case ast.KindAccessorKeyword: + return "accessor" + default: + return "" + } +} + +func (p *Program) createDiagnosticForNode(sourceFile *ast.SourceFile, node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { + return ast.NewDiagnostic(sourceFile, p.getErrorRangeForNode(sourceFile, node), message, args...) +} + +func (p *Program) getErrorRangeForNode(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange { + if node == nil { + return core.TextRange{} + } + + // Use scanner to skip trivia for proper diagnostic positioning + start := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) + return core.NewTextRange(start, node.End()) +} diff --git a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt index 3f291eea31..38b0898d4d 100644 --- a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt +++ b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt @@ -1,60 +1,57 @@ -test.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. -test.js(2,26): error TS8010: Type annotations can only be used in TypeScript files. -test.js(4,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -test.js(10,2): error TS8008: Type aliases can only be used in TypeScript files. -test.js(13,39): error TS8006: 'enum' declarations can only be used in TypeScript files. -test.js(20,2): error TS8006: 'module' declarations can only be used in TypeScript files. -test.js(25,2): error TS8006: 'module' declarations can only be used in TypeScript files. -test.js(33,12): error TS8013: Non-null assertions can only be used in TypeScript files. -test.js(36,23): error TS8016: Type assertion expressions can only be used in TypeScript files. +test.js(2,18): error TS8010: Type annotations can only be used in TypeScript files. +test.js(2,27): error TS8010: Type annotations can only be used in TypeScript files. +test.js(7,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +test.js(13,1): error TS8008: Type aliases can only be used in TypeScript files. +test.js(16,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +test.js(23,1): error TS8006: 'module' declarations can only be used in TypeScript files. +test.js(28,1): error TS8006: 'module' declarations can only be used in TypeScript files. +test.js(33,13): error TS8013: Non-null assertions can only be used in TypeScript files. +test.js(36,24): error TS8016: Type assertion expressions can only be used in TypeScript files. test.js(39,17): error TS2741: Property 'name' is missing in type '{}' but required in type 'Config'. -test.js(39,26): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -test.js(39,34): error TS8006: 'import type' declarations can only be used in TypeScript files. +test.js(39,27): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +test.js(42,1): error TS8006: 'import type' declarations can only be used in TypeScript files. test.js(42,31): error TS2307: Cannot find module './other' or its corresponding type declarations. -test.js(42,41): error TS8006: 'export type' declarations can only be used in TypeScript files. -test.js(45,26): error TS8002: 'import ... =' can only be used in TypeScript files. +test.js(45,1): error TS8006: 'export type' declarations can only be used in TypeScript files. +test.js(48,1): error TS8002: 'import ... =' can only be used in TypeScript files. test.js(48,22): error TS2307: Cannot find module './lib' or its corresponding type declarations. -test.js(48,31): error TS8003: 'export =' can only be used in TypeScript files. test.js(51,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -test.js(54,16): error TS8009: The 'public' modifier can only be used in TypeScript files. -test.js(55,17): error TS8010: Type annotations can only be used in TypeScript files. -test.js(55,25): error TS8009: The 'private' modifier can only be used in TypeScript files. -test.js(56,17): error TS8010: Type annotations can only be used in TypeScript files. -test.js(56,25): error TS8009: The 'protected' modifier can only be used in TypeScript files. -test.js(57,18): error TS8010: Type annotations can only be used in TypeScript files. -test.js(57,26): error TS8009: The 'readonly' modifier can only be used in TypeScript files. -test.js(58,20): error TS8010: Type annotations can only be used in TypeScript files. +test.js(51,1): error TS8003: 'export =' can only be used in TypeScript files. +test.js(55,5): error TS8009: The 'public' modifier can only be used in TypeScript files. +test.js(55,18): error TS8010: Type annotations can only be used in TypeScript files. +test.js(56,5): error TS8009: The 'private' modifier can only be used in TypeScript files. +test.js(56,18): error TS8010: Type annotations can only be used in TypeScript files. +test.js(57,5): error TS8009: The 'protected' modifier can only be used in TypeScript files. +test.js(57,19): error TS8010: Type annotations can only be used in TypeScript files. +test.js(58,5): error TS8009: The 'readonly' modifier can only be used in TypeScript files. +test.js(58,21): error TS8010: Type annotations can only be used in TypeScript files. test.js(60,17): error TS8012: Parameter modifiers can only be used in TypeScript files. -test.js(60,26): error TS8010: Type annotations can only be used in TypeScript files. -test.js(60,34): error TS8012: Parameter modifiers can only be used in TypeScript files. -test.js(60,45): error TS8010: Type annotations can only be used in TypeScript files. +test.js(60,27): error TS8010: Type annotations can only be used in TypeScript files. +test.js(60,35): error TS8012: Parameter modifiers can only be used in TypeScript files. +test.js(60,46): error TS8010: Type annotations can only be used in TypeScript files. test.js(69,25): error TS8009: The '?' modifier can only be used in TypeScript files. -test.js(69,27): error TS8010: Type annotations can only be used in TypeScript files. -test.js(71,2): error TS8017: Signature declarations can only be used in TypeScript files. -test.js(74,43): error TS8004: Type parameter declarations can only be used in TypeScript files. -test.js(77,23): error TS8010: Type annotations can only be used in TypeScript files. -test.js(77,27): error TS8010: Type annotations can only be used in TypeScript files. +test.js(69,28): error TS8010: Type annotations can only be used in TypeScript files. +test.js(74,1): error TS8017: Signature declarations can only be used in TypeScript files. +test.js(77,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +test.js(77,24): error TS8010: Type annotations can only be used in TypeScript files. +test.js(77,28): error TS8010: Type annotations can only be used in TypeScript files. test.js(82,19): error TS2693: 'string' only refers to a type, but is being used as a value here. test.js(82,27): error TS1109: Expression expected. -test.js(85,28): error TS8005: 'implements' clauses can only be used in TypeScript files. -test.js(90,21): error TS8010: Type annotations can only be used in TypeScript files. -test.js(92,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +test.js(85,29): error TS8005: 'implements' clauses can only be used in TypeScript files. +test.js(90,22): error TS8010: Type annotations can only be used in TypeScript files. +test.js(94,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ==== test.js (41 errors) ==== // Type annotations should be flagged as errors function func(x: number): string { - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. return x.toString(); } - - // Interface declarations should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ interface Person { ~~~~~~~~~~~~~~~~~~ name: string; @@ -64,19 +61,13 @@ test.js(92,2): error TS8006: 'interface' declarations can only be used in TypeSc } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - // Type alias declarations should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ type StringOrNumber = string | number; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8008: Type aliases can only be used in TypeScript files. - - // Enum declarations should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ enum Color { ~~~~~~~~~~~~ Red, @@ -88,11 +79,8 @@ test.js(92,2): error TS8006: 'interface' declarations can only be used in TypeSc } ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - // Module declarations should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ module MyModule { ~~~~~~~~~~~~~~~~~ export var x = 1; @@ -100,11 +88,8 @@ test.js(92,2): error TS8006: 'interface' declarations can only be used in TypeSc } ~ !!! error TS8006: 'module' declarations can only be used in TypeScript files. - - // Namespace declarations should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ namespace MyNamespace { ~~~~~~~~~~~~~~~~~~~~~~~ export var y = 2; @@ -115,12 +100,12 @@ test.js(92,2): error TS8006: 'interface' declarations can only be used in TypeSc // Non-null assertions should be flagged as errors let value = getValue()!; - ~~~~~~~~~~~~ + ~~~~~~~~~~~ !!! error TS8013: Non-null assertions can only be used in TypeScript files. // Type assertions should be flagged as errors let result = (value as string).toUpperCase(); - ~~~~~~~ + ~~~~~~ !!! error TS8016: Type assertion expressions can only be used in TypeScript files. // Satisfies expressions should be flagged as errors @@ -128,82 +113,66 @@ test.js(92,2): error TS8006: 'interface' declarations can only be used in TypeSc ~~~~~~~~~ !!! error TS2741: Property 'name' is missing in type '{}' but required in type 'Config'. !!! related TS2728 test.js:95:5: 'name' is declared here. - ~~~~~~~ + ~~~~~~ !!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - - // Import type should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import type { SomeType } from './other'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'import type' declarations can only be used in TypeScript files. ~~~~~~~~~ !!! error TS2307: Cannot find module './other' or its corresponding type declarations. - - // Export type should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export type { SomeType }; ~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'export type' declarations can only be used in TypeScript files. - - // Import equals should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import lib = require('./lib'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~ !!! error TS2307: Cannot find module './lib' or its corresponding type declarations. - - // Export equals should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export = MyModule; ~~~~~~~~~~~~~~~~~~ -!!! error TS8003: 'export =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~~~~~~~~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. // TypeScript modifiers should be flagged as errors class MyClass { - public name: string; - ~~~~~~~~~~ + ~~~~~~ !!! error TS8009: The 'public' modifier can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. - private age: number; - ~~~~~~~~~~~ + ~~~~~~~ !!! error TS8009: The 'private' modifier can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. - protected id: number; - ~~~~~~~~~~~~~ + ~~~~~~~~~ !!! error TS8009: The 'protected' modifier can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. - readonly value: number; - ~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS8009: The 'readonly' modifier can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. constructor(public x: number, private y: number) { ~~~~~~ !!! error TS8012: Parameter modifiers can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~~ + ~~~~~~~ !!! error TS8012: Parameter modifiers can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. this.name = ''; this.age = 0; @@ -216,28 +185,22 @@ test.js(92,2): error TS8006: 'interface' declarations can only be used in TypeSc function optionalParam(x?: number) { ~ !!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. return x || 0; } - - // Signature declarations should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function signatureOnly(x: number): string; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8017: Signature declarations can only be used in TypeScript files. - - // Type parameters should be flagged as errors - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function generic(x: T): T { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~ + ~ !!! error TS8010: Type annotations can only be used in TypeScript files. - ~~ + ~ !!! error TS8010: Type annotations can only be used in TypeScript files. return x; ~~~~~~~~~~~~~ @@ -254,19 +217,17 @@ test.js(92,2): error TS8006: 'interface' declarations can only be used in TypeSc // Implements clause should be flagged as errors class MyClassWithImplements implements Person { - ~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ !!! error TS8005: 'implements' clauses can only be used in TypeScript files. name = ''; age = 0; } function getValue(): any { - ~~~~ + ~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. return null; } - - interface Config { ~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt b/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt index 5f6cd8e252..c23b932b5f 100644 --- a/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt @@ -1,6 +1,6 @@ /test.js(3,9): error TS2322: Type '{}' is not assignable to type 'string'. -/test.js(4,6): error TS8009: The 'declare' modifier can only be used in TypeScript files. -/test.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. +/test.js(6,5): error TS8009: The 'declare' modifier can only be used in TypeScript files. +/test.js(6,19): error TS8010: Type annotations can only be used in TypeScript files. /test.js(9,19): error TS2339: Property 'foo' does not exist on type 'string'. @@ -11,13 +11,11 @@ ~~~~~~~~~ !!! error TS2322: Type '{}' is not assignable to type 'string'. } - - declare prop: string; - ~~~~~~~~~~~ + ~~~~~~~ !!! error TS8009: The 'declare' modifier can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. method() { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff deleted file mode 100644 index 5e205787a2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.ambientPropertyDeclarationInJs.errors.txt -+++ new.ambientPropertyDeclarationInJs.errors.txt -@@= skipped -0, +0 lines =@@ - /test.js(3,9): error TS2322: Type '{}' is not assignable to type 'string'. --/test.js(6,5): error TS8009: The 'declare' modifier can only be used in TypeScript files. --/test.js(6,19): error TS8010: Type annotations can only be used in TypeScript files. -+/test.js(4,6): error TS8009: The 'declare' modifier can only be used in TypeScript files. -+/test.js(6,18): error TS8010: Type annotations can only be used in TypeScript files. - /test.js(9,19): error TS2339: Property 'foo' does not exist on type 'string'. - - -@@= skipped -10, +10 lines =@@ - ~~~~~~~~~ - !!! error TS2322: Type '{}' is not assignable to type 'string'. - } -+ -+ - - declare prop: string; -- ~~~~~~~ -+ ~~~~~~~~~~~ - !!! error TS8009: The 'declare' modifier can only be used in TypeScript files. -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - - method() { \ No newline at end of file From d55f8040cdb46ba6060942d5ad6c409bb98cbf83 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:25:56 +0000 Subject: [PATCH 11/31] Fix false positives on JSDoc type arguments in JavaScript files Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/program.go | 39 ++- ...ypeArgumentCount1(strict=false).errors.txt | 8 +- ...TypeArgumentCount1(strict=true).errors.txt | 8 +- ...ypeArgumentCount2(strict=false).errors.txt | 34 --- ...ongBaseTypeArgumentCount2(strict=false).js | 32 ++ ...TypeArgumentCount2(strict=true).errors.txt | 8 +- .../compiler/decoratorInJsFile.errors.txt | 4 +- .../compiler/decoratorInJsFile1.errors.txt | 4 +- ...ssingTypeArgsOnJSConstructCalls.errors.txt | 19 +- .../compiler/jsExtendsImplicitAny.errors.txt | 5 +- ...FileCompilationAbstractModifier.errors.txt | 5 +- ...lationConstructorOverloadSyntax.errors.txt | 5 +- ...tionHeritageClauseSyntaxOfClass.errors.txt | 4 +- ...CompilationMethodOverloadSyntax.errors.txt | 5 +- ...ationReturnTypeSyntaxOfFunction.errors.txt | 4 +- ...jsFileCompilationTypeAssertions.errors.txt | 4 +- ...sFileCompilationTypeOfParameter.errors.txt | 4 +- ...arameterSyntaxOfClassExpression.errors.txt | 4 +- ...sFileCompilationTypeSyntaxOfVar.errors.txt | 4 +- .../compiler/modulePreserve4.errors.txt | 3 +- ...assCanExtendConstructorFunction.errors.txt | 5 +- .../exportSpecifiers_js.errors.txt | 4 +- .../conformance/extendsTag1.errors.txt | 12 - .../conformance/extendsTag5.errors.txt | 14 +- .../conformance/grammarErrors.errors.txt | 3 +- .../importSpecifiers_js.errors.txt | 4 +- .../jsDeclarationsClasses.errors.txt | 200 ------------- .../jsDeclarationsClassesErr.errors.txt | 85 +++--- .../jsDeclarationsEnums.errors.txt | 48 +-- .../jsDeclarationsExportFormsErr.errors.txt | 3 +- .../jsDeclarationsInterfaces.errors.txt | 105 ++----- .../jsDeclarationsTypeReferences4.errors.txt | 4 +- ...jsdocAugments_withTypeParameter.errors.txt | 16 - ...eModulesAllowJs1(module=node16).errors.txt | 105 ++----- ...eModulesAllowJs1(module=node18).errors.txt | 105 ++----- ...odulesAllowJs1(module=nodenext).errors.txt | 105 ++----- ...ExportAssignment(module=node16).errors.txt | 10 +- ...ExportAssignment(module=node18).errors.txt | 10 +- ...portAssignment(module=nodenext).errors.txt | 10 +- ...ImportAssignment(module=node16).errors.txt | 18 +- ...ImportAssignment(module=node18).errors.txt | 18 +- ...portAssignment(module=nodenext).errors.txt | 18 +- ...ronousCallErrors(module=node16).errors.txt | 12 +- ...ronousCallErrors(module=node18).errors.txt | 12 +- ...nousCallErrors(module=nodenext).errors.txt | 12 +- ...parserArrowFunctionExpression10.errors.txt | 6 +- ...parserArrowFunctionExpression13.errors.txt | 4 +- ...parserArrowFunctionExpression14.errors.txt | 12 +- ...parserArrowFunctionExpression15.errors.txt | 4 +- ...parserArrowFunctionExpression16.errors.txt | 4 +- ...parserArrowFunctionExpression17.errors.txt | 6 +- .../typeSatisfaction_js.errors.txt | 4 +- .../decoratorInJsFile.errors.txt.diff | 16 - .../decoratorInJsFile1.errors.txt.diff | 16 - ...TypeArgsOnJSConstructCalls.errors.txt.diff | 28 +- .../jsExtendsImplicitAny.errors.txt.diff | 11 +- ...ompilationAbstractModifier.errors.txt.diff | 16 +- ...nConstructorOverloadSyntax.errors.txt.diff | 9 +- ...eritageClauseSyntaxOfClass.errors.txt.diff | 13 +- ...lationMethodOverloadSyntax.errors.txt.diff | 9 +- ...ReturnTypeSyntaxOfFunction.errors.txt.diff | 13 +- ...eCompilationTypeAssertions.errors.txt.diff | 16 - ...CompilationTypeOfParameter.errors.txt.diff | 13 +- ...terSyntaxOfClassExpression.errors.txt.diff | 4 +- ...CompilationTypeSyntaxOfVar.errors.txt.diff | 13 +- .../compiler/modulePreserve4.errors.txt.diff | 5 +- ...nExtendConstructorFunction.errors.txt.diff | 7 +- .../exportSpecifiers_js.errors.txt.diff | 14 - .../conformance/extendsTag1.errors.txt.diff | 16 - .../conformance/extendsTag5.errors.txt.diff | 54 ---- .../conformance/grammarErrors.errors.txt.diff | 13 +- .../importSpecifiers_js.errors.txt.diff | 16 - .../jsDeclarationsClasses.errors.txt.diff | 204 ------------- .../jsDeclarationsClassesErr.errors.txt.diff | 170 +---------- .../jsDeclarationsEnums.errors.txt.diff | 50 +--- ...DeclarationsExportFormsErr.errors.txt.diff | 10 +- .../jsDeclarationsInterfaces.errors.txt.diff | 105 ++----- ...eclarationsTypeReferences4.errors.txt.diff | 6 +- ...Augments_withTypeParameter.errors.txt.diff | 20 -- ...lesAllowJs1(module=node16).errors.txt.diff | 281 ------------------ ...lesAllowJs1(module=node18).errors.txt.diff | 281 ------------------ ...sAllowJs1(module=nodenext).errors.txt.diff | 242 --------------- ...tAssignment(module=node16).errors.txt.diff | 30 +- ...tAssignment(module=node18).errors.txt.diff | 30 +- ...ssignment(module=nodenext).errors.txt.diff | 30 +- ...tAssignment(module=node16).errors.txt.diff | 52 ---- ...tAssignment(module=node18).errors.txt.diff | 52 ---- ...ssignment(module=nodenext).errors.txt.diff | 52 ---- ...sCallErrors(module=node16).errors.txt.diff | 48 --- ...sCallErrors(module=node18).errors.txt.diff | 48 --- ...allErrors(module=nodenext).errors.txt.diff | 38 --- ...rArrowFunctionExpression10.errors.txt.diff | 24 -- ...rArrowFunctionExpression13.errors.txt.diff | 19 -- ...rArrowFunctionExpression14.errors.txt.diff | 31 -- ...rArrowFunctionExpression15.errors.txt.diff | 14 - ...rArrowFunctionExpression16.errors.txt.diff | 14 - ...rArrowFunctionExpression17.errors.txt.diff | 25 -- .../typeSatisfaction_js.errors.txt.diff | 13 - 98 files changed, 461 insertions(+), 2911 deletions(-) delete mode 100644 testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/importSpecifiers_js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node18).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff diff --git a/internal/compiler/program.go b/internal/compiler/program.go index cf57e0c968..6e5281f7b5 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -1220,21 +1220,46 @@ func (p *Program) hasTypeArguments(node *ast.Node) bool { return false } + var typeArguments *ast.NodeList switch node.Kind { case ast.KindCallExpression: - return node.AsCallExpression() != nil && node.AsCallExpression().TypeArguments != nil + if node.AsCallExpression() != nil { + typeArguments = node.AsCallExpression().TypeArguments + } case ast.KindNewExpression: - return node.AsNewExpression() != nil && node.AsNewExpression().TypeArguments != nil + if node.AsNewExpression() != nil { + typeArguments = node.AsNewExpression().TypeArguments + } case ast.KindExpressionWithTypeArguments: - return node.AsExpressionWithTypeArguments() != nil && node.AsExpressionWithTypeArguments().TypeArguments != nil + if node.AsExpressionWithTypeArguments() != nil { + typeArguments = node.AsExpressionWithTypeArguments().TypeArguments + } case ast.KindJsxSelfClosingElement: - return node.AsJsxSelfClosingElement() != nil && node.AsJsxSelfClosingElement().TypeArguments != nil + if node.AsJsxSelfClosingElement() != nil { + typeArguments = node.AsJsxSelfClosingElement().TypeArguments + } case ast.KindJsxOpeningElement: - return node.AsJsxOpeningElement() != nil && node.AsJsxOpeningElement().TypeArguments != nil + if node.AsJsxOpeningElement() != nil { + typeArguments = node.AsJsxOpeningElement().TypeArguments + } case ast.KindTaggedTemplateExpression: - return node.AsTaggedTemplateExpression() != nil && node.AsTaggedTemplateExpression().TypeArguments != nil + if node.AsTaggedTemplateExpression() != nil { + typeArguments = node.AsTaggedTemplateExpression().TypeArguments + } } - return false + + if typeArguments == nil { + return false + } + + // Check if all type arguments are reparsed (JSDoc originated) + for _, ta := range typeArguments.Nodes { + if ta.Flags&ast.NodeFlagsReparsed == 0 { + return true // Found a non-reparsed type argument, so this is a TypeScript-only construct + } + } + + return false // All type arguments are reparsed (JSDoc originated), so this is valid in JS } func (p *Program) checkModifiers(sourceFile *ast.SourceFile, node *ast.Node, diags *[]*ast.Diagnostic) { diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt index 30ae3fa796..3ec287e6cb 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt @@ -1,5 +1,5 @@ -b.js(9,24): error TS8011: Type arguments can only be used in TypeScript files. -b.js(15,24): error TS8011: Type arguments can only be used in TypeScript files. +b.js(9,25): error TS8011: Type arguments can only be used in TypeScript files. +b.js(15,25): error TS8011: Type arguments can only be used in TypeScript files. ==== a.ts (0 errors) ==== @@ -15,7 +15,7 @@ b.js(15,24): error TS8011: Type arguments can only be used in TypeScript files. } export class B2 extends A { - ~~~~~~~~~~ + ~~~~~~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); @@ -23,7 +23,7 @@ b.js(15,24): error TS8011: Type arguments can only be used in TypeScript files. } export class B3 extends A { - ~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt index 7bb3b52da0..72c5de944d 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt @@ -1,6 +1,6 @@ b.js(3,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -b.js(9,24): error TS8011: Type arguments can only be used in TypeScript files. -b.js(15,24): error TS8011: Type arguments can only be used in TypeScript files. +b.js(9,25): error TS8011: Type arguments can only be used in TypeScript files. +b.js(15,25): error TS8011: Type arguments can only be used in TypeScript files. b.js(15,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -19,7 +19,7 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' } export class B2 extends A { - ~~~~~~~~~~ + ~~~~~~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); @@ -27,7 +27,7 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' } export class B3 extends A { - ~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt deleted file mode 100644 index 3ca8afa5ec..0000000000 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt +++ /dev/null @@ -1,34 +0,0 @@ -b.js(11,24): error TS8011: Type arguments can only be used in TypeScript files. -b.js(18,24): error TS8011: Type arguments can only be used in TypeScript files. - - -==== a.ts (0 errors) ==== - export class A {} - -==== b.js (2 errors) ==== - import { A } from './a.js'; - - /** @extends {A} */ - export class B1 extends A { - constructor() { - super(); - } - } - - /** @extends {A} */ - export class B2 extends A { - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. - constructor() { - super(); - } - } - - /** @extends {A} */ - export class B3 extends A { - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. - constructor() { - super(); - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).js b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).js index 331070d2fe..732da07a69 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).js +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).js @@ -79,3 +79,35 @@ export declare class B2 extends A { export declare class B3 extends A { constructor(); } + + +//// [DtsFileErrors] + + +b.d.ts(3,33): error TS2314: Generic type 'A' requires 1 type argument(s). +b.d.ts(11,33): error TS2314: Generic type 'A' requires 1 type argument(s). + + +==== a.d.ts (0 errors) ==== + export declare class A { + } + +==== b.d.ts (2 errors) ==== + import { A } from './a.js'; + /** @extends {A} */ + export declare class B1 extends A { + ~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). + constructor(); + } + /** @extends {A} */ + export declare class B2 extends A { + constructor(); + } + /** @extends {A} */ + export declare class B3 extends A { + ~~~~~~~~~~~~~~~~~ +!!! error TS2314: Generic type 'A' requires 1 type argument(s). + constructor(); + } + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt index 06142b48bc..a2ad36543e 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt @@ -1,13 +1,11 @@ b.js(4,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -b.js(11,24): error TS8011: Type arguments can only be used in TypeScript files. -b.js(18,24): error TS8011: Type arguments can only be used in TypeScript files. b.js(18,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== a.ts (0 errors) ==== export class A {} -==== b.js (4 errors) ==== +==== b.js (2 errors) ==== import { A } from './a.js'; /** @extends {A} */ @@ -21,8 +19,6 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' /** @extends {A} */ export class B2 extends A { - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); } @@ -30,8 +26,6 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' /** @extends {A} */ export class B3 extends A { - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. constructor() { diff --git a/testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt index b1d4e09602..520dc4d9d0 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt @@ -1,11 +1,11 @@ -a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ==== a.js (1 errors) ==== @SomeDecorator class SomeClass { foo(x: number) { - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } diff --git a/testdata/baselines/reference/submodule/compiler/decoratorInJsFile1.errors.txt b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile1.errors.txt index b1d4e09602..520dc4d9d0 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorInJsFile1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile1.errors.txt @@ -1,11 +1,11 @@ -a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. +a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. ==== a.js (1 errors) ==== @SomeDecorator class SomeClass { foo(x: number) { - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } diff --git a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt index 895ee75377..57c4eb2f2c 100644 --- a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@ -1,10 +1,10 @@ -BaseB.js(1,29): error TS8004: Type parameter declarations can only be used in TypeScript files. +BaseB.js(2,1): error TS8004: Type parameter declarations can only be used in TypeScript files. BaseB.js(2,25): error TS1005: ',' expected. -BaseB.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(3,14): error TS2304: Cannot find name 'Class'. -BaseB.js(4,24): error TS8010: Type annotations can only be used in TypeScript files. +BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(4,25): error TS2304: Cannot find name 'Class'. -SubB.js(3,34): error TS8011: Type arguments can only be used in TypeScript files. +BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. +SubB.js(3,35): error TS8011: Type arguments can only be used in TypeScript files. ==== BaseA.js (0 errors) ==== @@ -16,23 +16,22 @@ SubB.js(3,34): error TS8011: Type arguments can only be used in TypeScript files } ==== BaseB.js (6 errors) ==== import BaseA from './BaseA'; - export default class B { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS1005: ',' expected. _AClass: Class; ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2304: Cannot find name 'Class'. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor(AClass: Class) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2304: Cannot find name 'Class'. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. this._AClass = AClass; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } @@ -44,7 +43,7 @@ SubB.js(3,34): error TS8011: Type arguments can only be used in TypeScript files import SubA from './SubA'; import BaseB from './BaseB'; export default class SubB extends BaseB { - ~~~~~~~~~~~~ + ~~~~~~~~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(SubA); diff --git a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt index 509b83a4a5..82c630fced 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt @@ -1,13 +1,12 @@ /b.js(1,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. /b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -/b.js(9,16): error TS8011: Type arguments can only be used in TypeScript files. /b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== /a.d.ts (0 errors) ==== declare class A { x: T; } -==== /b.js (4 errors) ==== +==== /b.js (3 errors) ==== class B extends A {} ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -21,8 +20,6 @@ /** @augments A */ class D extends A {} - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new D().x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt index b446fc3a1e..781103d34d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt @@ -1,10 +1,9 @@ -a.js(1,19): error TS8009: The 'abstract' modifier can only be used in TypeScript files. +a.js(2,5): error TS8009: The 'abstract' modifier can only be used in TypeScript files. ==== a.js (1 errors) ==== abstract class c { - abstract x; - ~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt index b431db5082..0ff11a2b87 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt @@ -1,11 +1,10 @@ -a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. +a.js(2,3): error TS8017: Signature declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== class A { - constructor(); - ~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS8017: Signature declarations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt index c7c83910d7..7dfba357ec 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt @@ -1,7 +1,7 @@ -a.js(1,8): error TS8005: 'implements' clauses can only be used in TypeScript files. +a.js(1,9): error TS8005: 'implements' clauses can only be used in TypeScript files. ==== a.js (1 errors) ==== class C implements D { } - ~~~~~~~~~~~~~ + ~~~~~~~~~~~~ !!! error TS8005: 'implements' clauses can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt index ac4dcee555..1d54c0e41e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt @@ -1,11 +1,10 @@ -a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. +a.js(2,3): error TS8017: Signature declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== class A { - foo(); - ~~~~~~~~ + ~~~~~~ !!! error TS8017: Signature declarations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt index a6202acb9d..803bba76f6 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt @@ -1,7 +1,7 @@ -a.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. ==== a.js (1 errors) ==== function F(): number { } - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt index cb2816c47f..c120f1de95 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt @@ -1,11 +1,11 @@ -/src/a.js(1,5): error TS8016: Type assertion expressions can only be used in TypeScript files. +/src/a.js(1,6): error TS8016: Type assertion expressions can only be used in TypeScript files. /src/a.js(2,10): error TS17008: JSX element 'string' has no corresponding closing tag. /src/a.js(3,1): error TS1005: 'undefined; ~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt index df82865bb6..d8b17f44fc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt @@ -1,7 +1,7 @@ -a.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. +a.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. ==== a.js (1 errors) ==== function F(a: number) { } - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt index aeba725884..8f28eb5593 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt @@ -1,8 +1,8 @@ -a.js(1,12): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(1,13): error TS8004: Type parameter declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== const Bar = class {}; - ~~~~~~~~~~~~ + ~~~~~~~~~~~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt index 2239b21291..24e3e6fbca 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt @@ -1,7 +1,7 @@ -a.js(1,7): error TS8010: Type annotations can only be used in TypeScript files. +a.js(1,8): error TS8010: Type annotations can only be used in TypeScript files. ==== a.js (1 errors) ==== var v: () => number; - ~~~~~~~~~~~~~ + ~~~~~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt b/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt index 420f1cd7bd..993845bad6 100644 --- a/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt @@ -8,7 +8,7 @@ /main2.mts(14,8): error TS1192: Module '"/e"' has no default export. /main3.cjs(1,10): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(1,13): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. -/main3.cjs(1,28): error TS8002: 'import ... =' can only be used in TypeScript files. +/main3.cjs(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. /main3.cjs(5,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(8,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(10,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. @@ -119,7 +119,6 @@ !!! error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. ~ !!! error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. - ~~~~~~~~ import a1 = require("./a"); // Error in JS ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt index 022d12234b..321592a027 100644 --- a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt @@ -2,7 +2,6 @@ first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wago 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(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. -generic.js(9,22): error TS8011: Type arguments can only be used in TypeScript files. 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. @@ -106,7 +105,7 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con ~~~~~~~~~~ !!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (6 errors) ==== +==== generic.js (5 errors) ==== /** * @template T * @param {T} flavour @@ -116,8 +115,6 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con } /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { - ~~~~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. ~~~~ !!! error TS2507: Type '(flavour: T) => void' is not a constructor function type. log() { diff --git a/testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt b/testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt index cf7c46793e..cb436125a0 100644 --- a/testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt @@ -1,9 +1,9 @@ -a.js(2,9): error TS8006: 'export...type' declarations can only be used in TypeScript files. +a.js(2,10): error TS8006: 'export...type' declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== const foo = 0; export { type foo }; - ~~~~~~~~~ + ~~~~~~~~ !!! error TS8006: 'export...type' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt deleted file mode 100644 index 2d4912d227..0000000000 --- a/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -bug25101.js(5,17): error TS8011: Type arguments can only be used in TypeScript files. - - -==== bug25101.js (1 errors) ==== - /** - * @template T - * @extends {Set} Should prefer this Set, not the Set in the heritage clause - */ - class My extends Set {} - ~~~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt index b0960272ab..8c2c3e3e07 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt @@ -1,16 +1,12 @@ -/a.js(26,16): error TS8011: Type arguments can only be used in TypeScript files. /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(34,16): error TS8011: Type arguments can only be used in TypeScript files. -/a.js(39,16): error TS8011: Type arguments can only be used in TypeScript files. /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(44,16): error TS8011: Type arguments can only be used in TypeScript files. -==== /a.js (6 errors) ==== +==== /a.js (2 errors) ==== /** * @typedef {{ * a: number | string; @@ -37,8 +33,6 @@ * }>} */ class B extends A {} - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. /** * @extends {A<{ @@ -54,15 +48,11 @@ !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. */ class C extends A {} - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. /** * @extends {A<{a: string, b: string[]}>} */ class D extends A {} - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. /** * @extends {A<{a: string, b: string}>} @@ -72,6 +62,4 @@ !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. */ class E extends A {} - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt index 1f468f2305..80b0e5204b 100644 --- a/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt @@ -1,5 +1,5 @@ /a.js(1,1): error TS8006: 'import type' declarations can only be used in TypeScript files. -/a.js(1,26): error TS8006: 'export type' declarations can only be used in TypeScript files. +/a.js(2,1): error TS8006: 'export type' declarations can only be used in TypeScript files. /b.ts(1,8): error TS1363: A type-only import can specify a default import or named bindings, but not both. /c.ts(4,1): error TS1392: An import alias cannot use 'import type' @@ -18,7 +18,6 @@ import type A from './a'; ~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'import type' declarations can only be used in TypeScript files. - export type { A }; ~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'export type' declarations can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/importSpecifiers_js.errors.txt b/testdata/baselines/reference/submodule/conformance/importSpecifiers_js.errors.txt index 0afa3e7219..c934c298b2 100644 --- a/testdata/baselines/reference/submodule/conformance/importSpecifiers_js.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importSpecifiers_js.errors.txt @@ -1,4 +1,4 @@ -a.js(1,9): error TS8006: 'import...type' declarations can only be used in TypeScript files. +a.js(1,10): error TS8006: 'import...type' declarations can only be used in TypeScript files. ==== a.ts (0 errors) ==== @@ -6,6 +6,6 @@ a.js(1,9): error TS8006: 'import...type' declarations can only be used in TypeSc ==== a.js (1 errors) ==== import { type A } from "./a"; - ~~~~~~~ + ~~~~~~ !!! error TS8006: 'import...type' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt deleted file mode 100644 index 56139fa173..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt +++ /dev/null @@ -1,200 +0,0 @@ -index.js(173,23): error TS8011: Type arguments can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - export class A {} - - export class B { - static cat = "cat"; - } - - export class C { - static Cls = class {} - } - - export class D { - /** - * @param {number} a - * @param {number} b - */ - constructor(a, b) {} - } - - /** - * @template T,U - */ - export class E { - /** - * @type {T & U} - */ - field; - - // @readonly is currently unsupported, it seems - included here just in case that changes - /** - * @type {T & U} - * @readonly - */ - readonlyField; - - initializedField = 12; - - /** - * @return {U} - */ - get f1() { return /** @type {*} */(null); } - - /** - * @param {U} _p - */ - set f1(_p) {} - - /** - * @return {U} - */ - get f2() { return /** @type {*} */(null); } - - /** - * @param {U} _p - */ - set f3(_p) {} - - /** - * @param {T} a - * @param {U} b - */ - constructor(a, b) {} - - - /** - * @type {string} - */ - static staticField; - - // @readonly is currently unsupported, it seems - included here just in case that changes - /** - * @type {string} - * @readonly - */ - static staticReadonlyField; - - static staticInitializedField = 12; - - /** - * @return {string} - */ - static get s1() { return ""; } - - /** - * @param {string} _p - */ - static set s1(_p) {} - - /** - * @return {string} - */ - static get s2() { return ""; } - - /** - * @param {string} _p - */ - static set s3(_p) {} - } - - /** - * @template T,U - */ - export class F { - /** - * @type {T & U} - */ - field; - /** - * @param {T} a - * @param {U} b - */ - constructor(a, b) {} - - /** - * @template A,B - * @param {A} a - * @param {B} b - */ - static create(a, b) { return new F(a, b); } - } - - class G {} - - export { G }; - - class HH {} - - export { HH as H }; - - export class I {} - export { I as II }; - - export { J as JJ }; - export class J {} - - - export class K { - constructor() { - this.p1 = 12; - this.p2 = "ok"; - } - - method() { - return this.p1; - } - } - - export class L extends K {} - - export class M extends null { - constructor() { - this.prop = 12; - } - } - - - /** - * @template T - */ - export class N extends L { - /** - * @param {T} param - */ - constructor(param) { - super(); - this.another = param; - } - } - - /** - * @template U - * @extends {N} - */ - export class O extends N { - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. - /** - * @param {U} param - */ - constructor(param) { - super(param); - this.another2 = param; - } - } - - var x = /** @type {*} */(null); - - export class VariableBase extends x {} - - export class HasStatics { - static staticMethod() {} - } - - export class ExtendsStatics extends HasStatics { - static also() {} - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt index bafa8ccd78..254cdc6f9e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt @@ -1,52 +1,47 @@ -index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(5,11): error TS8010: Type annotations can only be used in TypeScript files. -index.js(6,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(8,26): error TS8011: Type arguments can only be used in TypeScript files. -index.js(9,11): error TS8010: Type annotations can only be used in TypeScript files. -index.js(13,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(19,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(23,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(27,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(28,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(32,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(39,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(43,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(47,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(48,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(52,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(53,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(59,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(63,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(67,10): error TS8010: Type annotations can only be used in TypeScript files. -index.js(68,10): error TS8010: Type annotations can only be used in TypeScript files. +index.js(4,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(8,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(8,27): error TS8011: Type arguments can only be used in TypeScript files. +index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. +index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(23,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(28,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(39,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(43,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(47,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(48,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(52,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(53,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(59,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(63,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(67,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(68,11): error TS8010: Type annotations can only be used in TypeScript files. ==== index.js (21 errors) ==== // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // but we should be able to synthesize declarations from the symbols regardless - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - export class M { ~~~~~~~~~~~~~~~~~~~ field: T; ~~~~~~~~~~~~~ - ~~ + ~ !!! error TS8010: Type annotations can only be used in TypeScript files. } ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - export class N extends M { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~ + ~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. other: U; ~~~~~~~~~~~~~ - ~~ + ~ !!! error TS8010: Type annotations can only be used in TypeScript files. } ~ @@ -54,7 +49,7 @@ index.js(68,10): error TS8010: Type annotations can only be used in TypeScript f export class O { [idx: string]: string; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } @@ -62,28 +57,28 @@ index.js(68,10): error TS8010: Type annotations can only be used in TypeScript f export class Q extends O { [idx: string]: "ok"; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class R extends O { [idx: number]: "ok"; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class S extends O { [idx: string]: "ok"; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: never; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class T { [idx: number]: string; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } @@ -92,31 +87,31 @@ index.js(68,10): error TS8010: Type annotations can only be used in TypeScript f export class V extends T { [idx: string]: string; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class W extends T { [idx: number]: "ok"; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class X extends T { [idx: string]: string; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: "ok"; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class Y { [idx: string]: {x: number}; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: {x: number, y: number}; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } @@ -124,22 +119,22 @@ index.js(68,10): error TS8010: Type annotations can only be used in TypeScript f export class AA extends Y { [idx: string]: {x: number, y: number}; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class BB extends Y { [idx: number]: {x: 0, y: 0}; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class CC extends Y { [idx: string]: {x: number, y: number}; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: {x: 0, y: 0}; - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt index 8a109dfe27..399d04fb81 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt @@ -1,29 +1,24 @@ -index.js(1,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(4,17): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(8,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(12,14): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(16,20): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(21,20): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(22,17): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(28,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(33,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(39,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(45,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(4,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(6,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(10,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(14,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(18,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(22,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(24,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(30,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(35,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(41,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(47,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(55,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ==== index.js (12 errors) ==== // Pretty much all of this should be an error, (since enums are forbidden in js), - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // but we should be able to synthesize declarations from the symbols regardless - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - export enum A {} ~~~~~~~~~~~~~~~~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum B { ~~~~~~~~~~~~~~~ @@ -32,24 +27,18 @@ index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript } ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - enum C {} ~~~~~~~~~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. export { C }; - - enum DD {} ~~~~~~~~~~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. export { DD as D }; - - export enum E {} ~~~~~~~~~~~~~~~~ @@ -57,12 +46,9 @@ index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript export { E as EE }; export { F as FF }; - export enum F {} ~~~~~~~~~~~~~~~~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum G { ~~~~~~~~~~~~~~~ @@ -75,8 +61,6 @@ index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript } ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum H { ~~~~~~~~~~~~~~~ @@ -87,8 +71,6 @@ index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript } ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum I { ~~~~~~~~~~~~~~~ @@ -101,8 +83,6 @@ index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript } ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export const enum J { ~~~~~~~~~~~~~~~~~~~~~ @@ -115,8 +95,6 @@ index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript } ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum K { ~~~~~~~~~~~~~~~ @@ -133,8 +111,6 @@ index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript } ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export const enum L { ~~~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt index 7463616df4..b62dd98da9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt @@ -1,5 +1,5 @@ bar.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -bar.js(1,30): error TS8003: 'export =' can only be used in TypeScript files. +bar.js(2,1): error TS8003: 'export =' can only be used in TypeScript files. globalNs.js(2,1): error TS1315: Global module exports may only appear in declaration files. @@ -10,7 +10,6 @@ globalNs.js(2,1): error TS1315: Global module exports may only appear in declara import ns = require("./cls"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - export = ns; // TS Only ~~~~~~~~~~~~ !!! error TS8003: 'export =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt index 86a240b454..7780b6f7c6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt @@ -1,43 +1,38 @@ -index.js(1,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(4,22): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(8,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(29,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(33,14): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(37,20): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(42,20): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(43,22): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(47,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(51,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(55,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(59,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(63,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(65,32): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(69,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(73,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(78,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(82,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(84,32): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(89,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(93,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(98,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(103,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(105,32): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(109,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(113,2): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(4,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(6,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(10,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(31,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(35,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(39,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(43,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(45,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(49,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(53,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(57,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(61,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(65,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(67,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(71,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(75,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(80,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(84,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(87,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(91,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(95,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(100,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(105,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(107,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(111,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(115,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ==== index.js (26 errors) ==== // Pretty much all of this should be an error, (since interfaces are forbidden in js), - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // but we should be able to synthesize declarations from the symbols regardless - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - export interface A {} ~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface B { ~~~~~~~~~~~~~~~~~~~~ @@ -46,8 +41,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface C { ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -90,24 +83,18 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - interface G {} ~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export { G }; - - interface HH {} ~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export { HH as H }; - - export interface I {} ~~~~~~~~~~~~~~~~~~~~~ @@ -115,12 +102,9 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type export { I as II }; export { J as JJ }; - export interface J {} ~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface K extends I,J { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -129,8 +113,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface L extends K { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -139,8 +121,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface M { ~~~~~~~~~~~~~~~~~~~~~~~ @@ -149,8 +129,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface N extends M { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -159,8 +137,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface O { ~~~~~~~~~~~~~~~~~~~~ @@ -169,14 +145,10 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface P extends O {} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface Q extends O { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -185,8 +157,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface R extends O { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -195,8 +165,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface S extends O { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -207,8 +175,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface T { ~~~~~~~~~~~~~~~~~~~~ @@ -217,15 +183,10 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface U extends T {} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - - export interface V extends T { @@ -235,8 +196,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface W extends T { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -245,8 +204,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface X extends T { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -257,8 +214,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface Y { ~~~~~~~~~~~~~~~~~~~~ @@ -269,14 +224,10 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface Z extends Y {} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface AA extends Y { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -285,8 +236,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface BB extends Y { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -295,8 +244,6 @@ index.js(113,2): error TS8006: 'interface' declarations can only be used in Type } ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface CC extends Y { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt index a304654b55..619007ca15 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt @@ -1,12 +1,10 @@ -index.js(2,28): error TS8006: 'module' declarations can only be used in TypeScript files. +index.js(4,1): error TS8006: 'module' declarations can only be used in TypeScript files. ==== index.js (1 errors) ==== /// export const Something = 2; // to show conflict that can occur - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @ts-ignore - ~~~~~~~~~~~~~ export namespace A { ~~~~~~~~~~~~~~~~~~~~ // @ts-ignore diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt deleted file mode 100644 index 31094fd912..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -/b.js(2,16): error TS8011: Type arguments can only be used in TypeScript files. - - -==== /a.d.ts (0 errors) ==== - declare class A { x: T } - -==== /b.js (1 errors) ==== - /** @augments A */ - class B extends A { - ~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. - m() { - return this.x; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node16).errors.txt index c50a44976a..13ade2052e 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node16).errors.txt @@ -9,21 +9,21 @@ index.cjs(16,22): error TS1479: The current file is a CommonJS module whose impo index.cjs(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. -index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -47,21 +47,21 @@ index.js(21,22): error TS2835: Relative import paths need explicit file extensio index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -85,21 +85,21 @@ index.mjs(21,22): error TS2835: Relative import paths need explicit file extensi index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -220,59 +220,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m27 = require("./subfolder/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m28 = require("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m29 = require("./subfolder2"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m30 = require("./subfolder2/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m31 = require("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -398,59 +385,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m27 = require("./subfolder/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m28 = require("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m29 = require("./subfolder2"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m30 = require("./subfolder2/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m31 = require("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -575,59 +549,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m27 = require("./subfolder/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m28 = require("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m29 = require("./subfolder2"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m30 = require("./subfolder2/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m31 = require("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node18).errors.txt index c50a44976a..13ade2052e 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node18).errors.txt @@ -9,21 +9,21 @@ index.cjs(16,22): error TS1479: The current file is a CommonJS module whose impo index.cjs(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. -index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -47,21 +47,21 @@ index.js(21,22): error TS2835: Relative import paths need explicit file extensio index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -85,21 +85,21 @@ index.mjs(21,22): error TS2835: Relative import paths need explicit file extensi index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? @@ -220,59 +220,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m27 = require("./subfolder/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m28 = require("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m29 = require("./subfolder2"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m30 = require("./subfolder2/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m31 = require("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -398,59 +385,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m27 = require("./subfolder/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m28 = require("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m29 = require("./subfolder2"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m30 = require("./subfolder2/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m31 = require("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -575,59 +549,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m27 = require("./subfolder/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m28 = require("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m29 = require("./subfolder2"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m30 = require("./subfolder2/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m31 = require("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt index 8e9807b2ac..ddbe7ecee4 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt @@ -1,14 +1,14 @@ -index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. -index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? index.cjs(77,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -31,17 +31,17 @@ index.js(21,22): error TS2835: Relative import paths need explicit file extensio index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? index.js(76,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -64,17 +64,17 @@ index.mjs(21,22): error TS2835: Relative import paths need explicit file extensi index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. -index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? index.mjs(76,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -194,51 +194,38 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m27 = require("./subfolder/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m28 = require("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m29 = require("./subfolder2"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m30 = require("./subfolder2/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m31 = require("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -340,51 +327,38 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m27 = require("./subfolder/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m28 = require("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m29 = require("./subfolder2"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m30 = require("./subfolder2/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m31 = require("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -507,51 +481,38 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi void m21; void m22; void m23; - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import m24 = require("./"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m27 = require("./subfolder/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m28 = require("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m29 = require("./subfolder2"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m30 = require("./subfolder2/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m31 = require("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt index cfec91f6b5..f3b7906029 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt @@ -1,13 +1,12 @@ file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. +index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. +subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. ==== subfolder/index.js (1 errors) ==== // cjs format file const a = {}; - export = a; ~~~~~~~~~~~ !!! error TS8003: 'export =' can only be used in TypeScript files. @@ -18,12 +17,11 @@ subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScrip ==== index.js (2 errors) ==== // esm format file const a = {}; - export = a; ~~~~~~~~~~~ -!!! error TS8003: 'export =' can only be used in TypeScript files. - ~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. ==== file.js (1 errors) ==== // esm format file import "fs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt index cfec91f6b5..f3b7906029 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt @@ -1,13 +1,12 @@ file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. +index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. +subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. ==== subfolder/index.js (1 errors) ==== // cjs format file const a = {}; - export = a; ~~~~~~~~~~~ !!! error TS8003: 'export =' can only be used in TypeScript files. @@ -18,12 +17,11 @@ subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScrip ==== index.js (2 errors) ==== // esm format file const a = {}; - export = a; ~~~~~~~~~~~ -!!! error TS8003: 'export =' can only be used in TypeScript files. - ~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. ==== file.js (1 errors) ==== // esm format file import "fs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt index cfec91f6b5..f3b7906029 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt @@ -1,13 +1,12 @@ file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. +index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. +subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. ==== subfolder/index.js (1 errors) ==== // cjs format file const a = {}; - export = a; ~~~~~~~~~~~ !!! error TS8003: 'export =' can only be used in TypeScript files. @@ -18,12 +17,11 @@ subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScrip ==== index.js (2 errors) ==== // esm format file const a = {}; - export = a; ~~~~~~~~~~~ -!!! error TS8003: 'export =' can only be used in TypeScript files. - ~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. ==== file.js (1 errors) ==== // esm format file import "fs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt index 4cb7a62505..476c47f703 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt @@ -1,30 +1,26 @@ -file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. -file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. +file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. ==== subfolder/index.js (2 errors) ==== // cjs format file - ~~~~~~~~~~~~~~~~~~ import fs = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. fs.readFile; - export import fs2 = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ==== index.js (2 errors) ==== // esm format file - ~~~~~~~~~~~~~~~~~~ import fs = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. fs.readFile; - export import fs2 = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -32,12 +28,10 @@ subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeS // esm format file const __require = null; const _createRequire = null; - import fs = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. fs.readFile; - export import fs2 = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt index 4cb7a62505..476c47f703 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt @@ -1,30 +1,26 @@ -file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. -file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. +file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. ==== subfolder/index.js (2 errors) ==== // cjs format file - ~~~~~~~~~~~~~~~~~~ import fs = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. fs.readFile; - export import fs2 = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ==== index.js (2 errors) ==== // esm format file - ~~~~~~~~~~~~~~~~~~ import fs = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. fs.readFile; - export import fs2 = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -32,12 +28,10 @@ subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeS // esm format file const __require = null; const _createRequire = null; - import fs = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. fs.readFile; - export import fs2 = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt index 4cb7a62505..476c47f703 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt @@ -1,30 +1,26 @@ -file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. -file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. +file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. ==== subfolder/index.js (2 errors) ==== // cjs format file - ~~~~~~~~~~~~~~~~~~ import fs = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. fs.readFile; - export import fs2 = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ==== index.js (2 errors) ==== // esm format file - ~~~~~~~~~~~~~~~~~~ import fs = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. fs.readFile; - export import fs2 = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -32,12 +28,10 @@ subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeS // esm format file const __require = null; const _createRequire = null; - import fs = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. fs.readFile; - export import fs2 = require("fs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt index 5c2e18b118..a4ba6ab81a 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt @@ -1,11 +1,11 @@ -index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. -subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. ==== subfolder/index.js (4 errors) ==== @@ -14,14 +14,12 @@ subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeS ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. !!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. - import mod = require("../index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; - import mod2 = require("./index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -33,14 +31,12 @@ subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeS ==== index.js (3 errors) ==== // esm format file import {h as _h} from "./index.js"; - import mod = require("./index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; - import mod2 = require("./subfolder/index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt index 5c2e18b118..a4ba6ab81a 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt @@ -1,11 +1,11 @@ -index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. -subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. ==== subfolder/index.js (4 errors) ==== @@ -14,14 +14,12 @@ subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeS ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. !!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. - import mod = require("../index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; - import mod2 = require("./index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -33,14 +31,12 @@ subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeS ==== index.js (3 errors) ==== // esm format file import {h as _h} from "./index.js"; - import mod = require("./index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~ !!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; - import mod2 = require("./subfolder/index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt index d5cb2a2793..2a46b9875d 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt @@ -1,18 +1,16 @@ -index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. -index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. -subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. +index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. +subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. ==== subfolder/index.js (2 errors) ==== // cjs format file import {h} from "../index.js"; - import mod = require("../index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. import {f as _f} from "./index.js"; - import mod2 = require("./index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -24,12 +22,10 @@ subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeS ==== index.js (2 errors) ==== // esm format file import {h as _h} from "./index.js"; - import mod = require("./index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. import {f} from "./subfolder/index.js"; - import mod2 = require("./subfolder/index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt index 7c45d5dbd5..fca3c29810 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt @@ -1,6 +1,6 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. -fileJs.js(1,10): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,11): error TS2304: Cannot find name 'c'. +fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,17): error TS2304: Cannot find name 'd'. fileJs.js(1,27): error TS2304: Cannot find name 'f'. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. @@ -13,10 +13,10 @@ fileTs.ts(1,27): error TS2304: Cannot find name 'f'. a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon ~ !!! error TS2304: Cannot find name 'a'. - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'c'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'd'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt index 87521aaabd..cfe16ee6c8 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt @@ -1,6 +1,6 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. fileJs.js(1,11): error TS2304: Cannot find name 'a'. -fileJs.js(1,20): error TS8010: Type annotations can only be used in TypeScript files. +fileJs.js(1,21): error TS8010: Type annotations can only be used in TypeScript files. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. fileTs.ts(1,11): error TS2304: Cannot find name 'a'. @@ -11,7 +11,7 @@ fileTs.ts(1,11): error TS2304: Cannot find name 'a'. !!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'a'. - ~~~~ + ~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ==== fileTs.ts (2 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt index 0961c06454..8908dde1bc 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt @@ -1,8 +1,8 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. -fileJs.js(1,10): error TS8010: Type annotations can only be used in TypeScript files. +fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,20): error TS8009: The '?' modifier can only be used in TypeScript files. -fileJs.js(1,22): error TS8010: Type annotations can only be used in TypeScript files. -fileJs.js(1,31): error TS8010: Type annotations can only be used in TypeScript files. +fileJs.js(1,23): error TS8010: Type annotations can only be used in TypeScript files. +fileJs.js(1,32): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,40): error TS2304: Cannot find name 'd'. fileJs.js(1,46): error TS2304: Cannot find name 'e'. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. @@ -14,13 +14,13 @@ fileTs.ts(1,46): error TS2304: Cannot find name 'e'. a() ? (b: number, c?: string): void => d() : e; // Not legal JS; "Unexpected token ':'" at first colon ~ !!! error TS2304: Cannot find name 'a'. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8009: The '?' modifier can only be used in TypeScript files. - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~ + ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'd'. diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt index 3df29f8c63..8cacfbe684 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt @@ -1,9 +1,9 @@ -fileJs.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. +fileJs.js(1,18): error TS8010: Type annotations can only be used in TypeScript files. ==== fileJs.js (1 errors) ==== false ? (param): string => param : null // Not legal JS; "Unexpected token ':'" at last colon - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ==== fileTs.ts (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt index 598acb3d84..237f9839c1 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt @@ -1,9 +1,9 @@ -fileJs.js(1,24): error TS8010: Type annotations can only be used in TypeScript files. +fileJs.js(1,25): error TS8010: Type annotations can only be used in TypeScript files. ==== fileJs.js (1 errors) ==== true ? false ? (param): string => param : null : null // Not legal JS; "Unexpected token ':'" at last colon - ~~~~~~~ + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ==== fileTs.ts (0 errors) ==== diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt index 910cef3733..28091b1745 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt @@ -1,7 +1,7 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. fileJs.js(1,5): error TS2304: Cannot find name 'b'. -fileJs.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,15): error TS2304: Cannot find name 'd'. +fileJs.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,20): error TS2304: Cannot find name 'e'. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. fileTs.ts(1,5): error TS2304: Cannot find name 'b'. @@ -15,10 +15,10 @@ fileTs.ts(1,20): error TS2304: Cannot find name 'e'. !!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'b'. - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'd'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'e'. diff --git a/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt b/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt index dc3b3d773a..0858b35c7e 100644 --- a/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt @@ -1,8 +1,8 @@ -/src/a.js(1,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. +/src/a.js(1,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files. ==== /src/a.js (1 errors) ==== var v = undefined satisfies 1; - ~~ + ~ !!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile.errors.txt.diff deleted file mode 100644 index a594e37091..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.decoratorInJsFile.errors.txt -+++ new.decoratorInJsFile.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== a.js (1 errors) ==== - @SomeDecorator - class SomeClass { - foo(x: number) { -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile1.errors.txt.diff deleted file mode 100644 index 92f8e9b3d3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/decoratorInJsFile1.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.decoratorInJsFile1.errors.txt -+++ new.decoratorInJsFile1.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(3,12): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(3,11): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== a.js (1 errors) ==== - @SomeDecorator - class SomeClass { - foo(x: number) { -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff index 577da8f609..c36d844b7d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff @@ -2,24 +2,20 @@ +++ new.fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@= skipped -0, +0 lines =@@ -BaseB.js(2,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -+BaseB.js(1,29): error TS8004: Type parameter declarations can only be used in TypeScript files. ++BaseB.js(2,1): error TS8004: Type parameter declarations can only be used in TypeScript files. BaseB.js(2,25): error TS1005: ',' expected. -+BaseB.js(3,13): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(3,14): error TS2304: Cannot find name 'Class'. --BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. -+BaseB.js(4,24): error TS8010: Type annotations can only be used in TypeScript files. + BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(4,25): error TS2304: Cannot find name 'Class'. --BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. + BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. -SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files. -+SubB.js(3,34): error TS8011: Type arguments can only be used in TypeScript files. ++SubB.js(3,35): error TS8011: Type arguments can only be used in TypeScript files. ==== BaseA.js (0 errors) ==== -@@= skipped -15, +15 lines =@@ - } +@@= skipped -16, +16 lines =@@ ==== BaseB.js (6 errors) ==== import BaseA from './BaseA'; -+ export default class B { - ~~~~~~~~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. @@ -28,20 +24,16 @@ !!! error TS1005: ',' expected. _AClass: Class; + ~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2304: Cannot find name 'Class'. -- ~~~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. constructor(AClass: Class) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~ !!! error TS2304: Cannot find name 'Class'. -- ~~~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. this._AClass = AClass; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } @@ -54,7 +46,7 @@ import BaseB from './BaseB'; export default class SubB extends BaseB { - ~~~~ -+ ~~~~~~~~~~~~ ++ ~~~~~~~~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(SubA); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff index ee041c4019..135c21c283 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff @@ -5,18 +5,11 @@ -/b.js(4,15): error TS2314: Generic type 'A' requires 1 type argument(s). -/b.js(8,15): error TS2314: Generic type 'A' requires 1 type argument(s). +/b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -+/b.js(9,16): error TS8011: Type arguments can only be used in TypeScript files. +/b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== /a.d.ts (0 errors) ==== - declare class A { x: T; } - --==== /b.js (3 errors) ==== -+==== /b.js (4 errors) ==== - class B extends A {} - ~ - !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. +@@= skipped -12, +12 lines =@@ new B().x; /** @augments A */ @@ -31,8 +24,6 @@ - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2314: Generic type 'A' requires 1 type argument(s). class D extends A {} -+ ~~ -+!!! error TS8011: Type arguments can only be used in TypeScript files. + ~ +!!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new D().x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff index c6d4d1e58e..61cda5b123 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff @@ -4,22 +4,16 @@ -error TS5055: Cannot write file 'a.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. -a.js(1,1): error TS8009: The 'abstract' modifier can only be used in TypeScript files. --a.js(2,5): error TS8009: The 'abstract' modifier can only be used in TypeScript files. -- -- + a.js(2,5): error TS8009: The 'abstract' modifier can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. -==== a.js (2 errors) ==== -+a.js(1,19): error TS8009: The 'abstract' modifier can only be used in TypeScript files. -+ -+ +==== a.js (1 errors) ==== abstract class c { - ~~~~~~~~ -!!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. -+ abstract x; -- ~~~~~~~~ -+ ~~~~~~~~~~~~ - !!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. - } \ No newline at end of file + ~~~~~~~~ + !!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff index 8d651c1cb1..794ce9898b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff @@ -1,16 +1,11 @@ --- old.jsFileCompilationConstructorOverloadSyntax.errors.txt +++ new.jsFileCompilationConstructorOverloadSyntax.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(2,3): error TS8017: Signature declarations can only be used in TypeScript files. -+a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. - - +@@= skipped -3, +3 lines =@@ ==== a.js (1 errors) ==== class A { -+ constructor(); - ~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~~~ ++ ~~~~~~~~~~~~~~ !!! error TS8017: Signature declarations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff index 3f7a5f4ef8..0d1a4754ba 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff @@ -3,16 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,9): error TS8005: 'implements' clauses can only be used in TypeScript files. -- -- + a.js(1,9): error TS8005: 'implements' clauses can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,8): error TS8005: 'implements' clauses can only be used in TypeScript files. -+ -+ ==== a.js (1 errors) ==== class C implements D { } -- ~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~ - !!! error TS8005: 'implements' clauses can only be used in TypeScript files. \ No newline at end of file + ~~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff index 62ea645dd7..e8fe861040 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff @@ -1,16 +1,11 @@ --- old.jsFileCompilationMethodOverloadSyntax.errors.txt +++ new.jsFileCompilationMethodOverloadSyntax.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(2,3): error TS8017: Signature declarations can only be used in TypeScript files. -+a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. - - +@@= skipped -3, +3 lines =@@ ==== a.js (1 errors) ==== class A { -+ foo(); - ~~~ -+ ~~~~~~~~ ++ ~~~~~~ !!! error TS8017: Signature declarations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff index 855fe20fb2..e4aed4c8cb 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff @@ -3,16 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. -- -- + a.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ ==== a.js (1 errors) ==== function F(): number { } -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file + ~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff deleted file mode 100644 index bea94a7714..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsFileCompilationTypeAssertions.errors.txt -+++ new.jsFileCompilationTypeAssertions.errors.txt -@@= skipped -0, +0 lines =@@ --/src/a.js(1,6): error TS8016: Type assertion expressions can only be used in TypeScript files. -+/src/a.js(1,5): error TS8016: Type assertion expressions can only be used in TypeScript files. - /src/a.js(2,10): error TS17008: JSX element 'string' has no corresponding closing tag. - /src/a.js(3,1): error TS1005: 'undefined; - ~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeOfParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeOfParameter.errors.txt.diff index ba1b0a8d7f..004ccb86f8 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeOfParameter.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeOfParameter.errors.txt.diff @@ -3,16 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. -- -- + a.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ ==== a.js (1 errors) ==== function F(a: number) { } -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file + ~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff index 126257198f..1bcc64608e 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff @@ -2,12 +2,12 @@ +++ new.jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt @@= skipped -0, +0 lines =@@ -a.js(1,19): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(1,12): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(1,13): error TS8004: Type parameter declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== const Bar = class {}; - ~ -+ ~~~~~~~~~~~~ ++ ~~~~~~~~~~~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff index 92f042dd59..3ae8aa2721 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff @@ -3,16 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,8): error TS8010: Type annotations can only be used in TypeScript files. -- -- + a.js(1,8): error TS8010: Type annotations can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,7): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ ==== a.js (1 errors) ==== var v: () => number; -- ~~~~~~~~~~~~ -+ ~~~~~~~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file + ~~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/modulePreserve4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/modulePreserve4.errors.txt.diff index d419c08d61..344e42e5be 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/modulePreserve4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/modulePreserve4.errors.txt.diff @@ -14,12 +14,10 @@ /main2.mts(14,8): error TS1192: Module '"/e"' has no default export. /main3.cjs(1,10): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. -/main3.cjs(1,13): error TS2305: Module '"./a"' has no exported member 'y'. --/main3.cjs(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +/main3.cjs(1,13): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. -+/main3.cjs(1,28): error TS8002: 'import ... =' can only be used in TypeScript files. + /main3.cjs(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. /main3.cjs(5,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(8,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. - /main3.cjs(10,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. @@= skipped -18, +16 lines =@@ /main3.cjs(17,8): error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. @@ -65,7 +63,6 @@ ~ -!!! error TS2305: Module '"./a"' has no exported member 'y'. +!!! error TS1293: ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. -+ ~~~~~~~~ import a1 = require("./a"); // Error in JS ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff index 95850d24be..2b89283198 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff @@ -11,7 +11,6 @@ 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,22): error TS8011: Type arguments can only be used in TypeScript files. +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. @@ -36,7 +35,7 @@ /** * @constructor * @param {number} numberOxen -@@= skipped -36, +34 lines =@@ +@@= skipped -36, +33 lines =@@ } // ok class Sql extends Wagon { @@ -103,7 +102,7 @@ +!!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (2 errors) ==== -+==== generic.js (6 errors) ==== ++==== generic.js (5 errors) ==== /** * @template T * @param {T} flavour @@ -111,8 +110,6 @@ } /** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */ class Chowder extends Soup { -+ ~~~~~ -+!!! error TS8011: Type arguments can only be used in TypeScript files. + ~~~~ +!!! error TS2507: Type '(flavour: T) => void' is not a constructor function type. log() { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff deleted file mode 100644 index 6c92e750c4..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.exportSpecifiers_js.errors.txt -+++ new.exportSpecifiers_js.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(2,10): error TS8006: 'export...type' declarations can only be used in TypeScript files. -+a.js(2,9): error TS8006: 'export...type' declarations can only be used in TypeScript files. - - - ==== a.js (1 errors) ==== - const foo = 0; - export { type foo }; -- ~~~~~~~~ -+ ~~~~~~~~~ - !!! error TS8006: 'export...type' declarations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff deleted file mode 100644 index 675c69e18e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.extendsTag1.errors.txt -+++ new.extendsTag1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+bug25101.js(5,17): error TS8011: Type arguments can only be used in TypeScript files. -+ -+ -+==== bug25101.js (1 errors) ==== -+ /** -+ * @template T -+ * @extends {Set} Should prefer this Set, not the Set in the heritage clause -+ */ -+ class My extends Set {} -+ ~~~~ -+!!! error TS8011: Type arguments can only be used in TypeScript files. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff deleted file mode 100644 index 231b1e98a7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff +++ /dev/null @@ -1,54 +0,0 @@ ---- old.extendsTag5.errors.txt -+++ new.extendsTag5.errors.txt -@@= skipped -0, +0 lines =@@ -+/a.js(26,16): error TS8011: Type arguments can only be used in TypeScript files. - /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(34,16): error TS8011: Type arguments can only be used in TypeScript files. -+/a.js(39,16): error TS8011: Type arguments can only be used in TypeScript files. - /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 (2 errors) ==== -+/a.js(44,16): error TS8011: Type arguments can only be used in TypeScript files. -+ -+ -+==== /a.js (6 errors) ==== - /** - * @typedef {{ - * a: number | string; -@@= skipped -32, +36 lines =@@ - * }>} - */ - class B extends A {} -+ ~~ -+!!! error TS8011: Type arguments can only be used in TypeScript files. - - /** - * @extends {A<{ -@@= skipped -15, +17 lines =@@ - !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. - */ - class C extends A {} -+ ~~ -+!!! error TS8011: Type arguments can only be used in TypeScript files. - - /** - * @extends {A<{a: string, b: string[]}>} - */ - class D extends A {} -+ ~~ -+!!! error TS8011: Type arguments can only be used in TypeScript files. - - /** - * @extends {A<{a: string, b: string}>} -@@= skipped -14, +18 lines =@@ - !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. - */ - class E extends A {} -+ ~~ -+!!! error TS8011: Type arguments can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff index 47e158ae7f..3ddd979217 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff @@ -5,8 +5,7 @@ - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS5056: Cannot write file '/a.js' because it would be overwritten by multiple input files. /a.js(1,1): error TS8006: 'import type' declarations can only be used in TypeScript files. --/a.js(2,1): error TS8006: 'export type' declarations can only be used in TypeScript files. -+/a.js(1,26): error TS8006: 'export type' declarations can only be used in TypeScript files. + /a.js(2,1): error TS8006: 'export type' declarations can only be used in TypeScript files. /b.ts(1,8): error TS1363: A type-only import can specify a default import or named bindings, but not both. /c.ts(4,1): error TS1392: An import alias cannot use 'import type' @@ -16,12 +15,4 @@ -!!! error TS5056: Cannot write file '/a.js' because it would be overwritten by multiple input files. ==== /a.ts (0 errors) ==== export default class A {} - export class B {} -@@= skipped -23, +17 lines =@@ - import type A from './a'; - ~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8006: 'import type' declarations can only be used in TypeScript files. -+ - export type { A }; - ~~~~~~~~~~~~~~~~~~ - !!! error TS8006: 'export type' declarations can only be used in TypeScript files. \ No newline at end of file + export class B {} \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importSpecifiers_js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importSpecifiers_js.errors.txt.diff deleted file mode 100644 index 4056302609..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importSpecifiers_js.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.importSpecifiers_js.errors.txt -+++ new.importSpecifiers_js.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(1,10): error TS8006: 'import...type' declarations can only be used in TypeScript files. -+a.js(1,9): error TS8006: 'import...type' declarations can only be used in TypeScript files. - - - ==== a.ts (0 errors) ==== -@@= skipped -5, +5 lines =@@ - - ==== a.js (1 errors) ==== - import { type A } from "./a"; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8006: 'import...type' declarations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff deleted file mode 100644 index 1879cc7b19..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff +++ /dev/null @@ -1,204 +0,0 @@ ---- old.jsDeclarationsClasses.errors.txt -+++ new.jsDeclarationsClasses.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(173,23): error TS8011: Type arguments can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ export class A {} -+ -+ export class B { -+ static cat = "cat"; -+ } -+ -+ export class C { -+ static Cls = class {} -+ } -+ -+ export class D { -+ /** -+ * @param {number} a -+ * @param {number} b -+ */ -+ constructor(a, b) {} -+ } -+ -+ /** -+ * @template T,U -+ */ -+ export class E { -+ /** -+ * @type {T & U} -+ */ -+ field; -+ -+ // @readonly is currently unsupported, it seems - included here just in case that changes -+ /** -+ * @type {T & U} -+ * @readonly -+ */ -+ readonlyField; -+ -+ initializedField = 12; -+ -+ /** -+ * @return {U} -+ */ -+ get f1() { return /** @type {*} */(null); } -+ -+ /** -+ * @param {U} _p -+ */ -+ set f1(_p) {} -+ -+ /** -+ * @return {U} -+ */ -+ get f2() { return /** @type {*} */(null); } -+ -+ /** -+ * @param {U} _p -+ */ -+ set f3(_p) {} -+ -+ /** -+ * @param {T} a -+ * @param {U} b -+ */ -+ constructor(a, b) {} -+ -+ -+ /** -+ * @type {string} -+ */ -+ static staticField; -+ -+ // @readonly is currently unsupported, it seems - included here just in case that changes -+ /** -+ * @type {string} -+ * @readonly -+ */ -+ static staticReadonlyField; -+ -+ static staticInitializedField = 12; -+ -+ /** -+ * @return {string} -+ */ -+ static get s1() { return ""; } -+ -+ /** -+ * @param {string} _p -+ */ -+ static set s1(_p) {} -+ -+ /** -+ * @return {string} -+ */ -+ static get s2() { return ""; } -+ -+ /** -+ * @param {string} _p -+ */ -+ static set s3(_p) {} -+ } -+ -+ /** -+ * @template T,U -+ */ -+ export class F { -+ /** -+ * @type {T & U} -+ */ -+ field; -+ /** -+ * @param {T} a -+ * @param {U} b -+ */ -+ constructor(a, b) {} -+ -+ /** -+ * @template A,B -+ * @param {A} a -+ * @param {B} b -+ */ -+ static create(a, b) { return new F(a, b); } -+ } -+ -+ class G {} -+ -+ export { G }; -+ -+ class HH {} -+ -+ export { HH as H }; -+ -+ export class I {} -+ export { I as II }; -+ -+ export { J as JJ }; -+ export class J {} -+ -+ -+ export class K { -+ constructor() { -+ this.p1 = 12; -+ this.p2 = "ok"; -+ } -+ -+ method() { -+ return this.p1; -+ } -+ } -+ -+ export class L extends K {} -+ -+ export class M extends null { -+ constructor() { -+ this.prop = 12; -+ } -+ } -+ -+ -+ /** -+ * @template T -+ */ -+ export class N extends L { -+ /** -+ * @param {T} param -+ */ -+ constructor(param) { -+ super(); -+ this.another = param; -+ } -+ } -+ -+ /** -+ * @template U -+ * @extends {N} -+ */ -+ export class O extends N { -+ ~~ -+!!! error TS8011: Type arguments can only be used in TypeScript files. -+ /** -+ * @param {U} param -+ */ -+ constructor(param) { -+ super(param); -+ this.another2 = param; -+ } -+ } -+ -+ var x = /** @type {*} */(null); -+ -+ export class VariableBase extends x {} -+ -+ export class HasStatics { -+ static staticMethod() {} -+ } -+ -+ export class ExtendsStatics extends HasStatics { -+ static also() {} -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff index dd75f32e84..558a18abee 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff @@ -2,190 +2,44 @@ +++ new.jsDeclarationsClassesErr.errors.txt @@= skipped -0, +0 lines =@@ -index.js(4,16): error TS8004: Type parameter declarations can only be used in TypeScript files. --index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(4,1): error TS8004: Type parameter declarations can only be used in TypeScript files. + index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(8,16): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(8,29): error TS8011: Type arguments can only be used in TypeScript files. --index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. --index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(23,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(28,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(39,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(43,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(47,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(48,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(52,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(53,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(59,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(63,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(67,11): error TS8010: Type annotations can only be used in TypeScript files. --index.js(68,11): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(5,11): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(6,2): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(8,26): error TS8011: Type arguments can only be used in TypeScript files. -+index.js(9,11): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(13,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(19,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(23,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(27,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(28,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(32,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(39,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(43,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(47,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(48,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(52,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(53,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(59,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(63,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(67,10): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(68,10): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== index.js (21 errors) ==== - // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++index.js(8,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(8,27): error TS8011: Type arguments can only be used in TypeScript files. + index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. + index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -25, +25 lines =@@ // but we should be able to synthesize declarations from the symbols regardless -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ export class M { - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~ field: T; -- ~ + ~~~~~~~~~~~~~ -+ ~~ + ~ !!! error TS8010: Type annotations can only be used in TypeScript files. } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ -+ export class N extends M { - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ ~~~~~ ++ ~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. other: U; -- ~ + ~~~~~~~~~~~~~ -+ ~~ + ~ !!! error TS8010: Type annotations can only be used in TypeScript files. } + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. export class O { - [idx: string]: string; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - -@@= skipped -52, +61 lines =@@ - - export class Q extends O { - [idx: string]: "ok"; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class R extends O { - [idx: number]: "ok"; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class S extends O { - [idx: string]: "ok"; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - [idx: number]: never; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class T { - [idx: number]: string; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - -@@= skipped -30, +30 lines =@@ - - export class V extends T { - [idx: string]: string; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class W extends T { - [idx: number]: "ok"; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class X extends T { - [idx: string]: string; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - [idx: number]: "ok"; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class Y { - [idx: string]: {x: number}; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - [idx: number]: {x: number, y: number}; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - -@@= skipped -32, +32 lines =@@ - - export class AA extends Y { - [idx: string]: {x: number, y: number}; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class BB extends Y { - [idx: number]: {x: 0, y: 0}; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class CC extends Y { - [idx: string]: {x: number, y: number}; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - [idx: number]: {x: 0, y: 0}; -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } - \ No newline at end of file + [idx: string]: string; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff index 951027bba3..bf84cfe593 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff @@ -13,33 +13,28 @@ -index.js(41,19): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(47,13): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(55,19): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(1,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(4,17): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(8,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(12,14): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(16,20): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(21,20): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(22,17): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(28,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(33,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(39,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(45,2): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(53,2): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(4,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(6,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(10,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(14,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(18,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(22,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(24,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(30,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(35,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(41,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(47,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ++index.js(55,1): error TS8006: 'enum' declarations can only be used in TypeScript files. ==== index.js (12 errors) ==== - // Pretty much all of this should be an error, (since enums are forbidden in js), -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +@@= skipped -16, +16 lines =@@ // but we should be able to synthesize declarations from the symbols regardless -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ export enum A {} - ~ + ~~~~~~~~~~~~~~~~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ -+ export enum B { - ~ @@ -50,8 +45,6 @@ } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ -+ enum C {} - ~ @@ -59,8 +52,6 @@ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. export { C }; -+ -+ enum DD {} - ~~ @@ -68,8 +59,6 @@ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. export { DD as D }; -+ -+ export enum E {} - ~ @@ -78,13 +67,10 @@ export { E as EE }; export { F as FF }; -+ export enum F {} - ~ + ~~~~~~~~~~~~~~~~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ -+ export enum G { - ~ @@ -99,8 +85,6 @@ } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ -+ export enum H { - ~ @@ -113,8 +97,6 @@ } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ -+ export enum I { - ~ @@ -129,8 +111,6 @@ } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ -+ export const enum J { - ~ @@ -145,8 +125,6 @@ } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ -+ export enum K { - ~ @@ -165,8 +143,6 @@ } + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ -+ export const enum L { - ~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff index ade0b751b8..d387876f66 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff @@ -2,18 +2,12 @@ +++ new.jsDeclarationsExportFormsErr.errors.txt @@= skipped -0, +0 lines =@@ bar.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. --bar.js(2,1): error TS8003: 'export =' can only be used in TypeScript files. + bar.js(2,1): error TS8003: 'export =' can only be used in TypeScript files. -bin.js(2,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+bar.js(1,30): error TS8003: 'export =' can only be used in TypeScript files. globalNs.js(2,1): error TS1315: Global module exports may only appear in declaration files. -@@= skipped -10, +9 lines =@@ - import ns = require("./cls"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - export = ns; // TS Only +@@= skipped -14, +13 lines =@@ ~~~~~~~~~~~~ !!! error TS8003: 'export =' can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff index e2da7af442..4f567d8bba 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff @@ -34,47 +34,42 @@ - - -==== index.js (30 errors) ==== -+index.js(1,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(4,22): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(8,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(29,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(33,14): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(37,20): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(42,20): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(43,22): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(47,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(51,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(55,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(59,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(63,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(65,32): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(69,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(73,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(78,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(82,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(84,32): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(89,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(93,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(98,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(103,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(105,32): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(109,2): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(113,2): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(4,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(6,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(10,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(31,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(35,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(39,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(43,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(45,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(49,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(53,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(57,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(61,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(65,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(67,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(71,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(75,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(80,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(84,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(87,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(91,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(95,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(100,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(105,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(107,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(111,1): error TS8006: 'interface' declarations can only be used in TypeScript files. ++index.js(115,1): error TS8006: 'interface' declarations can only be used in TypeScript files. + + +==== index.js (26 errors) ==== // Pretty much all of this should be an error, (since interfaces are forbidden in js), -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // but we should be able to synthesize declarations from the symbols regardless -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ export interface A {} - ~ + ~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface B { - ~ @@ -85,8 +80,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface C { - ~ @@ -131,8 +124,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ interface G {} - ~ @@ -142,8 +133,6 @@ export { G }; - ~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -+ -+ interface HH {} - ~~ @@ -153,8 +142,6 @@ export { HH as H }; - ~~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -+ -+ export interface I {} - ~ @@ -167,13 +154,10 @@ export { J as JJ }; - ~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -+ export interface J {} - ~ + ~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface K extends I,J { - ~ @@ -184,8 +168,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface L extends K { - ~ @@ -196,8 +178,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface M { - ~ @@ -208,8 +188,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface N extends M { - ~ @@ -220,8 +198,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface O { - ~ @@ -232,15 +208,11 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface P extends O {} - ~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface Q extends O { - ~ @@ -251,8 +223,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface R extends O { - ~ @@ -263,8 +233,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface S extends O { - ~ @@ -277,8 +245,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface T { - ~ @@ -289,16 +255,11 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface U extends T {} - ~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ -+ export interface V extends T { @@ -310,8 +271,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface W extends T { - ~ @@ -322,8 +281,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface X extends T { - ~ @@ -336,8 +293,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface Y { - ~ @@ -350,15 +305,11 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface Z extends Y {} - ~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface AA extends Y { - ~~ @@ -369,8 +320,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface BB extends Y { - ~~ @@ -381,8 +330,6 @@ } + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ export interface CC extends Y { - ~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff index 08ad6aed22..f9d8b04d2b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff @@ -2,15 +2,13 @@ +++ new.jsDeclarationsTypeReferences4.errors.txt @@= skipped -0, +0 lines =@@ -index.js(4,18): error TS8006: 'namespace' declarations can only be used in TypeScript files. -+index.js(2,28): error TS8006: 'module' declarations can only be used in TypeScript files. ++index.js(4,1): error TS8006: 'module' declarations can only be used in TypeScript files. ==== index.js (1 errors) ==== - /// +@@= skipped -5, +5 lines =@@ export const Something = 2; // to show conflict that can occur -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @ts-ignore -+ ~~~~~~~~~~~~~ export namespace A { - ~ -!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff deleted file mode 100644 index b23b773c08..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsdocAugments_withTypeParameter.errors.txt -+++ new.jsdocAugments_withTypeParameter.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/b.js(2,16): error TS8011: Type arguments can only be used in TypeScript files. -+ -+ -+==== /a.d.ts (0 errors) ==== -+ declare class A { x: T } -+ -+==== /b.js (1 errors) ==== -+ /** @augments A */ -+ class B extends A { -+ ~~ -+!!! error TS8011: Type arguments can only be used in TypeScript files. -+ m() { -+ return this.x; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff deleted file mode 100644 index 4fc98269cf..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff +++ /dev/null @@ -1,281 +0,0 @@ ---- old.nodeModulesAllowJs1(module=node16).errors.txt -+++ new.nodeModulesAllowJs1(module=node16).errors.txt -@@= skipped -8, +8 lines =@@ - index.cjs(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. - index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. - index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. --index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. - index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -38, +38 lines =@@ - index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? --index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. - index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -38, +38 lines =@@ - index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? --index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. - index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -135, +135 lines =@@ - void m21; - void m22; - void m23; -+ -+ - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import m24 = require("./"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~ - !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m25 = require("./index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~ - !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m26 = require("./subfolder"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m27 = require("./subfolder/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m28 = require("./subfolder/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m29 = require("./subfolder2"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m30 = require("./subfolder2/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m31 = require("./subfolder2/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m32 = require("./subfolder2/another"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m33 = require("./subfolder2/another/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m34 = require("./subfolder2/another/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -165, +178 lines =@@ - void m21; - void m22; - void m23; -+ -+ - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import m24 = require("./"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~ - !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m25 = require("./index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~ - !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m26 = require("./subfolder"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m27 = require("./subfolder/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m28 = require("./subfolder/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m29 = require("./subfolder2"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m30 = require("./subfolder2/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m31 = require("./subfolder2/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m32 = require("./subfolder2/another"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m33 = require("./subfolder2/another/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m34 = require("./subfolder2/another/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -164, +177 lines =@@ - void m21; - void m22; - void m23; -+ -+ - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import m24 = require("./"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~ - !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m25 = require("./index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~ - !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m26 = require("./subfolder"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m27 = require("./subfolder/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m28 = require("./subfolder/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m29 = require("./subfolder2"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m30 = require("./subfolder2/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m31 = require("./subfolder2/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m32 = require("./subfolder2/another"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m33 = require("./subfolder2/another/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m34 = require("./subfolder2/another/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node18).errors.txt.diff deleted file mode 100644 index c815b6d7ee..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node18).errors.txt.diff +++ /dev/null @@ -1,281 +0,0 @@ ---- old.nodeModulesAllowJs1(module=node18).errors.txt -+++ new.nodeModulesAllowJs1(module=node18).errors.txt -@@= skipped -8, +8 lines =@@ - index.cjs(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. - index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. - index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. --index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. - index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -38, +38 lines =@@ - index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? --index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. - index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -38, +38 lines =@@ - index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? --index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. - index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? -@@= skipped -135, +135 lines =@@ - void m21; - void m22; - void m23; -+ -+ - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import m24 = require("./"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~ - !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m25 = require("./index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~ - !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m26 = require("./subfolder"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m27 = require("./subfolder/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m28 = require("./subfolder/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m29 = require("./subfolder2"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m30 = require("./subfolder2/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m31 = require("./subfolder2/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m32 = require("./subfolder2/another"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m33 = require("./subfolder2/another/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m34 = require("./subfolder2/another/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -165, +178 lines =@@ - void m21; - void m22; - void m23; -+ -+ - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import m24 = require("./"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~ - !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m25 = require("./index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~ - !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m26 = require("./subfolder"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m27 = require("./subfolder/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m28 = require("./subfolder/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m29 = require("./subfolder2"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m30 = require("./subfolder2/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m31 = require("./subfolder2/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m32 = require("./subfolder2/another"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m33 = require("./subfolder2/another/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m34 = require("./subfolder2/another/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -164, +177 lines =@@ - void m21; - void m22; - void m23; -+ -+ - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import m24 = require("./"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~ - !!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m25 = require("./index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~ - !!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m26 = require("./subfolder"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m27 = require("./subfolder/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m28 = require("./subfolder/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m29 = require("./subfolder2"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m30 = require("./subfolder2/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m31 = require("./subfolder2/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m32 = require("./subfolder2/another"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m33 = require("./subfolder2/another/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. -+ - import m34 = require("./subfolder2/another/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt.diff deleted file mode 100644 index 48a55067da..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,242 +0,0 @@ ---- old.nodeModulesAllowJs1(module=nodenext).errors.txt -+++ new.nodeModulesAllowJs1(module=nodenext).errors.txt -@@= skipped -0, +0 lines =@@ --index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(48,10): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(51,28): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(52,33): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(53,37): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(54,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(55,43): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(56,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(57,39): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(58,44): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(59,46): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.cjs(60,47): error TS8002: 'import ... =' can only be used in TypeScript files. - index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. - index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? - index.cjs(77,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. -@@= skipped -30, +30 lines =@@ - index.js(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.js(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.js(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? --index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. - index.js(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? - index.js(76,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. -@@= skipped -33, +33 lines =@@ - index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. - index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? --index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(47,10): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(50,28): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(51,33): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(52,37): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(53,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(54,43): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(55,38): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(56,39): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(57,44): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(58,46): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.mjs(59,47): error TS8002: 'import ... =' can only be used in TypeScript files. - index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. - index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? - index.mjs(76,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. -@@= skipped -130, +130 lines =@@ - void m21; - void m22; - void m23; -+ -+ - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import m24 = require("./"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m25 = require("./index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m26 = require("./subfolder"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m27 = require("./subfolder/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m28 = require("./subfolder/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m29 = require("./subfolder2"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m30 = require("./subfolder2/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m31 = require("./subfolder2/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m32 = require("./subfolder2/another"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m33 = require("./subfolder2/another/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m34 = require("./subfolder2/another/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -133, +146 lines =@@ - void m21; - void m22; - void m23; -+ -+ - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import m24 = require("./"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m25 = require("./index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m26 = require("./subfolder"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m27 = require("./subfolder/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m28 = require("./subfolder/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m29 = require("./subfolder2"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m30 = require("./subfolder2/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m31 = require("./subfolder2/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m32 = require("./subfolder2/another"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m33 = require("./subfolder2/another/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m34 = require("./subfolder2/another/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -154, +167 lines =@@ - void m21; - void m22; - void m23; -+ -+ - - // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import m24 = require("./"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m25 = require("./index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m26 = require("./subfolder"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m27 = require("./subfolder/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m28 = require("./subfolder/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m29 = require("./subfolder2"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m30 = require("./subfolder2/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m31 = require("./subfolder2/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m32 = require("./subfolder2/another"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m33 = require("./subfolder2/another/"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -+ - import m34 = require("./subfolder2/another/index"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt.diff index 4b9751cb65..623a2be03a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node16).errors.txt.diff @@ -3,34 +3,10 @@ @@= skipped -0, +0 lines =@@ -file.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`. +file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -+index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. --index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. --subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. -+subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. - - - ==== subfolder/index.js (1 errors) ==== - // cjs format file - const a = {}; -+ - export = a; - ~~~~~~~~~~~ - !!! error TS8003: 'export =' can only be used in TypeScript files. -@@= skipped -16, +17 lines =@@ - ==== index.js (2 errors) ==== - // esm format file - const a = {}; -+ - export = a; - ~~~~~~~~~~~ --!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -- ~~~~~~~~~~~ - !!! error TS8003: 'export =' can only be used in TypeScript files. -+ ~~~~~~~~~~~ -+!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - ==== file.js (1 errors) ==== - // esm format file + index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. + subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. +@@= skipped -26, +26 lines =@@ import "fs"; const a = {}; module.exports = a; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt.diff index 22a9f447f2..31a49d11f9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=node18).errors.txt.diff @@ -3,34 +3,10 @@ @@= skipped -0, +0 lines =@@ -file.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`. +file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -+index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. --index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. --subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. -+subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. - - - ==== subfolder/index.js (1 errors) ==== - // cjs format file - const a = {}; -+ - export = a; - ~~~~~~~~~~~ - !!! error TS8003: 'export =' can only be used in TypeScript files. -@@= skipped -16, +17 lines =@@ - ==== index.js (2 errors) ==== - // esm format file - const a = {}; -+ - export = a; - ~~~~~~~~~~~ --!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -- ~~~~~~~~~~~ - !!! error TS8003: 'export =' can only be used in TypeScript files. -+ ~~~~~~~~~~~ -+!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - ==== file.js (1 errors) ==== - // esm format file + index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. + subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. +@@= skipped -26, +26 lines =@@ import "fs"; const a = {}; module.exports = a; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt.diff index d62f9f2874..ed88e6d3b2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt.diff @@ -3,34 +3,10 @@ @@= skipped -0, +0 lines =@@ -file.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`. +file.js(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -+index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. --index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. --subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. -+subfolder/index.js(2,14): error TS8003: 'export =' can only be used in TypeScript files. - - - ==== subfolder/index.js (1 errors) ==== - // cjs format file - const a = {}; -+ - export = a; - ~~~~~~~~~~~ - !!! error TS8003: 'export =' can only be used in TypeScript files. -@@= skipped -16, +17 lines =@@ - ==== index.js (2 errors) ==== - // esm format file - const a = {}; -+ - export = a; - ~~~~~~~~~~~ --!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -- ~~~~~~~~~~~ - !!! error TS8003: 'export =' can only be used in TypeScript files. -+ ~~~~~~~~~~~ -+!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - ==== file.js (1 errors) ==== - // esm format file + index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. + subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. +@@= skipped -26, +26 lines =@@ import "fs"; const a = {}; module.exports = a; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt.diff deleted file mode 100644 index 69b17f91b8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt.diff +++ /dev/null @@ -1,52 +0,0 @@ ---- old.nodeModulesAllowJsImportAssignment(module=node16).errors.txt -+++ new.nodeModulesAllowJsImportAssignment(module=node16).errors.txt -@@= skipped -0, +0 lines =@@ --file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. --file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. --subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. --subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. -+file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. - - - ==== subfolder/index.js (2 errors) ==== - // cjs format file -+ ~~~~~~~~~~~~~~~~~~ - import fs = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - fs.readFile; -+ - export import fs2 = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ==== index.js (2 errors) ==== - // esm format file -+ ~~~~~~~~~~~~~~~~~~ - import fs = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - fs.readFile; -+ - export import fs2 = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -27, +31 lines =@@ - // esm format file - const __require = null; - const _createRequire = null; -+ - import fs = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - fs.readFile; -+ - export import fs2 = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt.diff deleted file mode 100644 index b95116bf28..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt.diff +++ /dev/null @@ -1,52 +0,0 @@ ---- old.nodeModulesAllowJsImportAssignment(module=node18).errors.txt -+++ new.nodeModulesAllowJsImportAssignment(module=node18).errors.txt -@@= skipped -0, +0 lines =@@ --file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. --file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. --subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. --subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. -+file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. - - - ==== subfolder/index.js (2 errors) ==== - // cjs format file -+ ~~~~~~~~~~~~~~~~~~ - import fs = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - fs.readFile; -+ - export import fs2 = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ==== index.js (2 errors) ==== - // esm format file -+ ~~~~~~~~~~~~~~~~~~ - import fs = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - fs.readFile; -+ - export import fs2 = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -27, +31 lines =@@ - // esm format file - const __require = null; - const _createRequire = null; -+ - import fs = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - fs.readFile; -+ - export import fs2 = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt.diff deleted file mode 100644 index c2c9867961..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,52 +0,0 @@ ---- old.nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt -+++ new.nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt -@@= skipped -0, +0 lines =@@ --file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. --file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. --subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. --subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+file.js(3,29): error TS8002: 'import ... =' can only be used in TypeScript files. -+file.js(5,13): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(1,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(3,13): error TS8002: 'import ... =' can only be used in TypeScript files. - - - ==== subfolder/index.js (2 errors) ==== - // cjs format file -+ ~~~~~~~~~~~~~~~~~~ - import fs = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - fs.readFile; -+ - export import fs2 = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ==== index.js (2 errors) ==== - // esm format file -+ ~~~~~~~~~~~~~~~~~~ - import fs = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - fs.readFile; -+ - export import fs2 = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -27, +31 lines =@@ - // esm format file - const __require = null; - const _createRequire = null; -+ - import fs = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - fs.readFile; -+ - export import fs2 = require("fs"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt.diff deleted file mode 100644 index 483f70af3b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- old.nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt -+++ new.nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt -@@= skipped -0, +0 lines =@@ --index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. - subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. - To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. --subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. - subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. - - - ==== subfolder/index.js (4 errors) ==== -@@= skipped -13, +13 lines =@@ - ~~~~~~~~~~~~~ - !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. - !!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. -+ - import mod = require("../index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~ - !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import {f as _f} from "./index.js"; -+ - import mod2 = require("./index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -17, +19 lines =@@ - ==== index.js (3 errors) ==== - // esm format file - import {h as _h} from "./index.js"; -+ - import mod = require("./index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~ - !!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import {f} from "./subfolder/index.js"; -+ - import mod2 = require("./subfolder/index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt.diff deleted file mode 100644 index 681fc86565..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- old.nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt -+++ new.nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt -@@= skipped -0, +0 lines =@@ --index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. - index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. - subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. - To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. --subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. - subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. --subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. - - - ==== subfolder/index.js (4 errors) ==== -@@= skipped -13, +13 lines =@@ - ~~~~~~~~~~~~~ - !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. - !!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. -+ - import mod = require("../index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~~ - !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import {f as _f} from "./index.js"; -+ - import mod2 = require("./index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -17, +19 lines =@@ - ==== index.js (3 errors) ==== - // esm format file - import {h as _h} from "./index.js"; -+ - import mod = require("./index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - ~~~~~~~~~~~~ - !!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. - import {f} from "./subfolder/index.js"; -+ - import mod2 = require("./subfolder/index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt.diff deleted file mode 100644 index fd82370825..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt -+++ new.nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt -@@= skipped -0, +0 lines =@@ --index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. --index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. --subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. --subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(2,36): error TS8002: 'import ... =' can only be used in TypeScript files. -+index.js(4,40): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(2,31): error TS8002: 'import ... =' can only be used in TypeScript files. -+subfolder/index.js(4,36): error TS8002: 'import ... =' can only be used in TypeScript files. - - - ==== subfolder/index.js (2 errors) ==== - // cjs format file - import {h} from "../index.js"; -+ - import mod = require("../index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import {f as _f} from "./index.js"; -+ - import mod2 = require("./index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. -@@= skipped -21, +23 lines =@@ - ==== index.js (2 errors) ==== - // esm format file - import {h as _h} from "./index.js"; -+ - import mod = require("./index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. - import {f} from "./subfolder/index.js"; -+ - import mod2 = require("./subfolder/index.js"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8002: 'import ... =' can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff deleted file mode 100644 index 8e72301611..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.parserArrowFunctionExpression10.errors.txt -+++ new.parserArrowFunctionExpression10.errors.txt -@@= skipped -0, +0 lines =@@ - fileJs.js(1,1): error TS2304: Cannot find name 'a'. -+fileJs.js(1,10): error TS8010: Type annotations can only be used in TypeScript files. - fileJs.js(1,11): error TS2304: Cannot find name 'c'. --fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. - fileJs.js(1,17): error TS2304: Cannot find name 'd'. - fileJs.js(1,27): error TS2304: Cannot find name 'f'. - fileTs.ts(1,1): error TS2304: Cannot find name 'a'. -@@= skipped -12, +12 lines =@@ - a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon - ~ - !!! error TS2304: Cannot find name 'a'. -- ~ --!!! error TS2304: Cannot find name 'c'. -- ~ -+ ~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~ -+!!! error TS2304: Cannot find name 'c'. - ~ - !!! error TS2304: Cannot find name 'd'. - ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff deleted file mode 100644 index 6acd8ac0b6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.parserArrowFunctionExpression13.errors.txt -+++ new.parserArrowFunctionExpression13.errors.txt -@@= skipped -0, +0 lines =@@ - fileJs.js(1,1): error TS2304: Cannot find name 'a'. - fileJs.js(1,11): error TS2304: Cannot find name 'a'. --fileJs.js(1,21): error TS8010: Type annotations can only be used in TypeScript files. -+fileJs.js(1,20): error TS8010: Type annotations can only be used in TypeScript files. - fileTs.ts(1,1): error TS2304: Cannot find name 'a'. - fileTs.ts(1,11): error TS2304: Cannot find name 'a'. - -@@= skipped -10, +10 lines =@@ - !!! error TS2304: Cannot find name 'a'. - ~ - !!! error TS2304: Cannot find name 'a'. -- ~~~ -+ ~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - - ==== fileTs.ts (2 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff deleted file mode 100644 index 43ae273bdb..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.parserArrowFunctionExpression14.errors.txt -+++ new.parserArrowFunctionExpression14.errors.txt -@@= skipped -0, +0 lines =@@ - fileJs.js(1,1): error TS2304: Cannot find name 'a'. --fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. -+fileJs.js(1,10): error TS8010: Type annotations can only be used in TypeScript files. - fileJs.js(1,20): error TS8009: The '?' modifier can only be used in TypeScript files. --fileJs.js(1,23): error TS8010: Type annotations can only be used in TypeScript files. --fileJs.js(1,32): error TS8010: Type annotations can only be used in TypeScript files. -+fileJs.js(1,22): error TS8010: Type annotations can only be used in TypeScript files. -+fileJs.js(1,31): error TS8010: Type annotations can only be used in TypeScript files. - fileJs.js(1,40): error TS2304: Cannot find name 'd'. - fileJs.js(1,46): error TS2304: Cannot find name 'e'. - fileTs.ts(1,1): error TS2304: Cannot find name 'a'. -@@= skipped -13, +13 lines =@@ - a() ? (b: number, c?: string): void => d() : e; // Not legal JS; "Unexpected token ':'" at first colon - ~ - !!! error TS2304: Cannot find name 'a'. -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - ~ - !!! error TS8009: The '?' modifier can only be used in TypeScript files. -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. -- ~~~~ -+ ~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - ~ - !!! error TS2304: Cannot find name 'd'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff deleted file mode 100644 index 3b110331f0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.parserArrowFunctionExpression15.errors.txt -+++ new.parserArrowFunctionExpression15.errors.txt -@@= skipped -0, +0 lines =@@ --fileJs.js(1,18): error TS8010: Type annotations can only be used in TypeScript files. -+fileJs.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== fileJs.js (1 errors) ==== - false ? (param): string => param : null // Not legal JS; "Unexpected token ':'" at last colon -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - - ==== fileTs.ts (0 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff deleted file mode 100644 index a99495fd1a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.parserArrowFunctionExpression16.errors.txt -+++ new.parserArrowFunctionExpression16.errors.txt -@@= skipped -0, +0 lines =@@ --fileJs.js(1,25): error TS8010: Type annotations can only be used in TypeScript files. -+fileJs.js(1,24): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== fileJs.js (1 errors) ==== - true ? false ? (param): string => param : null : null // Not legal JS; "Unexpected token ':'" at last colon -- ~~~~~~ -+ ~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - - ==== fileTs.ts (0 errors) ==== \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff deleted file mode 100644 index 599c1a05ff..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.parserArrowFunctionExpression17.errors.txt -+++ new.parserArrowFunctionExpression17.errors.txt -@@= skipped -0, +0 lines =@@ - fileJs.js(1,1): error TS2304: Cannot find name 'a'. - fileJs.js(1,5): error TS2304: Cannot find name 'b'. -+fileJs.js(1,14): error TS8010: Type annotations can only be used in TypeScript files. - fileJs.js(1,15): error TS2304: Cannot find name 'd'. --fileJs.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. - fileJs.js(1,20): error TS2304: Cannot find name 'e'. - fileTs.ts(1,1): error TS2304: Cannot find name 'a'. - fileTs.ts(1,5): error TS2304: Cannot find name 'b'. -@@= skipped -14, +14 lines =@@ - !!! error TS2304: Cannot find name 'a'. - ~ - !!! error TS2304: Cannot find name 'b'. -- ~ --!!! error TS2304: Cannot find name 'd'. -- ~ -+ ~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~ -+!!! error TS2304: Cannot find name 'd'. - ~ - !!! error TS2304: Cannot find name 'e'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff deleted file mode 100644 index 8cab77cec8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.typeSatisfaction_js.errors.txt -+++ new.typeSatisfaction_js.errors.txt -@@= skipped -0, +0 lines =@@ --/src/a.js(1,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files. -+/src/a.js(1,28): error TS8037: Type satisfaction expressions can only be used in TypeScript files. - - - ==== /src/a.js (1 errors) ==== - var v = undefined satisfies 1; -- ~ -+ ~~ - !!! error TS8037: Type satisfaction expressions can only be used in TypeScript files. - \ No newline at end of file From 732f69980d046fa97f84da491653a25619c82962 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 15:57:23 +0000 Subject: [PATCH 12/31] Refactor JS diagnostics: move to separate file and use visitor pattern Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/js_diagnostics.go | 481 ++++++++++++++++++++++++++++ internal/compiler/program.go | 450 -------------------------- 2 files changed, 481 insertions(+), 450 deletions(-) create mode 100644 internal/compiler/js_diagnostics.go diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go new file mode 100644 index 0000000000..1cf4c5dd6b --- /dev/null +++ b/internal/compiler/js_diagnostics.go @@ -0,0 +1,481 @@ +package compiler + +import ( + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/scanner" +) + +// jsDiagnosticsVisitor is used to find TypeScript-only constructs in JavaScript files +type jsDiagnosticsVisitor struct { + sourceFile *ast.SourceFile + diagnostics []*ast.Diagnostic +} + +// getJSSyntacticDiagnosticsForFile returns diagnostics for TypeScript-only constructs in JavaScript files +func (p *Program) getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { + if result, ok := p.jsDiagnosticCache.Load(sourceFile); ok { + return result + } + + visitor := &jsDiagnosticsVisitor{ + sourceFile: sourceFile, + diagnostics: []*ast.Diagnostic{}, + } + + // Walk the entire AST to find TypeScript-only constructs + visitor.walkNodeForJSDiagnostics(sourceFile.AsNode(), sourceFile.AsNode()) + + p.jsDiagnosticCache.Store(sourceFile, visitor.diagnostics) + return visitor.diagnostics +} + +// walkNodeForJSDiagnostics walks the AST and collects diagnostics for TypeScript-only constructs +func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node) { + if node == nil { + return + } + + // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations + if node.Flags&ast.NodeFlagsReparsed != 0 { + return + } + + // Handle specific parent-child relationships first + switch parent.Kind { + case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: + // Check for question token (optional markers) - only parameters have question tokens + if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } + fallthrough + case ast.KindMethodSignature, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, + ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindVariableDeclaration: + // Check for type annotations + if v.isTypeAnnotation(parent, node) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check node-specific constructs + switch node.Kind { + case ast.KindImportClause: + if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) + return + } + + case ast.KindExportDeclaration: + if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) + return + } + + case ast.KindImportSpecifier: + if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) + return + } + + case ast.KindExportSpecifier: + if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) + return + } + + case ast.KindImportEqualsDeclaration: + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) + return + + case ast.KindExportAssignment: + if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindHeritageClause: + if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == ast.KindImplementsKeyword { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindInterfaceDeclaration: + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) + return + + case ast.KindModuleDeclaration: + moduleKeyword := "module" + // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) + return + + case ast.KindTypeAliasDeclaration: + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) + return + + case ast.KindEnumDeclaration: + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) + return + + case ast.KindNonNullExpression: + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) + return + + case ast.KindAsExpression: + if node.AsAsExpression() != nil { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindSatisfiesExpression: + if node.AsSatisfiesExpression() != nil { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) + return + } + + case ast.KindConstructor, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: + // Check for signature declarations (functions without bodies) + if v.isSignatureDeclaration(node) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) + return + } + } + + // Check for type parameters, type arguments, and modifiers + v.checkTypeParametersAndModifiers(node) + + // Recursively walk children + node.ForEachChild(func(child *ast.Node) bool { + v.walkNodeForJSDiagnostics(child, node) + return false + }) +} + +// isTypeAnnotation checks if a node is a type annotation in relation to its parent +func (v *jsDiagnosticsVisitor) isTypeAnnotation(parent *ast.Node, node *ast.Node) bool { + switch parent.Kind { + case ast.KindFunctionDeclaration: + return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node + case ast.KindFunctionExpression: + return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node + case ast.KindArrowFunction: + return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node + case ast.KindMethodDeclaration: + return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node + case ast.KindGetAccessor: + return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node + case ast.KindSetAccessor: + return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node + case ast.KindConstructor: + return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node + case ast.KindVariableDeclaration: + return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node + case ast.KindParameter: + return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node + case ast.KindPropertyDeclaration: + return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node + } + return false +} + +// isSignatureDeclaration checks if a node is a signature declaration (function without body) +func (v *jsDiagnosticsVisitor) isSignatureDeclaration(node *ast.Node) bool { + switch node.Kind { + case ast.KindFunctionDeclaration: + return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil + case ast.KindMethodDeclaration: + return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil + case ast.KindConstructor: + return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil + } + return false +} + +// checkTypeParametersAndModifiers checks for type parameters, type arguments, and modifiers +func (v *jsDiagnosticsVisitor) checkTypeParametersAndModifiers(node *ast.Node) { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return + } + + // Check type parameters + if v.hasTypeParameters(node) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) + } + + // Check type arguments + if v.hasTypeArguments(node) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) + } + + // Check modifiers + v.checkModifiers(node) +} + +// hasTypeParameters checks if a node has type parameters +func (v *jsDiagnosticsVisitor) hasTypeParameters(node *ast.Node) bool { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return false + } + + var typeParameters *ast.NodeList + switch node.Kind { + case ast.KindClassDeclaration: + if node.AsClassDeclaration() != nil { + typeParameters = node.AsClassDeclaration().TypeParameters + } + case ast.KindClassExpression: + if node.AsClassExpression() != nil { + typeParameters = node.AsClassExpression().TypeParameters + } + case ast.KindMethodDeclaration: + if node.AsMethodDeclaration() != nil { + typeParameters = node.AsMethodDeclaration().TypeParameters + } + case ast.KindConstructor: + if node.AsConstructorDeclaration() != nil { + typeParameters = node.AsConstructorDeclaration().TypeParameters + } + case ast.KindGetAccessor: + if node.AsGetAccessorDeclaration() != nil { + typeParameters = node.AsGetAccessorDeclaration().TypeParameters + } + case ast.KindSetAccessor: + if node.AsSetAccessorDeclaration() != nil { + typeParameters = node.AsSetAccessorDeclaration().TypeParameters + } + case ast.KindFunctionExpression: + if node.AsFunctionExpression() != nil { + typeParameters = node.AsFunctionExpression().TypeParameters + } + case ast.KindFunctionDeclaration: + if node.AsFunctionDeclaration() != nil { + typeParameters = node.AsFunctionDeclaration().TypeParameters + } + case ast.KindArrowFunction: + if node.AsArrowFunction() != nil { + typeParameters = node.AsArrowFunction().TypeParameters + } + default: + return false + } + + if typeParameters == nil { + return false + } + + // Check if all type parameters are reparsed (JSDoc originated) + for _, tp := range typeParameters.Nodes { + if tp.Flags&ast.NodeFlagsReparsed == 0 { + return true // Found a non-reparsed type parameter, so this is a TypeScript-only construct + } + } + + return false // All type parameters are reparsed (JSDoc originated), so this is valid in JS +} + +// hasTypeArguments checks if a node has type arguments +func (v *jsDiagnosticsVisitor) hasTypeArguments(node *ast.Node) bool { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return false + } + + var typeArguments *ast.NodeList + switch node.Kind { + case ast.KindCallExpression: + if node.AsCallExpression() != nil { + typeArguments = node.AsCallExpression().TypeArguments + } + case ast.KindNewExpression: + if node.AsNewExpression() != nil { + typeArguments = node.AsNewExpression().TypeArguments + } + case ast.KindExpressionWithTypeArguments: + if node.AsExpressionWithTypeArguments() != nil { + typeArguments = node.AsExpressionWithTypeArguments().TypeArguments + } + case ast.KindJsxSelfClosingElement: + if node.AsJsxSelfClosingElement() != nil { + typeArguments = node.AsJsxSelfClosingElement().TypeArguments + } + case ast.KindJsxOpeningElement: + if node.AsJsxOpeningElement() != nil { + typeArguments = node.AsJsxOpeningElement().TypeArguments + } + case ast.KindTaggedTemplateExpression: + if node.AsTaggedTemplateExpression() != nil { + typeArguments = node.AsTaggedTemplateExpression().TypeArguments + } + } + + if typeArguments == nil { + return false + } + + // Check if all type arguments are reparsed (JSDoc originated) + for _, ta := range typeArguments.Nodes { + if ta.Flags&ast.NodeFlagsReparsed == 0 { + return true // Found a non-reparsed type argument, so this is a TypeScript-only construct + } + } + + return false // All type arguments are reparsed (JSDoc originated), so this is valid in JS +} + +// checkModifiers checks for TypeScript-only modifiers on various declaration types +func (v *jsDiagnosticsVisitor) checkModifiers(node *ast.Node) { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return + } + + // Check for TypeScript-only modifiers on various declaration types + switch node.Kind { + case ast.KindVariableStatement: + if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { + v.checkModifierList(node.AsVariableStatement().Modifiers(), true) + } + case ast.KindPropertyDeclaration: + if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { + v.checkPropertyModifiers(node.AsPropertyDeclaration().Modifiers()) + } + case ast.KindParameter: + if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { + v.checkParameterModifiers(node.AsParameterDeclaration().Modifiers()) + } + } +} + +// checkModifierList checks a list of modifiers for TypeScript-only constructs +func (v *jsDiagnosticsVisitor) checkModifierList(modifiers *ast.ModifierList, isConstValid bool) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + v.checkModifier(modifier, isConstValid) + } +} + +// checkPropertyModifiers checks property modifiers for TypeScript-only constructs +func (v *jsDiagnosticsVisitor) checkPropertyModifiers(modifiers *ast.ModifierList) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + // Property modifiers allow static and accessor, but not other TypeScript modifiers + switch modifier.Kind { + case ast.KindStaticKeyword, ast.KindAccessorKeyword: + // These are valid in JavaScript + continue + default: + if v.isTypeScriptOnlyModifier(modifier) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, v.getTokenText(modifier))) + } + } + } +} + +// checkParameterModifiers checks parameter modifiers for TypeScript-only constructs +func (v *jsDiagnosticsVisitor) checkParameterModifiers(modifiers *ast.ModifierList) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + if v.isTypeScriptOnlyModifier(modifier) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) + } + } +} + +// checkModifier checks a single modifier for TypeScript-only constructs +func (v *jsDiagnosticsVisitor) checkModifier(modifier *ast.Node, isConstValid bool) { + switch modifier.Kind { + case ast.KindConstKeyword: + if !isConstValid { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "const")) + } + case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, + ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, v.getTokenText(modifier))) + case ast.KindStaticKeyword, ast.KindExportKeyword, ast.KindDefaultKeyword, ast.KindAccessorKeyword: + // These are valid in JavaScript + } +} + +// isTypeScriptOnlyModifier checks if a modifier is TypeScript-only +func (v *jsDiagnosticsVisitor) isTypeScriptOnlyModifier(modifier *ast.Node) bool { + switch modifier.Kind { + case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, + ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: + return true + } + return false +} + +// getTokenText returns the text representation of a token +func (v *jsDiagnosticsVisitor) getTokenText(node *ast.Node) string { + switch node.Kind { + case ast.KindPublicKeyword: + return "public" + case ast.KindPrivateKeyword: + return "private" + case ast.KindProtectedKeyword: + return "protected" + case ast.KindReadonlyKeyword: + return "readonly" + case ast.KindDeclareKeyword: + return "declare" + case ast.KindAbstractKeyword: + return "abstract" + case ast.KindOverrideKeyword: + return "override" + case ast.KindInKeyword: + return "in" + case ast.KindOutKeyword: + return "out" + case ast.KindConstKeyword: + return "const" + case ast.KindStaticKeyword: + return "static" + case ast.KindAccessorKeyword: + return "accessor" + default: + return "" + } +} + +// createDiagnosticForNode creates a diagnostic for a specific node +func (v *jsDiagnosticsVisitor) createDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { + return ast.NewDiagnostic(v.sourceFile, v.getErrorRangeForNode(node), message, args...) +} + +// getErrorRangeForNode gets the error range for a node, skipping trivia +func (v *jsDiagnosticsVisitor) getErrorRangeForNode(node *ast.Node) core.TextRange { + if node == nil { + return core.TextRange{} + } + + // Use scanner to skip trivia for proper diagnostic positioning + start := scanner.SkipTrivia(v.sourceFile.Text(), node.Pos()) + return core.NewTextRange(start, node.End()) +} diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 6e5281f7b5..febb4de7a5 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -955,453 +955,3 @@ var plainJSErrors = collections.NewSetFromItems( // Type errors diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value.Code(), ) - -// JS syntactic diagnostics functions - -func (p *Program) getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { - if result, ok := p.jsDiagnosticCache.Load(sourceFile); ok { - return result - } - - diagnostics := []*ast.Diagnostic{} - - // Walk the entire AST to find TypeScript-only constructs - p.walkNodeForJSDiagnostics(sourceFile, sourceFile.AsNode(), sourceFile.AsNode(), &diagnostics) - - p.jsDiagnosticCache.Store(sourceFile, diagnostics) - return diagnostics -} - -func (p *Program) walkNodeForJSDiagnostics(sourceFile *ast.SourceFile, node *ast.Node, parent *ast.Node, diags *[]*ast.Diagnostic) { - if node == nil { - return - } - - // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations - if node.Flags&ast.NodeFlagsReparsed != 0 { - return - } - - // Handle specific parent-child relationships first - switch parent.Kind { - case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: - // Check for question token (optional markers) - only parameters have question tokens - if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) - return - } - fallthrough - case ast.KindMethodSignature, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, - ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindVariableDeclaration: - // Check for type annotations - if p.isTypeAnnotation(parent, node) { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) - return - } - } - - // Check node-specific constructs - switch node.Kind { - case ast.KindImportClause: - if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) - return - } - - case ast.KindExportDeclaration: - if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) - return - } - - case ast.KindImportSpecifier: - if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) - return - } - - case ast.KindExportSpecifier: - if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) - return - } - - case ast.KindImportEqualsDeclaration: - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) - return - - case ast.KindExportAssignment: - if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) - return - } - - case ast.KindHeritageClause: - if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == ast.KindImplementsKeyword { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) - return - } - - case ast.KindInterfaceDeclaration: - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) - return - - case ast.KindModuleDeclaration: - moduleKeyword := "module" - // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) - return - - case ast.KindTypeAliasDeclaration: - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) - return - - case ast.KindEnumDeclaration: - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) - return - - case ast.KindNonNullExpression: - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) - return - - case ast.KindAsExpression: - if node.AsAsExpression() != nil { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) - return - } - - case ast.KindSatisfiesExpression: - if node.AsSatisfiesExpression() != nil { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) - return - } - - case ast.KindConstructor, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: - // Check for signature declarations (functions without bodies) - if p.isSignatureDeclaration(node) { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) - return - } - } - - // Check for type parameters, type arguments, and modifiers - p.checkTypeParametersAndModifiers(sourceFile, node, diags) - - // Recursively walk children - node.ForEachChild(func(child *ast.Node) bool { - p.walkNodeForJSDiagnostics(sourceFile, child, node, diags) - return false - }) -} - -func (p *Program) isTypeAnnotation(parent *ast.Node, node *ast.Node) bool { - switch parent.Kind { - case ast.KindFunctionDeclaration: - return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node - case ast.KindFunctionExpression: - return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node - case ast.KindArrowFunction: - return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node - case ast.KindMethodDeclaration: - return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node - case ast.KindGetAccessor: - return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node - case ast.KindSetAccessor: - return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node - case ast.KindConstructor: - return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node - case ast.KindVariableDeclaration: - return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node - case ast.KindParameter: - return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node - case ast.KindPropertyDeclaration: - return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node - } - return false -} - -func (p *Program) isSignatureDeclaration(node *ast.Node) bool { - switch node.Kind { - case ast.KindFunctionDeclaration: - return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil - case ast.KindMethodDeclaration: - return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil - case ast.KindConstructor: - return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil - } - return false -} - -func (p *Program) checkTypeParametersAndModifiers(sourceFile *ast.SourceFile, node *ast.Node, diags *[]*ast.Diagnostic) { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&ast.NodeFlagsReparsed != 0 { - return - } - - // Check type parameters - if p.hasTypeParameters(node) { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) - } - - // Check type arguments - if p.hasTypeArguments(node) { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) - } - - // Check modifiers - p.checkModifiers(sourceFile, node, diags) -} - -func (p *Program) hasTypeParameters(node *ast.Node) bool { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&ast.NodeFlagsReparsed != 0 { - return false - } - - var typeParameters *ast.NodeList - switch node.Kind { - case ast.KindClassDeclaration: - if node.AsClassDeclaration() != nil { - typeParameters = node.AsClassDeclaration().TypeParameters - } - case ast.KindClassExpression: - if node.AsClassExpression() != nil { - typeParameters = node.AsClassExpression().TypeParameters - } - case ast.KindMethodDeclaration: - if node.AsMethodDeclaration() != nil { - typeParameters = node.AsMethodDeclaration().TypeParameters - } - case ast.KindConstructor: - if node.AsConstructorDeclaration() != nil { - typeParameters = node.AsConstructorDeclaration().TypeParameters - } - case ast.KindGetAccessor: - if node.AsGetAccessorDeclaration() != nil { - typeParameters = node.AsGetAccessorDeclaration().TypeParameters - } - case ast.KindSetAccessor: - if node.AsSetAccessorDeclaration() != nil { - typeParameters = node.AsSetAccessorDeclaration().TypeParameters - } - case ast.KindFunctionExpression: - if node.AsFunctionExpression() != nil { - typeParameters = node.AsFunctionExpression().TypeParameters - } - case ast.KindFunctionDeclaration: - if node.AsFunctionDeclaration() != nil { - typeParameters = node.AsFunctionDeclaration().TypeParameters - } - case ast.KindArrowFunction: - if node.AsArrowFunction() != nil { - typeParameters = node.AsArrowFunction().TypeParameters - } - default: - return false - } - - if typeParameters == nil { - return false - } - - // Check if all type parameters are reparsed (JSDoc originated) - for _, tp := range typeParameters.Nodes { - if tp.Flags&ast.NodeFlagsReparsed == 0 { - return true // Found a non-reparsed type parameter, so this is a TypeScript-only construct - } - } - - return false // All type parameters are reparsed (JSDoc originated), so this is valid in JS -} - -func (p *Program) hasTypeArguments(node *ast.Node) bool { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&ast.NodeFlagsReparsed != 0 { - return false - } - - var typeArguments *ast.NodeList - switch node.Kind { - case ast.KindCallExpression: - if node.AsCallExpression() != nil { - typeArguments = node.AsCallExpression().TypeArguments - } - case ast.KindNewExpression: - if node.AsNewExpression() != nil { - typeArguments = node.AsNewExpression().TypeArguments - } - case ast.KindExpressionWithTypeArguments: - if node.AsExpressionWithTypeArguments() != nil { - typeArguments = node.AsExpressionWithTypeArguments().TypeArguments - } - case ast.KindJsxSelfClosingElement: - if node.AsJsxSelfClosingElement() != nil { - typeArguments = node.AsJsxSelfClosingElement().TypeArguments - } - case ast.KindJsxOpeningElement: - if node.AsJsxOpeningElement() != nil { - typeArguments = node.AsJsxOpeningElement().TypeArguments - } - case ast.KindTaggedTemplateExpression: - if node.AsTaggedTemplateExpression() != nil { - typeArguments = node.AsTaggedTemplateExpression().TypeArguments - } - } - - if typeArguments == nil { - return false - } - - // Check if all type arguments are reparsed (JSDoc originated) - for _, ta := range typeArguments.Nodes { - if ta.Flags&ast.NodeFlagsReparsed == 0 { - return true // Found a non-reparsed type argument, so this is a TypeScript-only construct - } - } - - return false // All type arguments are reparsed (JSDoc originated), so this is valid in JS -} - -func (p *Program) checkModifiers(sourceFile *ast.SourceFile, node *ast.Node, diags *[]*ast.Diagnostic) { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&ast.NodeFlagsReparsed != 0 { - return - } - - // Check for TypeScript-only modifiers on various declaration types - switch node.Kind { - case ast.KindVariableStatement: - if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { - p.checkModifierList(sourceFile, node.AsVariableStatement().Modifiers(), true, diags) - } - case ast.KindPropertyDeclaration: - if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { - p.checkPropertyModifiers(sourceFile, node.AsPropertyDeclaration().Modifiers(), diags) - } - case ast.KindParameter: - if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { - p.checkParameterModifiers(sourceFile, node.AsParameterDeclaration().Modifiers(), diags) - } - } -} - -func (p *Program) checkModifierList(sourceFile *ast.SourceFile, modifiers *ast.ModifierList, isConstValid bool, diags *[]*ast.Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - // Bail out early if this modifier has NodeFlagsReparsed - if modifier.Flags&ast.NodeFlagsReparsed != 0 { - continue - } - p.checkModifier(sourceFile, modifier, isConstValid, diags) - } -} - -func (p *Program) checkPropertyModifiers(sourceFile *ast.SourceFile, modifiers *ast.ModifierList, diags *[]*ast.Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - // Bail out early if this modifier has NodeFlagsReparsed - if modifier.Flags&ast.NodeFlagsReparsed != 0 { - continue - } - // Property modifiers allow static and accessor, but not other TypeScript modifiers - switch modifier.Kind { - case ast.KindStaticKeyword, ast.KindAccessorKeyword: - // These are valid in JavaScript - continue - default: - if p.isTypeScriptOnlyModifier(modifier) { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, p.getTokenText(modifier))) - } - } - } -} - -func (p *Program) checkParameterModifiers(sourceFile *ast.SourceFile, modifiers *ast.ModifierList, diags *[]*ast.Diagnostic) { - if modifiers == nil { - return - } - - for _, modifier := range modifiers.Nodes { - // Bail out early if this modifier has NodeFlagsReparsed - if modifier.Flags&ast.NodeFlagsReparsed != 0 { - continue - } - if p.isTypeScriptOnlyModifier(modifier) { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) - } - } -} - -func (p *Program) checkModifier(sourceFile *ast.SourceFile, modifier *ast.Node, isConstValid bool, diags *[]*ast.Diagnostic) { - switch modifier.Kind { - case ast.KindConstKeyword: - if !isConstValid { - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "const")) - } - case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, - ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: - *diags = append(*diags, p.createDiagnosticForNode(sourceFile, modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, p.getTokenText(modifier))) - case ast.KindStaticKeyword, ast.KindExportKeyword, ast.KindDefaultKeyword, ast.KindAccessorKeyword: - // These are valid in JavaScript - } -} - -func (p *Program) isTypeScriptOnlyModifier(modifier *ast.Node) bool { - switch modifier.Kind { - case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, - ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: - return true - } - return false -} - -func (p *Program) getTokenText(node *ast.Node) string { - switch node.Kind { - case ast.KindPublicKeyword: - return "public" - case ast.KindPrivateKeyword: - return "private" - case ast.KindProtectedKeyword: - return "protected" - case ast.KindReadonlyKeyword: - return "readonly" - case ast.KindDeclareKeyword: - return "declare" - case ast.KindAbstractKeyword: - return "abstract" - case ast.KindOverrideKeyword: - return "override" - case ast.KindInKeyword: - return "in" - case ast.KindOutKeyword: - return "out" - case ast.KindConstKeyword: - return "const" - case ast.KindStaticKeyword: - return "static" - case ast.KindAccessorKeyword: - return "accessor" - default: - return "" - } -} - -func (p *Program) createDiagnosticForNode(sourceFile *ast.SourceFile, node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { - return ast.NewDiagnostic(sourceFile, p.getErrorRangeForNode(sourceFile, node), message, args...) -} - -func (p *Program) getErrorRangeForNode(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange { - if node == nil { - return core.TextRange{} - } - - // Use scanner to skip trivia for proper diagnostic positioning - start := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) - return core.NewTextRange(start, node.End()) -} From eaeddaf712a564e51cee71bba8a09296be76e20c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 16:15:44 +0000 Subject: [PATCH 13/31] Refactor JS diagnostics to use binder and scanner functions for better error positioning Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/js_diagnostics.go | 55 +-- .../jsSyntacticDiagnostics.errors.txt | 61 ++-- ...ssingTypeArgsOnJSConstructCalls.errors.txt | 11 +- ...lationConstructorOverloadSyntax.errors.txt | 2 +- .../jsFileCompilationEnumSyntax.errors.txt | 4 +- ...mpilationFunctionOverloadSyntax.errors.txt | 4 +- ...sFileCompilationInterfaceSyntax.errors.txt | 4 +- ...CompilationMethodOverloadSyntax.errors.txt | 2 +- .../jsFileCompilationModuleSyntax.errors.txt | 4 +- ...sFileCompilationTypeAliasSyntax.errors.txt | 4 +- ...ationTypeParameterSyntaxOfClass.errors.txt | 4 +- ...arameterSyntaxOfClassExpression.errors.txt | 4 +- ...onTypeParameterSyntaxOfFunction.errors.txt | 4 +- .../compiler/jsdocTypedefNoCrash2.errors.txt | 4 +- ...signmentInNamespaceDeclaration1.errors.txt | 16 +- .../jsDeclarationsClassesErr.errors.txt | 16 +- .../jsDeclarationsEnums.errors.txt | 91 ++--- .../jsDeclarationsInterfaces.errors.txt | 197 ++++------- .../jsDeclarationsTypeReferences4.errors.txt | 14 +- ...TypeArgsOnJSConstructCalls.errors.txt.diff | 27 +- ...nConstructorOverloadSyntax.errors.txt.diff | 11 - ...sFileCompilationEnumSyntax.errors.txt.diff | 13 +- ...tionFunctionOverloadSyntax.errors.txt.diff | 13 - ...CompilationInterfaceSyntax.errors.txt.diff | 13 +- ...lationMethodOverloadSyntax.errors.txt.diff | 11 - ...ileCompilationModuleSyntax.errors.txt.diff | 13 +- ...CompilationTypeAliasSyntax.errors.txt.diff | 13 +- ...TypeParameterSyntaxOfClass.errors.txt.diff | 4 +- ...terSyntaxOfClassExpression.errors.txt.diff | 4 +- ...eParameterSyntaxOfFunction.errors.txt.diff | 4 +- .../jsdocTypedefNoCrash2.errors.txt.diff | 6 +- ...entInNamespaceDeclaration1.errors.txt.diff | 30 +- .../jsDeclarationsClassesErr.errors.txt.diff | 27 +- .../jsDeclarationsEnums.errors.txt.diff | 164 --------- .../jsDeclarationsInterfaces.errors.txt.diff | 329 +----------------- ...eclarationsTypeReferences4.errors.txt.diff | 28 +- 36 files changed, 233 insertions(+), 978 deletions(-) delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index 1cf4c5dd6b..b2a58a3f18 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -2,7 +2,7 @@ package compiler import ( "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/binder" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/scanner" ) @@ -27,8 +27,8 @@ func (p *Program) getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) [ // Walk the entire AST to find TypeScript-only constructs visitor.walkNodeForJSDiagnostics(sourceFile.AsNode(), sourceFile.AsNode()) - p.jsDiagnosticCache.Store(sourceFile, visitor.diagnostics) - return visitor.diagnostics + diagnostics, _ := p.jsDiagnosticCache.LoadOrStore(sourceFile, visitor.diagnostics) + return diagnostics } // walkNodeForJSDiagnostics walks the AST and collects diagnostics for TypeScript-only constructs @@ -384,7 +384,7 @@ func (v *jsDiagnosticsVisitor) checkPropertyModifiers(modifiers *ast.ModifierLis continue default: if v.isTypeScriptOnlyModifier(modifier) { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, v.getTokenText(modifier))) + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(modifier.Kind))) } } } @@ -416,7 +416,7 @@ func (v *jsDiagnosticsVisitor) checkModifier(modifier *ast.Node, isConstValid bo } case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, v.getTokenText(modifier))) + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(modifier.Kind))) case ast.KindStaticKeyword, ast.KindExportKeyword, ast.KindDefaultKeyword, ast.KindAccessorKeyword: // These are valid in JavaScript } @@ -432,50 +432,7 @@ func (v *jsDiagnosticsVisitor) isTypeScriptOnlyModifier(modifier *ast.Node) bool return false } -// getTokenText returns the text representation of a token -func (v *jsDiagnosticsVisitor) getTokenText(node *ast.Node) string { - switch node.Kind { - case ast.KindPublicKeyword: - return "public" - case ast.KindPrivateKeyword: - return "private" - case ast.KindProtectedKeyword: - return "protected" - case ast.KindReadonlyKeyword: - return "readonly" - case ast.KindDeclareKeyword: - return "declare" - case ast.KindAbstractKeyword: - return "abstract" - case ast.KindOverrideKeyword: - return "override" - case ast.KindInKeyword: - return "in" - case ast.KindOutKeyword: - return "out" - case ast.KindConstKeyword: - return "const" - case ast.KindStaticKeyword: - return "static" - case ast.KindAccessorKeyword: - return "accessor" - default: - return "" - } -} - // createDiagnosticForNode creates a diagnostic for a specific node func (v *jsDiagnosticsVisitor) createDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { - return ast.NewDiagnostic(v.sourceFile, v.getErrorRangeForNode(node), message, args...) -} - -// getErrorRangeForNode gets the error range for a node, skipping trivia -func (v *jsDiagnosticsVisitor) getErrorRangeForNode(node *ast.Node) core.TextRange { - if node == nil { - return core.TextRange{} - } - - // Use scanner to skip trivia for proper diagnostic positioning - start := scanner.SkipTrivia(v.sourceFile.Text(), node.Pos()) - return core.NewTextRange(start, node.End()) + return ast.NewDiagnostic(v.sourceFile, binder.GetErrorRangeForNode(v.sourceFile, node), message, args...) } diff --git a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt index 38b0898d4d..66e08671ec 100644 --- a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt +++ b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt @@ -1,10 +1,10 @@ test.js(2,18): error TS8010: Type annotations can only be used in TypeScript files. test.js(2,27): error TS8010: Type annotations can only be used in TypeScript files. -test.js(7,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -test.js(13,1): error TS8008: Type aliases can only be used in TypeScript files. -test.js(16,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -test.js(23,1): error TS8006: 'module' declarations can only be used in TypeScript files. -test.js(28,1): error TS8006: 'module' declarations can only be used in TypeScript files. +test.js(7,11): error TS8006: 'interface' declarations can only be used in TypeScript files. +test.js(13,6): error TS8008: Type aliases can only be used in TypeScript files. +test.js(16,6): error TS8006: 'enum' declarations can only be used in TypeScript files. +test.js(23,8): error TS8006: 'module' declarations can only be used in TypeScript files. +test.js(28,11): error TS8006: 'module' declarations can only be used in TypeScript files. test.js(33,13): error TS8013: Non-null assertions can only be used in TypeScript files. test.js(36,24): error TS8016: Type assertion expressions can only be used in TypeScript files. test.js(39,17): error TS2741: Property 'name' is missing in type '{}' but required in type 'Config'. @@ -30,15 +30,15 @@ test.js(60,35): error TS8012: Parameter modifiers can only be used in TypeScript test.js(60,46): error TS8010: Type annotations can only be used in TypeScript files. test.js(69,25): error TS8009: The '?' modifier can only be used in TypeScript files. test.js(69,28): error TS8010: Type annotations can only be used in TypeScript files. -test.js(74,1): error TS8017: Signature declarations can only be used in TypeScript files. -test.js(77,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +test.js(74,10): error TS8017: Signature declarations can only be used in TypeScript files. +test.js(77,10): error TS8004: Type parameter declarations can only be used in TypeScript files. test.js(77,24): error TS8010: Type annotations can only be used in TypeScript files. test.js(77,28): error TS8010: Type annotations can only be used in TypeScript files. test.js(82,19): error TS2693: 'string' only refers to a type, but is being used as a value here. test.js(82,27): error TS1109: Expression expected. test.js(85,29): error TS8005: 'implements' clauses can only be used in TypeScript files. test.js(90,22): error TS8010: Type annotations can only be used in TypeScript files. -test.js(94,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +test.js(94,11): error TS8006: 'interface' declarations can only be used in TypeScript files. ==== test.js (41 errors) ==== @@ -53,50 +53,39 @@ test.js(94,1): error TS8006: 'interface' declarations can only be used in TypeSc // Interface declarations should be flagged as errors interface Person { - ~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. name: string; - ~~~~~~~~~~~~~~~~~ age: number; - ~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. // Type alias declarations should be flagged as errors type StringOrNumber = string | number; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS8008: Type aliases can only be used in TypeScript files. // Enum declarations should be flagged as errors enum Color { - ~~~~~~~~~~~~ + ~~~~~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. Red, - ~~~~~~~~ Green, - ~~~~~~~~~~ Blue - ~~~~~~~~ } - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. // Module declarations should be flagged as errors module MyModule { - ~~~~~~~~~~~~~~~~~ + ~~~~~~~~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. export var x = 1; - ~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'module' declarations can only be used in TypeScript files. // Namespace declarations should be flagged as errors namespace MyNamespace { - ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. export var y = 2; - ~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'module' declarations can only be used in TypeScript files. // Non-null assertions should be flagged as errors let value = getValue()!; @@ -192,21 +181,19 @@ test.js(94,1): error TS8006: 'interface' declarations can only be used in TypeSc // Signature declarations should be flagged as errors function signatureOnly(x: number): string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~ !!! error TS8017: Signature declarations can only be used in TypeScript files. // Type parameters should be flagged as errors function generic(x: T): T { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ !!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS8010: Type annotations can only be used in TypeScript files. return x; - ~~~~~~~~~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. // Type arguments should be flagged as errors let array = Array(); @@ -230,9 +217,7 @@ test.js(94,1): error TS8006: 'interface' declarations can only be used in TypeSc } interface Config { - ~~~~~~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. name: string; - ~~~~~~~~~~~~~~~~~ - } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt index 57c4eb2f2c..f6d6e2dfb3 100644 --- a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@ -1,4 +1,4 @@ -BaseB.js(2,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +BaseB.js(2,22): error TS8004: Type parameter declarations can only be used in TypeScript files. BaseB.js(2,25): error TS1005: ',' expected. BaseB.js(3,14): error TS2304: Cannot find name 'Class'. BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. @@ -17,28 +17,23 @@ SubB.js(3,35): error TS8011: Type arguments can only be used in TypeScript files ==== BaseB.js (6 errors) ==== import BaseA from './BaseA'; export default class B { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ !!! error TS1005: ',' expected. _AClass: Class; - ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2304: Cannot find name 'Class'. ~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. constructor(AClass: Class) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ !!! error TS2304: Cannot find name 'Class'. ~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. this._AClass = AClass; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ==== SubB.js (1 errors) ==== import SubA from './SubA'; import BaseB from './BaseB'; diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt index 0ff11a2b87..c2eefe3d28 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt @@ -4,7 +4,7 @@ a.js(2,3): error TS8017: Signature declarations can only be used in TypeScript f ==== a.js (1 errors) ==== class A { constructor(); - ~~~~~~~~~~~~~~ + ~~~~~~~~~~~ !!! error TS8017: Signature declarations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt index b6b379725e..dcf285d25c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt @@ -1,7 +1,7 @@ -a.js(1,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +a.js(1,6): error TS8006: 'enum' declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== enum E { } - ~~~~~~~~~~ + ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt index 5af6399a20..1c10528f03 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt @@ -1,8 +1,8 @@ -a.js(1,1): error TS8017: Signature declarations can only be used in TypeScript files. +a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== function foo(); - ~~~~~~~~~~~~~~~ + ~~~ !!! error TS8017: Signature declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt index 1ac15ecbbc..82dbb5ba73 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt @@ -1,7 +1,7 @@ -a.js(1,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +a.js(1,11): error TS8006: 'interface' declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== interface I { } - ~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt index 1d54c0e41e..470da0781c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt @@ -4,7 +4,7 @@ a.js(2,3): error TS8017: Signature declarations can only be used in TypeScript f ==== a.js (1 errors) ==== class A { foo(); - ~~~~~~ + ~~~ !!! error TS8017: Signature declarations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt index 28d9ad8889..75eeb33902 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt @@ -1,7 +1,7 @@ -a.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. +a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== module M { } - ~~~~~~~~~~~~ + ~ !!! error TS8006: 'module' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt index 42fde88372..20317e1a2d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt @@ -1,7 +1,7 @@ -a.js(1,1): error TS8008: Type aliases can only be used in TypeScript files. +a.js(1,6): error TS8008: Type aliases can only be used in TypeScript files. ==== a.js (1 errors) ==== type a = b; - ~~~~~~~~~~~ + ~ !!! error TS8008: Type aliases can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt index bf7b029203..84a8a9b049 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt @@ -1,7 +1,7 @@ -a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(1,7): error TS8004: Type parameter declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== class C { } - ~~~~~~~~~~~~~~ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt index 8f28eb5593..c88df8b64d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt @@ -1,8 +1,8 @@ -a.js(1,13): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(1,7): error TS8004: Type parameter declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== const Bar = class {}; - ~~~~~~~~~~~ + ~~~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt index 8edbd7e8b6..edac463a92 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt @@ -1,7 +1,7 @@ -a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== function F() { } - ~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt index b0d2ab3a88..6239c728e6 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt @@ -1,9 +1,9 @@ -export.js(1,1): error TS8008: Type aliases can only be used in TypeScript files. +export.js(1,13): error TS8008: Type aliases can only be used in TypeScript files. ==== export.js (1 errors) ==== export type foo = 5; - ~~~~~~~~~~~~~~~~~~~~ + ~~~ !!! error TS8008: Type aliases can only be used in TypeScript files. /** * @typedef {{ diff --git a/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt b/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt index 9c939b76f0..2a89d7f79a 100644 --- a/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt @@ -1,28 +1,24 @@ -a.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. +a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. a.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. -b.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. +b.js(1,11): error TS8006: 'module' declarations can only be used in TypeScript files. b.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. ==== a.js (2 errors) ==== module foo { - ~~~~~~~~~~~~ + ~~~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. this.bar = 4; - ~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2331: 'this' cannot be referenced in a module or namespace body. } - ~ -!!! error TS8006: 'module' declarations can only be used in TypeScript files. ==== b.js (2 errors) ==== namespace blah { - ~~~~~~~~~~~~~~~~ + ~~~~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. this.prop = 42; - ~~~~~~~~~~~~~~~~~~~ ~~~~ !!! error TS2331: 'this' cannot be referenced in a module or namespace body. } - ~ -!!! error TS8006: 'module' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt index 254cdc6f9e..18b031cc03 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt @@ -1,6 +1,6 @@ -index.js(4,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(4,14): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(8,1): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(8,14): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(8,27): error TS8011: Type arguments can only be used in TypeScript files. index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. @@ -26,26 +26,22 @@ index.js(68,11): error TS8010: Type annotations can only be used in TypeScript f // but we should be able to synthesize declarations from the symbols regardless export class M { - ~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. field: T; - ~~~~~~~~~~~~~ ~ !!! error TS8010: Type annotations can only be used in TypeScript files. } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. export class N extends M { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. other: U; - ~~~~~~~~~~~~~ ~ !!! error TS8010: Type annotations can only be used in TypeScript files. } - ~ -!!! error TS8004: Type parameter declarations can only be used in TypeScript files. export class O { [idx: string]: string; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt index 399d04fb81..05318558dd 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt @@ -1,15 +1,15 @@ -index.js(4,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(6,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(10,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(14,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(18,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(22,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(24,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(30,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(35,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(41,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(47,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -index.js(55,1): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(4,13): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(6,13): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(10,6): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(14,6): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(18,13): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(22,13): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(24,13): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(30,13): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(35,13): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(41,19): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(47,13): error TS8006: 'enum' declarations can only be used in TypeScript files. +index.js(55,19): error TS8006: 'enum' declarations can only be used in TypeScript files. ==== index.js (12 errors) ==== @@ -17,114 +17,85 @@ index.js(55,1): error TS8006: 'enum' declarations can only be used in TypeScript // but we should be able to synthesize declarations from the symbols regardless export enum A {} - ~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. export enum B { - ~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. Member - ~~~~~~~~~~ } - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. enum C {} - ~~~~~~~~~ + ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. export { C }; enum DD {} - ~~~~~~~~~~ + ~~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. export { DD as D }; export enum E {} - ~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. export { E as EE }; export { F as FF }; export enum F {} - ~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'enum' declarations can only be used in TypeScript files. export enum G { - ~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. A = 1, - ~~~~~~~~~~ B, - ~~~~~~ C - ~~~~~ } - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. export enum H { - ~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. A = "a", - ~~~~~~~~~~~~ B = "b" - ~~~~~~~~~~~ } - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. export enum I { - ~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. A = "a", - ~~~~~~~~~~~~ B = 0, - ~~~~~~~~~~ C - ~~~~~ } - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. export const enum J { - ~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. A = 1, - ~~~~~~~~~~ B, - ~~~~~~ C - ~~~~~ } - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. export enum K { - ~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. None = 0, - ~~~~~~~~~~~~~~~ A = 1 << 0, - ~~~~~~~~~~~~~~~ B = 1 << 1, - ~~~~~~~~~~~~~~~ C = 1 << 2, - ~~~~~~~~~~~~~~~ Mask = A | B | C, - ~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. export const enum L { - ~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. None = 0, - ~~~~~~~~~~~~~~~ A = 1 << 0, - ~~~~~~~~~~~~~~~ B = 1 << 1, - ~~~~~~~~~~~~~~~ C = 1 << 2, - ~~~~~~~~~~~~~~~ Mask = A | B | C, - ~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'enum' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt index 7780b6f7c6..2e672eb09b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt @@ -1,29 +1,29 @@ -index.js(4,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(6,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(10,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(31,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(35,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(39,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(43,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(45,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(49,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(53,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(57,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(61,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(65,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(67,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(71,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(75,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(80,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(84,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(87,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(91,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(95,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(100,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(105,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(107,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(111,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(115,1): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(4,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(6,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(10,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(31,11): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(35,11): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(39,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(43,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(45,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(49,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(53,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(57,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(61,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(65,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(67,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(71,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(75,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(80,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(84,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(87,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(91,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(95,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(100,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(105,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(107,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(111,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +index.js(115,18): error TS8006: 'interface' declarations can only be used in TypeScript files. ==== index.js (26 errors) ==== @@ -31,227 +31,170 @@ index.js(115,1): error TS8006: 'interface' declarations can only be used in Type // but we should be able to synthesize declarations from the symbols regardless export interface A {} - ~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface B { - ~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. cat: string; - ~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface C { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. field: T & U; - ~~~~~~~~~~~~~~~~~ optionalField?: T; - ~~~~~~~~~~~~~~~~~~~~~~ readonly readonlyField: T & U; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ readonly readonlyOptionalField?: U; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (): number; - ~~~~~~~~~~~~~~~ (x: T): U; - ~~~~~~~~~~~~~~ (x: Q): T & Q; - ~~~~~~~~~~~~~~~~~~~~~ - new (): string; - ~~~~~~~~~~~~~~~~~~~ new (x: T): U; - ~~~~~~~~~~~~~~~~~~ new (x: Q): T & Q; - ~~~~~~~~~~~~~~~~~~~~~~~~~ - method(): number; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method(a: T & Q): Q & number; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method(a?: number): number; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method(...args: any[]): number; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - optMethod?(): number; - ~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. interface G {} - ~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export { G }; interface HH {} - ~~~~~~~~~~~~~~~ + ~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export { HH as H }; export interface I {} - ~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export { I as II }; export { J as JJ }; export interface J {} - ~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface K extends I,J { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. x: string; - ~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface L extends K { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. y: string; - ~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface M { - ~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. field: T; - ~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface N extends M { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. other: U; - ~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface O { - ~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: string]: string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface P extends O {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface Q extends O { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: string]: "ok"; - ~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface R extends O { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: number]: "ok"; - ~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface S extends O { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: string]: "ok"; - ~~~~~~~~~~~~~~~~~~~~~~~~ [idx: number]: never; - ~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface T { - ~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: number]: string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface U extends T {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface V extends T { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: string]: string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface W extends T { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: number]: "ok"; - ~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface X extends T { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: string]: string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~ [idx: number]: "ok"; - ~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface Y { - ~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: string]: {x: number}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [idx: number]: {x: number, y: number}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface Z extends Y {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface AA extends Y { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: string]: {x: number, y: number}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface BB extends Y { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: number]: {x: 0, y: 0}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. export interface CC extends Y { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. [idx: string]: {x: number, y: number}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [idx: number]: {x: 0, y: 0}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~ -!!! error TS8006: 'interface' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt index 619007ca15..d3923e7dac 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt @@ -1,4 +1,4 @@ -index.js(4,1): error TS8006: 'module' declarations can only be used in TypeScript files. +index.js(4,18): error TS8006: 'module' declarations can only be used in TypeScript files. ==== index.js (1 errors) ==== @@ -6,24 +6,16 @@ index.js(4,1): error TS8006: 'module' declarations can only be used in TypeScrip export const Something = 2; // to show conflict that can occur // @ts-ignore export namespace A { - ~~~~~~~~~~~~~~~~~~~~ + ~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. // @ts-ignore - ~~~~~~~~~~~~~~~~~ export namespace B { - ~~~~~~~~~~~~~~~~~~~~~~~~ const Something = require("fs").Something; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const thing = new Something(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @ts-ignore - ~~~~~~~~~~~~~~~~~~~~~ export { thing }; - ~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~ } - ~ -!!! error TS8006: 'module' declarations can only be used in TypeScript files. ==== node_modules/@types/node/index.d.ts (0 errors) ==== declare module "fs" { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff index c36d844b7d..fa69aff6d1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff @@ -2,7 +2,7 @@ +++ new.fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@= skipped -0, +0 lines =@@ -BaseB.js(2,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -+BaseB.js(2,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++BaseB.js(2,22): error TS8004: Type parameter declarations can only be used in TypeScript files. BaseB.js(2,25): error TS1005: ',' expected. BaseB.js(3,14): error TS2304: Cannot find name 'Class'. BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. @@ -18,30 +18,11 @@ import BaseA from './BaseA'; export default class B { - ~~~~~~~~ --!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ~ + !!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ !!! error TS1005: ',' expected. - _AClass: Class; -+ ~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~ - !!! error TS2304: Cannot find name 'Class'. - ~~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - constructor(AClass: Class) { -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~ - !!! error TS2304: Cannot find name 'Class'. - ~~~~~~~~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - this._AClass = AClass; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~~~~~ - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ==== SubB.js (1 errors) ==== +@@= skipped -21, +21 lines =@@ import SubA from './SubA'; import BaseB from './BaseB'; export default class SubB extends BaseB { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff deleted file mode 100644 index 794ce9898b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsFileCompilationConstructorOverloadSyntax.errors.txt -+++ new.jsFileCompilationConstructorOverloadSyntax.errors.txt -@@= skipped -3, +3 lines =@@ - ==== a.js (1 errors) ==== - class A { - constructor(); -- ~~~~~~~~~~~ -+ ~~~~~~~~~~~~~~ - !!! error TS8017: Signature declarations can only be used in TypeScript files. - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationEnumSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationEnumSyntax.errors.txt.diff index e80e3cf99b..fa6f9b2dcb 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationEnumSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationEnumSyntax.errors.txt.diff @@ -3,16 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,6): error TS8006: 'enum' declarations can only be used in TypeScript files. -- -- + a.js(1,6): error TS8006: 'enum' declarations can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+ -+ ==== a.js (1 errors) ==== enum E { } -- ~ -+ ~~~~~~~~~~ - !!! error TS8006: 'enum' declarations can only be used in TypeScript files. \ No newline at end of file + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff deleted file mode 100644 index cdef364579..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsFileCompilationFunctionOverloadSyntax.errors.txt -+++ new.jsFileCompilationFunctionOverloadSyntax.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(1,10): error TS8017: Signature declarations can only be used in TypeScript files. -+a.js(1,1): error TS8017: Signature declarations can only be used in TypeScript files. - - - ==== a.js (1 errors) ==== - function foo(); -- ~~~ -+ ~~~~~~~~~~~~~~~ - !!! error TS8017: Signature declarations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff index f854e7ee44..ed74994827 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff @@ -3,16 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,11): error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- + a.js(1,11): error TS8006: 'interface' declarations can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ ==== a.js (1 errors) ==== interface I { } -- ~ -+ ~~~~~~~~~~~~~~~ - !!! error TS8006: 'interface' declarations can only be used in TypeScript files. \ No newline at end of file + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff deleted file mode 100644 index e8fe861040..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.jsFileCompilationMethodOverloadSyntax.errors.txt -+++ new.jsFileCompilationMethodOverloadSyntax.errors.txt -@@= skipped -3, +3 lines =@@ - ==== a.js (1 errors) ==== - class A { - foo(); -- ~~~ -+ ~~~~~~ - !!! error TS8017: Signature declarations can only be used in TypeScript files. - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationModuleSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationModuleSyntax.errors.txt.diff index 18ab189b20..7463231c17 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationModuleSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationModuleSyntax.errors.txt.diff @@ -3,16 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. -- -- + a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. -+ -+ ==== a.js (1 errors) ==== module M { } -- ~ -+ ~~~~~~~~~~~~ - !!! error TS8006: 'module' declarations can only be used in TypeScript files. \ No newline at end of file + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff index c164e98564..4cef0c19e6 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff @@ -3,16 +3,11 @@ @@= skipped -0, +0 lines =@@ -error TS5055: Cannot write file 'a.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. --a.js(1,6): error TS8008: Type aliases can only be used in TypeScript files. -- -- + a.js(1,6): error TS8008: Type aliases can only be used in TypeScript files. + + -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,1): error TS8008: Type aliases can only be used in TypeScript files. -+ -+ ==== a.js (1 errors) ==== type a = b; -- ~ -+ ~~~~~~~~~~~ - !!! error TS8008: Type aliases can only be used in TypeScript files. \ No newline at end of file + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff index 3645a6d4bb..cb23443027 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff @@ -8,11 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(1,7): error TS8004: Type parameter declarations can only be used in TypeScript files. + + ==== a.js (1 errors) ==== class C { } - ~ -+ ~~~~~~~~~~~~~~ ++ ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff index 1bcc64608e..b0b971420a 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff @@ -2,12 +2,12 @@ +++ new.jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt @@= skipped -0, +0 lines =@@ -a.js(1,19): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(1,13): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(1,7): error TS8004: Type parameter declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== const Bar = class {}; - ~ -+ ~~~~~~~~~~~ ++ ~~~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff index 9638d0c1cf..ef66719877 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff @@ -8,11 +8,11 @@ - -!!! error TS5055: Cannot write file 'a.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. -+a.js(1,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. + + ==== a.js (1 errors) ==== function F() { } - ~ -+ ~~~~~~~~~~~~~~~~~~~ ++ ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff index 78dd8fda10..294da8e1b7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff @@ -2,20 +2,18 @@ +++ new.jsdocTypedefNoCrash2.errors.txt @@= skipped -0, +0 lines =@@ -export.js(1,13): error TS2451: Cannot redeclare block-scoped variable 'foo'. --export.js(1,13): error TS8008: Type aliases can only be used in TypeScript files. + export.js(1,13): error TS8008: Type aliases can only be used in TypeScript files. -export.js(6,14): error TS2451: Cannot redeclare block-scoped variable 'foo'. - - -==== export.js (3 errors) ==== -+export.js(1,1): error TS8008: Type aliases can only be used in TypeScript files. + + +==== export.js (1 errors) ==== export type foo = 5; -- ~~~ + ~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'foo'. - ~~~ -+ ~~~~~~~~~~~~~~~~~~~~ !!! error TS8008: Type aliases can only be used in TypeScript files. /** * @typedef {{ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff index ad4992268d..a4f96717f1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff @@ -1,37 +1,19 @@ --- old.thisAssignmentInNamespaceDeclaration1.errors.txt +++ new.thisAssignmentInNamespaceDeclaration1.errors.txt @@= skipped -0, +0 lines =@@ --a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. -+a.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. + a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. a.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. -b.js(1,11): error TS8006: 'namespace' declarations can only be used in TypeScript files. -+b.js(1,1): error TS8006: 'module' declarations can only be used in TypeScript files. ++b.js(1,11): error TS8006: 'module' declarations can only be used in TypeScript files. b.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. - ==== a.js (2 errors) ==== - module foo { -- ~~~ --!!! error TS8006: 'module' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~ - this.bar = 4; -+ ~~~~~~~~~~~~~~~~~ - ~~~~ - !!! error TS2331: 'this' cannot be referenced in a module or namespace body. - } -+ ~ -+!!! error TS8006: 'module' declarations can only be used in TypeScript files. - +@@= skipped -15, +15 lines =@@ ==== b.js (2 errors) ==== namespace blah { -- ~~~~ + ~~~~ -!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'module' declarations can only be used in TypeScript files. this.prop = 42; -+ ~~~~~~~~~~~~~~~~~~~ ~~~~ - !!! error TS2331: 'this' cannot be referenced in a module or namespace body. - } -+ ~ -+!!! error TS8006: 'module' declarations can only be used in TypeScript files. - \ No newline at end of file + !!! error TS2331: 'this' cannot be referenced in a module or namespace body. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff index 558a18abee..fe3ef77090 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff @@ -2,11 +2,11 @@ +++ new.jsDeclarationsClassesErr.errors.txt @@= skipped -0, +0 lines =@@ -index.js(4,16): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(4,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(4,14): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(8,16): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(8,29): error TS8011: Type arguments can only be used in TypeScript files. -+index.js(8,1): error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(8,14): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(8,27): error TS8011: Type arguments can only be used in TypeScript files. index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. @@ -16,30 +16,19 @@ export class M { - ~ --!!! error TS8004: Type parameter declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~ ++ ~ + !!! error TS8004: Type parameter declarations can only be used in TypeScript files. field: T; -+ ~~~~~~~~~~~~~ ~ - !!! error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -8, +8 lines =@@ } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. export class N extends M { - ~ --!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++ ~ + !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. other: U; -+ ~~~~~~~~~~~~~ - ~ - !!! error TS8010: Type annotations can only be used in TypeScript files. - } -+ ~ -+!!! error TS8004: Type parameter declarations can only be used in TypeScript files. - - export class O { - [idx: string]: string; \ No newline at end of file + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff deleted file mode 100644 index bf84cfe593..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff +++ /dev/null @@ -1,164 +0,0 @@ ---- old.jsDeclarationsEnums.errors.txt -+++ new.jsDeclarationsEnums.errors.txt -@@= skipped -0, +0 lines =@@ --index.js(4,13): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(6,13): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(10,6): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(14,6): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(18,13): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(22,13): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(24,13): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(30,13): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(35,13): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(41,19): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(47,13): error TS8006: 'enum' declarations can only be used in TypeScript files. --index.js(55,19): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(4,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(6,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(10,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(14,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(18,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(22,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(24,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(30,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(35,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(41,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(47,1): error TS8006: 'enum' declarations can only be used in TypeScript files. -+index.js(55,1): error TS8006: 'enum' declarations can only be used in TypeScript files. - - - ==== index.js (12 errors) ==== -@@= skipped -16, +16 lines =@@ - // but we should be able to synthesize declarations from the symbols regardless - - export enum A {} -- ~ -+ ~~~~~~~~~~~~~~~~ - !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum B { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~ - Member -+ ~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - enum C {} -- ~ -+ ~~~~~~~~~ - !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export { C }; - - enum DD {} -- ~~ -+ ~~~~~~~~~~ - !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export { DD as D }; - - export enum E {} -- ~ -+ ~~~~~~~~~~~~~~~~ - !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - export { E as EE }; - - export { F as FF }; - export enum F {} -- ~ -+ ~~~~~~~~~~~~~~~~ - !!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum G { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~ - A = 1, -+ ~~~~~~~~~~ - B, -+ ~~~~~~ - C -+ ~~~~~ - } -+ ~ -+!!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum H { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~ - A = "a", -+ ~~~~~~~~~~~~ - B = "b" -+ ~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum I { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~ - A = "a", -+ ~~~~~~~~~~~~ - B = 0, -+ ~~~~~~~~~~ - C -+ ~~~~~ - } -+ ~ -+!!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export const enum J { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~ - A = 1, -+ ~~~~~~~~~~ - B, -+ ~~~~~~ - C -+ ~~~~~ - } -+ ~ -+!!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export enum K { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~ - None = 0, -+ ~~~~~~~~~~~~~~~ - A = 1 << 0, -+ ~~~~~~~~~~~~~~~ - B = 1 << 1, -+ ~~~~~~~~~~~~~~~ - C = 1 << 2, -+ ~~~~~~~~~~~~~~~ - Mask = A | B | C, -+ ~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'enum' declarations can only be used in TypeScript files. - - export const enum L { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~ - None = 0, -+ ~~~~~~~~~~~~~~~ - A = 1 << 0, -+ ~~~~~~~~~~~~~~~ - B = 1 << 1, -+ ~~~~~~~~~~~~~~~ - C = 1 << 2, -+ ~~~~~~~~~~~~~~~ - Mask = A | B | C, -+ ~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'enum' declarations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff index 4f567d8bba..d8f703a957 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff @@ -1,133 +1,28 @@ --- old.jsDeclarationsInterfaces.errors.txt +++ new.jsDeclarationsInterfaces.errors.txt -@@= skipped -0, +0 lines =@@ --index.js(4,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(6,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(10,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(31,11): error TS8006: 'interface' declarations can only be used in TypeScript files. +@@= skipped -1, +1 lines =@@ + index.js(6,18): error TS8006: 'interface' declarations can only be used in TypeScript files. + index.js(10,18): error TS8006: 'interface' declarations can only be used in TypeScript files. + index.js(31,11): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(33,10): error TS18043: Types cannot appear in export declarations in JavaScript files. --index.js(35,11): error TS8006: 'interface' declarations can only be used in TypeScript files. + index.js(35,11): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(37,10): error TS18043: Types cannot appear in export declarations in JavaScript files. --index.js(39,18): error TS8006: 'interface' declarations can only be used in TypeScript files. + index.js(39,18): error TS8006: 'interface' declarations can only be used in TypeScript files. -index.js(40,10): error TS18043: Types cannot appear in export declarations in JavaScript files. -index.js(42,10): error TS18043: Types cannot appear in export declarations in JavaScript files. --index.js(43,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(45,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(49,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(53,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(57,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(61,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(65,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(67,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(71,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(75,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(80,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(84,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(87,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(91,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(95,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(100,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(105,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(107,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(111,18): error TS8006: 'interface' declarations can only be used in TypeScript files. --index.js(115,18): error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- + index.js(43,18): error TS8006: 'interface' declarations can only be used in TypeScript files. + index.js(45,18): error TS8006: 'interface' declarations can only be used in TypeScript files. + index.js(49,18): error TS8006: 'interface' declarations can only be used in TypeScript files. +@@= skipped -28, +24 lines =@@ + index.js(115,18): error TS8006: 'interface' declarations can only be used in TypeScript files. + + -==== index.js (30 errors) ==== -+index.js(4,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(6,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(10,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(31,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(35,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(39,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(43,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(45,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(49,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(53,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(57,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(61,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(65,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(67,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(71,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(75,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(80,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(84,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(87,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(91,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(95,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(100,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(105,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(107,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(111,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+index.js(115,1): error TS8006: 'interface' declarations can only be used in TypeScript files. -+ -+ +==== index.js (26 errors) ==== // Pretty much all of this should be an error, (since interfaces are forbidden in js), // but we should be able to synthesize declarations from the symbols regardless - export interface A {} -- ~ -+ ~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface B { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~ - cat: string; -+ ~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface C { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ - field: T & U; -+ ~~~~~~~~~~~~~~~~~ - optionalField?: T; -+ ~~~~~~~~~~~~~~~~~~~~~~ - readonly readonlyField: T & U; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - readonly readonlyOptionalField?: U; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - (): number; -+ ~~~~~~~~~~~~~~~ - (x: T): U; -+ ~~~~~~~~~~~~~~ - (x: Q): T & Q; -+ ~~~~~~~~~~~~~~~~~~~~~ -+ - - new (): string; -+ ~~~~~~~~~~~~~~~~~~~ - new (x: T): U; -+ ~~~~~~~~~~~~~~~~~~ - new (x: Q): T & Q; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+ - - method(): number; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - method(a: T & Q): Q & number; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - method(a?: number): number; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - method(...args: any[]): number; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ - - optMethod?(): number; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - interface G {} -- ~ -+ ~~~~~~~~~~~~~~ +@@= skipped -42, +42 lines =@@ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export { G }; @@ -135,8 +30,7 @@ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. interface HH {} -- ~~ -+ ~~~~~~~~~~~~~~~ + ~~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export { HH as H }; @@ -144,8 +38,7 @@ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. export interface I {} -- ~ -+ ~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS8006: 'interface' declarations can only be used in TypeScript files. export { I as II }; - ~ @@ -155,191 +48,5 @@ - ~ -!!! error TS18043: Types cannot appear in export declarations in JavaScript files. export interface J {} -- ~ -+ ~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface K extends I,J { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - x: string; -+ ~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface L extends K { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - y: string; -+ ~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface M { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~ - field: T; -+ ~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface N extends M { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - other: U; -+ ~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface O { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~ - [idx: string]: string; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface P extends O {} -- ~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface Q extends O { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: string]: "ok"; -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface R extends O { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: number]: "ok"; -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface S extends O { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: string]: "ok"; -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: number]: never; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface T { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~ - [idx: number]: string; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface U extends T {} -- ~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - - export interface V extends T { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: string]: string; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface W extends T { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: number]: "ok"; -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface X extends T { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: string]: string; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: number]: "ok"; -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface Y { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~ - [idx: string]: {x: number}; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: number]: {x: number, y: number}; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface Z extends Y {} -- ~ -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface AA extends Y { -- ~~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: string]: {x: number, y: number}; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface BB extends Y { -- ~~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: number]: {x: 0, y: 0}; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - - export interface CC extends Y { -- ~~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: string]: {x: number, y: number}; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [idx: number]: {x: 0, y: 0}; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~ -+!!! error TS8006: 'interface' declarations can only be used in TypeScript files. - \ No newline at end of file + ~ + !!! error TS8006: 'interface' declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff index f9d8b04d2b..7585170f91 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff @@ -2,34 +2,16 @@ +++ new.jsDeclarationsTypeReferences4.errors.txt @@= skipped -0, +0 lines =@@ -index.js(4,18): error TS8006: 'namespace' declarations can only be used in TypeScript files. -+index.js(4,1): error TS8006: 'module' declarations can only be used in TypeScript files. ++index.js(4,18): error TS8006: 'module' declarations can only be used in TypeScript files. ==== index.js (1 errors) ==== -@@= skipped -5, +5 lines =@@ - export const Something = 2; // to show conflict that can occur +@@= skipped -6, +6 lines =@@ // @ts-ignore export namespace A { -- ~ + ~ -!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8006: 'module' declarations can only be used in TypeScript files. // @ts-ignore -+ ~~~~~~~~~~~~~~~~~ export namespace B { -+ ~~~~~~~~~~~~~~~~~~~~~~~~ - const Something = require("fs").Something; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const thing = new Something(); -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // @ts-ignore -+ ~~~~~~~~~~~~~~~~~~~~~ - export { thing }; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ - } -+ ~~~~~ - } -+ ~ -+!!! error TS8006: 'module' declarations can only be used in TypeScript files. - - ==== node_modules/@types/node/index.d.ts (0 errors) ==== - declare module "fs" { \ No newline at end of file + const Something = require("fs").Something; \ No newline at end of file From 03054353462f538b3b4351bd6e08e061b8e029cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 17:22:14 +0000 Subject: [PATCH 14/31] Fix JS diagnostic positioning and detection issues Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/js_diagnostics.go | 89 ++++++++++++++++++- .../jsSyntacticDiagnostics.errors.txt | 4 +- ...ypeArgumentCount1(strict=false).errors.txt | 8 +- ...TypeArgumentCount1(strict=true).errors.txt | 10 +-- ...ssingTypeArgsOnJSConstructCalls.errors.txt | 4 +- ...FileCompilationAbstractModifier.errors.txt | 5 +- ...lationPublicMethodSyntaxOfClass.errors.txt | 5 +- ...signmentInNamespaceDeclaration1.errors.txt | 4 +- .../jsDeclarationsClassesErr.errors.txt | 4 +- .../jsDeclarationsTypeReferences4.errors.txt | 4 +- .../conformance/override_js3.errors.txt | 17 ++++ .../plainJSGrammarErrors.errors.txt | 5 +- ...TypeArgsOnJSConstructCalls.errors.txt.diff | 18 +--- ...ompilationAbstractModifier.errors.txt.diff | 19 ---- ...nPublicMethodSyntaxOfClass.errors.txt.diff | 18 ---- ...entInNamespaceDeclaration1.errors.txt.diff | 19 ---- .../jsDeclarationsClassesErr.errors.txt.diff | 11 +-- ...eclarationsTypeReferences4.errors.txt.diff | 17 ---- .../conformance/override_js3.errors.txt.diff | 21 ----- .../plainJSGrammarErrors.errors.txt.diff | 13 +-- 20 files changed, 142 insertions(+), 153 deletions(-) create mode 100644 testdata/baselines/reference/submodule/conformance/override_js3.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicMethodSyntaxOfClass.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index b2a58a3f18..3035ba9a0f 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -3,6 +3,7 @@ package compiler import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/binder" + "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/scanner" ) @@ -108,7 +109,16 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent * case ast.KindModuleDeclaration: moduleKeyword := "module" - // For now, we'll just use "module" as the default since we don't have a flag to distinguish namespace vs module + if node.AsModuleDeclaration() != nil { + switch node.AsModuleDeclaration().Keyword { + case ast.KindNamespaceKeyword: + moduleKeyword = "namespace" + case ast.KindModuleKeyword: + moduleKeyword = "module" + case ast.KindGlobalKeyword: + moduleKeyword = "global" + } + } v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) return @@ -207,8 +217,8 @@ func (v *jsDiagnosticsVisitor) checkTypeParametersAndModifiers(node *ast.Node) { } // Check type arguments - if v.hasTypeArguments(node) { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) + if typeArgs := v.getTypeArguments(node); typeArgs != nil { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNodeList(typeArgs, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)) } // Check modifiers @@ -278,6 +288,55 @@ func (v *jsDiagnosticsVisitor) hasTypeParameters(node *ast.Node) bool { return false // All type parameters are reparsed (JSDoc originated), so this is valid in JS } +// getTypeArguments returns the type arguments for a node if it has any +func (v *jsDiagnosticsVisitor) getTypeArguments(node *ast.Node) *ast.NodeList { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return nil + } + + var typeArguments *ast.NodeList + switch node.Kind { + case ast.KindCallExpression: + if node.AsCallExpression() != nil { + typeArguments = node.AsCallExpression().TypeArguments + } + case ast.KindNewExpression: + if node.AsNewExpression() != nil { + typeArguments = node.AsNewExpression().TypeArguments + } + case ast.KindExpressionWithTypeArguments: + if node.AsExpressionWithTypeArguments() != nil { + typeArguments = node.AsExpressionWithTypeArguments().TypeArguments + } + case ast.KindJsxSelfClosingElement: + if node.AsJsxSelfClosingElement() != nil { + typeArguments = node.AsJsxSelfClosingElement().TypeArguments + } + case ast.KindJsxOpeningElement: + if node.AsJsxOpeningElement() != nil { + typeArguments = node.AsJsxOpeningElement().TypeArguments + } + case ast.KindTaggedTemplateExpression: + if node.AsTaggedTemplateExpression() != nil { + typeArguments = node.AsTaggedTemplateExpression().TypeArguments + } + } + + if typeArguments == nil { + return nil + } + + // Check if all type arguments are reparsed (JSDoc originated) + for _, ta := range typeArguments.Nodes { + if ta.Flags&ast.NodeFlagsReparsed == 0 { + return typeArguments // Found a non-reparsed type argument, so return the type arguments + } + } + + return nil // All type arguments are reparsed (JSDoc originated), so this is valid in JS +} + // hasTypeArguments checks if a node has type arguments func (v *jsDiagnosticsVisitor) hasTypeArguments(node *ast.Node) bool { // Bail out early if this node has NodeFlagsReparsed @@ -348,6 +407,18 @@ func (v *jsDiagnosticsVisitor) checkModifiers(node *ast.Node) { if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { v.checkParameterModifiers(node.AsParameterDeclaration().Modifiers()) } + case ast.KindClassDeclaration: + if node.AsClassDeclaration() != nil && node.AsClassDeclaration().Modifiers() != nil { + v.checkModifierList(node.AsClassDeclaration().Modifiers(), false) + } + case ast.KindMethodDeclaration: + if node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Modifiers() != nil { + v.checkModifierList(node.AsMethodDeclaration().Modifiers(), false) + } + case ast.KindFunctionDeclaration: + if node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Modifiers() != nil { + v.checkModifierList(node.AsFunctionDeclaration().Modifiers(), false) + } } } @@ -436,3 +507,15 @@ func (v *jsDiagnosticsVisitor) isTypeScriptOnlyModifier(modifier *ast.Node) bool func (v *jsDiagnosticsVisitor) createDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { return ast.NewDiagnostic(v.sourceFile, binder.GetErrorRangeForNode(v.sourceFile, node), message, args...) } + +// createDiagnosticForNodeList creates a diagnostic for a NodeList +func (v *jsDiagnosticsVisitor) createDiagnosticForNodeList(nodeList *ast.NodeList, message *diagnostics.Message, args ...any) *ast.Diagnostic { + // If the NodeList's location is not set correctly, fall back to using the first node + if nodeList.Loc.Pos() == nodeList.Loc.End() && len(nodeList.Nodes) > 0 { + // Calculate the range from the first to last node + start := nodeList.Nodes[0].Pos() + end := nodeList.Nodes[len(nodeList.Nodes)-1].End() + return ast.NewDiagnostic(v.sourceFile, core.NewTextRange(start, end), message, args...) + } + return ast.NewDiagnostic(v.sourceFile, nodeList.Loc, message, args...) +} diff --git a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt index 66e08671ec..8d70d47a6d 100644 --- a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt +++ b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt @@ -4,7 +4,7 @@ test.js(7,11): error TS8006: 'interface' declarations can only be used in TypeSc test.js(13,6): error TS8008: Type aliases can only be used in TypeScript files. test.js(16,6): error TS8006: 'enum' declarations can only be used in TypeScript files. test.js(23,8): error TS8006: 'module' declarations can only be used in TypeScript files. -test.js(28,11): error TS8006: 'module' declarations can only be used in TypeScript files. +test.js(28,11): error TS8006: 'namespace' declarations can only be used in TypeScript files. test.js(33,13): error TS8013: Non-null assertions can only be used in TypeScript files. test.js(36,24): error TS8016: Type assertion expressions can only be used in TypeScript files. test.js(39,17): error TS2741: Property 'name' is missing in type '{}' but required in type 'Config'. @@ -83,7 +83,7 @@ test.js(94,11): error TS8006: 'interface' declarations can only be used in TypeS // Namespace declarations should be flagged as errors namespace MyNamespace { ~~~~~~~~~~~ -!!! error TS8006: 'module' declarations can only be used in TypeScript files. +!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. export var y = 2; } diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt index c79e6e9f64..7e0c1775a3 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt @@ -1,7 +1,7 @@ error TS5055: Cannot write file 'b.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. -b.js(9,25): error TS8011: Type arguments can only be used in TypeScript files. -b.js(15,25): error TS8011: Type arguments can only be used in TypeScript files. +b.js(9,27): error TS8011: Type arguments can only be used in TypeScript files. +b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. !!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. @@ -19,7 +19,7 @@ b.js(15,25): error TS8011: Type arguments can only be used in TypeScript files. } export class B2 extends A { - ~~~~~~~~~ + ~~~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); @@ -27,7 +27,7 @@ b.js(15,25): error TS8011: Type arguments can only be used in TypeScript files. } export class B3 extends A { - ~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt index 3afdad0463..3d32450ed8 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt @@ -1,9 +1,9 @@ error TS5055: Cannot write file 'b.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. b.js(3,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -b.js(9,25): error TS8011: Type arguments can only be used in TypeScript files. -b.js(15,25): error TS8011: Type arguments can only be used in TypeScript files. +b.js(9,27): error TS8011: Type arguments can only be used in TypeScript files. b.js(15,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. !!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. @@ -23,7 +23,7 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' } export class B2 extends A { - ~~~~~~~~~ + ~~~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); @@ -32,9 +32,9 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' export class B3 extends A { ~~~~~~~~~~~~~~~~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. - ~~~~~~~~~~~~~~~~~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. + ~~~~~~~~~~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); } diff --git a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt index f6d6e2dfb3..26d7ab44ab 100644 --- a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@ -4,7 +4,7 @@ BaseB.js(3,14): error TS2304: Cannot find name 'Class'. BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(4,25): error TS2304: Cannot find name 'Class'. BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. -SubB.js(3,35): error TS8011: Type arguments can only be used in TypeScript files. +SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files. ==== BaseA.js (0 errors) ==== @@ -38,7 +38,7 @@ SubB.js(3,35): error TS8011: Type arguments can only be used in TypeScript files import SubA from './SubA'; import BaseB from './BaseB'; export default class SubB extends BaseB { - ~~~~~~~~~~~ + ~~~~ !!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(SubA); diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt index af2d9bc178..fecf44cbf1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt @@ -1,12 +1,15 @@ error TS5055: Cannot write file 'a.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. +a.js(1,1): error TS8009: The 'abstract' modifier can only be used in TypeScript files. a.js(2,5): error TS8009: The 'abstract' modifier can only be used in TypeScript files. !!! error TS5055: Cannot write file 'a.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. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== abstract class c { + ~~~~~~~~ +!!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. abstract x; ~~~~~~~~ !!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicMethodSyntaxOfClass.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicMethodSyntaxOfClass.errors.txt index 63a92e4e09..c14f1e86e9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicMethodSyntaxOfClass.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicMethodSyntaxOfClass.errors.txt @@ -1,11 +1,14 @@ error TS5055: Cannot write file 'a.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. +a.js(2,5): error TS8009: The 'public' modifier can only be used in TypeScript files. !!! error TS5055: Cannot write file 'a.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. -==== a.js (0 errors) ==== +==== a.js (1 errors) ==== class C { public foo() { + ~~~~~~ +!!! error TS8009: The 'public' modifier can only be used in TypeScript files. } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt b/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt index 2a89d7f79a..3824bc8325 100644 --- a/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt @@ -1,6 +1,6 @@ a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. a.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. -b.js(1,11): error TS8006: 'module' declarations can only be used in TypeScript files. +b.js(1,11): error TS8006: 'namespace' declarations can only be used in TypeScript files. b.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. @@ -16,7 +16,7 @@ b.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace bo ==== b.js (2 errors) ==== namespace blah { ~~~~ -!!! error TS8006: 'module' declarations can only be used in TypeScript files. +!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. this.prop = 42; ~~~~ !!! error TS2331: 'this' cannot be referenced in a module or namespace body. diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt index 18b031cc03..dd581c5344 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt @@ -1,7 +1,7 @@ index.js(4,14): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(8,14): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(8,27): error TS8011: Type arguments can only be used in TypeScript files. +index.js(8,29): error TS8011: Type arguments can only be used in TypeScript files. index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. @@ -36,7 +36,7 @@ index.js(68,11): error TS8010: Type annotations can only be used in TypeScript f export class N extends M { ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~~~~ + ~ !!! error TS8011: Type arguments can only be used in TypeScript files. other: U; ~ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt index d3923e7dac..146844daa3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt @@ -1,4 +1,4 @@ -index.js(4,18): error TS8006: 'module' declarations can only be used in TypeScript files. +index.js(4,18): error TS8006: 'namespace' declarations can only be used in TypeScript files. ==== index.js (1 errors) ==== @@ -7,7 +7,7 @@ index.js(4,18): error TS8006: 'module' declarations can only be used in TypeScri // @ts-ignore export namespace A { ~ -!!! error TS8006: 'module' declarations can only be used in TypeScript files. +!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. // @ts-ignore export namespace B { const Something = require("fs").Something; diff --git a/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt new file mode 100644 index 0000000000..6e1d0dae65 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt @@ -0,0 +1,17 @@ +a.js(7,5): error TS8009: The 'override' modifier can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class B { + foo (v) {} + fooo (v) {} + } + + class D extends B { + override foo (v) {} + ~~~~~~~~ +!!! error TS8009: The 'override' modifier can only be used in TypeScript files. + /** @override */ + fooo (v) {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt index 1b08565cd6..74eb5f8873 100644 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt @@ -6,6 +6,7 @@ plainJSGrammarErrors.js(17,9): error TS18041: A 'return' statement cannot be use plainJSGrammarErrors.js(20,5): error TS1089: 'static' modifier cannot appear on a constructor declaration. plainJSGrammarErrors.js(21,5): error TS1089: 'async' modifier cannot appear on a constructor declaration. plainJSGrammarErrors.js(22,11): error TS1248: A class member cannot have the 'const' keyword. +plainJSGrammarErrors.js(23,5): error TS8009: The 'const' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(23,11): error TS1248: A class member cannot have the 'const' keyword. plainJSGrammarErrors.js(26,11): error TS1030: 'async' modifier already seen. plainJSGrammarErrors.js(28,11): error TS1029: 'static' modifier must precede 'async' modifier. @@ -94,7 +95,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (94 errors) ==== +==== plainJSGrammarErrors.js (95 errors) ==== class C { // #private mistakes q = #unbound @@ -134,6 +135,8 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot ~ !!! error TS1248: A class member cannot have the 'const' keyword. const y() { + ~~~~~ +!!! error TS8009: The 'const' modifier can only be used in TypeScript files. ~ !!! error TS1248: A class member cannot have the 'const' keyword. return 12 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff index fa69aff6d1..9954786528 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff @@ -6,13 +6,6 @@ BaseB.js(2,25): error TS1005: ',' expected. BaseB.js(3,14): error TS2304: Cannot find name 'Class'. BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. - BaseB.js(4,25): error TS2304: Cannot find name 'Class'. - BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. --SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files. -+SubB.js(3,35): error TS8011: Type arguments can only be used in TypeScript files. - - - ==== BaseA.js (0 errors) ==== @@= skipped -16, +16 lines =@@ ==== BaseB.js (6 errors) ==== import BaseA from './BaseA'; @@ -21,13 +14,4 @@ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ - !!! error TS1005: ',' expected. -@@= skipped -21, +21 lines =@@ - import SubA from './SubA'; - import BaseB from './BaseB'; - export default class SubB extends BaseB { -- ~~~~ -+ ~~~~~~~~~~~ - !!! error TS8011: Type arguments can only be used in TypeScript files. - constructor() { - super(SubA); \ No newline at end of file + !!! error TS1005: ',' expected. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff deleted file mode 100644 index 0a5ffccac8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.jsFileCompilationAbstractModifier.errors.txt -+++ new.jsFileCompilationAbstractModifier.errors.txt -@@= skipped -0, +0 lines =@@ - error TS5055: Cannot write file 'a.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. --a.js(1,1): error TS8009: The 'abstract' modifier can only be used in TypeScript files. - a.js(2,5): error TS8009: The 'abstract' modifier can only be used in TypeScript files. - - - !!! error TS5055: Cannot write file 'a.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. --==== a.js (2 errors) ==== -+==== a.js (1 errors) ==== - abstract class c { -- ~~~~~~~~ --!!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. - abstract x; - ~~~~~~~~ - !!! error TS8009: The 'abstract' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicMethodSyntaxOfClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicMethodSyntaxOfClass.errors.txt.diff deleted file mode 100644 index 7b12a213e1..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicMethodSyntaxOfClass.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.jsFileCompilationPublicMethodSyntaxOfClass.errors.txt -+++ new.jsFileCompilationPublicMethodSyntaxOfClass.errors.txt -@@= skipped -0, +0 lines =@@ - error TS5055: Cannot write file 'a.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. --a.js(2,5): error TS8009: The 'public' modifier can only be used in TypeScript files. - - - !!! error TS5055: Cannot write file 'a.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. --==== a.js (1 errors) ==== -+==== a.js (0 errors) ==== - class C { - public foo() { -- ~~~~~~ --!!! error TS8009: The 'public' modifier can only be used in TypeScript files. - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff deleted file mode 100644 index a4f96717f1..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.thisAssignmentInNamespaceDeclaration1.errors.txt -+++ new.thisAssignmentInNamespaceDeclaration1.errors.txt -@@= skipped -0, +0 lines =@@ - a.js(1,8): error TS8006: 'module' declarations can only be used in TypeScript files. - a.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. --b.js(1,11): error TS8006: 'namespace' declarations can only be used in TypeScript files. -+b.js(1,11): error TS8006: 'module' declarations can only be used in TypeScript files. - b.js(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. - - -@@= skipped -15, +15 lines =@@ - ==== b.js (2 errors) ==== - namespace blah { - ~~~~ --!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. -+!!! error TS8006: 'module' declarations can only be used in TypeScript files. - this.prop = 42; - ~~~~ - !!! error TS2331: 'this' cannot be referenced in a module or namespace body. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff index fe3ef77090..149c611c4f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff @@ -5,12 +5,10 @@ +index.js(4,14): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(8,16): error TS8004: Type parameter declarations can only be used in TypeScript files. --index.js(8,29): error TS8011: Type arguments can only be used in TypeScript files. +index.js(8,14): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(8,27): error TS8011: Type arguments can only be used in TypeScript files. + index.js(8,29): error TS8011: Type arguments can only be used in TypeScript files. index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. - index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. @@= skipped -25, +25 lines =@@ // but we should be able to synthesize declarations from the symbols regardless @@ -27,8 +25,5 @@ - ~ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. -- ~ -+ ~~~~ - !!! error TS8011: Type arguments can only be used in TypeScript files. - other: U; - ~ \ No newline at end of file + ~ + !!! error TS8011: Type arguments can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff deleted file mode 100644 index 7585170f91..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.jsDeclarationsTypeReferences4.errors.txt -+++ new.jsDeclarationsTypeReferences4.errors.txt -@@= skipped -0, +0 lines =@@ --index.js(4,18): error TS8006: 'namespace' declarations can only be used in TypeScript files. -+index.js(4,18): error TS8006: 'module' declarations can only be used in TypeScript files. - - - ==== index.js (1 errors) ==== -@@= skipped -6, +6 lines =@@ - // @ts-ignore - export namespace A { - ~ --!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. -+!!! error TS8006: 'module' declarations can only be used in TypeScript files. - // @ts-ignore - export namespace B { - const Something = require("fs").Something; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff deleted file mode 100644 index 81561936e0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.override_js3.errors.txt -+++ new.override_js3.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(7,5): error TS8009: The 'override' modifier can only be used in TypeScript files. -- -- --==== a.js (1 errors) ==== -- class B { -- foo (v) {} -- fooo (v) {} -- } -- -- class D extends B { -- override foo (v) {} -- ~~~~~~~~ --!!! error TS8009: The 'override' modifier can only be used in TypeScript files. -- /** @override */ -- fooo (v) {} -- } -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff index 56d5793373..3f76784f51 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff @@ -6,7 +6,7 @@ plainJSGrammarErrors.js(21,5): error TS1089: 'async' modifier cannot appear on a constructor declaration. -plainJSGrammarErrors.js(22,5): error TS8009: The 'const' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(22,11): error TS1248: A class member cannot have the 'const' keyword. --plainJSGrammarErrors.js(23,5): error TS8009: The 'const' modifier can only be used in TypeScript files. + plainJSGrammarErrors.js(23,5): error TS8009: The 'const' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(23,11): error TS1248: A class member cannot have the 'const' keyword. plainJSGrammarErrors.js(26,11): error TS1030: 'async' modifier already seen. plainJSGrammarErrors.js(28,11): error TS1029: 'static' modifier must precede 'async' modifier. @@ -15,7 +15,7 @@ plainJSGrammarErrors.js(30,5): error TS1031: 'export' modifier cannot appear on class elements of this kind. plainJSGrammarErrors.js(34,22): error TS1005: '{' expected. plainJSGrammarErrors.js(35,9): error TS1054: A 'get' accessor cannot have parameters. -@@= skipped -24, +21 lines =@@ +@@= skipped -24, +22 lines =@@ plainJSGrammarErrors.js(54,8): error TS1030: 'export' modifier already seen. plainJSGrammarErrors.js(55,8): error TS1044: 'static' modifier cannot appear on a module or namespace element. plainJSGrammarErrors.js(56,22): error TS1090: 'static' modifier cannot appear on a parameter. @@ -45,7 +45,7 @@ -==== plainJSGrammarErrors.js (102 errors) ==== -+==== plainJSGrammarErrors.js (94 errors) ==== ++==== plainJSGrammarErrors.js (95 errors) ==== class C { // #private mistakes q = #unbound @@ -58,12 +58,7 @@ ~ !!! error TS1248: A class member cannot have the 'const' keyword. const y() { -- ~~~~~ --!!! error TS8009: The 'const' modifier can only be used in TypeScript files. - ~ - !!! error TS1248: A class member cannot have the 'const' keyword. - return 12 -@@= skipped -21, +17 lines =@@ +@@= skipped -21, +19 lines =@@ export cantExportProperty = 1 ~~~~~~ !!! error TS1031: 'export' modifier cannot appear on class elements of this kind. From 457a6d3af7590d0fb95aa3f5662fd6680396084a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 17:44:04 +0000 Subject: [PATCH 15/31] Fix JS diagnostic positioning for type parameters to match TypeScript reference Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/js_diagnostics.go | 23 +++++++++------ .../jsSyntacticDiagnostics.errors.txt | 4 +-- ...ssingTypeArgsOnJSConstructCalls.errors.txt | 4 +-- ...ationTypeParameterSyntaxOfClass.errors.txt | 4 +-- ...arameterSyntaxOfClassExpression.errors.txt | 4 +-- ...onTypeParameterSyntaxOfFunction.errors.txt | 4 +-- .../jsDeclarationsClassesErr.errors.txt | 8 ++--- ...TypeArgsOnJSConstructCalls.errors.txt.diff | 17 ----------- ...TypeParameterSyntaxOfClass.errors.txt.diff | 16 ---------- ...terSyntaxOfClassExpression.errors.txt.diff | 13 --------- ...eParameterSyntaxOfFunction.errors.txt.diff | 16 ---------- .../jsDeclarationsClassesErr.errors.txt.diff | 29 ------------------- 12 files changed, 28 insertions(+), 114 deletions(-) delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index 3035ba9a0f..879abb3ad8 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -212,8 +212,8 @@ func (v *jsDiagnosticsVisitor) checkTypeParametersAndModifiers(node *ast.Node) { } // Check type parameters - if v.hasTypeParameters(node) { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) + if typeParams := v.getTypeParameters(node); typeParams != nil { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNodeList(typeParams, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) } // Check type arguments @@ -225,11 +225,11 @@ func (v *jsDiagnosticsVisitor) checkTypeParametersAndModifiers(node *ast.Node) { v.checkModifiers(node) } -// hasTypeParameters checks if a node has type parameters -func (v *jsDiagnosticsVisitor) hasTypeParameters(node *ast.Node) bool { +// getTypeParameters returns the type parameters for a node if it has any non-reparsed ones +func (v *jsDiagnosticsVisitor) getTypeParameters(node *ast.Node) *ast.NodeList { // Bail out early if this node has NodeFlagsReparsed if node.Flags&ast.NodeFlagsReparsed != 0 { - return false + return nil } var typeParameters *ast.NodeList @@ -271,21 +271,26 @@ func (v *jsDiagnosticsVisitor) hasTypeParameters(node *ast.Node) bool { typeParameters = node.AsArrowFunction().TypeParameters } default: - return false + return nil } if typeParameters == nil { - return false + return nil } // Check if all type parameters are reparsed (JSDoc originated) for _, tp := range typeParameters.Nodes { if tp.Flags&ast.NodeFlagsReparsed == 0 { - return true // Found a non-reparsed type parameter, so this is a TypeScript-only construct + return typeParameters // Found a non-reparsed type parameter, so return the type parameters } } - return false // All type parameters are reparsed (JSDoc originated), so this is valid in JS + return nil // All type parameters are reparsed (JSDoc originated), so this is valid in JS +} + +// hasTypeParameters checks if a node has type parameters +func (v *jsDiagnosticsVisitor) hasTypeParameters(node *ast.Node) bool { + return v.getTypeParameters(node) != nil } // getTypeArguments returns the type arguments for a node if it has any diff --git a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt index 8d70d47a6d..0a7a1231e2 100644 --- a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt +++ b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt @@ -31,7 +31,7 @@ test.js(60,46): error TS8010: Type annotations can only be used in TypeScript fi test.js(69,25): error TS8009: The '?' modifier can only be used in TypeScript files. test.js(69,28): error TS8010: Type annotations can only be used in TypeScript files. test.js(74,10): error TS8017: Signature declarations can only be used in TypeScript files. -test.js(77,10): error TS8004: Type parameter declarations can only be used in TypeScript files. +test.js(77,18): error TS8004: Type parameter declarations can only be used in TypeScript files. test.js(77,24): error TS8010: Type annotations can only be used in TypeScript files. test.js(77,28): error TS8010: Type annotations can only be used in TypeScript files. test.js(82,19): error TS2693: 'string' only refers to a type, but is being used as a value here. @@ -186,7 +186,7 @@ test.js(94,11): error TS8006: 'interface' declarations can only be used in TypeS // Type parameters should be flagged as errors function generic(x: T): T { - ~~~~~~~ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ !!! error TS8010: Type annotations can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt index 26d7ab44ab..a4e9026a3a 100644 --- a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@ -1,4 +1,4 @@ -BaseB.js(2,22): error TS8004: Type parameter declarations can only be used in TypeScript files. +BaseB.js(2,24): error TS8004: Type parameter declarations can only be used in TypeScript files. BaseB.js(2,25): error TS1005: ',' expected. BaseB.js(3,14): error TS2304: Cannot find name 'Class'. BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. @@ -17,7 +17,7 @@ SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files ==== BaseB.js (6 errors) ==== import BaseA from './BaseA'; export default class B { - ~ + ~~~~~~~~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ !!! error TS1005: ',' expected. diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt index 5db4f981ec..31366a04b9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt @@ -1,11 +1,11 @@ error TS5055: Cannot write file 'a.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. -a.js(1,7): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(1,9): error TS8004: Type parameter declarations can only be used in TypeScript files. !!! error TS5055: Cannot write file 'a.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. ==== a.js (1 errors) ==== class C { } - ~ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt index c88df8b64d..9adc8c87bb 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt @@ -1,8 +1,8 @@ -a.js(1,7): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(1,19): error TS8004: Type parameter declarations can only be used in TypeScript files. ==== a.js (1 errors) ==== const Bar = class {}; - ~~~ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt index 6ded033eb4..831e7c8003 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt @@ -1,11 +1,11 @@ error TS5055: Cannot write file 'a.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. -a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. +a.js(1,12): error TS8004: Type parameter declarations can only be used in TypeScript files. !!! error TS5055: Cannot write file 'a.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. ==== a.js (1 errors) ==== function F() { } - ~ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt index dd581c5344..548135e903 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt @@ -1,6 +1,6 @@ -index.js(4,14): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(4,16): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. -index.js(8,14): error TS8004: Type parameter declarations can only be used in TypeScript files. +index.js(8,16): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(8,29): error TS8011: Type arguments can only be used in TypeScript files. index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. @@ -26,7 +26,7 @@ index.js(68,11): error TS8010: Type annotations can only be used in TypeScript f // but we should be able to synthesize declarations from the symbols regardless export class M { - ~ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. field: T; ~ @@ -34,7 +34,7 @@ index.js(68,11): error TS8010: Type annotations can only be used in TypeScript f } export class N extends M { - ~ + ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. ~ !!! error TS8011: Type arguments can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff deleted file mode 100644 index 9954786528..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.fillInMissingTypeArgsOnJSConstructCalls.errors.txt -+++ new.fillInMissingTypeArgsOnJSConstructCalls.errors.txt -@@= skipped -0, +0 lines =@@ --BaseB.js(2,24): error TS8004: Type parameter declarations can only be used in TypeScript files. -+BaseB.js(2,22): error TS8004: Type parameter declarations can only be used in TypeScript files. - BaseB.js(2,25): error TS1005: ',' expected. - BaseB.js(3,14): error TS2304: Cannot find name 'Class'. - BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. -@@= skipped -16, +16 lines =@@ - ==== BaseB.js (6 errors) ==== - import BaseA from './BaseA'; - export default class B { -- ~~~~~~~~ -+ ~ - !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~ - !!! error TS1005: ',' expected. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff deleted file mode 100644 index e70b2a1f0c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsFileCompilationTypeParameterSyntaxOfClass.errors.txt -+++ new.jsFileCompilationTypeParameterSyntaxOfClass.errors.txt -@@= skipped -0, +0 lines =@@ - error TS5055: Cannot write file 'a.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. --a.js(1,9): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(1,7): error TS8004: Type parameter declarations can only be used in TypeScript files. - - - !!! error TS5055: Cannot write file 'a.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. - ==== a.js (1 errors) ==== - class C { } -- ~ -+ ~ - !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff deleted file mode 100644 index b0b971420a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt -+++ new.jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt -@@= skipped -0, +0 lines =@@ --a.js(1,19): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(1,7): error TS8004: Type parameter declarations can only be used in TypeScript files. - - - ==== a.js (1 errors) ==== - const Bar = class {}; -- ~ -+ ~~~ - !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff deleted file mode 100644 index 682e5e832d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt -+++ new.jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt -@@= skipped -0, +0 lines =@@ - error TS5055: Cannot write file 'a.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. --a.js(1,12): error TS8004: Type parameter declarations can only be used in TypeScript files. -+a.js(1,10): error TS8004: Type parameter declarations can only be used in TypeScript files. - - - !!! error TS5055: Cannot write file 'a.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. - ==== a.js (1 errors) ==== - function F() { } -- ~ -+ ~ - !!! error TS8004: Type parameter declarations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff deleted file mode 100644 index 149c611c4f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.jsDeclarationsClassesErr.errors.txt -+++ new.jsDeclarationsClassesErr.errors.txt -@@= skipped -0, +0 lines =@@ --index.js(4,16): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(4,14): error TS8004: Type parameter declarations can only be used in TypeScript files. - index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. --index.js(8,16): error TS8004: Type parameter declarations can only be used in TypeScript files. -+index.js(8,14): error TS8004: Type parameter declarations can only be used in TypeScript files. - index.js(8,29): error TS8011: Type arguments can only be used in TypeScript files. - index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. - index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. -@@= skipped -25, +25 lines =@@ - // but we should be able to synthesize declarations from the symbols regardless - - export class M { -- ~ -+ ~ - !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - field: T; - ~ -@@= skipped -8, +8 lines =@@ - } - - export class N extends M { -- ~ -+ ~ - !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~ - !!! error TS8011: Type arguments can only be used in TypeScript files. \ No newline at end of file From 88f567fa65d81900f8e58f14445ba42890286d16 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 18:06:31 +0000 Subject: [PATCH 16/31] Remove isTypeScriptOnlyModifier function and fix modifier checking logic Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/js_diagnostics.go | 22 ++--- .../plainJSGrammarErrors.errors.txt | 20 ++++- .../plainJSGrammarErrors.errors.txt.diff | 87 +------------------ 3 files changed, 27 insertions(+), 102 deletions(-) diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index 879abb3ad8..be772bb0c3 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -453,15 +453,14 @@ func (v *jsDiagnosticsVisitor) checkPropertyModifiers(modifiers *ast.ModifierLis if modifier.Flags&ast.NodeFlagsReparsed != 0 { continue } - // Property modifiers allow static and accessor, but not other TypeScript modifiers + // Property modifiers allow static and accessor, but all other modifiers are invalid switch modifier.Kind { case ast.KindStaticKeyword, ast.KindAccessorKeyword: // These are valid in JavaScript continue default: - if v.isTypeScriptOnlyModifier(modifier) { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(modifier.Kind))) - } + // All other modifiers are invalid on properties in JavaScript + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(modifier.Kind))) } } } @@ -477,9 +476,8 @@ func (v *jsDiagnosticsVisitor) checkParameterModifiers(modifiers *ast.ModifierLi if modifier.Flags&ast.NodeFlagsReparsed != 0 { continue } - if v.isTypeScriptOnlyModifier(modifier) { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) - } + // All parameter modifiers are invalid in JavaScript + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(modifier, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)) } } @@ -498,16 +496,6 @@ func (v *jsDiagnosticsVisitor) checkModifier(modifier *ast.Node, isConstValid bo } } -// isTypeScriptOnlyModifier checks if a modifier is TypeScript-only -func (v *jsDiagnosticsVisitor) isTypeScriptOnlyModifier(modifier *ast.Node) bool { - switch modifier.Kind { - case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword, ast.KindReadonlyKeyword, - ast.KindDeclareKeyword, ast.KindAbstractKeyword, ast.KindOverrideKeyword, ast.KindInKeyword, ast.KindOutKeyword: - return true - } - return false -} - // createDiagnosticForNode creates a diagnostic for a specific node func (v *jsDiagnosticsVisitor) createDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { return ast.NewDiagnostic(v.sourceFile, binder.GetErrorRangeForNode(v.sourceFile, node), message, args...) diff --git a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt index 74eb5f8873..40052689a8 100644 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt @@ -5,12 +5,14 @@ plainJSGrammarErrors.js(14,13): error TS18038: 'for await' loops cannot be used plainJSGrammarErrors.js(17,9): error TS18041: A 'return' statement cannot be used inside a class static block. plainJSGrammarErrors.js(20,5): error TS1089: 'static' modifier cannot appear on a constructor declaration. plainJSGrammarErrors.js(21,5): error TS1089: 'async' modifier cannot appear on a constructor declaration. +plainJSGrammarErrors.js(22,5): error TS8009: The 'const' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(22,11): error TS1248: A class member cannot have the 'const' keyword. plainJSGrammarErrors.js(23,5): error TS8009: The 'const' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(23,11): error TS1248: A class member cannot have the 'const' keyword. plainJSGrammarErrors.js(26,11): error TS1030: 'async' modifier already seen. plainJSGrammarErrors.js(28,11): error TS1029: 'static' modifier must precede 'async' modifier. plainJSGrammarErrors.js(29,5): error TS1031: 'export' modifier cannot appear on class elements of this kind. +plainJSGrammarErrors.js(29,5): error TS8009: The 'export' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(30,5): error TS1031: 'export' modifier cannot appear on class elements of this kind. plainJSGrammarErrors.js(34,22): error TS1005: '{' expected. plainJSGrammarErrors.js(35,9): error TS1054: A 'get' accessor cannot have parameters. @@ -27,12 +29,16 @@ plainJSGrammarErrors.js(51,9): error TS18013: Property '#m' is not accessible ou plainJSGrammarErrors.js(54,8): error TS1030: 'export' modifier already seen. plainJSGrammarErrors.js(55,8): error TS1044: 'static' modifier cannot appear on a module or namespace element. plainJSGrammarErrors.js(56,22): error TS1090: 'static' modifier cannot appear on a parameter. +plainJSGrammarErrors.js(56,22): error TS8012: Parameter modifiers can only be used in TypeScript files. plainJSGrammarErrors.js(57,7): error TS1029: 'export' modifier must precede 'async' modifier. plainJSGrammarErrors.js(58,26): error TS1090: 'export' modifier cannot appear on a parameter. +plainJSGrammarErrors.js(58,26): error TS8012: Parameter modifiers can only be used in TypeScript files. plainJSGrammarErrors.js(59,25): error TS1090: 'async' modifier cannot appear on a parameter. +plainJSGrammarErrors.js(59,25): error TS8012: Parameter modifiers can only be used in TypeScript files. plainJSGrammarErrors.js(60,7): error TS1030: 'async' modifier already seen. plainJSGrammarErrors.js(61,1): error TS1042: 'async' modifier cannot be used here. plainJSGrammarErrors.js(62,5): error TS1042: 'async' modifier cannot be used here. +plainJSGrammarErrors.js(62,5): error TS8009: The 'async' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(64,1): error TS1042: 'async' modifier cannot be used here. plainJSGrammarErrors.js(65,1): error TS1042: 'async' modifier cannot be used here. plainJSGrammarErrors.js(66,1): error TS1042: 'async' modifier cannot be used here. @@ -95,7 +101,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (95 errors) ==== +==== plainJSGrammarErrors.js (101 errors) ==== class C { // #private mistakes q = #unbound @@ -132,6 +138,8 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot ~~~~~ !!! error TS1089: 'async' modifier cannot appear on a constructor declaration. const x = 1 + ~~~~~ +!!! error TS8009: The 'const' modifier can only be used in TypeScript files. ~ !!! error TS1248: A class member cannot have the 'const' keyword. const y() { @@ -151,6 +159,8 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot export cantExportProperty = 1 ~~~~~~ !!! error TS1031: 'export' modifier cannot appear on class elements of this kind. + ~~~~~~ +!!! error TS8009: The 'export' modifier can only be used in TypeScript files. export cantExportMethod() { ~~~~~~ !!! error TS1031: 'export' modifier cannot appear on class elements of this kind. @@ -210,15 +220,21 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot function staticParam(static x = 1) { return x } ~~~~~~ !!! error TS1090: 'static' modifier cannot appear on a parameter. + ~~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. async export function oorder(x = 1) { return x } ~~~~~~ !!! error TS1029: 'export' modifier must precede 'async' modifier. function cantExportParam(export x = 1) { return x } ~~~~~~ !!! error TS1090: 'export' modifier cannot appear on a parameter. + ~~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. function cantAsyncParam(async x = 1) { return x } ~~~~~ !!! error TS1090: 'async' modifier cannot appear on a parameter. + ~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. async async function extremelyAsync() {} ~~~~~ !!! error TS1030: 'async' modifier already seen. @@ -228,6 +244,8 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot async cantAsyncPropert = 1 ~~~~~ !!! error TS1042: 'async' modifier cannot be used here. + ~~~~~ +!!! error TS8009: The 'async' modifier can only be used in TypeScript files. } async const cantAsyncConst = 2 ~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff index 3f76784f51..bf13bd6662 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff @@ -1,38 +1,6 @@ --- old.plainJSGrammarErrors.errors.txt +++ new.plainJSGrammarErrors.errors.txt -@@= skipped -4, +4 lines =@@ - plainJSGrammarErrors.js(17,9): error TS18041: A 'return' statement cannot be used inside a class static block. - plainJSGrammarErrors.js(20,5): error TS1089: 'static' modifier cannot appear on a constructor declaration. - plainJSGrammarErrors.js(21,5): error TS1089: 'async' modifier cannot appear on a constructor declaration. --plainJSGrammarErrors.js(22,5): error TS8009: The 'const' modifier can only be used in TypeScript files. - plainJSGrammarErrors.js(22,11): error TS1248: A class member cannot have the 'const' keyword. - plainJSGrammarErrors.js(23,5): error TS8009: The 'const' modifier can only be used in TypeScript files. - plainJSGrammarErrors.js(23,11): error TS1248: A class member cannot have the 'const' keyword. - plainJSGrammarErrors.js(26,11): error TS1030: 'async' modifier already seen. - plainJSGrammarErrors.js(28,11): error TS1029: 'static' modifier must precede 'async' modifier. - plainJSGrammarErrors.js(29,5): error TS1031: 'export' modifier cannot appear on class elements of this kind. --plainJSGrammarErrors.js(29,5): error TS8009: The 'export' modifier can only be used in TypeScript files. - plainJSGrammarErrors.js(30,5): error TS1031: 'export' modifier cannot appear on class elements of this kind. - plainJSGrammarErrors.js(34,22): error TS1005: '{' expected. - plainJSGrammarErrors.js(35,9): error TS1054: A 'get' accessor cannot have parameters. -@@= skipped -24, +22 lines =@@ - plainJSGrammarErrors.js(54,8): error TS1030: 'export' modifier already seen. - plainJSGrammarErrors.js(55,8): error TS1044: 'static' modifier cannot appear on a module or namespace element. - plainJSGrammarErrors.js(56,22): error TS1090: 'static' modifier cannot appear on a parameter. --plainJSGrammarErrors.js(56,22): error TS8012: Parameter modifiers can only be used in TypeScript files. - plainJSGrammarErrors.js(57,7): error TS1029: 'export' modifier must precede 'async' modifier. - plainJSGrammarErrors.js(58,26): error TS1090: 'export' modifier cannot appear on a parameter. --plainJSGrammarErrors.js(58,26): error TS8012: Parameter modifiers can only be used in TypeScript files. - plainJSGrammarErrors.js(59,25): error TS1090: 'async' modifier cannot appear on a parameter. --plainJSGrammarErrors.js(59,25): error TS8012: Parameter modifiers can only be used in TypeScript files. - plainJSGrammarErrors.js(60,7): error TS1030: 'async' modifier already seen. - plainJSGrammarErrors.js(61,1): error TS1042: 'async' modifier cannot be used here. - plainJSGrammarErrors.js(62,5): error TS1042: 'async' modifier cannot be used here. --plainJSGrammarErrors.js(62,5): error TS8009: The 'async' modifier can only be used in TypeScript files. - plainJSGrammarErrors.js(64,1): error TS1042: 'async' modifier cannot be used here. - plainJSGrammarErrors.js(65,1): error TS1042: 'async' modifier cannot be used here. - plainJSGrammarErrors.js(66,1): error TS1042: 'async' modifier cannot be used here. -@@= skipped -38, +34 lines =@@ +@@= skipped -66, +66 lines =@@ plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. @@ -45,60 +13,11 @@ -==== plainJSGrammarErrors.js (102 errors) ==== -+==== plainJSGrammarErrors.js (95 errors) ==== ++==== plainJSGrammarErrors.js (101 errors) ==== class C { // #private mistakes q = #unbound -@@= skipped -37, +37 lines =@@ - ~~~~~ - !!! error TS1089: 'async' modifier cannot appear on a constructor declaration. - const x = 1 -- ~~~~~ --!!! error TS8009: The 'const' modifier can only be used in TypeScript files. - ~ - !!! error TS1248: A class member cannot have the 'const' keyword. - const y() { -@@= skipped -21, +19 lines =@@ - export cantExportProperty = 1 - ~~~~~~ - !!! error TS1031: 'export' modifier cannot appear on class elements of this kind. -- ~~~~~~ --!!! error TS8009: The 'export' modifier can only be used in TypeScript files. - export cantExportMethod() { - ~~~~~~ - !!! error TS1031: 'export' modifier cannot appear on class elements of this kind. -@@= skipped -61, +59 lines =@@ - function staticParam(static x = 1) { return x } - ~~~~~~ - !!! error TS1090: 'static' modifier cannot appear on a parameter. -- ~~~~~~ --!!! error TS8012: Parameter modifiers can only be used in TypeScript files. - async export function oorder(x = 1) { return x } - ~~~~~~ - !!! error TS1029: 'export' modifier must precede 'async' modifier. - function cantExportParam(export x = 1) { return x } - ~~~~~~ - !!! error TS1090: 'export' modifier cannot appear on a parameter. -- ~~~~~~ --!!! error TS8012: Parameter modifiers can only be used in TypeScript files. - function cantAsyncParam(async x = 1) { return x } - ~~~~~ - !!! error TS1090: 'async' modifier cannot appear on a parameter. -- ~~~~~ --!!! error TS8012: Parameter modifiers can only be used in TypeScript files. - async async function extremelyAsync() {} - ~~~~~ - !!! error TS1030: 'async' modifier already seen. -@@= skipped -24, +18 lines =@@ - async cantAsyncPropert = 1 - ~~~~~ - !!! error TS1042: 'async' modifier cannot be used here. -- ~~~~~ --!!! error TS8009: The 'async' modifier can only be used in TypeScript files. - } - async const cantAsyncConst = 2 - ~~~~~ -@@= skipped -105, +103 lines =@@ +@@= skipped -248, +248 lines =@@ m?() { return 12 }, ~ !!! error TS1162: An object member cannot be declared optional. From 47234a320f3b0f85b357bea3ad4d97a85d26c7b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 18:25:27 +0000 Subject: [PATCH 17/31] Add missing question mark modifier check for method and property declarations Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/js_diagnostics.go | 26 ++++++++++++-- .../plainJSGrammarErrors.errors.txt | 11 +++++- .../plainJSGrammarErrors.errors.txt.diff | 34 +++++++++++++------ 3 files changed, 57 insertions(+), 14 deletions(-) diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index be772bb0c3..4f2b259372 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -45,14 +45,34 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent * // Handle specific parent-child relationships first switch parent.Kind { - case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: - // Check for question token (optional markers) - only parameters have question tokens + case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration, ast.KindPropertyAssignment, ast.KindMethodSignature, ast.KindPropertySignature: + // Check for question token (optional markers) if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) return } + if parent.Kind == ast.KindPropertyDeclaration && parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().PostfixToken == node { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } + if parent.Kind == ast.KindMethodDeclaration && parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().PostfixToken == node { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } + if parent.Kind == ast.KindPropertyAssignment && parent.AsPropertyAssignment() != nil && parent.AsPropertyAssignment().PostfixToken == node { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } + if parent.Kind == ast.KindMethodSignature && parent.AsMethodSignatureDeclaration() != nil && parent.AsMethodSignatureDeclaration().PostfixToken == node { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } + if parent.Kind == ast.KindPropertySignature && parent.AsPropertySignatureDeclaration() != nil && parent.AsPropertySignatureDeclaration().PostfixToken == node { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + return + } fallthrough - case ast.KindMethodSignature, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, + case ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindVariableDeclaration: // Check for type annotations if v.isTypeAnnotation(parent, node) { diff --git a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt index 40052689a8..86ec06c945 100644 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt @@ -66,9 +66,12 @@ plainJSGrammarErrors.js(104,6): error TS1171: A comma expression is not allowed plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allowed outside class bodies. plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. +plainJSGrammarErrors.js(108,25): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. +plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. +plainJSGrammarErrors.js(111,19): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. plainJSGrammarErrors.js(116,24): error TS1009: Trailing comma not allowed. plainJSGrammarErrors.js(117,29): error TS1097: 'extends' list cannot be empty. @@ -101,7 +104,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (101 errors) ==== +==== plainJSGrammarErrors.js (104 errors) ==== class C { // #private mistakes q = #unbound @@ -346,15 +349,21 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot cantHaveQuestionMark?: 1, ~ !!! error TS1162: An object member cannot be declared optional. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. m?() { return 12 }, ~ !!! error TS1162: An object member cannot be declared optional. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. definitely!, ~ !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. definiteMethod!() { return 13 }, ~ !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. } const noAssignment = { assignment = 1, diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff index bf13bd6662..94a213b87f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff @@ -1,28 +1,42 @@ --- old.plainJSGrammarErrors.errors.txt +++ new.plainJSGrammarErrors.errors.txt -@@= skipped -66, +66 lines =@@ +@@= skipped -65, +65 lines =@@ + plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allowed outside class bodies. plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. ++plainJSGrammarErrors.js(108,25): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. --plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. + plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. ++plainJSGrammarErrors.js(111,19): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. -@@= skipped -35, +34 lines =@@ + plainJSGrammarErrors.js(116,24): error TS1009: Trailing comma not allowed. + plainJSGrammarErrors.js(117,29): error TS1097: 'extends' list cannot be empty. +@@= skipped -36, +38 lines =@@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (102 errors) ==== -+==== plainJSGrammarErrors.js (101 errors) ==== ++==== plainJSGrammarErrors.js (104 errors) ==== class C { // #private mistakes q = #unbound -@@= skipped -248, +248 lines =@@ +@@= skipped -245, +245 lines =@@ + cantHaveQuestionMark?: 1, + ~ + !!! error TS1162: An object member cannot be declared optional. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. m?() { return 12 }, ~ !!! error TS1162: An object member cannot be declared optional. -- ~ --!!! error TS8009: The '?' modifier can only be used in TypeScript files. - definitely!, - ~ - !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. \ No newline at end of file +@@= skipped -11, +13 lines =@@ + definiteMethod!() { return 13 }, + ~ + !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + } + const noAssignment = { + assignment = 1, \ No newline at end of file From 5d296faceaf9b2bf519843747fdb2a3b1ffdd71e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 18:54:19 +0000 Subject: [PATCH 18/31] Remove duplicate JS diagnostic cases and fix token text detection - Remove PropertyAssignment, MethodSignature, PropertySignature cases that already error elsewhere - Fix token text to show actual tokens (? vs !) instead of hardcoded "?" - Add class context checking to avoid duplicate errors for object literal methods - Fixes remaining baseline diff in plainJSGrammarErrors test Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/js_diagnostics.go | 37 +++++++++++-------- ...tionalClassElementSyntaxOfClass.errors.txt | 8 +++- .../plainJSGrammarErrors.errors.txt | 11 +----- ...lClassElementSyntaxOfClass.errors.txt.diff | 22 ----------- .../plainJSGrammarErrors.errors.txt.diff | 34 +++++------------ 5 files changed, 39 insertions(+), 73 deletions(-) delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt.diff diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index 4f2b259372..b93b810a6f 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -45,30 +45,22 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent * // Handle specific parent-child relationships first switch parent.Kind { - case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration, ast.KindPropertyAssignment, ast.KindMethodSignature, ast.KindPropertySignature: + case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: // Check for question token (optional markers) if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) return } if parent.Kind == ast.KindPropertyDeclaration && parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().PostfixToken == node { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) return } if parent.Kind == ast.KindMethodDeclaration && parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().PostfixToken == node { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) - return - } - if parent.Kind == ast.KindPropertyAssignment && parent.AsPropertyAssignment() != nil && parent.AsPropertyAssignment().PostfixToken == node { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) - return - } - if parent.Kind == ast.KindMethodSignature && parent.AsMethodSignatureDeclaration() != nil && parent.AsMethodSignatureDeclaration().PostfixToken == node { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) - return - } - if parent.Kind == ast.KindPropertySignature && parent.AsPropertySignatureDeclaration() != nil && parent.AsPropertySignatureDeclaration().PostfixToken == node { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")) + // Only check MethodDeclaration PostfixToken if it's in a class context + // Methods in object literals already error elsewhere + if v.isInClassContext(parent) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) + } return } fallthrough @@ -532,3 +524,16 @@ func (v *jsDiagnosticsVisitor) createDiagnosticForNodeList(nodeList *ast.NodeLis } return ast.NewDiagnostic(v.sourceFile, nodeList.Loc, message, args...) } + +// isInClassContext checks if a node is within a class declaration context +func (v *jsDiagnosticsVisitor) isInClassContext(node *ast.Node) bool { + // Walk up the parent chain to find if we're in a class + current := node + for current != nil { + if current.Kind == ast.KindClassDeclaration || current.Kind == ast.KindClassExpression { + return true + } + current = current.Parent + } + return false +} diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt index 667303c917..c9114536f2 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt @@ -1,12 +1,18 @@ error TS5055: Cannot write file 'a.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. +a.js(2,8): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(4,8): error TS8009: The '?' modifier can only be used in TypeScript files. !!! error TS5055: Cannot write file 'a.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. -==== a.js (0 errors) ==== +==== a.js (2 errors) ==== class C { foo?() { + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. } bar? = 1; + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt index 86ec06c945..40052689a8 100644 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt @@ -66,12 +66,9 @@ plainJSGrammarErrors.js(104,6): error TS1171: A comma expression is not allowed plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allowed outside class bodies. plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. -plainJSGrammarErrors.js(108,25): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. -plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. -plainJSGrammarErrors.js(111,19): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. plainJSGrammarErrors.js(116,24): error TS1009: Trailing comma not allowed. plainJSGrammarErrors.js(117,29): error TS1097: 'extends' list cannot be empty. @@ -104,7 +101,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (104 errors) ==== +==== plainJSGrammarErrors.js (101 errors) ==== class C { // #private mistakes q = #unbound @@ -349,21 +346,15 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot cantHaveQuestionMark?: 1, ~ !!! error TS1162: An object member cannot be declared optional. - ~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. m?() { return 12 }, ~ !!! error TS1162: An object member cannot be declared optional. - ~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. definitely!, ~ !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. definiteMethod!() { return 13 }, ~ !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. - ~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. } const noAssignment = { assignment = 1, diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt.diff deleted file mode 100644 index 7a2b34613c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt -+++ new.jsFileCompilationOptionalClassElementSyntaxOfClass.errors.txt -@@= skipped -0, +0 lines =@@ - error TS5055: Cannot write file 'a.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. --a.js(2,8): error TS8009: The '?' modifier can only be used in TypeScript files. --a.js(4,8): error TS8009: The '?' modifier can only be used in TypeScript files. - - - !!! error TS5055: Cannot write file 'a.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. --==== a.js (2 errors) ==== -+==== a.js (0 errors) ==== - class C { - foo?() { -- ~ --!!! error TS8009: The '?' modifier can only be used in TypeScript files. - } - bar? = 1; -- ~ --!!! error TS8009: The '?' modifier can only be used in TypeScript files. - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff index 94a213b87f..bf13bd6662 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff @@ -1,42 +1,28 @@ --- old.plainJSGrammarErrors.errors.txt +++ new.plainJSGrammarErrors.errors.txt -@@= skipped -65, +65 lines =@@ - plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allowed outside class bodies. +@@= skipped -66, +66 lines =@@ plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. -+plainJSGrammarErrors.js(108,25): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. - plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. +-plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. -+plainJSGrammarErrors.js(111,19): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. - plainJSGrammarErrors.js(116,24): error TS1009: Trailing comma not allowed. - plainJSGrammarErrors.js(117,29): error TS1097: 'extends' list cannot be empty. -@@= skipped -36, +38 lines =@@ +@@= skipped -35, +34 lines =@@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (102 errors) ==== -+==== plainJSGrammarErrors.js (104 errors) ==== ++==== plainJSGrammarErrors.js (101 errors) ==== class C { // #private mistakes q = #unbound -@@= skipped -245, +245 lines =@@ - cantHaveQuestionMark?: 1, - ~ - !!! error TS1162: An object member cannot be declared optional. -+ ~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. +@@= skipped -248, +248 lines =@@ m?() { return 12 }, ~ !!! error TS1162: An object member cannot be declared optional. -@@= skipped -11, +13 lines =@@ - definiteMethod!() { return 13 }, - ~ - !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. -+ ~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. - } - const noAssignment = { - assignment = 1, \ No newline at end of file +- ~ +-!!! error TS8009: The '?' modifier can only be used in TypeScript files. + definitely!, + ~ + !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. \ No newline at end of file From bd46d8afc9c0f24df40bcfd870ee1c39bd67e96f Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:38:18 -0700 Subject: [PATCH 19/31] Manual tweak --- internal/compiler/js_diagnostics.go | 21 +++----------- .../plainJSGrammarErrors.errors.txt | 5 +++- .../plainJSGrammarErrors.errors.txt.diff | 28 ------------------- 3 files changed, 8 insertions(+), 46 deletions(-) delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index b93b810a6f..dc7d375d61 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -56,11 +56,11 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent * return } if parent.Kind == ast.KindMethodDeclaration && parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().PostfixToken == node { - // Only check MethodDeclaration PostfixToken if it's in a class context - // Methods in object literals already error elsewhere - if v.isInClassContext(parent) { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) + if node.Kind == ast.KindExclamationToken && parent.Parent.Kind == ast.KindObjectLiteralExpression { + // This already gets a grammar error. + return } + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) return } fallthrough @@ -524,16 +524,3 @@ func (v *jsDiagnosticsVisitor) createDiagnosticForNodeList(nodeList *ast.NodeLis } return ast.NewDiagnostic(v.sourceFile, nodeList.Loc, message, args...) } - -// isInClassContext checks if a node is within a class declaration context -func (v *jsDiagnosticsVisitor) isInClassContext(node *ast.Node) bool { - // Walk up the parent chain to find if we're in a class - current := node - for current != nil { - if current.Kind == ast.KindClassDeclaration || current.Kind == ast.KindClassExpression { - return true - } - current = current.Parent - } - return false -} diff --git a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt index 40052689a8..b92bd5df1b 100644 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt @@ -67,6 +67,7 @@ plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allow plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. +plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. @@ -101,7 +102,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (101 errors) ==== +==== plainJSGrammarErrors.js (102 errors) ==== class C { // #private mistakes q = #unbound @@ -349,6 +350,8 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot m?() { return 12 }, ~ !!! error TS1162: An object member cannot be declared optional. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. definitely!, ~ !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff deleted file mode 100644 index bf13bd6662..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.plainJSGrammarErrors.errors.txt -+++ new.plainJSGrammarErrors.errors.txt -@@= skipped -66, +66 lines =@@ - plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. - plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. - plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. --plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. - plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. - plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. - plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. -@@= skipped -35, +34 lines =@@ - plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. - - --==== plainJSGrammarErrors.js (102 errors) ==== -+==== plainJSGrammarErrors.js (101 errors) ==== - class C { - // #private mistakes - q = #unbound -@@= skipped -248, +248 lines =@@ - m?() { return 12 }, - ~ - !!! error TS1162: An object member cannot be declared optional. -- ~ --!!! error TS8009: The '?' modifier can only be used in TypeScript files. - definitely!, - ~ - !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. \ No newline at end of file From 8389be37c970c5e3b23b37923b5906d7d8aa8697 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 19:58:08 +0000 Subject: [PATCH 20/31] Extract JS diagnostics calculation into helper function Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/js_diagnostics.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index dc7d375d61..659ebd08bb 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -15,11 +15,7 @@ type jsDiagnosticsVisitor struct { } // getJSSyntacticDiagnosticsForFile returns diagnostics for TypeScript-only constructs in JavaScript files -func (p *Program) getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { - if result, ok := p.jsDiagnosticCache.Load(sourceFile); ok { - return result - } - +func getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { visitor := &jsDiagnosticsVisitor{ sourceFile: sourceFile, diagnostics: []*ast.Diagnostic{}, @@ -28,7 +24,12 @@ func (p *Program) getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) [ // Walk the entire AST to find TypeScript-only constructs visitor.walkNodeForJSDiagnostics(sourceFile.AsNode(), sourceFile.AsNode()) - diagnostics, _ := p.jsDiagnosticCache.LoadOrStore(sourceFile, visitor.diagnostics) + return visitor.diagnostics +} + +// getJSSyntacticDiagnosticsForFile returns diagnostics for TypeScript-only constructs in JavaScript files +func (p *Program) getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { + diagnostics, _ := p.jsDiagnosticCache.LoadOrStore(sourceFile, getJSSyntacticDiagnosticsForFile(sourceFile)) return diagnostics } From 94d8aed8b3f0f55bcfaabac11405f445fe526d3f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 20:13:22 +0000 Subject: [PATCH 21/31] Fix JS diagnostics caching to avoid unnecessary AST walks Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/compiler/js_diagnostics.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index 659ebd08bb..e8ddf8901d 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -29,6 +29,9 @@ func getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnos // getJSSyntacticDiagnosticsForFile returns diagnostics for TypeScript-only constructs in JavaScript files func (p *Program) getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { + if cached, ok := p.jsDiagnosticCache.Load(sourceFile); ok { + return cached + } diagnostics, _ := p.jsDiagnosticCache.LoadOrStore(sourceFile, getJSSyntacticDiagnosticsForFile(sourceFile)) return diagnostics } From 48946146786648aa4561940ec2cdb06bb5123ea5 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 11 Jul 2025 13:59:29 -0700 Subject: [PATCH 22/31] Move GetErrorRangeForNode to scanner --- internal/binder/binder.go | 82 +---------------------------- internal/checker/utilities.go | 2 +- internal/compiler/js_diagnostics.go | 3 +- internal/scanner/utilities.go | 80 ++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 84 deletions(-) diff --git a/internal/binder/binder.go b/internal/binder/binder.go index 05f8bc6382..8e15ad94f3 100644 --- a/internal/binder/binder.go +++ b/internal/binder/binder.go @@ -2758,7 +2758,7 @@ func (b *Binder) errorOrSuggestionOnRange(isError bool, startNode *ast.Node, end // If so, the node _must_ be in the current file (as that's the only way anything could have traversed to it to yield it as the error node) // This version of `createDiagnosticForNode` uses the binder's context to account for this, and always yields correct diagnostics even in these situations. func (b *Binder) createDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { - return ast.NewDiagnostic(b.file, GetErrorRangeForNode(b.file, node), message, args...) + return ast.NewDiagnostic(b.file, scanner.GetErrorRangeForNode(b.file, node), message, args...) } func (b *Binder) addDiagnostic(diagnostic *ast.Diagnostic) { @@ -2855,83 +2855,3 @@ func isAssignmentDeclaration(decl *ast.Node) bool { func isEffectiveModuleDeclaration(node *ast.Node) bool { return ast.IsModuleDeclaration(node) || ast.IsIdentifier(node) } - -func getErrorRangeForArrowFunction(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange { - pos := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) - body := node.AsArrowFunction().Body - if body != nil && body.Kind == ast.KindBlock { - startLine, _ := scanner.GetLineAndCharacterOfPosition(sourceFile, body.Pos()) - endLine, _ := scanner.GetLineAndCharacterOfPosition(sourceFile, body.End()) - if startLine < endLine { - // The arrow function spans multiple lines, - // make the error span be the first line, inclusive. - return core.NewTextRange(pos, scanner.GetEndLinePosition(sourceFile, startLine)) - } - } - return core.NewTextRange(pos, node.End()) -} - -func GetErrorRangeForNode(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange { - errorNode := node - switch node.Kind { - case ast.KindSourceFile: - pos := scanner.SkipTrivia(sourceFile.Text(), 0) - if pos == len(sourceFile.Text()) { - return core.NewTextRange(0, 0) - } - return scanner.GetRangeOfTokenAtPosition(sourceFile, pos) - // This list is a work in progress. Add missing node kinds to improve their error spans - case ast.KindFunctionDeclaration, ast.KindMethodDeclaration: - if node.Flags&ast.NodeFlagsReparsed != 0 { - errorNode = node - break - } - fallthrough - case ast.KindVariableDeclaration, ast.KindBindingElement, ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration, - ast.KindModuleDeclaration, ast.KindEnumDeclaration, ast.KindEnumMember, ast.KindFunctionExpression, - ast.KindGetAccessor, ast.KindSetAccessor, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindPropertyDeclaration, - ast.KindPropertySignature, ast.KindNamespaceImport: - errorNode = ast.GetNameOfDeclaration(node) - case ast.KindArrowFunction: - return getErrorRangeForArrowFunction(sourceFile, node) - case ast.KindCaseClause, ast.KindDefaultClause: - start := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) - end := node.End() - statements := node.AsCaseOrDefaultClause().Statements.Nodes - if len(statements) != 0 { - end = statements[0].Pos() - } - return core.NewTextRange(start, end) - case ast.KindReturnStatement, ast.KindYieldExpression: - pos := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) - return scanner.GetRangeOfTokenAtPosition(sourceFile, pos) - case ast.KindSatisfiesExpression: - pos := scanner.SkipTrivia(sourceFile.Text(), node.AsSatisfiesExpression().Expression.End()) - return scanner.GetRangeOfTokenAtPosition(sourceFile, pos) - case ast.KindConstructor: - if node.Flags&ast.NodeFlagsReparsed != 0 { - errorNode = node - break - } - scanner := scanner.GetScannerForSourceFile(sourceFile, node.Pos()) - start := scanner.TokenStart() - for scanner.Token() != ast.KindConstructorKeyword && scanner.Token() != ast.KindStringLiteral && scanner.Token() != ast.KindEndOfFile { - scanner.Scan() - } - return core.NewTextRange(start, scanner.TokenEnd()) - // !!! - // case KindJSDocSatisfiesTag: - // pos := scanner.SkipTrivia(sourceFile.Text(), node.tagName.pos) - // return scanner.GetRangeOfTokenAtPosition(sourceFile, pos) - } - if errorNode == nil { - // If we don't have a better node, then just set the error on the first token of - // construct. - return scanner.GetRangeOfTokenAtPosition(sourceFile, node.Pos()) - } - pos := errorNode.Pos() - if !ast.NodeIsMissing(errorNode) && !ast.IsJsxText(errorNode) { - pos = scanner.SkipTrivia(sourceFile.Text(), pos) - } - return core.NewTextRange(pos, errorNode.End()) -} diff --git a/internal/checker/utilities.go b/internal/checker/utilities.go index 321d069819..fab2c52440 100644 --- a/internal/checker/utilities.go +++ b/internal/checker/utilities.go @@ -23,7 +23,7 @@ func NewDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ... var loc core.TextRange if node != nil { file = ast.GetSourceFileOfNode(node) - loc = binder.GetErrorRangeForNode(file, node) + loc = scanner.GetErrorRangeForNode(file, node) } return ast.NewDiagnostic(file, loc, message, args...) } diff --git a/internal/compiler/js_diagnostics.go b/internal/compiler/js_diagnostics.go index e8ddf8901d..3825f965f5 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/compiler/js_diagnostics.go @@ -2,7 +2,6 @@ package compiler import ( "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/binder" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/scanner" @@ -514,7 +513,7 @@ func (v *jsDiagnosticsVisitor) checkModifier(modifier *ast.Node, isConstValid bo // createDiagnosticForNode creates a diagnostic for a specific node func (v *jsDiagnosticsVisitor) createDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { - return ast.NewDiagnostic(v.sourceFile, binder.GetErrorRangeForNode(v.sourceFile, node), message, args...) + return ast.NewDiagnostic(v.sourceFile, scanner.GetErrorRangeForNode(v.sourceFile, node), message, args...) } // createDiagnosticForNodeList creates a diagnostic for a NodeList diff --git a/internal/scanner/utilities.go b/internal/scanner/utilities.go index 06ba7cf666..15d2dd8f2a 100644 --- a/internal/scanner/utilities.go +++ b/internal/scanner/utilities.go @@ -65,3 +65,83 @@ func IsIdentifierText(name string, languageVariant core.LanguageVariant) bool { func IsIntrinsicJsxName(name string) bool { return len(name) != 0 && (name[0] >= 'a' && name[0] <= 'z' || strings.ContainsRune(name, '-')) } + +func getErrorRangeForArrowFunction(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange { + pos := SkipTrivia(sourceFile.Text(), node.Pos()) + body := node.AsArrowFunction().Body + if body != nil && body.Kind == ast.KindBlock { + startLine, _ := GetLineAndCharacterOfPosition(sourceFile, body.Pos()) + endLine, _ := GetLineAndCharacterOfPosition(sourceFile, body.End()) + if startLine < endLine { + // The arrow function spans multiple lines, + // make the error span be the first line, inclusive. + return core.NewTextRange(pos, GetEndLinePosition(sourceFile, startLine)) + } + } + return core.NewTextRange(pos, node.End()) +} + +func GetErrorRangeForNode(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange { + errorNode := node + switch node.Kind { + case ast.KindSourceFile: + pos := SkipTrivia(sourceFile.Text(), 0) + if pos == len(sourceFile.Text()) { + return core.NewTextRange(0, 0) + } + return GetRangeOfTokenAtPosition(sourceFile, pos) + // This list is a work in progress. Add missing node kinds to improve their error spans + case ast.KindFunctionDeclaration, ast.KindMethodDeclaration: + if node.Flags&ast.NodeFlagsReparsed != 0 { + errorNode = node + break + } + fallthrough + case ast.KindVariableDeclaration, ast.KindBindingElement, ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration, + ast.KindModuleDeclaration, ast.KindEnumDeclaration, ast.KindEnumMember, ast.KindFunctionExpression, + ast.KindGetAccessor, ast.KindSetAccessor, ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration, ast.KindPropertyDeclaration, + ast.KindPropertySignature, ast.KindNamespaceImport: + errorNode = ast.GetNameOfDeclaration(node) + case ast.KindArrowFunction: + return getErrorRangeForArrowFunction(sourceFile, node) + case ast.KindCaseClause, ast.KindDefaultClause: + start := SkipTrivia(sourceFile.Text(), node.Pos()) + end := node.End() + statements := node.AsCaseOrDefaultClause().Statements.Nodes + if len(statements) != 0 { + end = statements[0].Pos() + } + return core.NewTextRange(start, end) + case ast.KindReturnStatement, ast.KindYieldExpression: + pos := SkipTrivia(sourceFile.Text(), node.Pos()) + return GetRangeOfTokenAtPosition(sourceFile, pos) + case ast.KindSatisfiesExpression: + pos := SkipTrivia(sourceFile.Text(), node.AsSatisfiesExpression().Expression.End()) + return GetRangeOfTokenAtPosition(sourceFile, pos) + case ast.KindConstructor: + if node.Flags&ast.NodeFlagsReparsed != 0 { + errorNode = node + break + } + scanner := GetScannerForSourceFile(sourceFile, node.Pos()) + start := scanner.TokenStart() + for scanner.Token() != ast.KindConstructorKeyword && scanner.Token() != ast.KindStringLiteral && scanner.Token() != ast.KindEndOfFile { + scanner.Scan() + } + return core.NewTextRange(start, scanner.TokenEnd()) + // !!! + // case KindJSDocSatisfiesTag: + // pos := scanner.SkipTrivia(sourceFile.Text(), node.tagName.pos) + // return scanner.GetRangeOfTokenAtPosition(sourceFile, pos) + } + if errorNode == nil { + // If we don't have a better node, then just set the error on the first token of + // construct. + return GetRangeOfTokenAtPosition(sourceFile, node.Pos()) + } + pos := errorNode.Pos() + if !ast.NodeIsMissing(errorNode) && !ast.IsJsxText(errorNode) { + pos = SkipTrivia(sourceFile.Text(), pos) + } + return core.NewTextRange(pos, errorNode.End()) +} From 563ca59a28883eb416ae90c7078574b79ce1fa2a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 11 Jul 2025 14:00:41 -0700 Subject: [PATCH 23/31] Remove old todo --- internal/scanner/utilities.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/scanner/utilities.go b/internal/scanner/utilities.go index 15d2dd8f2a..076523ac9e 100644 --- a/internal/scanner/utilities.go +++ b/internal/scanner/utilities.go @@ -129,10 +129,6 @@ func GetErrorRangeForNode(sourceFile *ast.SourceFile, node *ast.Node) core.TextR scanner.Scan() } return core.NewTextRange(start, scanner.TokenEnd()) - // !!! - // case KindJSDocSatisfiesTag: - // pos := scanner.SkipTrivia(sourceFile.Text(), node.tagName.pos) - // return scanner.GetRangeOfTokenAtPosition(sourceFile, pos) } if errorNode == nil { // If we don't have a better node, then just set the error on the first token of From 1719219d3a350d86be817af349e18c2ee3b80fbe Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 11 Jul 2025 15:40:53 -0700 Subject: [PATCH 24/31] Move to parser --- internal/ast/ast.go | 9 +++++++++ internal/compiler/program.go | 4 ++-- internal/{compiler => parser}/js_diagnostics.go | 11 +---------- internal/parser/parser.go | 5 +++++ 4 files changed, 17 insertions(+), 12 deletions(-) rename internal/{compiler => parser}/js_diagnostics.go (97%) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 1a1db67532..04df5e445d 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -10049,6 +10049,7 @@ type SourceFile struct { // Fields set by parser diagnostics []*Diagnostic jsdocDiagnostics []*Diagnostic + jsSyntacticDiagnostics []*Diagnostic LanguageVariant core.LanguageVariant ScriptKind core.ScriptKind IsDeclarationFile bool @@ -10147,6 +10148,14 @@ func (node *SourceFile) SetJSDocDiagnostics(diags []*Diagnostic) { node.jsdocDiagnostics = diags } +func (node *SourceFile) JSSyntacticDiagnostics() []*Diagnostic { + return node.jsSyntacticDiagnostics +} + +func (node *SourceFile) SetJSSyntacticDiagnostics(diags []*Diagnostic) { + node.jsSyntacticDiagnostics = diags +} + func (node *SourceFile) JSDocCache() map[*Node][]*Node { return node.jsdocCache } diff --git a/internal/compiler/program.go b/internal/compiler/program.go index a63da5e266..701ed7c57c 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -869,8 +869,8 @@ func (p *Program) getOptionsDiagnosticsOfConfigFile() []*ast.Diagnostic { func (p *Program) getSyntacticDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { // For JavaScript files, we report semantic errors for using TypeScript-only // constructs from within a JavaScript file as syntactic errors. - if ast.IsSourceFileJS(sourceFile) { - return slices.Concat(p.getJSSyntacticDiagnosticsForFile(sourceFile), sourceFile.Diagnostics()) + if jsSyntacticDiagnostics := sourceFile.JSSyntacticDiagnostics(); len(jsSyntacticDiagnostics) > 0 { + return slices.Concat(jsSyntacticDiagnostics, sourceFile.Diagnostics()) } return sourceFile.Diagnostics() } diff --git a/internal/compiler/js_diagnostics.go b/internal/parser/js_diagnostics.go similarity index 97% rename from internal/compiler/js_diagnostics.go rename to internal/parser/js_diagnostics.go index 3825f965f5..faf69e58b7 100644 --- a/internal/compiler/js_diagnostics.go +++ b/internal/parser/js_diagnostics.go @@ -1,4 +1,4 @@ -package compiler +package parser import ( "github.com/microsoft/typescript-go/internal/ast" @@ -26,15 +26,6 @@ func getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnos return visitor.diagnostics } -// getJSSyntacticDiagnosticsForFile returns diagnostics for TypeScript-only constructs in JavaScript files -func (p *Program) getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { - if cached, ok := p.jsDiagnosticCache.Load(sourceFile); ok { - return cached - } - diagnostics, _ := p.jsDiagnosticCache.LoadOrStore(sourceFile, getJSSyntacticDiagnosticsForFile(sourceFile)) - return diagnostics -} - // walkNodeForJSDiagnostics walks the AST and collects diagnostics for TypeScript-only constructs func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node) { if node == nil { diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 6cc354802a..ad271ad756 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -381,6 +381,11 @@ func (p *Parser) finishSourceFile(result *ast.SourceFile, isDeclarationFile bool result.SetJSDocCache(p.jsdocCache) ast.SetExternalModuleIndicator(result, p.opts.ExternalModuleIndicatorOptions) + + if ast.IsSourceFileJS(result) { + // TODO: can these be done while parsing, rather than as a separate pass? + result.SetJSSyntacticDiagnostics(getJSSyntacticDiagnosticsForFile(result)) + } } func (p *Parser) parseToplevelStatement(i int) *ast.Node { From 4873b3989ca3da708f88b0148e2ec00770ed06ca Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 11 Jul 2025 15:45:58 -0700 Subject: [PATCH 25/31] Fix binding issue --- internal/parser/js_diagnostics.go | 63 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/internal/parser/js_diagnostics.go b/internal/parser/js_diagnostics.go index faf69e58b7..46d6310ee8 100644 --- a/internal/parser/js_diagnostics.go +++ b/internal/parser/js_diagnostics.go @@ -9,8 +9,9 @@ import ( // jsDiagnosticsVisitor is used to find TypeScript-only constructs in JavaScript files type jsDiagnosticsVisitor struct { - sourceFile *ast.SourceFile - diagnostics []*ast.Diagnostic + sourceFile *ast.SourceFile + diagnostics []*ast.Diagnostic + walkNodeForJSDiagnostics func(node *ast.Node) bool } // getJSSyntacticDiagnosticsForFile returns diagnostics for TypeScript-only constructs in JavaScript files @@ -19,22 +20,25 @@ func getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnos sourceFile: sourceFile, diagnostics: []*ast.Diagnostic{}, } + visitor.walkNodeForJSDiagnostics = visitor.walkNodeForJSDiagnosticsWorker // Walk the entire AST to find TypeScript-only constructs - visitor.walkNodeForJSDiagnostics(sourceFile.AsNode(), sourceFile.AsNode()) + sourceFile.ForEachChild(visitor.walkNodeForJSDiagnostics) return visitor.diagnostics } // walkNodeForJSDiagnostics walks the AST and collects diagnostics for TypeScript-only constructs -func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent *ast.Node) { +func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnosticsWorker(node *ast.Node) bool { if node == nil { - return + return false } + parent := node.Parent + // Bail out early if this node has NodeFlagsReparsed, as they are synthesized type annotations if node.Flags&ast.NodeFlagsReparsed != 0 { - return + return false } // Handle specific parent-child relationships first @@ -43,19 +47,19 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent * // Check for question token (optional markers) if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) - return + return false } if parent.Kind == ast.KindPropertyDeclaration && parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().PostfixToken == node { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) - return + return false } if parent.Kind == ast.KindMethodDeclaration && parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().PostfixToken == node { if node.Kind == ast.KindExclamationToken && parent.Parent.Kind == ast.KindObjectLiteralExpression { // This already gets a grammar error. - return + return false } v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) - return + return false } fallthrough case ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, @@ -63,7 +67,7 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent * // Check for type annotations if v.isTypeAnnotation(parent, node) { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) - return + return false } } @@ -72,46 +76,46 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent * case ast.KindImportClause: if node.AsImportClause() != nil && node.AsImportClause().IsTypeOnly { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type")) - return + return false } case ast.KindExportDeclaration: if node.AsExportDeclaration() != nil && node.AsExportDeclaration().IsTypeOnly { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type")) - return + return false } case ast.KindImportSpecifier: if node.AsImportSpecifier() != nil && node.AsImportSpecifier().IsTypeOnly { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type")) - return + return false } case ast.KindExportSpecifier: if node.AsExportSpecifier() != nil && node.AsExportSpecifier().IsTypeOnly { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type")) - return + return false } case ast.KindImportEqualsDeclaration: v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) - return + return false case ast.KindExportAssignment: if node.AsExportAssignment() != nil && node.AsExportAssignment().IsExportEquals { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_export_can_only_be_used_in_TypeScript_files)) - return + return false } case ast.KindHeritageClause: if node.AsHeritageClause() != nil && node.AsHeritageClause().Token == ast.KindImplementsKeyword { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files)) - return + return false } case ast.KindInterfaceDeclaration: v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface")) - return + return false case ast.KindModuleDeclaration: moduleKeyword := "module" @@ -126,37 +130,37 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent * } } v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)) - return + return false case ast.KindTypeAliasDeclaration: v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) - return + return false case ast.KindEnumDeclaration: v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum")) - return + return false case ast.KindNonNullExpression: v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) - return + return false case ast.KindAsExpression: if node.AsAsExpression() != nil { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node.AsAsExpression().Type, diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)) - return + return false } case ast.KindSatisfiesExpression: if node.AsSatisfiesExpression() != nil { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node.AsSatisfiesExpression().Type, diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files)) - return + return false } case ast.KindConstructor, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: // Check for signature declarations (functions without bodies) if v.isSignatureDeclaration(node) { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files)) - return + return false } } @@ -164,10 +168,9 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnostics(node *ast.Node, parent * v.checkTypeParametersAndModifiers(node) // Recursively walk children - node.ForEachChild(func(child *ast.Node) bool { - v.walkNodeForJSDiagnostics(child, node) - return false - }) + node.ForEachChild(v.walkNodeForJSDiagnostics) + + return false } // isTypeAnnotation checks if a node is a type annotation in relation to its parent From ec7ddc5ec7c7c0a0a8767d455c55e9c62f5fc256 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 11 Jul 2025 16:03:30 -0700 Subject: [PATCH 26/31] Remove cache --- internal/compiler/program.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 701ed7c57c..172ff45943 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -62,8 +62,6 @@ type Program struct { sourceFilesToEmitOnce sync.Once sourceFilesToEmit []*ast.SourceFile - - jsDiagnosticCache collections.SyncMap[*ast.SourceFile, []*ast.Diagnostic] } // FileExists implements checker.Program. From e67cd958698fb12b5c7864a718302c2e9974879e Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 11 Jul 2025 16:04:35 -0700 Subject: [PATCH 27/31] No need for empty slice anymore --- internal/parser/js_diagnostics.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/parser/js_diagnostics.go b/internal/parser/js_diagnostics.go index 46d6310ee8..41acb70b20 100644 --- a/internal/parser/js_diagnostics.go +++ b/internal/parser/js_diagnostics.go @@ -17,8 +17,7 @@ type jsDiagnosticsVisitor struct { // getJSSyntacticDiagnosticsForFile returns diagnostics for TypeScript-only constructs in JavaScript files func getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { visitor := &jsDiagnosticsVisitor{ - sourceFile: sourceFile, - diagnostics: []*ast.Diagnostic{}, + sourceFile: sourceFile, } visitor.walkNodeForJSDiagnostics = visitor.walkNodeForJSDiagnosticsWorker From 74416e19a9e836628787c1a61b5d16f785fbf453 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 21 Jul 2025 18:00:03 +0000 Subject: [PATCH 28/31] Simplify JS diagnostics code per review feedback - reduce redundancy and improve structure Co-authored-by: sandersn <293473+sandersn@users.noreply.github.com> --- internal/parser/js_diagnostics.go | 255 ++++++------------------------ 1 file changed, 50 insertions(+), 205 deletions(-) diff --git a/internal/parser/js_diagnostics.go b/internal/parser/js_diagnostics.go index 41acb70b20..d332ed6899 100644 --- a/internal/parser/js_diagnostics.go +++ b/internal/parser/js_diagnostics.go @@ -40,34 +40,30 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnosticsWorker(node *ast.Node) bo return false } - // Handle specific parent-child relationships first - switch parent.Kind { - case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: - // Check for question token (optional markers) - if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) + // Check for question tokens (optional markers) - these are always illegal in JS + if node.Kind == ast.KindQuestionToken { + // Skip if this is in an object literal method which already gets a grammar error + if parent.Kind == ast.KindMethodDeclaration && parent.Parent.Kind == ast.KindObjectLiteralExpression { return false } - if parent.Kind == ast.KindPropertyDeclaration && parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().PostfixToken == node { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) - return false - } - if parent.Kind == ast.KindMethodDeclaration && parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().PostfixToken == node { - if node.Kind == ast.KindExclamationToken && parent.Parent.Kind == ast.KindObjectLiteralExpression { - // This already gets a grammar error. - return false - } - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) - return false - } - fallthrough - case ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, - ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindVariableDeclaration: - // Check for type annotations - if v.isTypeAnnotation(parent, node) { - v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) + return false + } + + // Check for exclamation tokens (definite assignment assertions) - these are always illegal in JS + if node.Kind == ast.KindExclamationToken { + // Skip if this is in an object literal method which already gets a grammar error + if parent.Kind == ast.KindMethodDeclaration && parent.Parent.Kind == ast.KindObjectLiteralExpression { return false } + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) + return false + } + + // Check for type nodes - these are always illegal in JS + if ast.IsTypeNode(node) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return false } // Check node-specific constructs @@ -172,32 +168,6 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnosticsWorker(node *ast.Node) bo return false } -// isTypeAnnotation checks if a node is a type annotation in relation to its parent -func (v *jsDiagnosticsVisitor) isTypeAnnotation(parent *ast.Node, node *ast.Node) bool { - switch parent.Kind { - case ast.KindFunctionDeclaration: - return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node - case ast.KindFunctionExpression: - return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node - case ast.KindArrowFunction: - return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node - case ast.KindMethodDeclaration: - return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node - case ast.KindGetAccessor: - return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node - case ast.KindSetAccessor: - return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node - case ast.KindConstructor: - return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node - case ast.KindVariableDeclaration: - return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node - case ast.KindParameter: - return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node - case ast.KindPropertyDeclaration: - return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node - } - return false -} // isSignatureDeclaration checks if a node is a signature declaration (function without body) func (v *jsDiagnosticsVisitor) isSignatureDeclaration(node *ast.Node) bool { @@ -214,11 +184,6 @@ func (v *jsDiagnosticsVisitor) isSignatureDeclaration(node *ast.Node) bool { // checkTypeParametersAndModifiers checks for type parameters, type arguments, and modifiers func (v *jsDiagnosticsVisitor) checkTypeParametersAndModifiers(node *ast.Node) { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&ast.NodeFlagsReparsed != 0 { - return - } - // Check type parameters if typeParams := v.getTypeParameters(node); typeParams != nil { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNodeList(typeParams, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)) @@ -241,45 +206,13 @@ func (v *jsDiagnosticsVisitor) getTypeParameters(node *ast.Node) *ast.NodeList { } var typeParameters *ast.NodeList - switch node.Kind { - case ast.KindClassDeclaration: - if node.AsClassDeclaration() != nil { - typeParameters = node.AsClassDeclaration().TypeParameters - } - case ast.KindClassExpression: - if node.AsClassExpression() != nil { - typeParameters = node.AsClassExpression().TypeParameters - } - case ast.KindMethodDeclaration: - if node.AsMethodDeclaration() != nil { - typeParameters = node.AsMethodDeclaration().TypeParameters - } - case ast.KindConstructor: - if node.AsConstructorDeclaration() != nil { - typeParameters = node.AsConstructorDeclaration().TypeParameters - } - case ast.KindGetAccessor: - if node.AsGetAccessorDeclaration() != nil { - typeParameters = node.AsGetAccessorDeclaration().TypeParameters - } - case ast.KindSetAccessor: - if node.AsSetAccessorDeclaration() != nil { - typeParameters = node.AsSetAccessorDeclaration().TypeParameters - } - case ast.KindFunctionExpression: - if node.AsFunctionExpression() != nil { - typeParameters = node.AsFunctionExpression().TypeParameters - } - case ast.KindFunctionDeclaration: - if node.AsFunctionDeclaration() != nil { - typeParameters = node.AsFunctionDeclaration().TypeParameters - } - case ast.KindArrowFunction: - if node.AsArrowFunction() != nil { - typeParameters = node.AsArrowFunction().TypeParameters - } - default: - return nil + + // Try class-like nodes first + if classLike := node.ClassLikeData(); classLike != nil { + typeParameters = classLike.TypeParameters + } else if funcLike := node.FunctionLikeData(); funcLike != nil { + // Try function-like nodes + typeParameters = funcLike.TypeParameters } if typeParameters == nil { @@ -287,13 +220,12 @@ func (v *jsDiagnosticsVisitor) getTypeParameters(node *ast.Node) *ast.NodeList { } // Check if all type parameters are reparsed (JSDoc originated) - for _, tp := range typeParameters.Nodes { - if tp.Flags&ast.NodeFlagsReparsed == 0 { - return typeParameters // Found a non-reparsed type parameter, so return the type parameters - } + // Only check the first one since the reparser only sets type parameters if there are none already + if len(typeParameters.Nodes) > 0 && typeParameters.Nodes[0].Flags&ast.NodeFlagsReparsed != 0 { + return nil // All type parameters are reparsed (JSDoc originated), so this is valid in JS } - return nil // All type parameters are reparsed (JSDoc originated), so this is valid in JS + return typeParameters // Found non-reparsed type parameters } // hasTypeParameters checks if a node has type parameters @@ -309,31 +241,10 @@ func (v *jsDiagnosticsVisitor) getTypeArguments(node *ast.Node) *ast.NodeList { } var typeArguments *ast.NodeList - switch node.Kind { - case ast.KindCallExpression: - if node.AsCallExpression() != nil { - typeArguments = node.AsCallExpression().TypeArguments - } - case ast.KindNewExpression: - if node.AsNewExpression() != nil { - typeArguments = node.AsNewExpression().TypeArguments - } - case ast.KindExpressionWithTypeArguments: - if node.AsExpressionWithTypeArguments() != nil { - typeArguments = node.AsExpressionWithTypeArguments().TypeArguments - } - case ast.KindJsxSelfClosingElement: - if node.AsJsxSelfClosingElement() != nil { - typeArguments = node.AsJsxSelfClosingElement().TypeArguments - } - case ast.KindJsxOpeningElement: - if node.AsJsxOpeningElement() != nil { - typeArguments = node.AsJsxOpeningElement().TypeArguments - } - case ast.KindTaggedTemplateExpression: - if node.AsTaggedTemplateExpression() != nil { - typeArguments = node.AsTaggedTemplateExpression().TypeArguments - } + + // Use the built-in TypeArgumentList() method for supported nodes + if ast.IsCallLikeExpression(node) || node.Kind == ast.KindExpressionWithTypeArguments { + typeArguments = node.TypeArgumentList() } if typeArguments == nil { @@ -341,97 +252,31 @@ func (v *jsDiagnosticsVisitor) getTypeArguments(node *ast.Node) *ast.NodeList { } // Check if all type arguments are reparsed (JSDoc originated) - for _, ta := range typeArguments.Nodes { - if ta.Flags&ast.NodeFlagsReparsed == 0 { - return typeArguments // Found a non-reparsed type argument, so return the type arguments - } + // Only check the first one since the reparser only sets type arguments if there are none already + if len(typeArguments.Nodes) > 0 && typeArguments.Nodes[0].Flags&ast.NodeFlagsReparsed != 0 { + return nil // All type arguments are reparsed (JSDoc originated), so this is valid in JS } - return nil // All type arguments are reparsed (JSDoc originated), so this is valid in JS -} - -// hasTypeArguments checks if a node has type arguments -func (v *jsDiagnosticsVisitor) hasTypeArguments(node *ast.Node) bool { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&ast.NodeFlagsReparsed != 0 { - return false - } - - var typeArguments *ast.NodeList - switch node.Kind { - case ast.KindCallExpression: - if node.AsCallExpression() != nil { - typeArguments = node.AsCallExpression().TypeArguments - } - case ast.KindNewExpression: - if node.AsNewExpression() != nil { - typeArguments = node.AsNewExpression().TypeArguments - } - case ast.KindExpressionWithTypeArguments: - if node.AsExpressionWithTypeArguments() != nil { - typeArguments = node.AsExpressionWithTypeArguments().TypeArguments - } - case ast.KindJsxSelfClosingElement: - if node.AsJsxSelfClosingElement() != nil { - typeArguments = node.AsJsxSelfClosingElement().TypeArguments - } - case ast.KindJsxOpeningElement: - if node.AsJsxOpeningElement() != nil { - typeArguments = node.AsJsxOpeningElement().TypeArguments - } - case ast.KindTaggedTemplateExpression: - if node.AsTaggedTemplateExpression() != nil { - typeArguments = node.AsTaggedTemplateExpression().TypeArguments - } - } - - if typeArguments == nil { - return false - } - - // Check if all type arguments are reparsed (JSDoc originated) - for _, ta := range typeArguments.Nodes { - if ta.Flags&ast.NodeFlagsReparsed == 0 { - return true // Found a non-reparsed type argument, so this is a TypeScript-only construct - } - } - - return false // All type arguments are reparsed (JSDoc originated), so this is valid in JS + return typeArguments // Found non-reparsed type arguments } // checkModifiers checks for TypeScript-only modifiers on various declaration types func (v *jsDiagnosticsVisitor) checkModifiers(node *ast.Node) { - // Bail out early if this node has NodeFlagsReparsed - if node.Flags&ast.NodeFlagsReparsed != 0 { + modifiers := node.Modifiers() + if modifiers == nil { return } - // Check for TypeScript-only modifiers on various declaration types + // Handle different types of nodes with different modifier rules switch node.Kind { case ast.KindVariableStatement: - if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { - v.checkModifierList(node.AsVariableStatement().Modifiers(), true) - } + v.checkModifierList(modifiers, true) // const is valid for variable statements case ast.KindPropertyDeclaration: - if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { - v.checkPropertyModifiers(node.AsPropertyDeclaration().Modifiers()) - } + v.checkPropertyModifiers(modifiers) case ast.KindParameter: - if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { - v.checkParameterModifiers(node.AsParameterDeclaration().Modifiers()) - } - case ast.KindClassDeclaration: - if node.AsClassDeclaration() != nil && node.AsClassDeclaration().Modifiers() != nil { - v.checkModifierList(node.AsClassDeclaration().Modifiers(), false) - } - case ast.KindMethodDeclaration: - if node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Modifiers() != nil { - v.checkModifierList(node.AsMethodDeclaration().Modifiers(), false) - } - case ast.KindFunctionDeclaration: - if node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Modifiers() != nil { - v.checkModifierList(node.AsFunctionDeclaration().Modifiers(), false) - } + v.checkParameterModifiers(modifiers) + default: + v.checkModifierList(modifiers, false) // const is not valid for other declarations } } @@ -442,7 +287,7 @@ func (v *jsDiagnosticsVisitor) checkModifierList(modifiers *ast.ModifierList, is } for _, modifier := range modifiers.Nodes { - // Bail out early if this modifier has NodeFlagsReparsed + // Skip reparsed modifiers (from JSDoc) but continue checking others if modifier.Flags&ast.NodeFlagsReparsed != 0 { continue } @@ -457,7 +302,7 @@ func (v *jsDiagnosticsVisitor) checkPropertyModifiers(modifiers *ast.ModifierLis } for _, modifier := range modifiers.Nodes { - // Bail out early if this modifier has NodeFlagsReparsed + // Skip reparsed modifiers (from JSDoc) but continue checking others if modifier.Flags&ast.NodeFlagsReparsed != 0 { continue } @@ -480,7 +325,7 @@ func (v *jsDiagnosticsVisitor) checkParameterModifiers(modifiers *ast.ModifierLi } for _, modifier := range modifiers.Nodes { - // Bail out early if this modifier has NodeFlagsReparsed + // Skip reparsed modifiers (from JSDoc) but continue checking others if modifier.Flags&ast.NodeFlagsReparsed != 0 { continue } From b48403d7a96024951923449442c73c5560b0e062 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 21 Jul 2025 18:16:04 +0000 Subject: [PATCH 29/31] Fix type argument panic and improve type node detection - partial fix for literal null/undefined issue Co-authored-by: sandersn <293473+sandersn@users.noreply.github.com> --- internal/parser/js_diagnostics.go | 45 +++- ...ypeArgumentCount1(strict=false).errors.txt | 17 +- ...TypeArgumentCount1(strict=true).errors.txt | 17 +- ...ypeArgumentCount2(strict=false).errors.txt | 11 +- ...TypeArgumentCount2(strict=true).errors.txt | 11 +- ...mentsReferenceInConstructor3_Js.errors.txt | 33 +++ .../argumentsReferenceInMethod3_Js.errors.txt | 29 +++ ...aintOfJavascriptClassExpression.errors.txt | 5 +- .../checkJsFiles_noErrorLocation.errors.txt | 25 ++ .../compiler/classExtendingAny.errors.txt | 38 +++ .../classFieldSuperAccessibleJs1.errors.txt | 18 ++ .../classFieldSuperAccessibleJs2.errors.txt | 30 +++ .../classFieldSuperNotAccessibleJs.errors.txt | 5 +- ...tPropsEmptyCurlyBecomesAnyForJs.errors.txt | 29 +++ ...ssingTypeArgsOnJSConstructCalls.errors.txt | 11 +- .../compiler/genericDefaultsJs.errors.txt | 98 ++++++++ ...mportDeclFromTypeNodeInJsSource.errors.txt | 60 +++++ ...ipt(verbatimmodulesyntax=false).errors.txt | 48 ++++ ...ript(verbatimmodulesyntax=true).errors.txt | 48 ++++ .../javascriptCommonjsModule.errors.txt | 12 + ...riptThisAssignmentInStaticBlock.errors.txt | 24 ++ .../jsDeclarationsInheritedTypes.errors.txt | 40 ++++ .../jsEmitIntersectionProperty.errors.txt | 35 +++ .../compiler/jsExtendsImplicitAny.errors.txt | 11 +- .../compiler/jsFileMethodOverloads.errors.txt | 53 +++++ .../jsFileMethodOverloads2.errors.txt | 50 ++++ ...itAnyNoCascadingReferenceErrors.errors.txt | 5 +- .../compiler/superNoModifiersCrash.errors.txt | 17 ++ .../conformance/checkJsdocTypeTag5.errors.txt | 5 +- ...assCanExtendConstructorFunction.errors.txt | 19 +- .../conformance/extendsTag1.errors.txt | 12 + .../conformance/extendsTag2.errors.txt | 26 +++ .../conformance/extendsTag3.errors.txt | 36 +++ .../conformance/extendsTag5.errors.txt | 14 +- .../conformance/extendsTag6.errors.txt | 23 ++ .../conformance/extendsTagEmit.errors.txt | 5 +- ...ingClassMembersFromAssignments3.errors.txt | 17 ++ ...ingClassMembersFromAssignments4.errors.txt | 18 ++ ...ingClassMembersFromAssignments5.errors.txt | 22 ++ .../jsDeclarationsClassAccessor.errors.txt | 41 ++++ ...larationsClassExtendsVisibility.errors.txt | 5 +- .../jsDeclarationsClassStatic2.errors.txt | 18 ++ .../jsDeclarationsClasses.errors.txt | 215 +++++++++++++++++ .../jsDeclarationsClassesErr.errors.txt | 92 +++++++- .../jsDeclarationsDefault.errors.txt | 43 ++++ .../conformance/jsDeclarationsDefault.js | 76 ------ .../conformance/jsDeclarationsDefault.js.diff | 78 +------ ...ExportDoubleAssignmentInClosure.errors.txt | 17 ++ ...eclarationsExportedClassAliases.errors.txt | 23 ++ .../jsDeclarationsGetterSetter.errors.txt | 130 +++++++++++ ...thExplicitNoArgumentConstructor.errors.txt | 19 ++ .../jsDeclarationsThisTypes.errors.txt | 16 ++ .../jsdocAccessibilityTags.errors.txt | 8 +- .../jsdocAugmentsMissingType.errors.txt | 5 +- ...gments_errorInExtendsExpression.errors.txt | 5 +- .../jsdocAugments_nameMismatch.errors.txt | 5 +- ...jsdocAugments_withTypeParameter.errors.txt | 16 ++ .../conformance/jsdocFunctionType.errors.txt | 5 +- .../conformance/jsdocOverrideTag1.errors.txt | 5 +- .../conformance/jsdocTypeTagCast.errors.txt | 5 +- .../conformance/overloadTag2.errors.txt | 5 +- .../conformance/override_js1.errors.txt | 26 +++ .../conformance/override_js2.errors.txt | 5 +- .../conformance/override_js3.errors.txt | 5 +- .../conformance/override_js4.errors.txt | 5 +- ...parserArrowFunctionExpression10.errors.txt | 5 +- ...parserArrowFunctionExpression11.errors.txt | 8 +- ...parserArrowFunctionExpression12.errors.txt | 5 +- ...parserArrowFunctionExpression13.errors.txt | 5 +- ...parserArrowFunctionExpression14.errors.txt | 5 +- ...parserArrowFunctionExpression15.errors.txt | 5 +- ...parserArrowFunctionExpression16.errors.txt | 8 +- ...parserArrowFunctionExpression17.errors.txt | 5 +- .../parserArrowFunctionExpression8.errors.txt | 5 +- .../parserArrowFunctionExpression9.errors.txt | 5 +- .../plainJSGrammarErrors.errors.txt | 26 ++- .../conformance/returnTagTypeGuard.errors.txt | 67 ++++++ .../spellingUncheckedJS.errors.txt | 55 +++++ ...thisPropertyAssignmentInherited.errors.txt | 28 +++ .../thisPropertyOverridesAccessors.errors.txt | 19 ++ .../typeFromPropertyAssignment23.errors.txt | 11 +- .../typeFromPropertyAssignment25.errors.txt | 5 +- .../typeFromPropertyAssignment26.errors.txt | 5 +- .../typeFromPropertyAssignment9.errors.txt | 5 +- .../typeFromPropertyAssignment9_1.errors.txt | 5 +- ...romPropertyAssignmentOutOfOrder.errors.txt | 8 +- .../conformance/typedefTagWrapping.errors.txt | 10 +- ...ReferenceInConstructor3_Js.errors.txt.diff | 37 +++ ...mentsReferenceInMethod3_Js.errors.txt.diff | 33 +++ ...fJavascriptClassExpression.errors.txt.diff | 16 +- ...eckJsFiles_noErrorLocation.errors.txt.diff | 29 +++ .../classExtendingAny.errors.txt.diff | 42 ++++ ...assFieldSuperAccessibleJs1.errors.txt.diff | 32 +-- ...assFieldSuperAccessibleJs2.errors.txt.diff | 34 +++ ...sFieldSuperNotAccessibleJs.errors.txt.diff | 21 +- ...sEmptyCurlyBecomesAnyForJs.errors.txt.diff | 33 +++ ...TypeArgsOnJSConstructCalls.errors.txt.diff | 34 +++ .../genericDefaultsJs.errors.txt.diff | 102 ++++++++ ...DeclFromTypeNodeInJsSource.errors.txt.diff | 64 +++++ ...erbatimmodulesyntax=false).errors.txt.diff | 52 +++++ ...verbatimmodulesyntax=true).errors.txt.diff | 52 +++++ .../javascriptCommonjsModule.errors.txt.diff | 16 ++ ...hisAssignmentInStaticBlock.errors.txt.diff | 28 +++ ...DeclarationsInheritedTypes.errors.txt.diff | 44 ++++ ...jsEmitIntersectionProperty.errors.txt.diff | 39 ++++ .../jsExtendsImplicitAny.errors.txt.diff | 17 +- .../jsFileMethodOverloads.errors.txt.diff | 57 +++++ .../jsFileMethodOverloads2.errors.txt.diff | 54 +++++ ...NoCascadingReferenceErrors.errors.txt.diff | 21 ++ .../superNoModifiersCrash.errors.txt.diff | 21 ++ .../checkJsdocTypeTag5.errors.txt.diff | 11 +- ...nExtendConstructorFunction.errors.txt.diff | 41 +++- .../conformance/extendsTag1.errors.txt.diff | 16 ++ .../conformance/extendsTag2.errors.txt.diff | 37 ++- .../conformance/extendsTag3.errors.txt.diff | 40 ++++ .../conformance/extendsTag5.errors.txt.diff | 54 +++++ .../conformance/extendsTag6.errors.txt.diff | 27 +++ .../extendsTagEmit.errors.txt.diff | 16 +- ...assMembersFromAssignments3.errors.txt.diff | 21 ++ ...assMembersFromAssignments4.errors.txt.diff | 22 ++ ...assMembersFromAssignments5.errors.txt.diff | 26 +++ ...sDeclarationsClassAccessor.errors.txt.diff | 45 ++++ ...ionsClassExtendsVisibility.errors.txt.diff | 5 +- ...jsDeclarationsClassStatic2.errors.txt.diff | 22 ++ .../jsDeclarationsClasses.errors.txt.diff | 219 +++++++++++++++++ .../jsDeclarationsClassesErr.errors.txt.diff | 220 ++++++++++++++++++ .../jsDeclarationsDefault.errors.txt.diff | 47 ++++ ...tDoubleAssignmentInClosure.errors.txt.diff | 21 ++ ...ationsExportedClassAliases.errors.txt.diff | 27 +++ ...jsDeclarationsGetterSetter.errors.txt.diff | 134 +++++++++++ ...licitNoArgumentConstructor.errors.txt.diff | 23 ++ .../jsDeclarationsThisTypes.errors.txt.diff | 20 ++ .../jsdocAccessibilityTags.errors.txt.diff | 36 +++ .../jsdocAugmentsMissingType.errors.txt.diff | 5 +- ...s_errorInExtendsExpression.errors.txt.diff | 19 ++ ...jsdocAugments_nameMismatch.errors.txt.diff | 21 ++ ...Augments_withTypeParameter.errors.txt.diff | 20 ++ .../jsdocFunctionType.errors.txt.diff | 9 +- .../jsdocOverrideTag1.errors.txt.diff | 23 ++ .../jsdocTypeTagCast.errors.txt.diff | 20 +- .../conformance/overloadTag2.errors.txt.diff | 18 ++ .../conformance/override_js1.errors.txt.diff | 30 +++ .../conformance/override_js2.errors.txt.diff | 23 ++ .../conformance/override_js3.errors.txt.diff | 20 ++ .../conformance/override_js4.errors.txt.diff | 19 ++ ...rArrowFunctionExpression10.errors.txt.diff | 22 ++ ...rArrowFunctionExpression11.errors.txt.diff | 28 +++ ...rArrowFunctionExpression12.errors.txt.diff | 22 ++ ...rArrowFunctionExpression13.errors.txt.diff | 21 ++ ...rArrowFunctionExpression14.errors.txt.diff | 22 ++ ...rArrowFunctionExpression15.errors.txt.diff | 15 ++ ...rArrowFunctionExpression16.errors.txt.diff | 18 ++ ...rArrowFunctionExpression17.errors.txt.diff | 22 ++ ...erArrowFunctionExpression8.errors.txt.diff | 18 ++ ...erArrowFunctionExpression9.errors.txt.diff | 22 ++ .../plainJSGrammarErrors.errors.txt.diff | 80 +++++++ .../returnTagTypeGuard.errors.txt.diff | 71 ++++++ .../spellingUncheckedJS.errors.txt.diff | 59 +++++ ...ropertyAssignmentInherited.errors.txt.diff | 32 +++ ...PropertyOverridesAccessors.errors.txt.diff | 23 ++ ...peFromPropertyAssignment23.errors.txt.diff | 11 +- ...peFromPropertyAssignment25.errors.txt.diff | 5 +- ...peFromPropertyAssignment26.errors.txt.diff | 12 +- ...ypeFromPropertyAssignment9.errors.txt.diff | 5 +- ...eFromPropertyAssignment9_1.errors.txt.diff | 5 +- ...opertyAssignmentOutOfOrder.errors.txt.diff | 8 +- .../typedefTagWrapping.errors.txt.diff | 41 +++- 167 files changed, 4683 insertions(+), 309 deletions(-) create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/checkJsFiles_noErrorLocation.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/classExtendingAny.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs2.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/genericDefaultsJs.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/importDeclFromTypeNodeInJsSource.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsEmitIntersectionProperty.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/superNoModifiersCrash.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/extendsTag2.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/extendsTag3.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/extendsTag6.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments3.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments4.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments5.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic2.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsExportedClassAliases.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/override_js1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/spellingUncheckedJS.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/thisPropertyOverridesAccessors.errors.txt create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles_noErrorLocation.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/classExtendingAny.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/importDeclFromTypeNodeInJsSource.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/javascriptThisAssignmentInStaticBlock.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsEmitIntersectionProperty.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/superNoModifiersCrash.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag6.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments4.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments5.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDoubleAssignmentInClosure.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportedClassAliases.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_errorInExtendsExpression.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_nameMismatch.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression11.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression12.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression8.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression9.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/spellingUncheckedJS.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyOverridesAccessors.errors.txt.diff diff --git a/internal/parser/js_diagnostics.go b/internal/parser/js_diagnostics.go index d332ed6899..abf0b1d7f1 100644 --- a/internal/parser/js_diagnostics.go +++ b/internal/parser/js_diagnostics.go @@ -60,10 +60,41 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnosticsWorker(node *ast.Node) bo return false } - // Check for type nodes - these are always illegal in JS - if ast.IsTypeNode(node) { + // Check for specific TypeScript-only constructs + switch node.Kind { + // Type nodes that are always illegal in JS (but exclude some that are valid as literals/expressions) + case ast.KindAnyKeyword, ast.KindUnknownKeyword, ast.KindNumberKeyword, ast.KindBigIntKeyword, + ast.KindStringKeyword, ast.KindBooleanKeyword, ast.KindSymbolKeyword, ast.KindObjectKeyword, + ast.KindNeverKeyword, ast.KindIntrinsicKeyword: v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) return false + case ast.KindVoidKeyword: + // Only flag void when not used as void expression + if parent.Kind != ast.KindVoidExpression { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return false + } + case ast.KindNullKeyword, ast.KindUndefinedKeyword: + // Only flag null/undefined when used in type context, not as literal values + if ast.IsPartOfTypeNode(node) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return false + } + case ast.KindExpressionWithTypeArguments: + // Only flag when it's actually part of a type expression (implements clause), not extends clause + if ast.IsPartOfTypeNode(node) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return false + } + } + + // Check for type nodes in the type node range + if node.Kind >= ast.KindFirstTypeNode && node.Kind <= ast.KindLastTypeNode { + // Skip ExpressionWithTypeArguments as it's handled above + if node.Kind != ast.KindExpressionWithTypeArguments { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return false + } } // Check node-specific constructs @@ -242,8 +273,14 @@ func (v *jsDiagnosticsVisitor) getTypeArguments(node *ast.Node) *ast.NodeList { var typeArguments *ast.NodeList - // Use the built-in TypeArgumentList() method for supported nodes - if ast.IsCallLikeExpression(node) || node.Kind == ast.KindExpressionWithTypeArguments { + // Handle specific node types that can have type arguments + switch node.Kind { + case ast.KindCallExpression, ast.KindNewExpression, ast.KindTaggedTemplateExpression, + ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement: + if ast.IsCallLikeExpression(node) { + typeArguments = node.TypeArgumentList() + } + case ast.KindExpressionWithTypeArguments: typeArguments = node.TypeArgumentList() } diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt index 7e0c1775a3..4b913fca00 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt @@ -1,7 +1,8 @@ error TS5055: Cannot write file 'b.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. -b.js(9,27): error TS8011: Type arguments can only be used in TypeScript files. -b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. +b.js(3,25): error TS8010: Type annotations can only be used in TypeScript files. +b.js(9,25): error TS8010: Type annotations can only be used in TypeScript files. +b.js(15,25): error TS8010: Type annotations can only be used in TypeScript files. !!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. @@ -9,26 +10,28 @@ b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. ==== a.ts (0 errors) ==== export class A {} -==== b.js (2 errors) ==== +==== b.js (3 errors) ==== import { A } from './a.js'; export class B1 extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } } export class B2 extends A { - ~~~~~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } } export class B3 extends A { - ~~~~~~~~~~~~~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt index 3d32450ed8..2ece3e3d06 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt @@ -1,9 +1,10 @@ error TS5055: Cannot write file 'b.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. +b.js(3,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(3,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -b.js(9,27): error TS8011: Type arguments can only be used in TypeScript files. +b.js(9,25): error TS8010: Type annotations can only be used in TypeScript files. +b.js(15,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(15,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. !!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. @@ -11,11 +12,13 @@ b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. ==== a.ts (0 errors) ==== export class A {} -==== b.js (4 errors) ==== +==== b.js (5 errors) ==== import { A } from './a.js'; export class B1 extends A { ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. constructor() { super(); @@ -23,8 +26,8 @@ b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. } export class B2 extends A { - ~~~~~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } @@ -32,9 +35,9 @@ b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. export class B3 extends A { ~~~~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. - ~~~~~~~~~~~~~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); } diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt index ea03590841..d4aa32fcce 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt @@ -1,5 +1,8 @@ error TS5055: Cannot write file 'b.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. +b.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. +b.js(11,25): error TS8010: Type annotations can only be used in TypeScript files. +b.js(18,25): error TS8010: Type annotations can only be used in TypeScript files. !!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. @@ -7,11 +10,13 @@ error TS5055: Cannot write file 'b.js' because it would overwrite input file. ==== a.ts (0 errors) ==== export class A {} -==== b.js (0 errors) ==== +==== b.js (3 errors) ==== import { A } from './a.js'; /** @extends {A} */ export class B1 extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } @@ -19,6 +24,8 @@ error TS5055: Cannot write file 'b.js' because it would overwrite input file. /** @extends {A} */ export class B2 extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } @@ -26,6 +33,8 @@ error TS5055: Cannot write file 'b.js' because it would overwrite input file. /** @extends {A} */ export class B3 extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt index b114e4bfab..c2be17af46 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt @@ -1,6 +1,9 @@ error TS5055: Cannot write file 'b.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. +b.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(4,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +b.js(11,25): error TS8010: Type annotations can only be used in TypeScript files. +b.js(18,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(18,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -9,12 +12,14 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' ==== a.ts (0 errors) ==== export class A {} -==== b.js (2 errors) ==== +==== b.js (5 errors) ==== import { A } from './a.js'; /** @extends {A} */ export class B1 extends A { ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. constructor() { super(); @@ -23,6 +28,8 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' /** @extends {A} */ export class B2 extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } @@ -31,6 +38,8 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' /** @extends {A} */ export class B3 extends A { ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. constructor() { super(); diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt new file mode 100644 index 0000000000..bd0cdb5d70 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt @@ -0,0 +1,33 @@ +/a.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class A { + get arguments() { + return { bar: {} }; + } + } + + class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + super(); + + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = super.arguments.foo; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt new file mode 100644 index 0000000000..58ce3dc3f0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt @@ -0,0 +1,29 @@ +/a.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + class A { + get arguments() { + return { bar: {} }; + } + } + + class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + /** + * @type object + */ + this.x = foo; + + /** + * @type object + */ + this.y = super.arguments.bar; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt index 91e5fd5a6c..541c1d9eff 100644 --- a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt @@ -1,11 +1,12 @@ error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. weird.js(1,1): error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? weird.js(1,23): error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. +weird.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. !!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== weird.js (3 errors) ==== +==== weird.js (4 errors) ==== someFunction(function(BaseClass) { ~~~~~~~~~~~~ !!! error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? @@ -15,6 +16,8 @@ weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); this.foo = "bar"; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsFiles_noErrorLocation.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsFiles_noErrorLocation.errors.txt new file mode 100644 index 0000000000..dfeeed3d23 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/checkJsFiles_noErrorLocation.errors.txt @@ -0,0 +1,25 @@ +a.js(11,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + // @ts-check + class A { + constructor() { + + } + foo() { + return 4; + } + } + + class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + this.foo = () => 3; + } + } + + const i = new B(); + i.foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classExtendingAny.errors.txt b/testdata/baselines/reference/submodule/compiler/classExtendingAny.errors.txt new file mode 100644 index 0000000000..a2f4e5c8b6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/classExtendingAny.errors.txt @@ -0,0 +1,38 @@ +b.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.ts (0 errors) ==== + declare var Err: any + class A extends Err { + payload: string + constructor() { + super(1,2,3,3,4,56) + super.unknown + super['unknown'] + } + process() { + return this.payload + "!"; + } + } + + var o = { + m() { + super.unknown + } + } +==== b.js (1 errors) ==== + class B extends Err { + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super() + this.wat = 12 + } + f() { + this.wat + this.wit + this['wot'] + super.alsoBad + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt b/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt new file mode 100644 index 0000000000..75a3ee4c4a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt @@ -0,0 +1,18 @@ +index.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + class C { + static blah1 = 123; + } + C.blah2 = 456; + + class D extends C { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + static { + console.log(super.blah1); + console.log(super.blah2); + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs2.errors.txt b/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs2.errors.txt new file mode 100644 index 0000000000..c992438eda --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs2.errors.txt @@ -0,0 +1,30 @@ +index.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + class C { + constructor() { + this.foo = () => { + console.log("called arrow"); + }; + } + foo() { + console.log("called method"); + } + } + + class D extends C { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + foo() { + console.log("SUPER:"); + super.foo(); + console.log("THIS:"); + this.foo(); + } + } + + const obj = new D(); + obj.foo(); + D.prototype.foo.call(obj); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt b/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt index 912485f742..4685d09321 100644 --- a/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt @@ -1,11 +1,12 @@ index.js(7,14): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'. index.js(9,9): error TS7053: Element implicitly has an 'any' type because expression of type '"literalElementAccess"' can't be used to index type 'YaddaBase'. Property 'literalElementAccess' does not exist on type 'YaddaBase'. +index.js(18,28): error TS8010: Type annotations can only be used in TypeScript files. index.js(26,22): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'. index.js(29,22): error TS2339: Property 'literalElementAccess' does not exist on type 'YaddaBase'. -==== index.js (4 errors) ==== +==== index.js (5 errors) ==== // https://github.com/microsoft/TypeScript/issues/55884 class YaddaBase { @@ -29,6 +30,8 @@ index.js(29,22): error TS2339: Property 'literalElementAccess' does not exist on } class DerivedYadda extends YaddaBase { + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. get rootTests() { return super.roots; } diff --git a/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt b/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt new file mode 100644 index 0000000000..962247cfd7 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt @@ -0,0 +1,29 @@ +component.js(2,28): error TS8010: Type annotations can only be used in TypeScript files. + + +==== library.d.ts (0 errors) ==== + export class Foo { + props: T; + state: U; + constructor(props: T, state: U); + } + +==== component.js (1 errors) ==== + import { Foo } from "./library"; + export class MyFoo extends Foo { + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + member; + } + +==== typed_component.ts (0 errors) ==== + import { MyFoo } from "./component"; + export class TypedFoo extends MyFoo { + constructor() { + super({x: "string", y: 42}, { value: undefined }); + this.props.x; + this.props.y; + this.state.value; + this.member; + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt index a4e9026a3a..13d4cb7de4 100644 --- a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@ -4,15 +4,18 @@ BaseB.js(3,14): error TS2304: Cannot find name 'Class'. BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(4,25): error TS2304: Cannot find name 'Class'. BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. -SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files. +SubA.js(2,35): error TS8010: Type annotations can only be used in TypeScript files. +SubB.js(3,35): error TS8010: Type annotations can only be used in TypeScript files. ==== BaseA.js (0 errors) ==== export default class BaseA { } -==== SubA.js (0 errors) ==== +==== SubA.js (1 errors) ==== import BaseA from './BaseA'; export default class SubA extends BaseA { + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. } ==== BaseB.js (6 errors) ==== import BaseA from './BaseA'; @@ -38,8 +41,8 @@ SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files import SubA from './SubA'; import BaseB from './BaseB'; export default class SubB extends BaseB { - ~~~~ -!!! error TS8011: Type arguments can only be used in TypeScript files. + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(SubA); } diff --git a/testdata/baselines/reference/submodule/compiler/genericDefaultsJs.errors.txt b/testdata/baselines/reference/submodule/compiler/genericDefaultsJs.errors.txt new file mode 100644 index 0000000000..1703b50e33 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/genericDefaultsJs.errors.txt @@ -0,0 +1,98 @@ +main.js(19,21): error TS8010: Type annotations can only be used in TypeScript files. +main.js(20,21): error TS8010: Type annotations can only be used in TypeScript files. +main.js(25,21): error TS8010: Type annotations can only be used in TypeScript files. +main.js(43,21): error TS8010: Type annotations can only be used in TypeScript files. +main.js(44,21): error TS8010: Type annotations can only be used in TypeScript files. +main.js(49,21): error TS8010: Type annotations can only be used in TypeScript files. + + +==== decls.d.ts (0 errors) ==== + declare function f0(x?: T): T; + declare function f1(x?: T): [T, U]; + declare class C0 { + y: T; + constructor(x?: T); + } + declare class C1 { + y: [T, U]; + constructor(x?: T); + } +==== main.js (6 errors) ==== + const f0_v0 = f0(); + const f0_v1 = f0(1); + + const f1_c0 = f1(); + const f1_c1 = f1(1); + + const C0_v0 = new C0(); + const C0_v0_y = C0_v0.y; + + const C0_v1 = new C0(1); + const C0_v1_y = C0_v1.y; + + const C1_v0 = new C1(); + const C1_v0_y = C1_v0.y; + + const C1_v1 = new C1(1); + const C1_v1_y = C1_v1.y; + + class C0_B0 extends C0 {} + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + class C0_B1 extends C0 { + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + } + } + class C0_B2 extends C0 { + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(1); + } + } + + const C0_B0_v0 = new C0_B0(); + const C0_B0_v0_y = C0_B0_v0.y; + + const C0_B0_v1 = new C0_B0(1); + const C0_B0_v1_y = C0_B0_v1.y; + + const C0_B1_v0 = new C0_B1(); + const C0_B1_v0_y = C0_B1_v0.y; + + const C0_B2_v0 = new C0_B2(); + const C0_B2_v0_y = C0_B2_v0.y; + + class C1_B0 extends C1 {} + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + class C1_B1 extends C1 { + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + } + } + class C1_B2 extends C1 { + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(1); + } + } + + const C1_B0_v0 = new C1_B0(); + const C1_B0_v0_y = C1_B0_v0.y; + + const C1_B0_v1 = new C1_B0(1); + const C1_B0_v1_y = C1_B0_v1.y; + + const C1_B1_v0 = new C1_B1(); + const C1_B1_v0_y = C1_B1_v0.y; + + const C1_B2_v0 = new C1_B2(); + const C1_B2_v0_y = C1_B2_v0.y; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importDeclFromTypeNodeInJsSource.errors.txt b/testdata/baselines/reference/submodule/compiler/importDeclFromTypeNodeInJsSource.errors.txt new file mode 100644 index 0000000000..fd05054d60 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importDeclFromTypeNodeInJsSource.errors.txt @@ -0,0 +1,60 @@ +/src/b.js(5,26): error TS8010: Type annotations can only be used in TypeScript files. +/src/b.js(8,27): error TS8010: Type annotations can only be used in TypeScript files. +/src/b.js(11,27): error TS8010: Type annotations can only be used in TypeScript files. +/src/b.js(14,27): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /src/node_modules/@types/node/index.d.ts (0 errors) ==== + /// +==== /src/node_modules/@types/node/events.d.ts (0 errors) ==== + declare module "events" { + namespace EventEmitter { + class EventEmitter { + constructor(); + } + } + export = EventEmitter; + } + declare module "nestNamespaceModule" { + namespace a1.a2 { + class d { } + } + + namespace a1.a2.n3 { + class c { } + } + export = a1.a2; + } + declare module "renameModule" { + namespace a.b { + class c { } + } + import d = a.b; + export = d; + } + +==== /src/b.js (4 errors) ==== + import { EventEmitter } from 'events'; + import { n3, d } from 'nestNamespaceModule'; + import { c } from 'renameModule'; + + export class Foo extends EventEmitter { + ~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class Foo2 extends n3.c { + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class Foo3 extends d { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class Foo4 extends c { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt new file mode 100644 index 0000000000..ec866483f6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt @@ -0,0 +1,48 @@ +/index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /node_modules/tslib/package.json (0 errors) ==== + { + "name": "tslib", + "main": "tslib.js", + "module": "tslib.es6.js", + "jsnext:main": "tslib.es6.js", + "typings": "tslib.d.ts", + "exports": { + ".": { + "module": { + "types": "./modules/index.d.ts", + "default": "./tslib.es6.mjs" + }, + "import": { + "node": "./modules/index.js", + "default": { + "types": "./modules/index.d.ts", + "default": "./tslib.es6.mjs" + } + }, + "default": "./tslib.js" + }, + "./*": "./*", + "./": "./" + } + } + +==== /node_modules/tslib/tslib.d.ts (0 errors) ==== + export declare var __extends: any; + +==== /node_modules/tslib/modules/package.json (0 errors) ==== + { "type": "module" } + +==== /node_modules/tslib/modules/index.d.ts (0 errors) ==== + export {}; + +==== /index.js (1 errors) ==== + class Foo {} + + class Bar extends Foo {} + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + module.exports = Bar; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt new file mode 100644 index 0000000000..ec866483f6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt @@ -0,0 +1,48 @@ +/index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /node_modules/tslib/package.json (0 errors) ==== + { + "name": "tslib", + "main": "tslib.js", + "module": "tslib.es6.js", + "jsnext:main": "tslib.es6.js", + "typings": "tslib.d.ts", + "exports": { + ".": { + "module": { + "types": "./modules/index.d.ts", + "default": "./tslib.es6.mjs" + }, + "import": { + "node": "./modules/index.js", + "default": { + "types": "./modules/index.d.ts", + "default": "./tslib.es6.mjs" + } + }, + "default": "./tslib.js" + }, + "./*": "./*", + "./": "./" + } + } + +==== /node_modules/tslib/tslib.d.ts (0 errors) ==== + export declare var __extends: any; + +==== /node_modules/tslib/modules/package.json (0 errors) ==== + { "type": "module" } + +==== /node_modules/tslib/modules/index.d.ts (0 errors) ==== + export {}; + +==== /index.js (1 errors) ==== + class Foo {} + + class Bar extends Foo {} + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + module.exports = Bar; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.errors.txt b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.errors.txt new file mode 100644 index 0000000000..1e63514ebf --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.errors.txt @@ -0,0 +1,12 @@ +index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + class Foo {} + + class Bar extends Foo {} + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + module.exports = Bar; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.errors.txt b/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.errors.txt new file mode 100644 index 0000000000..c2a0afced1 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.errors.txt @@ -0,0 +1,24 @@ +/src/a.js(10,29): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /src/a.js (1 errors) ==== + class Thing { + static { + this.doSomething = () => {}; + } + } + + Thing.doSomething(); + + // GH#46468 + class ElementsArray extends Array { + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + static { + const superisArray = super.isArray; + const customIsArray = (arg)=> superisArray(arg); + this.isArray = customIsArray; + } + } + + ElementsArray.isArray(new ElementsArray()); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt new file mode 100644 index 0000000000..b114779864 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt @@ -0,0 +1,40 @@ +a.js(18,18): error TS8010: Type annotations can only be used in TypeScript files. +a.js(25,18): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (2 errors) ==== + /** + * @typedef A + * @property {string} a + */ + + /** + * @typedef B + * @property {number} b + */ + + class C1 { + /** + * @type {A} + */ + value; + } + + class C2 extends C1 { + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + /** + * @type {A} + */ + value; + } + + class C3 extends C1 { + ~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + /** + * @type {A & B} + */ + value; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEmitIntersectionProperty.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEmitIntersectionProperty.errors.txt new file mode 100644 index 0000000000..4302bd8f7b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsEmitIntersectionProperty.errors.txt @@ -0,0 +1,35 @@ +index.js(1,34): error TS8010: Type annotations can only be used in TypeScript files. + + +==== globals.d.ts (0 errors) ==== + declare class CoreObject { + static extend< + Statics, + Instance extends B1, + T1, + B1 + >( + this: Statics & { new(): Instance }, + arg1: T1 + ): Readonly & { new(): T1 & Instance }; + + toString(): string; + } + + declare class Mixin { + static create( + args?: T + ): Mixin; + } + declare const Observable: Mixin<{}> + declare class EmberObject extends CoreObject.extend(Observable) {} + declare class CoreView extends EmberObject.extend({}) {} + declare class Component extends CoreView.extend({}) {} + +==== index.js (1 errors) ==== + export class MyComponent extends Component { + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt index 82c630fced..56d37e29dd 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt @@ -1,25 +1,34 @@ +/b.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. /b.js(1,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +/b.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. /b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +/b.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. /b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== /a.d.ts (0 errors) ==== declare class A { x: T; } -==== /b.js (3 errors) ==== +==== /b.js (6 errors) ==== class B extends A {} ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new B().x; /** @augments A */ class C extends A { } ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new C().x; /** @augments A */ class D extends A {} ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new D().x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt new file mode 100644 index 0000000000..7a57869ffa --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt @@ -0,0 +1,53 @@ +jsFileMethodOverloads.js(44,15): error TS8009: The '?' modifier can only be used in TypeScript files. + + +==== jsFileMethodOverloads.js (1 errors) ==== + /** + * @template T + */ + class Example { + /** + * @param {T} value + */ + constructor(value) { + this.value = value; + } + + /** + * @overload + * @param {Example} this + * @returns {'number'} + */ + /** + * @overload + * @param {Example} this + * @returns {'string'} + */ + /** + * @returns {string} + */ + getTypeName() { + return typeof this.value; + } + + /** + * @template U + * @overload + * @param {(y: T) => U} fn + * @returns {U} + */ + /** + * @overload + * @returns {T} + */ + /** + * @param {(y: T) => unknown} [fn] + * @returns {unknown} + */ + transform(fn) { + return fn ? fn(this.value) : this.value; + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt new file mode 100644 index 0000000000..78e37a5fdf --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt @@ -0,0 +1,50 @@ +jsFileMethodOverloads2.js(41,15): error TS8009: The '?' modifier can only be used in TypeScript files. + + +==== jsFileMethodOverloads2.js (1 errors) ==== + // Also works if all @overload tags are combined in one comment. + /** + * @template T + */ + class Example { + /** + * @param {T} value + */ + constructor(value) { + this.value = value; + } + + /** + * @overload + * @param {Example} this + * @returns {'number'} + * + * @overload + * @param {Example} this + * @returns {'string'} + * + * @returns {string} + */ + getTypeName() { + return typeof this.value; + } + + /** + * @template U + * @overload + * @param {(y: T) => U} fn + * @returns {U} + * + * @overload + * @returns {T} + * + * @param {(y: T) => unknown} [fn] + * @returns {unknown} + */ + transform(fn) { + return fn ? fn(this.value) : this.value; + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt b/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt index 6155497229..37a78b9342 100644 --- a/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt @@ -1,3 +1,4 @@ +index.js(3,21): error TS8010: Type annotations can only be used in TypeScript files. index.js(3,21): error TS8026: Expected Foo type arguments; provide these with an '@extends' tag. @@ -5,11 +6,13 @@ index.js(3,21): error TS8026: Expected Foo type arguments; provide these with export declare class Foo { prop: T; } -==== index.js (1 errors) ==== +==== index.js (2 errors) ==== import {Foo} from "./somelib"; class MyFoo extends Foo { ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ !!! error TS8026: Expected Foo type arguments; provide these with an '@extends' tag. constructor() { super(); diff --git a/testdata/baselines/reference/submodule/compiler/superNoModifiersCrash.errors.txt b/testdata/baselines/reference/submodule/compiler/superNoModifiersCrash.errors.txt new file mode 100644 index 0000000000..661a662c48 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/superNoModifiersCrash.errors.txt @@ -0,0 +1,17 @@ +File.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. + + +==== File.js (1 errors) ==== + class Parent { + initialize() { + super.initialize(...arguments) + return this.asdf = '' + } + } + + class Child extends Parent { + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + initialize() { + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt index 285e2ac7c4..2b1591ab51 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag5.errors.txt @@ -5,11 +5,12 @@ 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(30,35): error TS8009: The '?' modifier can only be used in TypeScript files. 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) ==== +==== test.js (7 errors) ==== // all 6 should error on return statement/expression /** @type {(x: number) => string} */ function h(x) { return x } @@ -54,6 +55,8 @@ test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. /** @type {Gioconda} */ function monaLisa(sb) { return typeof sb === 'string' ? 1 : 2; + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. } /** @type {2 | 3} - overloads are not supported, so there will be an error */ diff --git a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt index 321592a027..3e716a524c 100644 --- a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt @@ -1,8 +1,13 @@ +first.js(10,19): error TS8009: The '?' modifier can only be used in TypeScript files. +first.js(16,47): error TS8009: The '?' modifier can only be used in TypeScript files. first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. +first.js(21,19): error TS8010: Type annotations can only be used in TypeScript files. 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(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. +first.js(47,24): error TS8010: Type annotations can only be used in TypeScript files. generic.js(9,23): error TS2507: Type '(flavour: T) => void' is not a constructor function type. +generic.js(9,23): error TS8010: Type annotations can only be used in TypeScript files. 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'. @@ -12,7 +17,7 @@ second.ts(14,25): error TS2507: Type '{ (numberOxen: number): void; circle: (wag second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== first.js (4 errors) ==== +==== first.js (8 errors) ==== /** * @constructor * @param {number} numberOxen @@ -23,12 +28,16 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con /** @param {Wagon[]=} wagons */ Wagon.circle = function (wagons) { return wagons ? wagons.length : 3.14; + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. } /** @param {*[]=} supplies - *[]= is my favourite type */ Wagon.prototype.load = function (supplies) { } /** @param {*[]=} supplies - Yep, still a great type */ Wagon.prototype.weight = supplies => supplies ? supplies.length : -1 + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. Wagon.prototype.speed = function () { return this.numberOxen / this.weight() } @@ -36,6 +45,8 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con class Sql extends Wagon { ~~~~~ !!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); // error: not enough arguments this.foonly = 12 @@ -68,6 +79,8 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con class Drakkhen extends Dragon { ~~~~~~ !!! error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. } @@ -105,7 +118,7 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con ~~~~~~~~~~ !!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (5 errors) ==== +==== generic.js (6 errors) ==== /** * @template T * @param {T} flavour @@ -117,6 +130,8 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con class Chowder extends Soup { ~~~~ !!! error TS2507: Type '(flavour: T) => void' is not a constructor function type. + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. log() { return this.flavour ~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt new file mode 100644 index 0000000000..687c017a35 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/extendsTag1.errors.txt @@ -0,0 +1,12 @@ +bug25101.js(5,18): error TS8010: Type annotations can only be used in TypeScript files. + + +==== bug25101.js (1 errors) ==== + /** + * @template T + * @extends {Set} Should prefer this Set, not the Set in the heritage clause + */ + class My extends Set {} + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag2.errors.txt new file mode 100644 index 0000000000..d2c1642db5 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/extendsTag2.errors.txt @@ -0,0 +1,26 @@ +foo.js(15,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.js (1 errors) ==== + /** + * @constructor + */ + class A { + constructor() {} + } + + /** + * @extends {A} + */ + + /** + * @constructor + */ + class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag3.errors.txt new file mode 100644 index 0000000000..6bd90e23b8 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/extendsTag3.errors.txt @@ -0,0 +1,36 @@ +foo.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. +foo.js(22,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.js (2 errors) ==== + /** + * @constructor + */ + class A { + constructor() {} + } + + /** + * @extends {A} + * @constructor + */ + class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + } + } + + /** + * @extends { A } + * @constructor + */ + class C extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt index 8c2c3e3e07..c2b4e69721 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTag5.errors.txt @@ -1,12 +1,16 @@ +/a.js(26,17): error TS8010: Type annotations can only be used in TypeScript files. /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(34,17): error TS8010: Type annotations can only be used in TypeScript files. +/a.js(39,17): error TS8010: Type annotations can only be used in TypeScript files. /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(44,17): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (6 errors) ==== /** * @typedef {{ * a: number | string; @@ -33,6 +37,8 @@ * }>} */ class B extends A {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** * @extends {A<{ @@ -48,11 +54,15 @@ !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. */ class C extends A {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** * @extends {A<{a: string, b: string[]}>} */ class D extends A {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** * @extends {A<{a: string, b: string}>} @@ -62,4 +72,6 @@ !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. */ class E extends A {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag6.errors.txt new file mode 100644 index 0000000000..c1a774832b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/extendsTag6.errors.txt @@ -0,0 +1,23 @@ +foo.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.js (1 errors) ==== + /** + * @constructor + */ + class A { + constructor() {} + } + + /** + * @extends { A } + * @constructor + */ + class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt index 7f2002cbad..1b8f34d893 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt @@ -1,14 +1,17 @@ main.js(2,15): error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. +main.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. ==== super.js (0 errors) ==== export class B { } -==== main.js (1 errors) ==== +==== main.js (2 errors) ==== import { B } from './super' /** @extends {Mismatch} */ ~~~~~~~~ !!! error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. class C extends B { } + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments3.errors.txt b/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments3.errors.txt new file mode 100644 index 0000000000..718a3a7526 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments3.errors.txt @@ -0,0 +1,17 @@ +a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class Base { + constructor() { + this.p = 1 + } + } + class Derived extends Base { + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + m() { + this.p = 1 + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments4.errors.txt b/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments4.errors.txt new file mode 100644 index 0000000000..965544c6ce --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments4.errors.txt @@ -0,0 +1,18 @@ +a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class Base { + m() { + this.p = 1 + } + } + class Derived extends Base { + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + m() { + // should be OK, and p should have type number | undefined from its base + this.p = 1 + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments5.errors.txt b/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments5.errors.txt new file mode 100644 index 0000000000..d4fe89fced --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments5.errors.txt @@ -0,0 +1,22 @@ +a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class Base { + m() { + this.p = 1 + } + } + class Derived extends Base { + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + // should be OK, and p should have type number from this assignment + this.p = 1 + } + test() { + return this.p + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt new file mode 100644 index 0000000000..3d0fba95ff --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt @@ -0,0 +1,41 @@ +argument.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. + + +==== supplement.d.ts (0 errors) ==== + export { }; + declare module "./argument.js" { + interface Argument { + idlType: any; + default: null; + } + } +==== base.js (0 errors) ==== + export class Base { + constructor() { } + + toJSON() { + const json = { type: undefined, name: undefined, inheritance: undefined }; + return json; + } + } +==== argument.js (1 errors) ==== + import { Base } from "./base.js"; + export class Argument extends Base { + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + /** + * @param {*} tokeniser + */ + static parse(tokeniser) { + return; + } + + get type() { + return "argument"; + } + + /** + * @param {*} defs + */ + *validate(defs) { } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.errors.txt index cbb4b6d57d..6c46284e83 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.errors.txt @@ -1,14 +1,17 @@ +cls.js(6,19): error TS8010: Type annotations can only be used in TypeScript files. cls.js(7,1): error TS2309: An export assignment cannot be used in a module with other exported elements. cls.js(8,16): error TS2339: Property 'Strings' does not exist on type 'typeof Foo'. -==== cls.js (2 errors) ==== +==== cls.js (3 errors) ==== const Bar = require("./bar"); const Strings = { a: "A", b: "B" }; class Foo extends Bar {} + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. module.exports = Foo; ~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic2.errors.txt new file mode 100644 index 0000000000..a63f19414e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic2.errors.txt @@ -0,0 +1,18 @@ +Foo.js(4,26): error TS8010: Type annotations can only be used in TypeScript files. + + +==== Foo.js (1 errors) ==== + class Base { + static foo = ""; + } + export class Foo extends Base {} + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + Foo.foo = "foo"; + +==== Bar.ts (0 errors) ==== + import { Foo } from "./Foo.js"; + + class Bar extends Foo {} + Bar.foo = "foo"; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt new file mode 100644 index 0000000000..4856a5e716 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt @@ -0,0 +1,215 @@ +index.js(147,24): error TS8010: Type annotations can only be used in TypeScript files. +index.js(149,24): error TS8010: Type annotations can only be used in TypeScript files. +index.js(159,24): error TS8010: Type annotations can only be used in TypeScript files. +index.js(173,24): error TS8010: Type annotations can only be used in TypeScript files. +index.js(185,35): error TS8010: Type annotations can only be used in TypeScript files. +index.js(191,37): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (6 errors) ==== + export class A {} + + export class B { + static cat = "cat"; + } + + export class C { + static Cls = class {} + } + + export class D { + /** + * @param {number} a + * @param {number} b + */ + constructor(a, b) {} + } + + /** + * @template T,U + */ + export class E { + /** + * @type {T & U} + */ + field; + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {T & U} + * @readonly + */ + readonlyField; + + initializedField = 12; + + /** + * @return {U} + */ + get f1() { return /** @type {*} */(null); } + + /** + * @param {U} _p + */ + set f1(_p) {} + + /** + * @return {U} + */ + get f2() { return /** @type {*} */(null); } + + /** + * @param {U} _p + */ + set f3(_p) {} + + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} + + + /** + * @type {string} + */ + static staticField; + + // @readonly is currently unsupported, it seems - included here just in case that changes + /** + * @type {string} + * @readonly + */ + static staticReadonlyField; + + static staticInitializedField = 12; + + /** + * @return {string} + */ + static get s1() { return ""; } + + /** + * @param {string} _p + */ + static set s1(_p) {} + + /** + * @return {string} + */ + static get s2() { return ""; } + + /** + * @param {string} _p + */ + static set s3(_p) {} + } + + /** + * @template T,U + */ + export class F { + /** + * @type {T & U} + */ + field; + /** + * @param {T} a + * @param {U} b + */ + constructor(a, b) {} + + /** + * @template A,B + * @param {A} a + * @param {B} b + */ + static create(a, b) { return new F(a, b); } + } + + class G {} + + export { G }; + + class HH {} + + export { HH as H }; + + export class I {} + export { I as II }; + + export { J as JJ }; + export class J {} + + + export class K { + constructor() { + this.p1 = 12; + this.p2 = "ok"; + } + + method() { + return this.p1; + } + } + + export class L extends K {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + export class M extends null { + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + this.prop = 12; + } + } + + + /** + * @template T + */ + export class N extends L { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + /** + * @param {T} param + */ + constructor(param) { + super(); + this.another = param; + } + } + + /** + * @template U + * @extends {N} + */ + export class O extends N { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + /** + * @param {U} param + */ + constructor(param) { + super(param); + this.another2 = param; + } + } + + var x = /** @type {*} */(null); + + export class VariableBase extends x {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + + export class HasStatics { + static staticMethod() {} + } + + export class ExtendsStatics extends HasStatics { + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + static also() {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt index 548135e903..5269dd50c0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt @@ -1,27 +1,55 @@ index.js(4,16): error TS8004: Type parameter declarations can only be used in TypeScript files. index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(8,16): error TS8004: Type parameter declarations can only be used in TypeScript files. -index.js(8,29): error TS8011: Type arguments can only be used in TypeScript files. +index.js(8,27): error TS8010: Type annotations can only be used in TypeScript files. index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(13,20): error TS8010: Type annotations can only be used in TypeScript files. +index.js(16,24): error TS8010: Type annotations can only be used in TypeScript files. +index.js(18,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,20): error TS8010: Type annotations can only be used in TypeScript files. +index.js(22,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(23,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(23,20): error TS8010: Type annotations can only be used in TypeScript files. +index.js(26,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(27,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(28,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(28,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(32,20): error TS8010: Type annotations can only be used in TypeScript files. +index.js(35,24): error TS8010: Type annotations can only be used in TypeScript files. +index.js(38,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(39,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(39,20): error TS8010: Type annotations can only be used in TypeScript files. +index.js(42,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(43,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(43,20): error TS8010: Type annotations can only be used in TypeScript files. +index.js(46,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(47,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(47,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(48,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(48,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(52,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(52,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(53,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(53,20): error TS8010: Type annotations can only be used in TypeScript files. +index.js(56,24): error TS8010: Type annotations can only be used in TypeScript files. +index.js(58,25): error TS8010: Type annotations can only be used in TypeScript files. index.js(59,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(59,20): error TS8010: Type annotations can only be used in TypeScript files. +index.js(62,25): error TS8010: Type annotations can only be used in TypeScript files. index.js(63,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(63,20): error TS8010: Type annotations can only be used in TypeScript files. +index.js(66,25): error TS8010: Type annotations can only be used in TypeScript files. index.js(67,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(67,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(68,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(68,20): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (21 errors) ==== +==== index.js (49 errors) ==== // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), // but we should be able to synthesize declarations from the symbols regardless @@ -36,8 +64,8 @@ index.js(68,11): error TS8010: Type annotations can only be used in TypeScript f export class N extends M { ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. - ~ -!!! error TS8011: Type arguments can only be used in TypeScript files. + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. other: U; ~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -46,91 +74,147 @@ index.js(68,11): error TS8010: Type annotations can only be used in TypeScript f export class O { [idx: string]: string; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class P extends O {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export class Q extends O { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: "ok"; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class R extends O { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: "ok"; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class S extends O { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: "ok"; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: never; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class T { [idx: number]: string; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class U extends T {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export class V extends T { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: string; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class W extends T { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: "ok"; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class X extends T { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: string; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: "ok"; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class Y { [idx: string]: {x: number}; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: {x: number, y: number}; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class Z extends Y {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. export class AA extends Y { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: {x: number, y: number}; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class BB extends Y { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: {x: 0, y: 0}; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } export class CC extends Y { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: {x: number, y: number}; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: {x: 0, y: 0}; ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt new file mode 100644 index 0000000000..a8e153abd9 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt @@ -0,0 +1,43 @@ +index4.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index1.js (0 errors) ==== + export default 12; + +==== index2.js (0 errors) ==== + export default function foo() { + return foo; + } + export const x = foo; + export { foo as bar }; + +==== index3.js (0 errors) ==== + export default class Foo { + a = /** @type {Foo} */(null); + }; + export const X = Foo; + export { Foo as Bar }; + +==== index4.js (1 errors) ==== + import Fab from "./index3"; + class Bar extends Fab { + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + x = /** @type {Bar} */(null); + } + export default Bar; + +==== index5.js (0 errors) ==== + // merge type alias and const (OK) + export default 12; + /** + * @typedef {string | number} default + */ + +==== index6.js (0 errors) ==== + // merge type alias and function (OK) + export default function func() {}; + /** + * @typedef {string | number} default + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js index fabe4f7586..bafa2fc294 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js @@ -113,79 +113,3 @@ export type default = string | number; // merge type alias and function (OK) export default function func(): void; export type default = string | number; - - -//// [DtsFileErrors] - - -out/index5.d.ts(3,1): error TS1128: Declaration or statement expected. -out/index5.d.ts(3,8): error TS2304: Cannot find name 'type'. -out/index5.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. -out/index5.d.ts(3,21): error TS1128: Declaration or statement expected. -out/index5.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. -out/index5.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. -out/index6.d.ts(3,1): error TS1128: Declaration or statement expected. -out/index6.d.ts(3,8): error TS2304: Cannot find name 'type'. -out/index6.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. -out/index6.d.ts(3,21): error TS1128: Declaration or statement expected. -out/index6.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. -out/index6.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. - - -==== out/index1.d.ts (0 errors) ==== - declare const _default: number; - export default _default; - -==== out/index2.d.ts (0 errors) ==== - export default function foo(): typeof foo; - export declare const x: typeof foo; - export { foo as bar }; - -==== out/index3.d.ts (0 errors) ==== - export default class Foo { - a: Foo; - } - export declare const X: typeof Foo; - export { Foo as Bar }; - -==== out/index4.d.ts (0 errors) ==== - import Fab from "./index3"; - declare class Bar extends Fab { - x: Bar; - } - export default Bar; - -==== out/index5.d.ts (6 errors) ==== - declare const _default: number; - export default _default; - export type default = string | number; - ~~~~~~ -!!! error TS1128: Declaration or statement expected. - ~~~~ -!!! error TS2304: Cannot find name 'type'. - ~~~~~~~ -!!! error TS2457: Type alias name cannot be 'default'. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~ -!!! error TS2693: 'string' only refers to a type, but is being used as a value here. - ~~~~~~ -!!! error TS2693: 'number' only refers to a type, but is being used as a value here. - -==== out/index6.d.ts (6 errors) ==== - // merge type alias and function (OK) - export default function func(): void; - export type default = string | number; - ~~~~~~ -!!! error TS1128: Declaration or statement expected. - ~~~~ -!!! error TS2304: Cannot find name 'type'. - ~~~~~~~ -!!! error TS2457: Type alias name cannot be 'default'. - ~ -!!! error TS1128: Declaration or statement expected. - ~~~~~~ -!!! error TS2693: 'string' only refers to a type, but is being used as a value here. - ~~~~~~ -!!! error TS2693: 'number' only refers to a type, but is being used as a value here. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff index 913922e847..c9e29891cb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff @@ -81,80 +81,4 @@ -export default func; +// merge type alias and function (OK) +export default function func(): void; -+export type default = string | number; -+ -+ -+//// [DtsFileErrors] -+ -+ -+out/index5.d.ts(3,1): error TS1128: Declaration or statement expected. -+out/index5.d.ts(3,8): error TS2304: Cannot find name 'type'. -+out/index5.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. -+out/index5.d.ts(3,21): error TS1128: Declaration or statement expected. -+out/index5.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. -+out/index5.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. -+out/index6.d.ts(3,1): error TS1128: Declaration or statement expected. -+out/index6.d.ts(3,8): error TS2304: Cannot find name 'type'. -+out/index6.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. -+out/index6.d.ts(3,21): error TS1128: Declaration or statement expected. -+out/index6.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. -+out/index6.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. -+ -+ -+==== out/index1.d.ts (0 errors) ==== -+ declare const _default: number; -+ export default _default; -+ -+==== out/index2.d.ts (0 errors) ==== -+ export default function foo(): typeof foo; -+ export declare const x: typeof foo; -+ export { foo as bar }; -+ -+==== out/index3.d.ts (0 errors) ==== -+ export default class Foo { -+ a: Foo; -+ } -+ export declare const X: typeof Foo; -+ export { Foo as Bar }; -+ -+==== out/index4.d.ts (0 errors) ==== -+ import Fab from "./index3"; -+ declare class Bar extends Fab { -+ x: Bar; -+ } -+ export default Bar; -+ -+==== out/index5.d.ts (6 errors) ==== -+ declare const _default: number; -+ export default _default; -+ export type default = string | number; -+ ~~~~~~ -+!!! error TS1128: Declaration or statement expected. -+ ~~~~ -+!!! error TS2304: Cannot find name 'type'. -+ ~~~~~~~ -+!!! error TS2457: Type alias name cannot be 'default'. -+ ~ -+!!! error TS1128: Declaration or statement expected. -+ ~~~~~~ -+!!! error TS2693: 'string' only refers to a type, but is being used as a value here. -+ ~~~~~~ -+!!! error TS2693: 'number' only refers to a type, but is being used as a value here. -+ -+==== out/index6.d.ts (6 errors) ==== -+ // merge type alias and function (OK) -+ export default function func(): void; -+ export type default = string | number; -+ ~~~~~~ -+!!! error TS1128: Declaration or statement expected. -+ ~~~~ -+!!! error TS2304: Cannot find name 'type'. -+ ~~~~~~~ -+!!! error TS2457: Type alias name cannot be 'default'. -+ ~ -+!!! error TS1128: Declaration or statement expected. -+ ~~~~~~ -+!!! error TS2693: 'string' only refers to a type, but is being used as a value here. -+ ~~~~~~ -+!!! error TS2693: 'number' only refers to a type, but is being used as a value here. -+ \ No newline at end of file ++export type default = string | number; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.errors.txt new file mode 100644 index 0000000000..6f7b4415c3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDoubleAssignmentInClosure.errors.txt @@ -0,0 +1,17 @@ +index.js(4,28): error TS8009: The '?' modifier can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + // @ts-nocheck + function foo() { + module.exports = exports = function (o) { + return (o == null) ? create(base) : defineProperties(Object(o), descriptors); + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + }; + const m = function () { + // I have no idea what to put here + } + exports.methods = m; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportedClassAliases.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportedClassAliases.errors.txt new file mode 100644 index 0000000000..b8da545e26 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportedClassAliases.errors.txt @@ -0,0 +1,23 @@ +utils/errors.js(1,26): error TS8010: Type annotations can only be used in TypeScript files. + + +==== utils/index.js (0 errors) ==== + // issue arises here on compilation + const errors = require("./errors"); + + module.exports = { + errors + }; +==== utils/errors.js (1 errors) ==== + class FancyError extends Error { + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor(status) { + super(`error with status ${status}`); + } + } + + module.exports = { + FancyError + }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt new file mode 100644 index 0000000000..0abc6ed848 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsGetterSetter.errors.txt @@ -0,0 +1,130 @@ +index.js(90,24): error TS8009: The '?' modifier can only be used in TypeScript files. +index.js(103,24): error TS8009: The '?' modifier can only be used in TypeScript files. +index.js(116,24): error TS8009: The '?' modifier can only be used in TypeScript files. + + +==== index.js (3 errors) ==== + export class A { + get x() { + return 12; + } + } + + export class B { + /** + * @param {number} _arg + */ + set x(_arg) { + } + } + + export class C { + get x() { + return 12; + } + set x(_arg) { + } + } + + export class D {} + Object.defineProperty(D.prototype, "x", { + get() { + return 12; + } + }); + + export class E {} + Object.defineProperty(E.prototype, "x", { + /** + * @param {number} _arg + */ + set(_arg) {} + }); + + export class F {} + Object.defineProperty(F.prototype, "x", { + get() { + return 12; + }, + /** + * @param {number} _arg + */ + set(_arg) {} + }); + + export class G {} + Object.defineProperty(G.prototype, "x", { + /** + * @param {number[]} args + */ + set(...args) {} + }); + + export class H {} + Object.defineProperty(H.prototype, "x", { + set() {} + }); + + + export class I {} + Object.defineProperty(I.prototype, "x", { + /** + * @param {number} v + */ + set: (v) => {} + }); + + /** + * @param {number} v + */ + const jSetter = (v) => {} + export class J {} + Object.defineProperty(J.prototype, "x", { + set: jSetter + }); + + /** + * @param {number} v + */ + const kSetter1 = (v) => {} + /** + * @param {number} v + */ + const kSetter2 = (v) => {} + export class K {} + Object.defineProperty(K.prototype, "x", { + set: Math.random() ? kSetter1 : kSetter2 + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + }); + + /** + * @param {number} v + */ + const lSetter1 = (v) => {} + /** + * @param {string} v + */ + const lSetter2 = (v) => {} + export class L {} + Object.defineProperty(L.prototype, "x", { + set: Math.random() ? lSetter1 : lSetter2 + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + }); + + /** + * @param {number | boolean} v + */ + const mSetter1 = (v) => {} + /** + * @param {string | boolean} v + */ + const mSetter2 = (v) => {} + export class M {} + Object.defineProperty(M.prototype, "x", { + set: Math.random() ? mSetter1 : mSetter2 + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt new file mode 100644 index 0000000000..457e1a0fee --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt @@ -0,0 +1,19 @@ +index.js(9,26): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + export class Super { + /** + * @param {string} firstArg + * @param {string} secondArg + */ + constructor(firstArg, secondArg) { } + } + + export class Sub extends Super { + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super('first', 'second'); + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt new file mode 100644 index 0000000000..8e79921c1e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt @@ -0,0 +1,16 @@ +index.js(7,35): error TS8010: Type annotations can only be used in TypeScript files. + + +==== index.js (1 errors) ==== + export class A { + /** @returns {this} */ + method() { + return this; + } + } + export default class Base extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + // This method is required to reproduce #35932 + verify() { } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt index 6386334b80..38ae19e627 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt @@ -1,4 +1,6 @@ +jsdocAccessibilityTag.js(48,17): error TS8010: Type annotations can only be used in TypeScript files. jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. +jsdocAccessibilityTag.js(53,17): error TS8010: Type annotations can only be used in TypeScript files. jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. jsdocAccessibilityTag.js(58,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. @@ -10,7 +12,7 @@ jsdocAccessibilityTag.js(61,9): error TS2341: Property 'priv2' is private and on jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. -==== jsdocAccessibilityTag.js (10 errors) ==== +==== jsdocAccessibilityTag.js (12 errors) ==== class A { /** * Ap docs @@ -59,6 +61,8 @@ jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and h() { return this.priv2 } } class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. m() { this.priv + this.prot + this.pub ~~~~ @@ -66,6 +70,8 @@ jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and } } class D extends C { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. n() { this.priv2 + this.prot2 + this.pub2 ~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugmentsMissingType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugmentsMissingType.errors.txt index f3a1da2292..710974ba24 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugmentsMissingType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugmentsMissingType.errors.txt @@ -1,12 +1,15 @@ /a.js(2,14): error TS8023: JSDoc '@augments ' does not match the 'extends A' clause. +/a.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== class A { constructor() { this.x = 0; } } /** @augments */ !!! error TS8023: JSDoc '@augments ' does not match the 'extends A' clause. class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. m() { this.x } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_errorInExtendsExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_errorInExtendsExpression.errors.txt index 11a7311fc3..f011935b63 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_errorInExtendsExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_errorInExtendsExpression.errors.txt @@ -1,10 +1,13 @@ /a.js(3,17): error TS2304: Cannot find name 'err'. +/a.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== class A {} /** @augments A */ class B extends err() {} ~~~ !!! error TS2304: Cannot find name 'err'. + ~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt index f6d9d88210..306c0c428f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt @@ -1,7 +1,8 @@ /b.js(4,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. +/b.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. -==== /b.js (1 errors) ==== +==== /b.js (2 errors) ==== class A {} class B {} @@ -9,4 +10,6 @@ ~ !!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. class C extends B {} + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt new file mode 100644 index 0000000000..a46f6f5b86 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_withTypeParameter.errors.txt @@ -0,0 +1,16 @@ +/b.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== /a.d.ts (0 errors) ==== + declare class A { x: T } + +==== /b.js (1 errors) ==== + /** @augments A */ + class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + m() { + return this.x; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt index bed5688d1f..f13a073ffe 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocFunctionType.errors.txt @@ -6,12 +6,13 @@ functions.js(15,14): error TS7006: Parameter 'c' implicitly has an 'any' type. 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(31,51): error TS8009: The '?' modifier can only be used in TypeScript files. 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(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} @@ -62,6 +63,8 @@ functions.js(72,14): error TS7019: Rest parameter 'args' implicitly has an 'any[ !!! error TS7006: Parameter 'ab' implicitly has an 'any' type. ~~~~~~ !!! error TS7006: Parameter 'onetwo' implicitly has an 'any' type. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. /** diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt index d6655383b2..688449403c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt @@ -1,9 +1,10 @@ +0.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. 0.js(27,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'A'. 0.js(32,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. 0.js(40,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. -==== 0.js (3 errors) ==== +==== 0.js (4 errors) ==== class A { /** @@ -20,6 +21,8 @@ } class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** * @override * @method diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt index 5ca40c9e5b..f33a0f0a24 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt @@ -1,4 +1,5 @@ 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(20,27): error TS8010: Type annotations can only be used in TypeScript files. b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. @@ -13,7 +14,7 @@ b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. ==== a.ts (0 errors) ==== var W: string; -==== b.js (9 errors) ==== +==== b.js (10 errors) ==== // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); @@ -36,6 +37,8 @@ b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. } } class SomeDerived extends SomeBase { + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); this.x = 42; diff --git a/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt index c45c97b5eb..86b4913420 100644 --- a/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/overloadTag2.errors.txt @@ -1,11 +1,14 @@ +overloadTag2.js(2,15): error TS8009: The '?' modifier can only be used in TypeScript files. overloadTag2.js(14,9): error TS2394: This overload signature is not compatible with its implementation signature. 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 (3 errors) ==== +==== overloadTag2.js (4 errors) ==== export class Foo { #a = true ? 1 : "1" + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. #b /** diff --git a/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt new file mode 100644 index 0000000000..fe82afac38 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt @@ -0,0 +1,26 @@ +a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. + + +==== a.js (1 errors) ==== + class B { + foo (v) {} + fooo (v) {} + } + + class D extends B { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + foo (v) {} + /** @override */ + fooo (v) {} + /** @override */ + bar(v) {} + } + + class C { + foo () {} + /** @override */ + fooo (v) {} + /** @override */ + bar(v) {} + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt index 2240d94df8..7940c85f84 100644 --- a/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt @@ -1,16 +1,19 @@ +a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. a.js(7,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'B'. a.js(11,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'B'. a.js(17,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. a.js(19,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. -==== a.js (4 errors) ==== +==== a.js (5 errors) ==== class B { foo (v) {} fooo (v) {} } class D extends B { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. foo (v) {} ~~~ !!! error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'B'. diff --git a/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt index 6e1d0dae65..f2c222a730 100644 --- a/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt @@ -1,13 +1,16 @@ +a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. a.js(7,5): error TS8009: The 'override' modifier can only be used in TypeScript files. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== class B { foo (v) {} fooo (v) {} } class D extends B { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. override foo (v) {} ~~~~~~~~ !!! error TS8009: The 'override' modifier can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt index 0e3d59fcf6..defcb06096 100644 --- a/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt @@ -1,12 +1,15 @@ +a.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. a.js(7,5): error TS4123: This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class 'A'. Did you mean 'doSomething'? -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== class A { doSomething() {} } class B extends A { + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. /** @override */ doSomethang() {} ~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt index fca3c29810..e157b6aabc 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt @@ -1,4 +1,5 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. +fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,11): error TS2304: Cannot find name 'c'. fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,17): error TS2304: Cannot find name 'd'. @@ -9,10 +10,12 @@ fileTs.ts(1,17): error TS2304: Cannot find name 'd'. fileTs.ts(1,27): error TS2304: Cannot find name 'f'. -==== fileJs.js (5 errors) ==== +==== fileJs.js (6 errors) ==== a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon ~ !!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'c'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression11.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression11.errors.txt index ea4670f392..c8fcf0e466 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression11.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression11.errors.txt @@ -1,5 +1,7 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. +fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,5): error TS2304: Cannot find name 'b'. +fileJs.js(1,7): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,9): error TS2304: Cannot find name 'c'. fileJs.js(1,14): error TS2304: Cannot find name 'd'. fileJs.js(1,24): error TS2304: Cannot find name 'f'. @@ -10,12 +12,16 @@ fileTs.ts(1,14): error TS2304: Cannot find name 'd'. fileTs.ts(1,24): error TS2304: Cannot find name 'f'. -==== fileJs.js (5 errors) ==== +==== fileJs.js (7 errors) ==== a ? b ? c : (d) : e => f // Legal JS ~ !!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'c'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression12.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression12.errors.txt index 4e6a7f90a9..1144b67461 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression12.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression12.errors.txt @@ -1,4 +1,5 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. +fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,13): error TS2304: Cannot find name 'c'. fileJs.js(1,22): error TS2304: Cannot find name 'e'. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. @@ -6,10 +7,12 @@ fileTs.ts(1,13): error TS2304: Cannot find name 'c'. fileTs.ts(1,22): error TS2304: Cannot find name 'e'. -==== fileJs.js (3 errors) ==== +==== fileJs.js (4 errors) ==== a ? (b) => (c): d => e // Legal JS ~ !!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'c'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt index cfe16ee6c8..77c9bc8d38 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt @@ -1,14 +1,17 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. +fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,11): error TS2304: Cannot find name 'a'. fileJs.js(1,21): error TS8010: Type annotations can only be used in TypeScript files. fileTs.ts(1,1): error TS2304: Cannot find name 'a'. fileTs.ts(1,11): error TS2304: Cannot find name 'a'. -==== fileJs.js (3 errors) ==== +==== fileJs.js (4 errors) ==== a ? () => a() : (): any => null; // Not legal JS; "Unexpected token ')'" at last paren ~ !!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'a'. ~~~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt index 8908dde1bc..5fd3cfa6fe 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt @@ -1,4 +1,5 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. +fileJs.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. fileJs.js(1,20): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,23): error TS8010: Type annotations can only be used in TypeScript files. @@ -10,10 +11,12 @@ fileTs.ts(1,40): error TS2304: Cannot find name 'd'. fileTs.ts(1,46): error TS2304: Cannot find name 'e'. -==== fileJs.js (7 errors) ==== +==== fileJs.js (8 errors) ==== a() ? (b: number, c?: string): void => d() : e; // Not legal JS; "Unexpected token ':'" at first colon ~ !!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt index 8cacfbe684..27cbfdb997 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt @@ -1,8 +1,11 @@ +fileJs.js(1,7): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,18): error TS8010: Type annotations can only be used in TypeScript files. -==== fileJs.js (1 errors) ==== +==== fileJs.js (2 errors) ==== false ? (param): string => param : null // Not legal JS; "Unexpected token ':'" at last colon + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt index 237f9839c1..5f289ec61a 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt @@ -1,8 +1,14 @@ +fileJs.js(1,6): error TS8009: The '?' modifier can only be used in TypeScript files. +fileJs.js(1,14): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,25): error TS8010: Type annotations can only be used in TypeScript files. -==== fileJs.js (1 errors) ==== +==== fileJs.js (3 errors) ==== true ? false ? (param): string => param : null : null // Not legal JS; "Unexpected token ':'" at last colon + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt index 28091b1745..1f14e32a57 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt @@ -1,4 +1,5 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. +fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,5): error TS2304: Cannot find name 'b'. fileJs.js(1,15): error TS2304: Cannot find name 'd'. fileJs.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. @@ -9,10 +10,12 @@ fileTs.ts(1,15): error TS2304: Cannot find name 'd'. fileTs.ts(1,20): error TS2304: Cannot find name 'e'. -==== fileJs.js (5 errors) ==== +==== fileJs.js (6 errors) ==== a ? b : (c) : d => e // Not legal JS; "Unexpected token ':'" at last colon ~ !!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'b'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression8.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression8.errors.txt index 84bfdbcfbd..37b56e332e 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression8.errors.txt @@ -1,11 +1,14 @@ fileJs.js(1,1): error TS2304: Cannot find name 'x'. +fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. fileTs.ts(1,1): error TS2304: Cannot find name 'x'. -==== fileJs.js (1 errors) ==== +==== fileJs.js (2 errors) ==== x ? y => ({ y }) : z => ({ z }) // Legal JS ~ !!! error TS2304: Cannot find name 'x'. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ==== fileTs.ts (1 errors) ==== x ? y => ({ y }) : z => ({ z }) diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression9.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression9.errors.txt index e197b3a1da..403b57cd15 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression9.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression9.errors.txt @@ -1,4 +1,5 @@ fileJs.js(1,1): error TS2304: Cannot find name 'b'. +fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. fileJs.js(1,6): error TS2304: Cannot find name 'c'. fileJs.js(1,16): error TS2304: Cannot find name 'e'. fileTs.ts(1,1): error TS2304: Cannot find name 'b'. @@ -6,10 +7,12 @@ fileTs.ts(1,6): error TS2304: Cannot find name 'c'. fileTs.ts(1,16): error TS2304: Cannot find name 'e'. -==== fileJs.js (3 errors) ==== +==== fileJs.js (4 errors) ==== b ? (c) : d => e // Legal JS ~ !!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'c'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt index b92bd5df1b..2015d1ee84 100644 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt @@ -21,8 +21,13 @@ plainJSGrammarErrors.js(37,9): error TS1049: A 'set' accessor must have exactly plainJSGrammarErrors.js(38,18): error TS1053: A 'set' accessor cannot have rest parameter. plainJSGrammarErrors.js(41,5): error TS18006: Classes may not have a field named 'constructor'. plainJSGrammarErrors.js(43,1): error TS1211: A class declaration without the 'default' modifier must have a name. +plainJSGrammarErrors.js(46,23): error TS8010: Type annotations can only be used in TypeScript files. plainJSGrammarErrors.js(46,25): error TS1172: 'extends' clause already seen. +plainJSGrammarErrors.js(46,33): error TS8010: Type annotations can only be used in TypeScript files. +plainJSGrammarErrors.js(47,23): error TS8010: Type annotations can only be used in TypeScript files. plainJSGrammarErrors.js(47,25): error TS1174: Classes can only extend a single class. +plainJSGrammarErrors.js(47,25): error TS8010: Type annotations can only be used in TypeScript files. +plainJSGrammarErrors.js(47,27): error TS8010: Type annotations can only be used in TypeScript files. plainJSGrammarErrors.js(49,1): error TS18016: Private identifiers are not allowed outside class bodies. plainJSGrammarErrors.js(50,6): error TS18016: Private identifiers are not allowed outside class bodies. plainJSGrammarErrors.js(51,9): error TS18013: Property '#m' is not accessible outside class 'C' because it has a private identifier. @@ -66,9 +71,10 @@ plainJSGrammarErrors.js(104,6): error TS1171: A comma expression is not allowed plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allowed outside class bodies. plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. +plainJSGrammarErrors.js(108,25): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. -plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. +plainJSGrammarErrors.js(110,15): error TS8009: The '!' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. plainJSGrammarErrors.js(116,24): error TS1009: Trailing comma not allowed. @@ -102,7 +108,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (102 errors) ==== +==== plainJSGrammarErrors.js (108 errors) ==== class C { // #private mistakes q = #unbound @@ -195,11 +201,21 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot missingName = true } class Doubler extends C extends C { } + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~ !!! error TS1172: 'extends' clause already seen. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. class Trebler extends C,C,C { } + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS1174: Classes can only extend a single class. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. // #private mistakes #unrelated ~~~~~~~~~~ @@ -347,14 +363,16 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot cantHaveQuestionMark?: 1, ~ !!! error TS1162: An object member cannot be declared optional. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. m?() { return 12 }, ~ !!! error TS1162: An object member cannot be declared optional. - ~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. definitely!, ~ !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. + ~ +!!! error TS8009: The '!' modifier can only be used in TypeScript files. definiteMethod!() { return 13 }, ~ !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. diff --git a/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt new file mode 100644 index 0000000000..78c0a8a806 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/returnTagTypeGuard.errors.txt @@ -0,0 +1,67 @@ +bug25127.js(27,33): error TS8009: The '?' modifier can only be used in TypeScript files. + + +==== bug25127.js (1 errors) ==== + class Entry { + constructor() { + this.c = 1 + } + /** + * @param {any} x + * @return {this is Entry} + */ + isInit(x) { + return true + } + } + class Group { + constructor() { + this.d = 'no' + } + /** + * @param {any} x + * @return {false} + */ + isInit(x) { + return false + } + } + /** @param {Entry | Group} chunk */ + function f(chunk) { + let x = chunk.isInit(chunk) ? chunk.c : chunk.d + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + return x + } + + /** + * @param {any} value + * @return {value is boolean} + */ + function isBoolean(value) { + return typeof value === "boolean"; + } + + /** @param {boolean | number} val */ + function foo(val) { + if (isBoolean(val)) { + val; + } + } + + /** + * @callback Cb + * @param {unknown} x + * @return {x is number} + */ + + /** @type {Cb} */ + function isNumber(x) { return typeof x === "number" } + + /** @param {unknown} x */ + function g(x) { + if (isNumber(x)) { + x * 2; + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/spellingUncheckedJS.errors.txt b/testdata/baselines/reference/submodule/conformance/spellingUncheckedJS.errors.txt new file mode 100644 index 0000000000..1782e82dbe --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/spellingUncheckedJS.errors.txt @@ -0,0 +1,55 @@ +spellingUncheckedJS.js(19,23): error TS8010: Type annotations can only be used in TypeScript files. + + +==== spellingUncheckedJS.js (1 errors) ==== + export var inModule = 1 + inmodule.toFixed() + + function f() { + var locals = 2 + true + locale.toFixed() + // @ts-expect-error + localf.toExponential() + // @ts-expect-error + "this is fine" + } + class Classe { + non = 'oui' + methode() { + // no error on 'this' references + return this.none + } + } + class Derivee extends Classe { + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + methode() { + // no error on 'super' references + return super.none + } + } + + + var object = { + spaaace: 3 + } + object.spaaaace // error on read + object.spaace = 12 // error on write + object.fresh = 12 // OK + other.puuuce // OK, from another file + new Date().getGMTDate() // OK, from another file + + // No suggestions for globals from other files + const atoc = setIntegral(() => console.log('ok'), 500) + AudioBuffin // etc + Jimmy + Jon + +==== other.js (0 errors) ==== + var Jimmy = 1 + var John = 2 + Jon // error, it's from the same file + var other = { + puuce: 4 + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt b/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt new file mode 100644 index 0000000000..b7683bd571 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt @@ -0,0 +1,28 @@ +thisPropertyAssignmentInherited.js(11,34): error TS8010: Type annotations can only be used in TypeScript files. +thisPropertyAssignmentInherited.js(12,34): error TS8010: Type annotations can only be used in TypeScript files. + + +==== thisPropertyAssignmentInherited.js (2 errors) ==== + export class Element { + /** + * @returns {String} + */ + get textContent() { + return '' + } + set textContent(x) {} + cloneNode() { return this} + } + export class HTMLElement extends Element {} + ~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + export class TextElement extends HTMLElement { + ~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + get innerHTML() { return this.textContent; } + set innerHTML(html) { this.textContent = html; } + toString() { + } + } + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisPropertyOverridesAccessors.errors.txt b/testdata/baselines/reference/submodule/conformance/thisPropertyOverridesAccessors.errors.txt new file mode 100644 index 0000000000..f49d30f121 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/thisPropertyOverridesAccessors.errors.txt @@ -0,0 +1,19 @@ +bar.js(1,19): error TS8010: Type annotations can only be used in TypeScript files. + + +==== foo.ts (0 errors) ==== + class Foo { + get p() { return 1 } + set p(value) { } + } + +==== bar.js (1 errors) ==== + class Bar extends Foo { + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super() + this.p = 2 + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment23.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment23.errors.txt index 6db0b0a65a..39c914fb72 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment23.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment23.errors.txt @@ -1,8 +1,11 @@ +a.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. +a.js(15,17): error TS8010: Type annotations can only be used in TypeScript files. a.js(23,18): error TS2339: Property 'identifier' does not exist on type 'Module'. a.js(24,18): error TS2339: Property 'size' does not exist on type 'Module'. +a.js(26,28): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (5 errors) ==== class B { constructor () { this.n = 1 @@ -12,12 +15,16 @@ a.js(24,18): error TS2339: Property 'size' does not exist on type 'Module'. } class C extends B { } + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. // this override should be fine (even if it's a little odd) C.prototype.foo = function() { } class D extends B { } + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. D.prototype.foo = () => { this.n = 'not checked, so no error' } @@ -33,6 +40,8 @@ a.js(24,18): error TS2339: Property 'size' does not exist on type 'Module'. !!! error TS2339: Property 'size' does not exist on type 'Module'. class NormalModule extends Module { + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. identifier() { return 'normal' } diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment25.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment25.errors.txt index 51003f82a9..3ff1b334bf 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment25.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment25.errors.txt @@ -1,7 +1,8 @@ bug24703.js(7,8): error TS2506: 'O' is referenced directly or indirectly in its own base expression. +bug24703.js(7,26): error TS8010: Type annotations can only be used in TypeScript files. -==== bug24703.js (1 errors) ==== +==== bug24703.js (2 errors) ==== var Common = {}; Common.I = class { constructor() { @@ -11,6 +12,8 @@ bug24703.js(7,8): error TS2506: 'O' is referenced directly or indirectly in its Common.O = class extends Common.I { ~ !!! error TS2506: 'O' is referenced directly or indirectly in its own base expression. + ~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super() this.o = 2 diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment26.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment26.errors.txt index db005b1254..6368f7ec18 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment26.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment26.errors.txt @@ -1,8 +1,9 @@ bug24730.js(1,5): error TS7022: 'UI' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. bug24730.js(7,1): error TS7022: 'context' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +bug24730.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. -==== bug24730.js (2 errors) ==== +==== bug24730.js (3 errors) ==== var UI = {} ~~ !!! error TS7022: 'UI' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. @@ -16,6 +17,8 @@ bug24730.js(7,1): error TS7022: 'context' implicitly has type 'any' because it d !!! error TS7022: 'context' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. class C extends UI.TreeElement { + ~~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. onpopulate() { this.doesNotExist this.treeOutline.doesntExistEither() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment9.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment9.errors.txt index e7ec37fab0..3601ef212a 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment9.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment9.errors.txt @@ -1,7 +1,8 @@ +a.js(22,27): error TS8009: The '?' modifier can only be used in TypeScript files. a.js(33,16): error TS2304: Cannot find name 'global'. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== var my = my || {}; /** @param {number} n */ my.method = function(n) { @@ -24,6 +25,8 @@ a.js(33,16): error TS2304: Cannot find name 'global'. */ my.predicate.sort = my.predicate.sort || function (first, second) { return first > second ? first : second; + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. } my.predicate.type = class { m() { return 101; } diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment9_1.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment9_1.errors.txt index 7d583c79c8..02614fbbf7 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment9_1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment9_1.errors.txt @@ -1,7 +1,8 @@ +a.js(22,27): error TS8009: The '?' modifier can only be used in TypeScript files. a.js(33,16): error TS2304: Cannot find name 'global'. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== var my = my ?? {}; /** @param {number} n */ my.method = function(n) { @@ -24,6 +25,8 @@ a.js(33,16): error TS2304: Cannot find name 'global'. */ my.predicate.sort = my.predicate.sort ?? function (first, second) { return first > second ? first : second; + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. } my.predicate.type = class { m() { return 101; } diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt index c10ea07ed6..aab3121bf3 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt @@ -1,24 +1,30 @@ index.js(1,7): error TS2339: Property 'Item' does not exist on type '{}'. index.js(2,8): error TS2339: Property 'Object' does not exist on type '{}'. +index.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. 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,34): error TS8010: Type annotations can only be used in TypeScript files. 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 (6 errors) ==== +==== index.js (8 errors) ==== First.Item = class I {} ~~~~ !!! error TS2339: Property 'Item' does not exist on type '{}'. Common.Object = class extends First.Item {} ~~~~~~ !!! error TS2339: Property 'Object' does not exist on type '{}'. + ~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~ !!! error TS2339: Property 'Item' does not exist on type '{}'. Workspace.Object = class extends Common.Object {} ~~~~~~ !!! error TS2339: Property 'Object' does not exist on type '{}'. + ~~~~~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2339: Property 'Object' does not exist on type '{}'. diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt index 6b2506e05c..6d5c4776f4 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagWrapping.errors.txt @@ -1,9 +1,11 @@ mod1.js(2,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? mod1.js(9,12): error TS2304: Cannot find name 'Type1'. +mod2.js(15,18): error TS8009: The '?' modifier can only be used in TypeScript files. 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'. +mod5.js(18,18): error TS8009: The '?' modifier can only be used in TypeScript files. ==== mod1.js (2 errors) ==== @@ -28,7 +30,7 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. return func(arg); } -==== mod2.js (0 errors) ==== +==== mod2.js (1 errors) ==== /** * @typedef {{ * num: number, @@ -44,6 +46,8 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. */ function check(obj) { return obj.boo ? obj.num : obj.str; + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. } ==== mod3.js (2 errors) ==== @@ -97,7 +101,7 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. return func(bool, str, num) } -==== mod5.js (0 errors) ==== +==== mod5.js (1 errors) ==== /** * @typedef {{ * num: @@ -116,6 +120,8 @@ mod4.js(11,12): error TS2304: Cannot find name 'StringOrNumber2'. */ function check5(obj) { return obj.boo ? obj.num : obj.str; + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. } ==== mod6.js (0 errors) ==== diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff new file mode 100644 index 0000000000..1dd778ec76 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff @@ -0,0 +1,37 @@ +--- old.argumentsReferenceInConstructor3_Js.errors.txt ++++ new.argumentsReferenceInConstructor3_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class A { ++ get arguments() { ++ return { bar: {} }; ++ } ++ } ++ ++ class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ /** ++ * Constructor ++ * ++ * @param {object} [foo={}] ++ */ ++ constructor(foo = {}) { ++ super(); ++ ++ /** ++ * @type object ++ */ ++ this.foo = foo; ++ ++ /** ++ * @type object ++ */ ++ this.bar = super.arguments.foo; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff new file mode 100644 index 0000000000..ea555b1e2b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff @@ -0,0 +1,33 @@ +--- old.argumentsReferenceInMethod3_Js.errors.txt ++++ new.argumentsReferenceInMethod3_Js.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/a.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (1 errors) ==== ++ class A { ++ get arguments() { ++ return { bar: {} }; ++ } ++ } ++ ++ class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ /** ++ * @param {object} [foo={}] ++ */ ++ m(foo = {}) { ++ /** ++ * @type object ++ */ ++ this.x = foo; ++ ++ /** ++ * @type object ++ */ ++ this.y = super.arguments.bar; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt.diff index 09726f841b..c10024b7b3 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt.diff @@ -4,10 +4,22 @@ +error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. weird.js(1,1): error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? weird.js(1,23): error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. ++weird.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. +-==== weird.js (3 errors) ==== +!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. - ==== weird.js (3 errors) ==== ++==== weird.js (4 errors) ==== someFunction(function(BaseClass) { - ~~~~~~~~~~~~ \ No newline at end of file + ~~~~~~~~~~~~ + !!! error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? +@@= skipped -12, +15 lines =@@ + 'use strict'; + const DEFAULT_MESSAGE = "nop!"; + class Hello extends BaseClass { ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + this.foo = "bar"; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles_noErrorLocation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles_noErrorLocation.errors.txt.diff new file mode 100644 index 0000000000..9012601bbf --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles_noErrorLocation.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.checkJsFiles_noErrorLocation.errors.txt ++++ new.checkJsFiles_noErrorLocation.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(11,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (1 errors) ==== ++ // @ts-check ++ class A { ++ constructor() { ++ ++ } ++ foo() { ++ return 4; ++ } ++ } ++ ++ class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super(); ++ this.foo = () => 3; ++ } ++ } ++ ++ const i = new B(); ++ i.foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classExtendingAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/classExtendingAny.errors.txt.diff new file mode 100644 index 0000000000..c03a7d0f6d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/classExtendingAny.errors.txt.diff @@ -0,0 +1,42 @@ +--- old.classExtendingAny.errors.txt ++++ new.classExtendingAny.errors.txt +@@= skipped -0, +0 lines =@@ +- ++b.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.ts (0 errors) ==== ++ declare var Err: any ++ class A extends Err { ++ payload: string ++ constructor() { ++ super(1,2,3,3,4,56) ++ super.unknown ++ super['unknown'] ++ } ++ process() { ++ return this.payload + "!"; ++ } ++ } ++ ++ var o = { ++ m() { ++ super.unknown ++ } ++ } ++==== b.js (1 errors) ==== ++ class B extends Err { ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super() ++ this.wat = 12 ++ } ++ f() { ++ this.wat ++ this.wit ++ this['wot'] ++ super.alsoBad ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff index b6cb604258..ea1fba2565 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff @@ -2,21 +2,21 @@ +++ new.classFieldSuperAccessibleJs1.errors.txt @@= skipped -0, +0 lines =@@ -index.js(9,23): error TS2565: Property 'blah2' is used before being assigned. -- -- --==== index.js (1 errors) ==== -- class C { -- static blah1 = 123; -- } -- C.blah2 = 456; -- -- class D extends C { -- static { -- console.log(super.blah1); -- console.log(super.blah2); ++index.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== index.js (1 errors) ==== +@@= skipped -7, +7 lines =@@ + C.blah2 = 456; + + class D extends C { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + static { + console.log(super.blah1); + console.log(super.blah2); - ~~~~~ -!!! error TS2565: Property 'blah2' is used before being assigned. -- } -- } -- -+ \ No newline at end of file + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs2.errors.txt.diff new file mode 100644 index 0000000000..9c48e0906f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs2.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.classFieldSuperAccessibleJs2.errors.txt ++++ new.classFieldSuperAccessibleJs2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (1 errors) ==== ++ class C { ++ constructor() { ++ this.foo = () => { ++ console.log("called arrow"); ++ }; ++ } ++ foo() { ++ console.log("called method"); ++ } ++ } ++ ++ class D extends C { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ foo() { ++ console.log("SUPER:"); ++ super.foo(); ++ console.log("THIS:"); ++ this.foo(); ++ } ++ } ++ ++ const obj = new D(); ++ obj.foo(); ++ D.prototype.foo.call(obj); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff index f8cc61293a..f087625ae6 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff @@ -5,15 +5,22 @@ -index.js(23,22): error TS2855: Class field 'foo' defined by the parent class is not accessible in the child class via super. -index.js(26,22): error TS2855: Class field 'justProp' defined by the parent class is not accessible in the child class via super. -index.js(29,22): error TS2855: Class field ''literalElementAccess'' defined by the parent class is not accessible in the child class via super. +- +- +-==== index.js (4 errors) ==== +index.js(7,14): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'. +index.js(9,9): error TS7053: Element implicitly has an 'any' type because expression of type '"literalElementAccess"' can't be used to index type 'YaddaBase'. + Property 'literalElementAccess' does not exist on type 'YaddaBase'. ++index.js(18,28): error TS8010: Type annotations can only be used in TypeScript files. +index.js(26,22): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'. +index.js(29,22): error TS2339: Property 'literalElementAccess' does not exist on type 'YaddaBase'. - - - ==== index.js (4 errors) ==== -@@= skipped -11, +12 lines =@@ ++ ++ ++==== index.js (5 errors) ==== + // https://github.com/microsoft/TypeScript/issues/55884 + + class YaddaBase { +@@= skipped -11, +13 lines =@@ this.roots = "hi"; /** @type number */ this.justProp; @@ -27,8 +34,12 @@ this.b() } -@@= skipped -13, +18 lines =@@ +@@= skipped -11, +16 lines =@@ + } + class DerivedYadda extends YaddaBase { ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. get rootTests() { return super.roots; - ~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt.diff new file mode 100644 index 0000000000..d8af22459c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt.diff @@ -0,0 +1,33 @@ +--- old.defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt ++++ new.defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++component.js(2,28): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== library.d.ts (0 errors) ==== ++ export class Foo { ++ props: T; ++ state: U; ++ constructor(props: T, state: U); ++ } ++ ++==== component.js (1 errors) ==== ++ import { Foo } from "./library"; ++ export class MyFoo extends Foo { ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ member; ++ } ++ ++==== typed_component.ts (0 errors) ==== ++ import { MyFoo } from "./component"; ++ export class TypedFoo extends MyFoo { ++ constructor() { ++ super({x: "string", y: 42}, { value: undefined }); ++ this.props.x; ++ this.props.y; ++ this.state.value; ++ this.member; ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff new file mode 100644 index 0000000000..e282c4d5f8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff @@ -0,0 +1,34 @@ +--- old.fillInMissingTypeArgsOnJSConstructCalls.errors.txt ++++ new.fillInMissingTypeArgsOnJSConstructCalls.errors.txt +@@= skipped -3, +3 lines =@@ + BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. + BaseB.js(4,25): error TS2304: Cannot find name 'Class'. + BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. +-SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files. ++SubA.js(2,35): error TS8010: Type annotations can only be used in TypeScript files. ++SubB.js(3,35): error TS8010: Type annotations can only be used in TypeScript files. + + + ==== BaseA.js (0 errors) ==== + export default class BaseA { + } +-==== SubA.js (0 errors) ==== ++==== SubA.js (1 errors) ==== + import BaseA from './BaseA'; + export default class SubA extends BaseA { ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + } + ==== BaseB.js (6 errors) ==== + import BaseA from './BaseA'; +@@= skipped -34, +37 lines =@@ + import SubA from './SubA'; + import BaseB from './BaseB'; + export default class SubB extends BaseB { +- ~~~~ +-!!! error TS8011: Type arguments can only be used in TypeScript files. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(SubA); + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.errors.txt.diff new file mode 100644 index 0000000000..a0a68269c2 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.errors.txt.diff @@ -0,0 +1,102 @@ +--- old.genericDefaultsJs.errors.txt ++++ new.genericDefaultsJs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++main.js(19,21): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(20,21): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(25,21): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(43,21): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(44,21): error TS8010: Type annotations can only be used in TypeScript files. ++main.js(49,21): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== decls.d.ts (0 errors) ==== ++ declare function f0(x?: T): T; ++ declare function f1(x?: T): [T, U]; ++ declare class C0 { ++ y: T; ++ constructor(x?: T); ++ } ++ declare class C1 { ++ y: [T, U]; ++ constructor(x?: T); ++ } ++==== main.js (6 errors) ==== ++ const f0_v0 = f0(); ++ const f0_v1 = f0(1); ++ ++ const f1_c0 = f1(); ++ const f1_c1 = f1(1); ++ ++ const C0_v0 = new C0(); ++ const C0_v0_y = C0_v0.y; ++ ++ const C0_v1 = new C0(1); ++ const C0_v1_y = C0_v1.y; ++ ++ const C1_v0 = new C1(); ++ const C1_v0_y = C1_v0.y; ++ ++ const C1_v1 = new C1(1); ++ const C1_v1_y = C1_v1.y; ++ ++ class C0_B0 extends C0 {} ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ class C0_B1 extends C0 { ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super(); ++ } ++ } ++ class C0_B2 extends C0 { ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super(1); ++ } ++ } ++ ++ const C0_B0_v0 = new C0_B0(); ++ const C0_B0_v0_y = C0_B0_v0.y; ++ ++ const C0_B0_v1 = new C0_B0(1); ++ const C0_B0_v1_y = C0_B0_v1.y; ++ ++ const C0_B1_v0 = new C0_B1(); ++ const C0_B1_v0_y = C0_B1_v0.y; ++ ++ const C0_B2_v0 = new C0_B2(); ++ const C0_B2_v0_y = C0_B2_v0.y; ++ ++ class C1_B0 extends C1 {} ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ class C1_B1 extends C1 { ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super(); ++ } ++ } ++ class C1_B2 extends C1 { ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super(1); ++ } ++ } ++ ++ const C1_B0_v0 = new C1_B0(); ++ const C1_B0_v0_y = C1_B0_v0.y; ++ ++ const C1_B0_v1 = new C1_B0(1); ++ const C1_B0_v1_y = C1_B0_v1.y; ++ ++ const C1_B1_v0 = new C1_B1(); ++ const C1_B1_v0_y = C1_B1_v0.y; ++ ++ const C1_B2_v0 = new C1_B2(); ++ const C1_B2_v0_y = C1_B2_v0.y; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importDeclFromTypeNodeInJsSource.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/importDeclFromTypeNodeInJsSource.errors.txt.diff new file mode 100644 index 0000000000..ce27abcc49 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/importDeclFromTypeNodeInJsSource.errors.txt.diff @@ -0,0 +1,64 @@ +--- old.importDeclFromTypeNodeInJsSource.errors.txt ++++ new.importDeclFromTypeNodeInJsSource.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/src/b.js(5,26): error TS8010: Type annotations can only be used in TypeScript files. ++/src/b.js(8,27): error TS8010: Type annotations can only be used in TypeScript files. ++/src/b.js(11,27): error TS8010: Type annotations can only be used in TypeScript files. ++/src/b.js(14,27): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /src/node_modules/@types/node/index.d.ts (0 errors) ==== ++ /// ++==== /src/node_modules/@types/node/events.d.ts (0 errors) ==== ++ declare module "events" { ++ namespace EventEmitter { ++ class EventEmitter { ++ constructor(); ++ } ++ } ++ export = EventEmitter; ++ } ++ declare module "nestNamespaceModule" { ++ namespace a1.a2 { ++ class d { } ++ } ++ ++ namespace a1.a2.n3 { ++ class c { } ++ } ++ export = a1.a2; ++ } ++ declare module "renameModule" { ++ namespace a.b { ++ class c { } ++ } ++ import d = a.b; ++ export = d; ++ } ++ ++==== /src/b.js (4 errors) ==== ++ import { EventEmitter } from 'events'; ++ import { n3, d } from 'nestNamespaceModule'; ++ import { c } from 'renameModule'; ++ ++ export class Foo extends EventEmitter { ++ ~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ } ++ ++ export class Foo2 extends n3.c { ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ } ++ ++ export class Foo3 extends d { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ } ++ ++ export class Foo4 extends c { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt.diff new file mode 100644 index 0000000000..d6ebbfb883 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt.diff @@ -0,0 +1,52 @@ +--- old.importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt ++++ new.importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt +@@= skipped -0, +0 lines =@@ +- ++/index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /node_modules/tslib/package.json (0 errors) ==== ++ { ++ "name": "tslib", ++ "main": "tslib.js", ++ "module": "tslib.es6.js", ++ "jsnext:main": "tslib.es6.js", ++ "typings": "tslib.d.ts", ++ "exports": { ++ ".": { ++ "module": { ++ "types": "./modules/index.d.ts", ++ "default": "./tslib.es6.mjs" ++ }, ++ "import": { ++ "node": "./modules/index.js", ++ "default": { ++ "types": "./modules/index.d.ts", ++ "default": "./tslib.es6.mjs" ++ } ++ }, ++ "default": "./tslib.js" ++ }, ++ "./*": "./*", ++ "./": "./" ++ } ++ } ++ ++==== /node_modules/tslib/tslib.d.ts (0 errors) ==== ++ export declare var __extends: any; ++ ++==== /node_modules/tslib/modules/package.json (0 errors) ==== ++ { "type": "module" } ++ ++==== /node_modules/tslib/modules/index.d.ts (0 errors) ==== ++ export {}; ++ ++==== /index.js (1 errors) ==== ++ class Foo {} ++ ++ class Bar extends Foo {} ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ++ module.exports = Bar; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt.diff new file mode 100644 index 0000000000..a998215641 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt.diff @@ -0,0 +1,52 @@ +--- old.importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt ++++ new.importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt +@@= skipped -0, +0 lines =@@ +- ++/index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /node_modules/tslib/package.json (0 errors) ==== ++ { ++ "name": "tslib", ++ "main": "tslib.js", ++ "module": "tslib.es6.js", ++ "jsnext:main": "tslib.es6.js", ++ "typings": "tslib.d.ts", ++ "exports": { ++ ".": { ++ "module": { ++ "types": "./modules/index.d.ts", ++ "default": "./tslib.es6.mjs" ++ }, ++ "import": { ++ "node": "./modules/index.js", ++ "default": { ++ "types": "./modules/index.d.ts", ++ "default": "./tslib.es6.mjs" ++ } ++ }, ++ "default": "./tslib.js" ++ }, ++ "./*": "./*", ++ "./": "./" ++ } ++ } ++ ++==== /node_modules/tslib/tslib.d.ts (0 errors) ==== ++ export declare var __extends: any; ++ ++==== /node_modules/tslib/modules/package.json (0 errors) ==== ++ { "type": "module" } ++ ++==== /node_modules/tslib/modules/index.d.ts (0 errors) ==== ++ export {}; ++ ++==== /index.js (1 errors) ==== ++ class Foo {} ++ ++ class Bar extends Foo {} ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ++ module.exports = Bar; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.errors.txt.diff new file mode 100644 index 0000000000..15db22dcb7 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.javascriptCommonjsModule.errors.txt ++++ new.javascriptCommonjsModule.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (1 errors) ==== ++ class Foo {} ++ ++ class Bar extends Foo {} ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ++ module.exports = Bar; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptThisAssignmentInStaticBlock.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/javascriptThisAssignmentInStaticBlock.errors.txt.diff new file mode 100644 index 0000000000..4cd35f6350 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/javascriptThisAssignmentInStaticBlock.errors.txt.diff @@ -0,0 +1,28 @@ +--- old.javascriptThisAssignmentInStaticBlock.errors.txt ++++ new.javascriptThisAssignmentInStaticBlock.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/src/a.js(10,29): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /src/a.js (1 errors) ==== ++ class Thing { ++ static { ++ this.doSomething = () => {}; ++ } ++ } ++ ++ Thing.doSomething(); ++ ++ // GH#46468 ++ class ElementsArray extends Array { ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ static { ++ const superisArray = super.isArray; ++ const customIsArray = (arg)=> superisArray(arg); ++ this.isArray = customIsArray; ++ } ++ } ++ ++ ElementsArray.isArray(new ElementsArray()); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff new file mode 100644 index 0000000000..14b541e491 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff @@ -0,0 +1,44 @@ +--- old.jsDeclarationsInheritedTypes.errors.txt ++++ new.jsDeclarationsInheritedTypes.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(18,18): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(25,18): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (2 errors) ==== ++ /** ++ * @typedef A ++ * @property {string} a ++ */ ++ ++ /** ++ * @typedef B ++ * @property {number} b ++ */ ++ ++ class C1 { ++ /** ++ * @type {A} ++ */ ++ value; ++ } ++ ++ class C2 extends C1 { ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ /** ++ * @type {A} ++ */ ++ value; ++ } ++ ++ class C3 extends C1 { ++ ~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ /** ++ * @type {A & B} ++ */ ++ value; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEmitIntersectionProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEmitIntersectionProperty.errors.txt.diff new file mode 100644 index 0000000000..5deb46a77d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEmitIntersectionProperty.errors.txt.diff @@ -0,0 +1,39 @@ +--- old.jsEmitIntersectionProperty.errors.txt ++++ new.jsEmitIntersectionProperty.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(1,34): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== globals.d.ts (0 errors) ==== ++ declare class CoreObject { ++ static extend< ++ Statics, ++ Instance extends B1, ++ T1, ++ B1 ++ >( ++ this: Statics & { new(): Instance }, ++ arg1: T1 ++ ): Readonly & { new(): T1 & Instance }; ++ ++ toString(): string; ++ } ++ ++ declare class Mixin { ++ static create( ++ args?: T ++ ): Mixin; ++ } ++ declare const Observable: Mixin<{}> ++ declare class EmberObject extends CoreObject.extend(Observable) {} ++ declare class CoreView extends EmberObject.extend({}) {} ++ declare class Component extends CoreView.extend({}) {} ++ ++==== index.js (1 errors) ==== ++ export class MyComponent extends Component { ++ ~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff index 135c21c283..170c181f4d 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff @@ -1,15 +1,26 @@ --- old.jsExtendsImplicitAny.errors.txt +++ new.jsExtendsImplicitAny.errors.txt @@= skipped -0, +0 lines =@@ ++/b.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. /b.js(1,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -/b.js(4,15): error TS2314: Generic type 'A' requires 1 type argument(s). -/b.js(8,15): error TS2314: Generic type 'A' requires 1 type argument(s). ++/b.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. +/b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ++/b.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. +/b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. ==== /a.d.ts (0 errors) ==== -@@= skipped -12, +12 lines =@@ + declare class A { x: T; } + +-==== /b.js (3 errors) ==== ++==== /b.js (6 errors) ==== + class B extends A {} + ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~ + !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new B().x; /** @augments A */ @@ -17,6 +28,8 @@ -!!! error TS2314: Generic type 'A' requires 1 type argument(s). class C extends A { } + ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~ +!!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new C().x; @@ -25,5 +38,7 @@ -!!! error TS2314: Generic type 'A' requires 1 type argument(s). class D extends A {} + ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~ +!!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new D().x; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff new file mode 100644 index 0000000000..4fbe8b42ce --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff @@ -0,0 +1,57 @@ +--- old.jsFileMethodOverloads.errors.txt ++++ new.jsFileMethodOverloads.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsFileMethodOverloads.js(44,15): error TS8009: The '?' modifier can only be used in TypeScript files. ++ ++ ++==== jsFileMethodOverloads.js (1 errors) ==== ++ /** ++ * @template T ++ */ ++ class Example { ++ /** ++ * @param {T} value ++ */ ++ constructor(value) { ++ this.value = value; ++ } ++ ++ /** ++ * @overload ++ * @param {Example} this ++ * @returns {'number'} ++ */ ++ /** ++ * @overload ++ * @param {Example} this ++ * @returns {'string'} ++ */ ++ /** ++ * @returns {string} ++ */ ++ getTypeName() { ++ return typeof this.value; ++ } ++ ++ /** ++ * @template U ++ * @overload ++ * @param {(y: T) => U} fn ++ * @returns {U} ++ */ ++ /** ++ * @overload ++ * @returns {T} ++ */ ++ /** ++ * @param {(y: T) => unknown} [fn] ++ * @returns {unknown} ++ */ ++ transform(fn) { ++ return fn ? fn(this.value) : this.value; ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff new file mode 100644 index 0000000000..0a49b2e201 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff @@ -0,0 +1,54 @@ +--- old.jsFileMethodOverloads2.errors.txt ++++ new.jsFileMethodOverloads2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsFileMethodOverloads2.js(41,15): error TS8009: The '?' modifier can only be used in TypeScript files. ++ ++ ++==== jsFileMethodOverloads2.js (1 errors) ==== ++ // Also works if all @overload tags are combined in one comment. ++ /** ++ * @template T ++ */ ++ class Example { ++ /** ++ * @param {T} value ++ */ ++ constructor(value) { ++ this.value = value; ++ } ++ ++ /** ++ * @overload ++ * @param {Example} this ++ * @returns {'number'} ++ * ++ * @overload ++ * @param {Example} this ++ * @returns {'string'} ++ * ++ * @returns {string} ++ */ ++ getTypeName() { ++ return typeof this.value; ++ } ++ ++ /** ++ * @template U ++ * @overload ++ * @param {(y: T) => U} fn ++ * @returns {U} ++ * ++ * @overload ++ * @returns {T} ++ * ++ * @param {(y: T) => unknown} [fn] ++ * @returns {unknown} ++ */ ++ transform(fn) { ++ return fn ? fn(this.value) : this.value; ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt.diff new file mode 100644 index 0000000000..87400e0683 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt ++++ new.jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt +@@= skipped -0, +0 lines =@@ ++index.js(3,21): error TS8010: Type annotations can only be used in TypeScript files. + index.js(3,21): error TS8026: Expected Foo type arguments; provide these with an '@extends' tag. + + +@@= skipped -4, +5 lines =@@ + export declare class Foo { + prop: T; + } +-==== index.js (1 errors) ==== ++==== index.js (2 errors) ==== + import {Foo} from "./somelib"; + + class MyFoo extends Foo { ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~ + !!! error TS8026: Expected Foo type arguments; provide these with an '@extends' tag. + constructor() { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/superNoModifiersCrash.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/superNoModifiersCrash.errors.txt.diff new file mode 100644 index 0000000000..566d191af9 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/superNoModifiersCrash.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.superNoModifiersCrash.errors.txt ++++ new.superNoModifiersCrash.errors.txt +@@= skipped -0, +0 lines =@@ +- ++File.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== File.js (1 errors) ==== ++ class Parent { ++ initialize() { ++ super.initialize(...arguments) ++ return this.asdf = '' ++ } ++ } ++ ++ class Child extends Parent { ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ initialize() { ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff index c6f159b314..2d0f9e15ef 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag5.errors.txt.diff @@ -13,12 +13,13 @@ +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(30,35): error TS8009: The '?' modifier can only be used in TypeScript files. 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) ==== -+==== test.js (6 errors) ==== ++==== test.js (7 errors) ==== // all 6 should error on return statement/expression /** @type {(x: number) => string} */ function h(x) { return x } @@ -56,7 +57,7 @@ /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ -@@= skipped -45, +45 lines =@@ +@@= skipped -45, +46 lines =@@ /** @type {0 | 1 | 2} - assignment should not error */ var zeroonetwo = blargle('hi') @@ -70,4 +71,8 @@ -!!! error TS8030: The type of a function declaration must match the function's signature. function monaLisa(sb) { return typeof sb === 'string' ? 1 : 2; - } \ No newline at end of file ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + } + + /** @type {2 | 3} - overloads are not supported, so there will be an error */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff index 2b89283198..89737d071c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff @@ -5,13 +5,18 @@ -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(10,19): error TS8009: The '?' modifier can only be used in TypeScript files. ++first.js(16,47): error TS8009: The '?' modifier can only be used in TypeScript files. +first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. ++first.js(21,19): error TS8010: Type annotations can only be used in TypeScript files. +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(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"; }'. ++first.js(47,24): error TS8010: Type annotations can only be used in TypeScript files. +generic.js(9,23): error TS2507: Type '(flavour: T) => void' is not a constructor function type. ++generic.js(9,23): error TS8010: Type annotations can only be used in TypeScript files. +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'. @@ -31,16 +36,33 @@ +second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. + + -+==== first.js (4 errors) ==== ++==== first.js (8 errors) ==== /** * @constructor * @param {number} numberOxen -@@= skipped -36, +33 lines =@@ +@@= skipped -25, +27 lines =@@ + /** @param {Wagon[]=} wagons */ + Wagon.circle = function (wagons) { + return wagons ? wagons.length : 3.14; ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + } + /** @param {*[]=} supplies - *[]= is my favourite type */ + Wagon.prototype.load = function (supplies) { + } + /** @param {*[]=} supplies - Yep, still a great type */ + Wagon.prototype.weight = supplies => supplies ? supplies.length : -1 ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + Wagon.prototype.speed = function () { + return this.numberOxen / this.weight() } // ok class Sql extends Wagon { + ~~~~~ +!!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); // error: not enough arguments - ~~~~~ @@ -63,7 +85,7 @@ if (format === "xmlolololol") { throw new Error("please do not use XML. It was a joke."); } -@@= skipped -30, +27 lines =@@ +@@= skipped -41, +44 lines =@@ } var db = new Sql(); db.numberOxen = db.foonly @@ -72,7 +94,14 @@ // error, can't extend a TS constructor function class Drakkhen extends Dragon { -@@= skipped -25, +27 lines =@@ + ~~~~~~ + !!! error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + } + +@@= skipped -25, +29 lines =@@ } // ok class Conestoga extends Wagon { @@ -102,7 +131,7 @@ +!!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== generic.js (2 errors) ==== -+==== generic.js (5 errors) ==== ++==== generic.js (6 errors) ==== /** * @template T * @param {T} flavour @@ -112,6 +141,8 @@ class Chowder extends Soup { + ~~~~ +!!! error TS2507: Type '(flavour: T) => void' is not a constructor function type. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. log() { return this.flavour + ~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff new file mode 100644 index 0000000000..172706579f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag1.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.extendsTag1.errors.txt ++++ new.extendsTag1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++bug25101.js(5,18): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== bug25101.js (1 errors) ==== ++ /** ++ * @template T ++ * @extends {Set} Should prefer this Set, not the Set in the heritage clause ++ */ ++ class My extends Set {} ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag2.errors.txt.diff index 9a45cc583d..1adc7b6144 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag2.errors.txt.diff @@ -6,24 +6,19 @@ - -!!! error TS8022: JSDoc '@extends' is not attached to a class. -==== foo.js (0 errors) ==== -- /** -- * @constructor -- */ -- class A { -- constructor() {} -- } -- -- /** -- * @extends {A} -- */ -- -- /** -- * @constructor -- */ -- class B extends A { -- constructor() { -- super(); -- } -- } -- -+ \ No newline at end of file ++foo.js(15,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (1 errors) ==== + /** + * @constructor + */ +@@= skipped -17, +16 lines =@@ + * @constructor + */ + class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag3.errors.txt.diff new file mode 100644 index 0000000000..2664119427 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag3.errors.txt.diff @@ -0,0 +1,40 @@ +--- old.extendsTag3.errors.txt ++++ new.extendsTag3.errors.txt +@@= skipped -0, +0 lines =@@ +- ++foo.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. ++foo.js(22,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (2 errors) ==== ++ /** ++ * @constructor ++ */ ++ class A { ++ constructor() {} ++ } ++ ++ /** ++ * @extends {A} ++ * @constructor ++ */ ++ class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super(); ++ } ++ } ++ ++ /** ++ * @extends { A } ++ * @constructor ++ */ ++ class C extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super(); ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff new file mode 100644 index 0000000000..1aaf2c54f7 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag5.errors.txt.diff @@ -0,0 +1,54 @@ +--- old.extendsTag5.errors.txt ++++ new.extendsTag5.errors.txt +@@= skipped -0, +0 lines =@@ ++/a.js(26,17): error TS8010: Type annotations can only be used in TypeScript files. + /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(34,17): error TS8010: Type annotations can only be used in TypeScript files. ++/a.js(39,17): error TS8010: Type annotations can only be used in TypeScript files. + /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 (2 errors) ==== ++/a.js(44,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (6 errors) ==== + /** + * @typedef {{ + * a: number | string; +@@= skipped -32, +36 lines =@@ + * }>} + */ + class B extends A {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + /** + * @extends {A<{ +@@= skipped -15, +17 lines =@@ + !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. + */ + class C extends A {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + /** + * @extends {A<{a: string, b: string[]}>} + */ + class D extends A {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + /** + * @extends {A<{a: string, b: string}>} +@@= skipped -14, +18 lines =@@ + !!! error TS2344: Type 'string' is not assignable to type 'boolean | string[]'. + */ + class E extends A {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag6.errors.txt.diff new file mode 100644 index 0000000000..ee67cdaafa --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag6.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.extendsTag6.errors.txt ++++ new.extendsTag6.errors.txt +@@= skipped -0, +0 lines =@@ +- ++foo.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.js (1 errors) ==== ++ /** ++ * @constructor ++ */ ++ class A { ++ constructor() {} ++ } ++ ++ /** ++ * @extends { A } ++ * @constructor ++ */ ++ class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super(); ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTagEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTagEmit.errors.txt.diff index c87cc5fa7c..c2a305fbe6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTagEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTagEmit.errors.txt.diff @@ -3,17 +3,19 @@ @@= skipped -0, +0 lines =@@ -main.js(2,15): error TS2304: Cannot find name 'Mismatch'. main.js(2,15): error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. ++main.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. ==== super.js (0 errors) ==== - export class B { } - --==== main.js (2 errors) ==== -+==== main.js (1 errors) ==== +@@= skipped -8, +8 lines =@@ import { B } from './super' /** @extends {Mismatch} */ -- ~~~~~~~~ --!!! error TS2304: Cannot find name 'Mismatch'. ~~~~~~~~ +-!!! error TS2304: Cannot find name 'Mismatch'. +- ~~~~~~~~ !!! error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. - class C extends B { } \ No newline at end of file + class C extends B { } ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments3.errors.txt.diff new file mode 100644 index 0000000000..310839c4fa --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments3.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.inferringClassMembersFromAssignments3.errors.txt ++++ new.inferringClassMembersFromAssignments3.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (1 errors) ==== ++ class Base { ++ constructor() { ++ this.p = 1 ++ } ++ } ++ class Derived extends Base { ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ m() { ++ this.p = 1 ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments4.errors.txt.diff new file mode 100644 index 0000000000..99422ec5ce --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments4.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.inferringClassMembersFromAssignments4.errors.txt ++++ new.inferringClassMembersFromAssignments4.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (1 errors) ==== ++ class Base { ++ m() { ++ this.p = 1 ++ } ++ } ++ class Derived extends Base { ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ m() { ++ // should be OK, and p should have type number | undefined from its base ++ this.p = 1 ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments5.errors.txt.diff new file mode 100644 index 0000000000..a5216fe6dc --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments5.errors.txt.diff @@ -0,0 +1,26 @@ +--- old.inferringClassMembersFromAssignments5.errors.txt ++++ new.inferringClassMembersFromAssignments5.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (1 errors) ==== ++ class Base { ++ m() { ++ this.p = 1 ++ } ++ } ++ class Derived extends Base { ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super(); ++ // should be OK, and p should have type number from this assignment ++ this.p = 1 ++ } ++ test() { ++ return this.p ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff new file mode 100644 index 0000000000..6d9534351f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff @@ -0,0 +1,45 @@ +--- old.jsDeclarationsClassAccessor.errors.txt ++++ new.jsDeclarationsClassAccessor.errors.txt +@@= skipped -0, +0 lines =@@ +- ++argument.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== supplement.d.ts (0 errors) ==== ++ export { }; ++ declare module "./argument.js" { ++ interface Argument { ++ idlType: any; ++ default: null; ++ } ++ } ++==== base.js (0 errors) ==== ++ export class Base { ++ constructor() { } ++ ++ toJSON() { ++ const json = { type: undefined, name: undefined, inheritance: undefined }; ++ return json; ++ } ++ } ++==== argument.js (1 errors) ==== ++ import { Base } from "./base.js"; ++ export class Argument extends Base { ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ /** ++ * @param {*} tokeniser ++ */ ++ static parse(tokeniser) { ++ return; ++ } ++ ++ get type() { ++ return "argument"; ++ } ++ ++ /** ++ * @param {*} defs ++ */ ++ *validate(defs) { } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.errors.txt.diff index a6219f736e..78dcd07dc1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.errors.txt.diff @@ -2,17 +2,20 @@ +++ new.jsDeclarationsClassExtendsVisibility.errors.txt @@= skipped -0, +0 lines =@@ - ++cls.js(6,19): error TS8010: Type annotations can only be used in TypeScript files. +cls.js(7,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +cls.js(8,16): error TS2339: Property 'Strings' does not exist on type 'typeof Foo'. + + -+==== cls.js (2 errors) ==== ++==== cls.js (3 errors) ==== + const Bar = require("./bar"); + const Strings = { + a: "A", + b: "B" + }; + class Foo extends Bar {} ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + module.exports = Foo; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic2.errors.txt.diff new file mode 100644 index 0000000000..0a767ad09b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic2.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.jsDeclarationsClassStatic2.errors.txt ++++ new.jsDeclarationsClassStatic2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++Foo.js(4,26): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== Foo.js (1 errors) ==== ++ class Base { ++ static foo = ""; ++ } ++ export class Foo extends Base {} ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ Foo.foo = "foo"; ++ ++==== Bar.ts (0 errors) ==== ++ import { Foo } from "./Foo.js"; ++ ++ class Bar extends Foo {} ++ Bar.foo = "foo"; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff new file mode 100644 index 0000000000..8fe7861c21 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff @@ -0,0 +1,219 @@ +--- old.jsDeclarationsClasses.errors.txt ++++ new.jsDeclarationsClasses.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(147,24): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(149,24): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(159,24): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(173,24): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(185,35): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(191,37): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (6 errors) ==== ++ export class A {} ++ ++ export class B { ++ static cat = "cat"; ++ } ++ ++ export class C { ++ static Cls = class {} ++ } ++ ++ export class D { ++ /** ++ * @param {number} a ++ * @param {number} b ++ */ ++ constructor(a, b) {} ++ } ++ ++ /** ++ * @template T,U ++ */ ++ export class E { ++ /** ++ * @type {T & U} ++ */ ++ field; ++ ++ // @readonly is currently unsupported, it seems - included here just in case that changes ++ /** ++ * @type {T & U} ++ * @readonly ++ */ ++ readonlyField; ++ ++ initializedField = 12; ++ ++ /** ++ * @return {U} ++ */ ++ get f1() { return /** @type {*} */(null); } ++ ++ /** ++ * @param {U} _p ++ */ ++ set f1(_p) {} ++ ++ /** ++ * @return {U} ++ */ ++ get f2() { return /** @type {*} */(null); } ++ ++ /** ++ * @param {U} _p ++ */ ++ set f3(_p) {} ++ ++ /** ++ * @param {T} a ++ * @param {U} b ++ */ ++ constructor(a, b) {} ++ ++ ++ /** ++ * @type {string} ++ */ ++ static staticField; ++ ++ // @readonly is currently unsupported, it seems - included here just in case that changes ++ /** ++ * @type {string} ++ * @readonly ++ */ ++ static staticReadonlyField; ++ ++ static staticInitializedField = 12; ++ ++ /** ++ * @return {string} ++ */ ++ static get s1() { return ""; } ++ ++ /** ++ * @param {string} _p ++ */ ++ static set s1(_p) {} ++ ++ /** ++ * @return {string} ++ */ ++ static get s2() { return ""; } ++ ++ /** ++ * @param {string} _p ++ */ ++ static set s3(_p) {} ++ } ++ ++ /** ++ * @template T,U ++ */ ++ export class F { ++ /** ++ * @type {T & U} ++ */ ++ field; ++ /** ++ * @param {T} a ++ * @param {U} b ++ */ ++ constructor(a, b) {} ++ ++ /** ++ * @template A,B ++ * @param {A} a ++ * @param {B} b ++ */ ++ static create(a, b) { return new F(a, b); } ++ } ++ ++ class G {} ++ ++ export { G }; ++ ++ class HH {} ++ ++ export { HH as H }; ++ ++ export class I {} ++ export { I as II }; ++ ++ export { J as JJ }; ++ export class J {} ++ ++ ++ export class K { ++ constructor() { ++ this.p1 = 12; ++ this.p2 = "ok"; ++ } ++ ++ method() { ++ return this.p1; ++ } ++ } ++ ++ export class L extends K {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ++ export class M extends null { ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ this.prop = 12; ++ } ++ } ++ ++ ++ /** ++ * @template T ++ */ ++ export class N extends L { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ /** ++ * @param {T} param ++ */ ++ constructor(param) { ++ super(); ++ this.another = param; ++ } ++ } ++ ++ /** ++ * @template U ++ * @extends {N} ++ */ ++ export class O extends N { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ /** ++ * @param {U} param ++ */ ++ constructor(param) { ++ super(param); ++ this.another2 = param; ++ } ++ } ++ ++ var x = /** @type {*} */(null); ++ ++ export class VariableBase extends x {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ++ export class HasStatics { ++ static staticMethod() {} ++ } ++ ++ export class ExtendsStatics extends HasStatics { ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ static also() {} ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff new file mode 100644 index 0000000000..2b008b79c1 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff @@ -0,0 +1,220 @@ +--- old.jsDeclarationsClassesErr.errors.txt ++++ new.jsDeclarationsClassesErr.errors.txt +@@= skipped -0, +0 lines =@@ + index.js(4,16): error TS8004: Type parameter declarations can only be used in TypeScript files. + index.js(5,12): error TS8010: Type annotations can only be used in TypeScript files. + index.js(8,16): error TS8004: Type parameter declarations can only be used in TypeScript files. +-index.js(8,29): error TS8011: Type arguments can only be used in TypeScript files. ++index.js(8,27): error TS8010: Type annotations can only be used in TypeScript files. + index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. + index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(13,20): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(16,24): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(18,24): error TS8010: Type annotations can only be used in TypeScript files. + index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(19,20): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(22,24): error TS8010: Type annotations can only be used in TypeScript files. + index.js(23,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(23,20): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(26,24): error TS8010: Type annotations can only be used in TypeScript files. + index.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(27,20): error TS8010: Type annotations can only be used in TypeScript files. + index.js(28,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(28,20): error TS8010: Type annotations can only be used in TypeScript files. + index.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(32,20): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(35,24): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(38,24): error TS8010: Type annotations can only be used in TypeScript files. + index.js(39,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(39,20): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(42,24): error TS8010: Type annotations can only be used in TypeScript files. + index.js(43,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(43,20): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(46,24): error TS8010: Type annotations can only be used in TypeScript files. + index.js(47,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(47,20): error TS8010: Type annotations can only be used in TypeScript files. + index.js(48,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(48,20): error TS8010: Type annotations can only be used in TypeScript files. + index.js(52,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(52,20): error TS8010: Type annotations can only be used in TypeScript files. + index.js(53,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(53,20): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(56,24): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(58,25): error TS8010: Type annotations can only be used in TypeScript files. + index.js(59,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(59,20): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(62,25): error TS8010: Type annotations can only be used in TypeScript files. + index.js(63,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(63,20): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(66,25): error TS8010: Type annotations can only be used in TypeScript files. + index.js(67,11): error TS8010: Type annotations can only be used in TypeScript files. ++index.js(67,20): error TS8010: Type annotations can only be used in TypeScript files. + index.js(68,11): error TS8010: Type annotations can only be used in TypeScript files. +- +- +-==== index.js (21 errors) ==== ++index.js(68,20): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (49 errors) ==== + // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), + // but we should be able to synthesize declarations from the symbols regardless + +@@= skipped -35, +63 lines =@@ + export class N extends M { + ~ + !!! error TS8004: Type parameter declarations can only be used in TypeScript files. +- ~ +-!!! error TS8011: Type arguments can only be used in TypeScript files. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + other: U; + ~ + !!! error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -11, +11 lines =@@ + [idx: string]: string; + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class P extends O {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + export class Q extends O { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: string]: "ok"; + ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class R extends O { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: "ok"; + ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class S extends O { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: string]: "ok"; + ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: never; + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class T { + [idx: number]: string; + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class U extends T {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + + export class V extends T { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: string]: string; + ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class W extends T { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: "ok"; + ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class X extends T { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: string]: string; + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: "ok"; + ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + +@@= skipped -59, +95 lines =@@ + [idx: string]: {x: number}; + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: {x: number, y: number}; + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class Z extends Y {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + export class AA extends Y { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: string]: {x: number, y: number}; + ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class BB extends Y { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: {x: 0, y: 0}; + ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + + export class CC extends Y { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: string]: {x: number, y: number}; + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + [idx: number]: {x: 0, y: 0}; + ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff new file mode 100644 index 0000000000..442f4161f3 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff @@ -0,0 +1,47 @@ +--- old.jsDeclarationsDefault.errors.txt ++++ new.jsDeclarationsDefault.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index4.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index1.js (0 errors) ==== ++ export default 12; ++ ++==== index2.js (0 errors) ==== ++ export default function foo() { ++ return foo; ++ } ++ export const x = foo; ++ export { foo as bar }; ++ ++==== index3.js (0 errors) ==== ++ export default class Foo { ++ a = /** @type {Foo} */(null); ++ }; ++ export const X = Foo; ++ export { Foo as Bar }; ++ ++==== index4.js (1 errors) ==== ++ import Fab from "./index3"; ++ class Bar extends Fab { ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ x = /** @type {Bar} */(null); ++ } ++ export default Bar; ++ ++==== index5.js (0 errors) ==== ++ // merge type alias and const (OK) ++ export default 12; ++ /** ++ * @typedef {string | number} default ++ */ ++ ++==== index6.js (0 errors) ==== ++ // merge type alias and function (OK) ++ export default function func() {}; ++ /** ++ * @typedef {string | number} default ++ */ ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDoubleAssignmentInClosure.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDoubleAssignmentInClosure.errors.txt.diff new file mode 100644 index 0000000000..bda4b5d8aa --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDoubleAssignmentInClosure.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.jsDeclarationsExportDoubleAssignmentInClosure.errors.txt ++++ new.jsDeclarationsExportDoubleAssignmentInClosure.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(4,28): error TS8009: The '?' modifier can only be used in TypeScript files. ++ ++ ++==== index.js (1 errors) ==== ++ // @ts-nocheck ++ function foo() { ++ module.exports = exports = function (o) { ++ return (o == null) ? create(base) : defineProperties(Object(o), descriptors); ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ }; ++ const m = function () { ++ // I have no idea what to put here ++ } ++ exports.methods = m; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportedClassAliases.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportedClassAliases.errors.txt.diff new file mode 100644 index 0000000000..c6541ff471 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportedClassAliases.errors.txt.diff @@ -0,0 +1,27 @@ +--- old.jsDeclarationsExportedClassAliases.errors.txt ++++ new.jsDeclarationsExportedClassAliases.errors.txt +@@= skipped -0, +0 lines =@@ +- ++utils/errors.js(1,26): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== utils/index.js (0 errors) ==== ++ // issue arises here on compilation ++ const errors = require("./errors"); ++ ++ module.exports = { ++ errors ++ }; ++==== utils/errors.js (1 errors) ==== ++ class FancyError extends Error { ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor(status) { ++ super(`error with status ${status}`); ++ } ++ } ++ ++ module.exports = { ++ FancyError ++ }; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff new file mode 100644 index 0000000000..5b817cbf0b --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsGetterSetter.errors.txt.diff @@ -0,0 +1,134 @@ +--- old.jsDeclarationsGetterSetter.errors.txt ++++ new.jsDeclarationsGetterSetter.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(90,24): error TS8009: The '?' modifier can only be used in TypeScript files. ++index.js(103,24): error TS8009: The '?' modifier can only be used in TypeScript files. ++index.js(116,24): error TS8009: The '?' modifier can only be used in TypeScript files. ++ ++ ++==== index.js (3 errors) ==== ++ export class A { ++ get x() { ++ return 12; ++ } ++ } ++ ++ export class B { ++ /** ++ * @param {number} _arg ++ */ ++ set x(_arg) { ++ } ++ } ++ ++ export class C { ++ get x() { ++ return 12; ++ } ++ set x(_arg) { ++ } ++ } ++ ++ export class D {} ++ Object.defineProperty(D.prototype, "x", { ++ get() { ++ return 12; ++ } ++ }); ++ ++ export class E {} ++ Object.defineProperty(E.prototype, "x", { ++ /** ++ * @param {number} _arg ++ */ ++ set(_arg) {} ++ }); ++ ++ export class F {} ++ Object.defineProperty(F.prototype, "x", { ++ get() { ++ return 12; ++ }, ++ /** ++ * @param {number} _arg ++ */ ++ set(_arg) {} ++ }); ++ ++ export class G {} ++ Object.defineProperty(G.prototype, "x", { ++ /** ++ * @param {number[]} args ++ */ ++ set(...args) {} ++ }); ++ ++ export class H {} ++ Object.defineProperty(H.prototype, "x", { ++ set() {} ++ }); ++ ++ ++ export class I {} ++ Object.defineProperty(I.prototype, "x", { ++ /** ++ * @param {number} v ++ */ ++ set: (v) => {} ++ }); ++ ++ /** ++ * @param {number} v ++ */ ++ const jSetter = (v) => {} ++ export class J {} ++ Object.defineProperty(J.prototype, "x", { ++ set: jSetter ++ }); ++ ++ /** ++ * @param {number} v ++ */ ++ const kSetter1 = (v) => {} ++ /** ++ * @param {number} v ++ */ ++ const kSetter2 = (v) => {} ++ export class K {} ++ Object.defineProperty(K.prototype, "x", { ++ set: Math.random() ? kSetter1 : kSetter2 ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ }); ++ ++ /** ++ * @param {number} v ++ */ ++ const lSetter1 = (v) => {} ++ /** ++ * @param {string} v ++ */ ++ const lSetter2 = (v) => {} ++ export class L {} ++ Object.defineProperty(L.prototype, "x", { ++ set: Math.random() ? lSetter1 : lSetter2 ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ }); ++ ++ /** ++ * @param {number | boolean} v ++ */ ++ const mSetter1 = (v) => {} ++ /** ++ * @param {string | boolean} v ++ */ ++ const mSetter2 = (v) => {} ++ export class M {} ++ Object.defineProperty(M.prototype, "x", { ++ set: Math.random() ? mSetter1 : mSetter2 ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ }); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff new file mode 100644 index 0000000000..0f334f3c76 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt ++++ new.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(9,26): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (1 errors) ==== ++ export class Super { ++ /** ++ * @param {string} firstArg ++ * @param {string} secondArg ++ */ ++ constructor(firstArg, secondArg) { } ++ } ++ ++ export class Sub extends Super { ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super('first', 'second'); ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff new file mode 100644 index 0000000000..e005e77d09 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.jsDeclarationsThisTypes.errors.txt ++++ new.jsDeclarationsThisTypes.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(7,35): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== index.js (1 errors) ==== ++ export class A { ++ /** @returns {this} */ ++ method() { ++ return this; ++ } ++ } ++ export default class Base extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ // This method is required to reproduce #35932 ++ verify() { } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff new file mode 100644 index 0000000000..2550410002 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff @@ -0,0 +1,36 @@ +--- old.jsdocAccessibilityTags.errors.txt ++++ new.jsdocAccessibilityTags.errors.txt +@@= skipped -0, +0 lines =@@ ++jsdocAccessibilityTag.js(48,17): error TS8010: Type annotations can only be used in TypeScript files. + jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. ++jsdocAccessibilityTag.js(53,17): error TS8010: Type annotations can only be used in TypeScript files. + jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. + jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. + jsdocAccessibilityTag.js(58,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. +@@= skipped -9, +11 lines =@@ + jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. + + +-==== jsdocAccessibilityTag.js (10 errors) ==== ++==== jsdocAccessibilityTag.js (12 errors) ==== + class A { + /** + * Ap docs +@@= skipped -49, +49 lines =@@ + h() { return this.priv2 } + } + class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + m() { + this.priv + this.prot + this.pub + ~~~~ +@@= skipped -7, +9 lines =@@ + } + } + class D extends C { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + n() { + this.priv2 + this.prot2 + this.pub2 + ~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugmentsMissingType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugmentsMissingType.errors.txt.diff index 0d8dfe2f9e..c62fd06126 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugmentsMissingType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugmentsMissingType.errors.txt.diff @@ -7,9 +7,10 @@ - - -==== /a.js (3 errors) ==== ++/a.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== /a.js (1 errors) ==== ++==== /a.js (2 errors) ==== class A { constructor() { this.x = 0; } } /** @augments */ @@ -17,6 +18,8 @@ - !!! error TS8023: JSDoc '@augments ' does not match the 'extends A' clause. class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. m() { this.x - ~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_errorInExtendsExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_errorInExtendsExpression.errors.txt.diff new file mode 100644 index 0000000000..896f5141a0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_errorInExtendsExpression.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.jsdocAugments_errorInExtendsExpression.errors.txt ++++ new.jsdocAugments_errorInExtendsExpression.errors.txt +@@= skipped -0, +0 lines =@@ + /a.js(3,17): error TS2304: Cannot find name 'err'. +- +- +-==== /a.js (1 errors) ==== ++/a.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.js (2 errors) ==== + class A {} + /** @augments A */ + class B extends err() {} + ~~~ + !!! error TS2304: Cannot find name 'err'. ++ ~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_nameMismatch.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_nameMismatch.errors.txt.diff new file mode 100644 index 0000000000..9fb0bd353d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_nameMismatch.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.jsdocAugments_nameMismatch.errors.txt ++++ new.jsdocAugments_nameMismatch.errors.txt +@@= skipped -0, +0 lines =@@ + /b.js(4,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. +- +- +-==== /b.js (1 errors) ==== ++/b.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /b.js (2 errors) ==== + class A {} + class B {} + +@@= skipped -8, +9 lines =@@ + ~ + !!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. + class C extends B {} ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff new file mode 100644 index 0000000000..b4759a5ad5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_withTypeParameter.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.jsdocAugments_withTypeParameter.errors.txt ++++ new.jsdocAugments_withTypeParameter.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/b.js(2,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== /a.d.ts (0 errors) ==== ++ declare class A { x: T } ++ ++==== /b.js (1 errors) ==== ++ /** @augments A */ ++ class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ m() { ++ return this.x; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff index 6b6ecc5911..310c64d901 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocFunctionType.errors.txt.diff @@ -14,12 +14,13 @@ +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(31,51): error TS8009: The '?' modifier can only be used in TypeScript files. +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(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} @@ -50,7 +51,7 @@ return c } -@@= skipped -32, +53 lines =@@ +@@= skipped -32, +54 lines =@@ z.length; /** @type {function ("a" | "b", 1 | 2): 3 | 4} */ @@ -62,10 +63,12 @@ +!!! error TS7006: Parameter 'ab' implicitly has an 'any' type. + ~~~~~~ +!!! error TS7006: Parameter 'onetwo' implicitly has an 'any' type. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. /** -@@= skipped -19, +26 lines =@@ +@@= skipped -19, +28 lines =@@ /** * @param {function(new: D, number)} dref * @return {D} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff new file mode 100644 index 0000000000..ce5f83de41 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.jsdocOverrideTag1.errors.txt ++++ new.jsdocOverrideTag1.errors.txt +@@= skipped -0, +0 lines =@@ ++0.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. + 0.js(27,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'A'. + 0.js(32,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. + 0.js(40,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. + + +-==== 0.js (3 errors) ==== ++==== 0.js (4 errors) ==== + class A { + + /** +@@= skipped -19, +20 lines =@@ + } + + class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** + * @override + * @method \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff index cb553f8687..6d7fbde880 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff @@ -15,6 +15,7 @@ - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. +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(20,27): error TS8010: Type annotations can only be used in TypeScript files. +b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. +b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x +b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. @@ -22,13 +23,7 @@ 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, +12 lines =@@ - ==== a.ts (0 errors) ==== - var W: string; - --==== b.js (10 errors) ==== -+==== b.js (9 errors) ==== - // @ts-check +@@= skipped -25, +18 lines =@@ var W = /** @type {string} */(/** @type {*} */ (4)); var W = /** @type {string} */(4); // Error @@ -37,7 +32,16 @@ !!! 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 {*} */ -@@= skipped -48, +48 lines =@@ +@@= skipped -18, +18 lines =@@ + } + } + class SomeDerived extends SomeBase { ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super(); + this.x = 42; +@@= skipped -25, +27 lines =@@ someBase = /** @type {SomeBase} */(someDerived); someBase = /** @type {SomeBase} */(someBase); someBase = /** @type {SomeBase} */(someOther); // Error diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff new file mode 100644 index 0000000000..9dcc142c75 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/overloadTag2.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.overloadTag2.errors.txt ++++ new.overloadTag2.errors.txt +@@= skipped -0, +0 lines =@@ ++overloadTag2.js(2,15): error TS8009: The '?' modifier can only be used in TypeScript files. + overloadTag2.js(14,9): error TS2394: This overload signature is not compatible with its implementation signature. + 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 (3 errors) ==== ++==== overloadTag2.js (4 errors) ==== + export class Foo { + #a = true ? 1 : "1" ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + #b + + /** \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff new file mode 100644 index 0000000000..299f10f006 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff @@ -0,0 +1,30 @@ +--- old.override_js1.errors.txt ++++ new.override_js1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== a.js (1 errors) ==== ++ class B { ++ foo (v) {} ++ fooo (v) {} ++ } ++ ++ class D extends B { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ foo (v) {} ++ /** @override */ ++ fooo (v) {} ++ /** @override */ ++ bar(v) {} ++ } ++ ++ class C { ++ foo () {} ++ /** @override */ ++ fooo (v) {} ++ /** @override */ ++ bar(v) {} ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff new file mode 100644 index 0000000000..55c441fdab --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.override_js2.errors.txt ++++ new.override_js2.errors.txt +@@= skipped -0, +0 lines =@@ ++a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. + a.js(7,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'B'. + a.js(11,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'B'. + a.js(17,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. + a.js(19,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. + + +-==== a.js (4 errors) ==== ++==== a.js (5 errors) ==== + class B { + foo (v) {} + fooo (v) {} + } + + class D extends B { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + foo (v) {} + ~~~ + !!! error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'B'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff new file mode 100644 index 0000000000..7ff4fadd64 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.override_js3.errors.txt ++++ new.override_js3.errors.txt +@@= skipped -0, +0 lines =@@ ++a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. + a.js(7,5): error TS8009: The 'override' modifier can only be used in TypeScript files. + + +-==== a.js (1 errors) ==== ++==== a.js (2 errors) ==== + class B { + foo (v) {} + fooo (v) {} + } + + class D extends B { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + override foo (v) {} + ~~~~~~~~ + !!! error TS8009: The 'override' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff new file mode 100644 index 0000000000..7793263ccf --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.override_js4.errors.txt ++++ new.override_js4.errors.txt +@@= skipped -0, +0 lines =@@ ++a.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. + a.js(7,5): error TS4123: This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class 'A'. Did you mean 'doSomething'? + + +-==== a.js (1 errors) ==== ++==== a.js (2 errors) ==== + class A { + doSomething() {} + } + + class B extends A { ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + /** @override */ + doSomethang() {} + ~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff new file mode 100644 index 0000000000..5f12433ec5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.parserArrowFunctionExpression10.errors.txt ++++ new.parserArrowFunctionExpression10.errors.txt +@@= skipped -0, +0 lines =@@ + fileJs.js(1,1): error TS2304: Cannot find name 'a'. ++fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,11): error TS2304: Cannot find name 'c'. + fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. + fileJs.js(1,17): error TS2304: Cannot find name 'd'. +@@= skipped -8, +9 lines =@@ + fileTs.ts(1,27): error TS2304: Cannot find name 'f'. + + +-==== fileJs.js (5 errors) ==== ++==== fileJs.js (6 errors) ==== + a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon + ~ + !!! error TS2304: Cannot find name 'a'. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~ + !!! error TS2304: Cannot find name 'c'. + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression11.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression11.errors.txt.diff new file mode 100644 index 0000000000..cecee11110 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression11.errors.txt.diff @@ -0,0 +1,28 @@ +--- old.parserArrowFunctionExpression11.errors.txt ++++ new.parserArrowFunctionExpression11.errors.txt +@@= skipped -0, +0 lines =@@ + fileJs.js(1,1): error TS2304: Cannot find name 'a'. ++fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,5): error TS2304: Cannot find name 'b'. ++fileJs.js(1,7): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,9): error TS2304: Cannot find name 'c'. + fileJs.js(1,14): error TS2304: Cannot find name 'd'. + fileJs.js(1,24): error TS2304: Cannot find name 'f'. +@@= skipped -9, +11 lines =@@ + fileTs.ts(1,24): error TS2304: Cannot find name 'f'. + + +-==== fileJs.js (5 errors) ==== ++==== fileJs.js (7 errors) ==== + a ? b ? c : (d) : e => f // Legal JS + ~ + !!! error TS2304: Cannot find name 'a'. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~ + !!! error TS2304: Cannot find name 'b'. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~ + !!! error TS2304: Cannot find name 'c'. + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression12.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression12.errors.txt.diff new file mode 100644 index 0000000000..260430eb94 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression12.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.parserArrowFunctionExpression12.errors.txt ++++ new.parserArrowFunctionExpression12.errors.txt +@@= skipped -0, +0 lines =@@ + fileJs.js(1,1): error TS2304: Cannot find name 'a'. ++fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,13): error TS2304: Cannot find name 'c'. + fileJs.js(1,22): error TS2304: Cannot find name 'e'. + fileTs.ts(1,1): error TS2304: Cannot find name 'a'. +@@= skipped -5, +6 lines =@@ + fileTs.ts(1,22): error TS2304: Cannot find name 'e'. + + +-==== fileJs.js (3 errors) ==== ++==== fileJs.js (4 errors) ==== + a ? (b) => (c): d => e // Legal JS + ~ + !!! error TS2304: Cannot find name 'a'. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~ + !!! error TS2304: Cannot find name 'c'. + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff new file mode 100644 index 0000000000..16ad2e6db0 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff @@ -0,0 +1,21 @@ +--- old.parserArrowFunctionExpression13.errors.txt ++++ new.parserArrowFunctionExpression13.errors.txt +@@= skipped -0, +0 lines =@@ + fileJs.js(1,1): error TS2304: Cannot find name 'a'. ++fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,11): error TS2304: Cannot find name 'a'. + fileJs.js(1,21): error TS8010: Type annotations can only be used in TypeScript files. + fileTs.ts(1,1): error TS2304: Cannot find name 'a'. + fileTs.ts(1,11): error TS2304: Cannot find name 'a'. + + +-==== fileJs.js (3 errors) ==== ++==== fileJs.js (4 errors) ==== + a ? () => a() : (): any => null; // Not legal JS; "Unexpected token ')'" at last paren + ~ + !!! error TS2304: Cannot find name 'a'. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~ + !!! error TS2304: Cannot find name 'a'. + ~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff new file mode 100644 index 0000000000..a72ae7ea65 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.parserArrowFunctionExpression14.errors.txt ++++ new.parserArrowFunctionExpression14.errors.txt +@@= skipped -0, +0 lines =@@ + fileJs.js(1,1): error TS2304: Cannot find name 'a'. ++fileJs.js(1,5): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. + fileJs.js(1,20): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,23): error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -9, +10 lines =@@ + fileTs.ts(1,46): error TS2304: Cannot find name 'e'. + + +-==== fileJs.js (7 errors) ==== ++==== fileJs.js (8 errors) ==== + a() ? (b: number, c?: string): void => d() : e; // Not legal JS; "Unexpected token ':'" at first colon + ~ + !!! error TS2304: Cannot find name 'a'. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff new file mode 100644 index 0000000000..49dccdcd87 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff @@ -0,0 +1,15 @@ +--- old.parserArrowFunctionExpression15.errors.txt ++++ new.parserArrowFunctionExpression15.errors.txt +@@= skipped -0, +0 lines =@@ ++fileJs.js(1,7): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,18): error TS8010: Type annotations can only be used in TypeScript files. + + +-==== fileJs.js (1 errors) ==== ++==== fileJs.js (2 errors) ==== + false ? (param): string => param : null // Not legal JS; "Unexpected token ':'" at last colon ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff new file mode 100644 index 0000000000..1da8ce4d72 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.parserArrowFunctionExpression16.errors.txt ++++ new.parserArrowFunctionExpression16.errors.txt +@@= skipped -0, +0 lines =@@ ++fileJs.js(1,6): error TS8009: The '?' modifier can only be used in TypeScript files. ++fileJs.js(1,14): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,25): error TS8010: Type annotations can only be used in TypeScript files. + + +-==== fileJs.js (1 errors) ==== ++==== fileJs.js (3 errors) ==== + true ? false ? (param): string => param : null : null // Not legal JS; "Unexpected token ':'" at last colon ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ + !!! error TS8010: Type annotations can only be used in TypeScript files. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff new file mode 100644 index 0000000000..0ff4576571 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.parserArrowFunctionExpression17.errors.txt ++++ new.parserArrowFunctionExpression17.errors.txt +@@= skipped -0, +0 lines =@@ + fileJs.js(1,1): error TS2304: Cannot find name 'a'. ++fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,5): error TS2304: Cannot find name 'b'. + fileJs.js(1,15): error TS2304: Cannot find name 'd'. + fileJs.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -8, +9 lines =@@ + fileTs.ts(1,20): error TS2304: Cannot find name 'e'. + + +-==== fileJs.js (5 errors) ==== ++==== fileJs.js (6 errors) ==== + a ? b : (c) : d => e // Not legal JS; "Unexpected token ':'" at last colon + ~ + !!! error TS2304: Cannot find name 'a'. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~ + !!! error TS2304: Cannot find name 'b'. + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression8.errors.txt.diff new file mode 100644 index 0000000000..3551256b95 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression8.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.parserArrowFunctionExpression8.errors.txt ++++ new.parserArrowFunctionExpression8.errors.txt +@@= skipped -0, +0 lines =@@ + fileJs.js(1,1): error TS2304: Cannot find name 'x'. ++fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. + fileTs.ts(1,1): error TS2304: Cannot find name 'x'. + + +-==== fileJs.js (1 errors) ==== ++==== fileJs.js (2 errors) ==== + x ? y => ({ y }) : z => ({ z }) // Legal JS + ~ + !!! error TS2304: Cannot find name 'x'. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + + ==== fileTs.ts (1 errors) ==== + x ? y => ({ y }) : z => ({ z }) \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression9.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression9.errors.txt.diff new file mode 100644 index 0000000000..f01f3f8169 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression9.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.parserArrowFunctionExpression9.errors.txt ++++ new.parserArrowFunctionExpression9.errors.txt +@@= skipped -0, +0 lines =@@ + fileJs.js(1,1): error TS2304: Cannot find name 'b'. ++fileJs.js(1,3): error TS8009: The '?' modifier can only be used in TypeScript files. + fileJs.js(1,6): error TS2304: Cannot find name 'c'. + fileJs.js(1,16): error TS2304: Cannot find name 'e'. + fileTs.ts(1,1): error TS2304: Cannot find name 'b'. +@@= skipped -5, +6 lines =@@ + fileTs.ts(1,16): error TS2304: Cannot find name 'e'. + + +-==== fileJs.js (3 errors) ==== ++==== fileJs.js (4 errors) ==== + b ? (c) : d => e // Legal JS + ~ + !!! error TS2304: Cannot find name 'b'. ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~ + !!! error TS2304: Cannot find name 'c'. + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff new file mode 100644 index 0000000000..ca45a3c9de --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff @@ -0,0 +1,80 @@ +--- old.plainJSGrammarErrors.errors.txt ++++ new.plainJSGrammarErrors.errors.txt +@@= skipped -20, +20 lines =@@ + plainJSGrammarErrors.js(38,18): error TS1053: A 'set' accessor cannot have rest parameter. + plainJSGrammarErrors.js(41,5): error TS18006: Classes may not have a field named 'constructor'. + plainJSGrammarErrors.js(43,1): error TS1211: A class declaration without the 'default' modifier must have a name. ++plainJSGrammarErrors.js(46,23): error TS8010: Type annotations can only be used in TypeScript files. + plainJSGrammarErrors.js(46,25): error TS1172: 'extends' clause already seen. ++plainJSGrammarErrors.js(46,33): error TS8010: Type annotations can only be used in TypeScript files. ++plainJSGrammarErrors.js(47,23): error TS8010: Type annotations can only be used in TypeScript files. + plainJSGrammarErrors.js(47,25): error TS1174: Classes can only extend a single class. ++plainJSGrammarErrors.js(47,25): error TS8010: Type annotations can only be used in TypeScript files. ++plainJSGrammarErrors.js(47,27): error TS8010: Type annotations can only be used in TypeScript files. + plainJSGrammarErrors.js(49,1): error TS18016: Private identifiers are not allowed outside class bodies. + plainJSGrammarErrors.js(50,6): error TS18016: Private identifiers are not allowed outside class bodies. + plainJSGrammarErrors.js(51,9): error TS18013: Property '#m' is not accessible outside class 'C' because it has a private identifier. +@@= skipped -45, +50 lines =@@ + plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allowed outside class bodies. + plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. + plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. ++plainJSGrammarErrors.js(108,25): error TS8009: The '?' modifier can only be used in TypeScript files. + plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. +-plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. + plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. ++plainJSGrammarErrors.js(110,15): error TS8009: The '!' modifier can only be used in TypeScript files. + plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. + plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. + plainJSGrammarErrors.js(116,24): error TS1009: Trailing comma not allowed. +@@= skipped -36, +37 lines =@@ + plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. + + +-==== plainJSGrammarErrors.js (102 errors) ==== ++==== plainJSGrammarErrors.js (108 errors) ==== + class C { + // #private mistakes + q = #unbound +@@= skipped -93, +93 lines =@@ + missingName = true + } + class Doubler extends C extends C { } ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~~ + !!! error TS1172: 'extends' clause already seen. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + class Trebler extends C,C,C { } ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ + !!! error TS1174: Classes can only extend a single class. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + // #private mistakes + #unrelated + ~~~~~~~~~~ +@@= skipped -152, +162 lines =@@ + cantHaveQuestionMark?: 1, + ~ + !!! error TS1162: An object member cannot be declared optional. +- m?() { return 12 }, +- ~ +-!!! error TS1162: An object member cannot be declared optional. +- ~ ++ ~ + !!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ m?() { return 12 }, ++ ~ ++!!! error TS1162: An object member cannot be declared optional. + definitely!, + ~ + !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. ++ ~ ++!!! error TS8009: The '!' modifier can only be used in TypeScript files. + definiteMethod!() { return 13 }, + ~ + !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff new file mode 100644 index 0000000000..8eca402c61 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/returnTagTypeGuard.errors.txt.diff @@ -0,0 +1,71 @@ +--- old.returnTagTypeGuard.errors.txt ++++ new.returnTagTypeGuard.errors.txt +@@= skipped -0, +0 lines =@@ +- ++bug25127.js(27,33): error TS8009: The '?' modifier can only be used in TypeScript files. ++ ++ ++==== bug25127.js (1 errors) ==== ++ class Entry { ++ constructor() { ++ this.c = 1 ++ } ++ /** ++ * @param {any} x ++ * @return {this is Entry} ++ */ ++ isInit(x) { ++ return true ++ } ++ } ++ class Group { ++ constructor() { ++ this.d = 'no' ++ } ++ /** ++ * @param {any} x ++ * @return {false} ++ */ ++ isInit(x) { ++ return false ++ } ++ } ++ /** @param {Entry | Group} chunk */ ++ function f(chunk) { ++ let x = chunk.isInit(chunk) ? chunk.c : chunk.d ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. ++ return x ++ } ++ ++ /** ++ * @param {any} value ++ * @return {value is boolean} ++ */ ++ function isBoolean(value) { ++ return typeof value === "boolean"; ++ } ++ ++ /** @param {boolean | number} val */ ++ function foo(val) { ++ if (isBoolean(val)) { ++ val; ++ } ++ } ++ ++ /** ++ * @callback Cb ++ * @param {unknown} x ++ * @return {x is number} ++ */ ++ ++ /** @type {Cb} */ ++ function isNumber(x) { return typeof x === "number" } ++ ++ /** @param {unknown} x */ ++ function g(x) { ++ if (isNumber(x)) { ++ x * 2; ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/spellingUncheckedJS.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/spellingUncheckedJS.errors.txt.diff new file mode 100644 index 0000000000..fedd959a81 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/spellingUncheckedJS.errors.txt.diff @@ -0,0 +1,59 @@ +--- old.spellingUncheckedJS.errors.txt ++++ new.spellingUncheckedJS.errors.txt +@@= skipped -0, +0 lines =@@ +- ++spellingUncheckedJS.js(19,23): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== spellingUncheckedJS.js (1 errors) ==== ++ export var inModule = 1 ++ inmodule.toFixed() ++ ++ function f() { ++ var locals = 2 + true ++ locale.toFixed() ++ // @ts-expect-error ++ localf.toExponential() ++ // @ts-expect-error ++ "this is fine" ++ } ++ class Classe { ++ non = 'oui' ++ methode() { ++ // no error on 'this' references ++ return this.none ++ } ++ } ++ class Derivee extends Classe { ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ methode() { ++ // no error on 'super' references ++ return super.none ++ } ++ } ++ ++ ++ var object = { ++ spaaace: 3 ++ } ++ object.spaaaace // error on read ++ object.spaace = 12 // error on write ++ object.fresh = 12 // OK ++ other.puuuce // OK, from another file ++ new Date().getGMTDate() // OK, from another file ++ ++ // No suggestions for globals from other files ++ const atoc = setIntegral(() => console.log('ok'), 500) ++ AudioBuffin // etc ++ Jimmy ++ Jon ++ ++==== other.js (0 errors) ==== ++ var Jimmy = 1 ++ var John = 2 ++ Jon // error, it's from the same file ++ var other = { ++ puuce: 4 ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff new file mode 100644 index 0000000000..1640bb88aa --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff @@ -0,0 +1,32 @@ +--- old.thisPropertyAssignmentInherited.errors.txt ++++ new.thisPropertyAssignmentInherited.errors.txt +@@= skipped -0, +0 lines =@@ +- ++thisPropertyAssignmentInherited.js(11,34): error TS8010: Type annotations can only be used in TypeScript files. ++thisPropertyAssignmentInherited.js(12,34): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== thisPropertyAssignmentInherited.js (2 errors) ==== ++ export class Element { ++ /** ++ * @returns {String} ++ */ ++ get textContent() { ++ return '' ++ } ++ set textContent(x) {} ++ cloneNode() { return this} ++ } ++ export class HTMLElement extends Element {} ++ ~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ export class TextElement extends HTMLElement { ++ ~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ get innerHTML() { return this.textContent; } ++ set innerHTML(html) { this.textContent = html; } ++ toString() { ++ } ++ } ++ ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyOverridesAccessors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyOverridesAccessors.errors.txt.diff new file mode 100644 index 0000000000..cffc69bf83 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyOverridesAccessors.errors.txt.diff @@ -0,0 +1,23 @@ +--- old.thisPropertyOverridesAccessors.errors.txt ++++ new.thisPropertyOverridesAccessors.errors.txt +@@= skipped -0, +0 lines =@@ +- ++bar.js(1,19): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== foo.ts (0 errors) ==== ++ class Foo { ++ get p() { return 1 } ++ set p(value) { } ++ } ++ ++==== bar.js (1 errors) ==== ++ class Bar extends Foo { ++ ~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. ++ constructor() { ++ super() ++ this.p = 2 ++ } ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment23.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment23.errors.txt.diff index e1c59506b4..8c1f2cd10a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment23.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment23.errors.txt.diff @@ -2,11 +2,14 @@ +++ new.typeFromPropertyAssignment23.errors.txt @@= skipped -0, +0 lines =@@ - ++a.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. ++a.js(15,17): error TS8010: Type annotations can only be used in TypeScript files. +a.js(23,18): error TS2339: Property 'identifier' does not exist on type 'Module'. +a.js(24,18): error TS2339: Property 'size' does not exist on type 'Module'. ++a.js(26,28): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (2 errors) ==== ++==== a.js (5 errors) ==== + class B { + constructor () { + this.n = 1 @@ -16,12 +19,16 @@ + } + + class C extends B { } ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + + // this override should be fine (even if it's a little odd) + C.prototype.foo = function() { + } + + class D extends B { } ++ ~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + D.prototype.foo = () => { + this.n = 'not checked, so no error' + } @@ -37,6 +44,8 @@ +!!! error TS2339: Property 'size' does not exist on type 'Module'. + + class NormalModule extends Module { ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + identifier() { + return 'normal' + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment25.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment25.errors.txt.diff index c427274095..897aca92ee 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment25.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment25.errors.txt.diff @@ -3,9 +3,10 @@ @@= skipped -0, +0 lines =@@ - +bug24703.js(7,8): error TS2506: 'O' is referenced directly or indirectly in its own base expression. ++bug24703.js(7,26): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== bug24703.js (1 errors) ==== ++==== bug24703.js (2 errors) ==== + var Common = {}; + Common.I = class { + constructor() { @@ -15,6 +16,8 @@ + Common.O = class extends Common.I { + ~ +!!! error TS2506: 'O' is referenced directly or indirectly in its own base expression. ++ ~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super() + this.o = 2 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment26.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment26.errors.txt.diff index 2f5710bd3e..c0fe98cbbb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment26.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment26.errors.txt.diff @@ -3,11 +3,15 @@ @@= skipped -0, +0 lines =@@ -bug24730.js(11,14): error TS2339: Property 'doesNotExist' does not exist on type 'C'. -bug24730.js(12,26): error TS2339: Property 'doesntExistEither' does not exist on type 'number'. +- +- +-==== bug24730.js (2 errors) ==== +bug24730.js(1,5): error TS7022: 'UI' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +bug24730.js(7,1): error TS7022: 'context' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - - - ==== bug24730.js (2 errors) ==== ++bug24730.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== bug24730.js (3 errors) ==== var UI = {} + ~~ +!!! error TS7022: 'UI' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. @@ -21,6 +25,8 @@ +!!! error TS7022: 'context' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. class C extends UI.TreeElement { ++ ~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. onpopulate() { this.doesNotExist - ~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment9.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment9.errors.txt.diff index 4922da61e6..1d9b178155 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment9.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment9.errors.txt.diff @@ -2,10 +2,11 @@ +++ new.typeFromPropertyAssignment9.errors.txt @@= skipped -0, +0 lines =@@ - ++a.js(22,27): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(33,16): error TS2304: Cannot find name 'global'. + + -+==== a.js (1 errors) ==== ++==== a.js (2 errors) ==== + var my = my || {}; + /** @param {number} n */ + my.method = function(n) { @@ -28,6 +29,8 @@ + */ + my.predicate.sort = my.predicate.sort || function (first, second) { + return first > second ? first : second; ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + } + my.predicate.type = class { + m() { return 101; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment9_1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment9_1.errors.txt.diff index d9cb295214..5437ac9cb1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment9_1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment9_1.errors.txt.diff @@ -2,10 +2,11 @@ +++ new.typeFromPropertyAssignment9_1.errors.txt @@= skipped -0, +0 lines =@@ - ++a.js(22,27): error TS8009: The '?' modifier can only be used in TypeScript files. +a.js(33,16): error TS2304: Cannot find name 'global'. + + -+==== a.js (1 errors) ==== ++==== a.js (2 errors) ==== + var my = my ?? {}; + /** @param {number} n */ + my.method = function(n) { @@ -28,6 +29,8 @@ + */ + my.predicate.sort = my.predicate.sort ?? function (first, second) { + return first > second ? first : second; ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + } + my.predicate.type = class { + m() { return 101; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff index 5dfed1d5ae..67e39fecce 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff @@ -4,25 +4,31 @@ - +index.js(1,7): error TS2339: Property 'Item' does not exist on type '{}'. +index.js(2,8): error TS2339: Property 'Object' does not exist on type '{}'. ++index.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. +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,34): error TS8010: Type annotations can only be used in TypeScript files. +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 (6 errors) ==== ++==== index.js (8 errors) ==== + First.Item = class I {} + ~~~~ +!!! error TS2339: Property 'Item' does not exist on type '{}'. + Common.Object = class extends First.Item {} + ~~~~~~ +!!! error TS2339: Property 'Object' does not exist on type '{}'. ++ ~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ +!!! error TS2339: Property 'Item' does not exist on type '{}'. + + Workspace.Object = class extends Common.Object {} + ~~~~~~ +!!! error TS2339: Property 'Object' does not exist on type '{}'. ++ ~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2339: Property 'Object' does not exist on type '{}'. + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff index eaa71cd329..fbdd114798 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagWrapping.errors.txt.diff @@ -8,10 +8,12 @@ -==== mod1.js (0 errors) ==== +mod1.js(2,14): error TS2552: Cannot find name 'function'. Did you mean 'Function'? +mod1.js(9,12): error TS2304: Cannot find name 'Type1'. ++mod2.js(15,18): error TS8009: The '?' modifier can only be used in TypeScript files. +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'. ++mod5.js(18,18): error TS8009: The '?' modifier can only be used in TypeScript files. + + +==== mod1.js (2 errors) ==== @@ -23,7 +25,7 @@ * Type1 */ -@@= skipped -11, +18 lines =@@ +@@= skipped -11, +20 lines =@@ * Tries to use a type whose name is on a different * line than the typedef tag. * @param {Type1} func The function to call. @@ -32,8 +34,21 @@ * @param {string} arg The argument to call it with. * @returns {boolean} The return. */ -@@= skipped -25, +27 lines =@@ +@@= skipped -7, +9 lines =@@ + return func(arg); + } + +-==== mod2.js (0 errors) ==== ++==== mod2.js (1 errors) ==== + /** + * @typedef {{ + * num: number, +@@= skipped -16, +16 lines =@@ + */ + function check(obj) { return obj.boo ? obj.num : obj.str; ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. } -==== mod3.js (0 errors) ==== @@ -56,7 +71,7 @@ * @param {boolean} bool The condition. * @param {string} str The string. * @param {number} num The number. -@@= skipped -20, +25 lines =@@ +@@= skipped -22, +29 lines =@@ return func(bool, str, num) } @@ -81,7 +96,25 @@ * @param {boolean} bool The condition. * @param {string} str The string. * @param {number} num The number. -@@= skipped -50, +52 lines =@@ +@@= skipped -9, +11 lines =@@ + return func(bool, str, num) + } + +-==== mod5.js (0 errors) ==== ++==== mod5.js (1 errors) ==== + /** + * @typedef {{ + * num: +@@= skipped -19, +19 lines =@@ + */ + function check5(obj) { + return obj.boo ? obj.num : obj.str; ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + } + + ==== mod6.js (0 errors) ==== +@@= skipped -22, +24 lines =@@ } From a76f6f6f1d3b21b5dbc33997da41e386afc954ca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 21 Jul 2025 18:58:51 +0000 Subject: [PATCH 30/31] Fix JS syntactic diagnostics for null/undefined literals and type arguments in heritage clauses Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/parser/js_diagnostics.go | 75 +++++++++++-- ...ypeArgumentCount1(strict=false).errors.txt | 5 +- ...TypeArgumentCount1(strict=true).errors.txt | 5 +- ...ypeArgumentCount2(strict=false).errors.txt | 5 +- ...TypeArgumentCount2(strict=true).errors.txt | 5 +- ...mentsReferenceInConstructor3_Js.errors.txt | 33 ------ .../argumentsReferenceInMethod3_Js.errors.txt | 29 ----- ...aintOfJavascriptClassExpression.errors.txt | 5 +- .../checkJsFiles_noErrorLocation.errors.txt | 25 ----- .../compiler/classExtendingAny.errors.txt | 38 ------- .../classFieldSuperAccessibleJs1.errors.txt | 18 ---- .../classFieldSuperAccessibleJs2.errors.txt | 30 ------ .../classFieldSuperNotAccessibleJs.errors.txt | 5 +- ...tPropsEmptyCurlyBecomesAnyForJs.errors.txt | 29 ----- ...ssingTypeArgsOnJSConstructCalls.errors.txt | 5 +- .../compiler/genericDefaultsJs.errors.txt | 98 ----------------- ...mportDeclFromTypeNodeInJsSource.errors.txt | 60 ----------- ...ipt(verbatimmodulesyntax=false).errors.txt | 48 --------- ...ript(verbatimmodulesyntax=true).errors.txt | 48 --------- .../javascriptCommonjsModule.errors.txt | 12 --- ...riptThisAssignmentInStaticBlock.errors.txt | 24 ----- .../jsDeclarationsInheritedTypes.errors.txt | 40 ------- .../jsEmitIntersectionProperty.errors.txt | 35 ------ .../compiler/jsExtendsImplicitAny.errors.txt | 8 +- ...itAnyNoCascadingReferenceErrors.errors.txt | 5 +- .../compiler/superNoModifiersCrash.errors.txt | 17 --- ...assCanExtendConstructorFunction.errors.txt | 8 +- .../conformance/extendsTag2.errors.txt | 26 ----- .../conformance/extendsTag3.errors.txt | 36 ------- .../conformance/extendsTag6.errors.txt | 23 ---- .../conformance/extendsTagEmit.errors.txt | 5 +- ...ingClassMembersFromAssignments3.errors.txt | 17 --- ...ingClassMembersFromAssignments4.errors.txt | 18 ---- ...ingClassMembersFromAssignments5.errors.txt | 22 ---- .../jsDeclarationsClassAccessor.errors.txt | 41 ------- ...larationsClassExtendsVisibility.errors.txt | 5 +- .../jsDeclarationsClassStatic2.errors.txt | 18 ---- .../jsDeclarationsClasses.errors.txt | 17 +-- .../jsDeclarationsClassesErr.errors.txt | 38 +------ .../jsDeclarationsDefault.errors.txt | 43 -------- .../conformance/jsDeclarationsDefault.js | 76 +++++++++++++ .../conformance/jsDeclarationsDefault.js.diff | 78 +++++++++++++- ...eclarationsExportedClassAliases.errors.txt | 23 ---- ...thExplicitNoArgumentConstructor.errors.txt | 19 ---- .../jsDeclarationsThisTypes.errors.txt | 16 --- .../jsdocAccessibilityTags.errors.txt | 8 +- .../jsdocAugmentsMissingType.errors.txt | 5 +- ...gments_errorInExtendsExpression.errors.txt | 5 +- .../jsdocAugments_nameMismatch.errors.txt | 5 +- .../conformance/jsdocOverrideTag1.errors.txt | 5 +- .../conformance/jsdocTypeTagCast.errors.txt | 5 +- .../conformance/override_js1.errors.txt | 26 ----- .../conformance/override_js2.errors.txt | 5 +- .../conformance/override_js3.errors.txt | 5 +- .../conformance/override_js4.errors.txt | 5 +- .../plainJSGrammarErrors.errors.txt | 17 +-- .../spellingUncheckedJS.errors.txt | 55 ---------- ...thisPropertyAssignmentInherited.errors.txt | 28 ----- .../thisPropertyOverridesAccessors.errors.txt | 19 ---- .../typeFromPropertyAssignment23.errors.txt | 11 +- .../typeFromPropertyAssignment25.errors.txt | 5 +- .../typeFromPropertyAssignment26.errors.txt | 5 +- ...romPropertyAssignmentOutOfOrder.errors.txt | 8 +- ...ReferenceInConstructor3_Js.errors.txt.diff | 37 ------- ...mentsReferenceInMethod3_Js.errors.txt.diff | 33 ------ ...fJavascriptClassExpression.errors.txt.diff | 16 +-- ...eckJsFiles_noErrorLocation.errors.txt.diff | 29 ----- .../classExtendingAny.errors.txt.diff | 42 -------- ...assFieldSuperAccessibleJs1.errors.txt.diff | 32 +++--- ...assFieldSuperAccessibleJs2.errors.txt.diff | 34 ------ ...sFieldSuperNotAccessibleJs.errors.txt.diff | 21 +--- ...sEmptyCurlyBecomesAnyForJs.errors.txt.diff | 33 ------ ...TypeArgsOnJSConstructCalls.errors.txt.diff | 14 +-- .../genericDefaultsJs.errors.txt.diff | 102 ------------------ ...DeclFromTypeNodeInJsSource.errors.txt.diff | 64 ----------- ...erbatimmodulesyntax=false).errors.txt.diff | 52 --------- ...verbatimmodulesyntax=true).errors.txt.diff | 52 --------- .../javascriptCommonjsModule.errors.txt.diff | 16 --- ...hisAssignmentInStaticBlock.errors.txt.diff | 28 ----- ...DeclarationsInheritedTypes.errors.txt.diff | 44 -------- ...jsEmitIntersectionProperty.errors.txt.diff | 39 ------- .../jsExtendsImplicitAny.errors.txt.diff | 8 +- ...NoCascadingReferenceErrors.errors.txt.diff | 21 ---- .../superNoModifiersCrash.errors.txt.diff | 21 ---- ...nExtendConstructorFunction.errors.txt.diff | 19 +--- .../conformance/extendsTag2.errors.txt.diff | 37 ++++--- .../conformance/extendsTag3.errors.txt.diff | 40 ------- .../conformance/extendsTag6.errors.txt.diff | 27 ----- .../extendsTagEmit.errors.txt.diff | 16 ++- ...assMembersFromAssignments3.errors.txt.diff | 21 ---- ...assMembersFromAssignments4.errors.txt.diff | 22 ---- ...assMembersFromAssignments5.errors.txt.diff | 26 ----- ...sDeclarationsClassAccessor.errors.txt.diff | 45 -------- ...ionsClassExtendsVisibility.errors.txt.diff | 5 +- ...jsDeclarationsClassStatic2.errors.txt.diff | 22 ---- .../jsDeclarationsClasses.errors.txt.diff | 17 +-- .../jsDeclarationsClassesErr.errors.txt.diff | 80 ++++---------- .../jsDeclarationsDefault.errors.txt.diff | 47 -------- ...ationsExportedClassAliases.errors.txt.diff | 27 ----- ...licitNoArgumentConstructor.errors.txt.diff | 23 ---- .../jsDeclarationsThisTypes.errors.txt.diff | 20 ---- .../jsdocAccessibilityTags.errors.txt.diff | 36 ------- .../jsdocAugmentsMissingType.errors.txt.diff | 5 +- ...s_errorInExtendsExpression.errors.txt.diff | 19 ---- ...jsdocAugments_nameMismatch.errors.txt.diff | 21 ---- .../jsdocOverrideTag1.errors.txt.diff | 23 ---- .../jsdocTypeTagCast.errors.txt.diff | 20 ++-- .../conformance/override_js1.errors.txt.diff | 30 ------ .../conformance/override_js2.errors.txt.diff | 23 ---- .../conformance/override_js3.errors.txt.diff | 20 ---- .../conformance/override_js4.errors.txt.diff | 19 ---- .../plainJSGrammarErrors.errors.txt.diff | 42 +------- .../spellingUncheckedJS.errors.txt.diff | 59 ---------- ...ropertyAssignmentInherited.errors.txt.diff | 32 ------ ...PropertyOverridesAccessors.errors.txt.diff | 23 ---- ...peFromPropertyAssignment23.errors.txt.diff | 11 +- ...peFromPropertyAssignment25.errors.txt.diff | 5 +- ...peFromPropertyAssignment26.errors.txt.diff | 12 +-- ...opertyAssignmentOutOfOrder.errors.txt.diff | 8 +- 119 files changed, 346 insertions(+), 2752 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/checkJsFiles_noErrorLocation.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/classExtendingAny.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/genericDefaultsJs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/importDeclFromTypeNodeInJsSource.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsEmitIntersectionProperty.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/superNoModifiersCrash.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/extendsTag2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/extendsTag3.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/extendsTag6.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments3.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments4.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments5.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsExportedClassAliases.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/override_js1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/spellingUncheckedJS.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/thisPropertyOverridesAccessors.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles_noErrorLocation.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/classExtendingAny.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/importDeclFromTypeNodeInJsSource.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/javascriptThisAssignmentInStaticBlock.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsEmitIntersectionProperty.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/superNoModifiersCrash.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/extendsTag6.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments5.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportedClassAliases.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_errorInExtendsExpression.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_nameMismatch.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/spellingUncheckedJS.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyOverridesAccessors.errors.txt.diff diff --git a/internal/parser/js_diagnostics.go b/internal/parser/js_diagnostics.go index abf0b1d7f1..d2f749dfff 100644 --- a/internal/parser/js_diagnostics.go +++ b/internal/parser/js_diagnostics.go @@ -76,18 +76,26 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnosticsWorker(node *ast.Node) bo } case ast.KindNullKeyword, ast.KindUndefinedKeyword: // Only flag null/undefined when used in type context, not as literal values - if ast.IsPartOfTypeNode(node) { + // Check if this is actually used as a type annotation by examining the parent context + if v.isUsedAsTypeAnnotation(node) { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) return false } case ast.KindExpressionWithTypeArguments: - // Only flag when it's actually part of a type expression (implements clause), not extends clause + // In heritage clauses, flag as type annotation error if it has type arguments + if parent.Kind == ast.KindHeritageClause && + node.AsExpressionWithTypeArguments() != nil && + node.AsExpressionWithTypeArguments().TypeArguments != nil { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + return false + } + // Use the standard type node check for other cases (e.g., implements clauses) if ast.IsPartOfTypeNode(node) { v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) return false } } - + // Check for type nodes in the type node range if node.Kind >= ast.KindFirstTypeNode && node.Kind <= ast.KindLastTypeNode { // Skip ExpressionWithTypeArguments as it's handled above @@ -199,7 +207,6 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnosticsWorker(node *ast.Node) bo return false } - // isSignatureDeclaration checks if a node is a signature declaration (function without body) func (v *jsDiagnosticsVisitor) isSignatureDeclaration(node *ast.Node) bool { switch node.Kind { @@ -237,7 +244,7 @@ func (v *jsDiagnosticsVisitor) getTypeParameters(node *ast.Node) *ast.NodeList { } var typeParameters *ast.NodeList - + // Try class-like nodes first if classLike := node.ClassLikeData(); classLike != nil { typeParameters = classLike.TypeParameters @@ -272,11 +279,11 @@ func (v *jsDiagnosticsVisitor) getTypeArguments(node *ast.Node) *ast.NodeList { } var typeArguments *ast.NodeList - + // Handle specific node types that can have type arguments switch node.Kind { case ast.KindCallExpression, ast.KindNewExpression, ast.KindTaggedTemplateExpression, - ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement: + ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement: if ast.IsCallLikeExpression(node) { typeArguments = node.TypeArgumentList() } @@ -386,6 +393,60 @@ func (v *jsDiagnosticsVisitor) checkModifier(modifier *ast.Node, isConstValid bo } } +// isUsedAsTypeAnnotation checks if a node is used as a type annotation rather than a literal value +func (v *jsDiagnosticsVisitor) isUsedAsTypeAnnotation(node *ast.Node) bool { + parent := node.Parent + if parent == nil { + return false + } + + // Check parent context to determine if this is a type annotation + switch parent.Kind { + case ast.KindUnionType, ast.KindIntersectionType, ast.KindConditionalType, + ast.KindMappedType, ast.KindIndexedAccessType, ast.KindTypeReference, + ast.KindTypePredicate, ast.KindTypeOperator, ast.KindInferType: + return true + case ast.KindParameter: + // Check if this is the type annotation of a parameter + if param := parent.AsParameterDeclaration(); param != nil && param.Type == node { + return true + } + case ast.KindVariableDeclaration: + // Check if this is the type annotation of a variable + if varDecl := parent.AsVariableDeclaration(); varDecl != nil && varDecl.Type == node { + return true + } + case ast.KindPropertyDeclaration: + // Check if this is the type annotation of a property + if propDecl := parent.AsPropertyDeclaration(); propDecl != nil && propDecl.Type == node { + return true + } + case ast.KindMethodDeclaration, ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindFunctionExpression: + // Check if this is the return type annotation + if fnLike := parent.FunctionLikeData(); fnLike != nil && fnLike.Type == node { + return true + } + case ast.KindTypeAssertionExpression: + // Check if this is the type in a type assertion + if typeAssertion := parent.AsTypeAssertion(); typeAssertion != nil && typeAssertion.Type == node { + return true + } + case ast.KindAsExpression: + // Check if this is the type in an 'as' expression + if asExpression := parent.AsAsExpression(); asExpression != nil && asExpression.Type == node { + return true + } + case ast.KindSatisfiesExpression: + // Check if this is the type in a 'satisfies' expression + if satisfiesExpression := parent.AsSatisfiesExpression(); satisfiesExpression != nil && satisfiesExpression.Type == node { + return true + } + } + + // If none of the above type annotation contexts match, this is likely a literal value + return false +} + // createDiagnosticForNode creates a diagnostic for a specific node func (v *jsDiagnosticsVisitor) createDiagnosticForNode(node *ast.Node, message *diagnostics.Message, args ...any) *ast.Diagnostic { return ast.NewDiagnostic(v.sourceFile, scanner.GetErrorRangeForNode(v.sourceFile, node), message, args...) diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt index 4b913fca00..974618352e 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt @@ -1,6 +1,5 @@ error TS5055: Cannot write file 'b.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. -b.js(3,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(9,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(15,25): error TS8010: Type annotations can only be used in TypeScript files. @@ -10,12 +9,10 @@ b.js(15,25): error TS8010: Type annotations can only be used in TypeScript files ==== a.ts (0 errors) ==== export class A {} -==== b.js (3 errors) ==== +==== b.js (2 errors) ==== import { A } from './a.js'; export class B1 extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt index 2ece3e3d06..870a939ca0 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt @@ -1,6 +1,5 @@ error TS5055: Cannot write file 'b.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. -b.js(3,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(3,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. b.js(9,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(15,25): error TS8010: Type annotations can only be used in TypeScript files. @@ -12,13 +11,11 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' ==== a.ts (0 errors) ==== export class A {} -==== b.js (5 errors) ==== +==== b.js (4 errors) ==== import { A } from './a.js'; export class B1 extends A { ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. constructor() { super(); diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt index d4aa32fcce..bf5a012e3d 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt @@ -1,6 +1,5 @@ error TS5055: Cannot write file 'b.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. -b.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(11,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(18,25): error TS8010: Type annotations can only be used in TypeScript files. @@ -10,13 +9,11 @@ b.js(18,25): error TS8010: Type annotations can only be used in TypeScript files ==== a.ts (0 errors) ==== export class A {} -==== b.js (3 errors) ==== +==== b.js (2 errors) ==== import { A } from './a.js'; /** @extends {A} */ export class B1 extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt index c2be17af46..8be4e00c16 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=true).errors.txt @@ -1,6 +1,5 @@ error TS5055: Cannot write file 'b.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. -b.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(4,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. b.js(11,25): error TS8010: Type annotations can only be used in TypeScript files. b.js(18,25): error TS8010: Type annotations can only be used in TypeScript files. @@ -12,14 +11,12 @@ b.js(18,25): error TS8026: Expected A type arguments; provide these with an ' ==== a.ts (0 errors) ==== export class A {} -==== b.js (5 errors) ==== +==== b.js (4 errors) ==== import { A } from './a.js'; /** @extends {A} */ export class B1 extends A { ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. constructor() { super(); diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt deleted file mode 100644 index bd0cdb5d70..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInConstructor3_Js.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -/a.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class A { - get arguments() { - return { bar: {} }; - } - } - - class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - /** - * Constructor - * - * @param {object} [foo={}] - */ - constructor(foo = {}) { - super(); - - /** - * @type object - */ - this.foo = foo; - - /** - * @type object - */ - this.bar = super.arguments.foo; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt b/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt deleted file mode 100644 index 58ce3dc3f0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/argumentsReferenceInMethod3_Js.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -/a.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /a.js (1 errors) ==== - class A { - get arguments() { - return { bar: {} }; - } - } - - class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - /** - * @param {object} [foo={}] - */ - m(foo = {}) { - /** - * @type object - */ - this.x = foo; - - /** - * @type object - */ - this.y = super.arguments.bar; - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt b/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt index 541c1d9eff..91e5fd5a6c 100644 --- a/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt @@ -1,12 +1,11 @@ error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. weird.js(1,1): error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? weird.js(1,23): error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. -weird.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. !!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== weird.js (4 errors) ==== +==== weird.js (3 errors) ==== someFunction(function(BaseClass) { ~~~~~~~~~~~~ !!! error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? @@ -16,8 +15,6 @@ weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); this.foo = "bar"; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsFiles_noErrorLocation.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsFiles_noErrorLocation.errors.txt deleted file mode 100644 index dfeeed3d23..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsFiles_noErrorLocation.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -a.js(11,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (1 errors) ==== - // @ts-check - class A { - constructor() { - - } - foo() { - return 4; - } - } - - class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - this.foo = () => 3; - } - } - - const i = new B(); - i.foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classExtendingAny.errors.txt b/testdata/baselines/reference/submodule/compiler/classExtendingAny.errors.txt deleted file mode 100644 index a2f4e5c8b6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/classExtendingAny.errors.txt +++ /dev/null @@ -1,38 +0,0 @@ -b.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.ts (0 errors) ==== - declare var Err: any - class A extends Err { - payload: string - constructor() { - super(1,2,3,3,4,56) - super.unknown - super['unknown'] - } - process() { - return this.payload + "!"; - } - } - - var o = { - m() { - super.unknown - } - } -==== b.js (1 errors) ==== - class B extends Err { - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super() - this.wat = 12 - } - f() { - this.wat - this.wit - this['wot'] - super.alsoBad - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt b/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt deleted file mode 100644 index 75a3ee4c4a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs1.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -index.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - class C { - static blah1 = 123; - } - C.blah2 = 456; - - class D extends C { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - static { - console.log(super.blah1); - console.log(super.blah2); - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs2.errors.txt b/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs2.errors.txt deleted file mode 100644 index c992438eda..0000000000 --- a/testdata/baselines/reference/submodule/compiler/classFieldSuperAccessibleJs2.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -index.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - class C { - constructor() { - this.foo = () => { - console.log("called arrow"); - }; - } - foo() { - console.log("called method"); - } - } - - class D extends C { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - foo() { - console.log("SUPER:"); - super.foo(); - console.log("THIS:"); - this.foo(); - } - } - - const obj = new D(); - obj.foo(); - D.prototype.foo.call(obj); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt b/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt index 4685d09321..912485f742 100644 --- a/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/classFieldSuperNotAccessibleJs.errors.txt @@ -1,12 +1,11 @@ index.js(7,14): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'. index.js(9,9): error TS7053: Element implicitly has an 'any' type because expression of type '"literalElementAccess"' can't be used to index type 'YaddaBase'. Property 'literalElementAccess' does not exist on type 'YaddaBase'. -index.js(18,28): error TS8010: Type annotations can only be used in TypeScript files. index.js(26,22): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'. index.js(29,22): error TS2339: Property 'literalElementAccess' does not exist on type 'YaddaBase'. -==== index.js (5 errors) ==== +==== index.js (4 errors) ==== // https://github.com/microsoft/TypeScript/issues/55884 class YaddaBase { @@ -30,8 +29,6 @@ index.js(29,22): error TS2339: Property 'literalElementAccess' does not exist on } class DerivedYadda extends YaddaBase { - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. get rootTests() { return super.roots; } diff --git a/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt b/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt deleted file mode 100644 index 962247cfd7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -component.js(2,28): error TS8010: Type annotations can only be used in TypeScript files. - - -==== library.d.ts (0 errors) ==== - export class Foo { - props: T; - state: U; - constructor(props: T, state: U); - } - -==== component.js (1 errors) ==== - import { Foo } from "./library"; - export class MyFoo extends Foo { - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - member; - } - -==== typed_component.ts (0 errors) ==== - import { MyFoo } from "./component"; - export class TypedFoo extends MyFoo { - constructor() { - super({x: "string", y: 42}, { value: undefined }); - this.props.x; - this.props.y; - this.state.value; - this.member; - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt index 13d4cb7de4..decd2d3d86 100644 --- a/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@ -4,18 +4,15 @@ BaseB.js(3,14): error TS2304: Cannot find name 'Class'. BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. BaseB.js(4,25): error TS2304: Cannot find name 'Class'. BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. -SubA.js(2,35): error TS8010: Type annotations can only be used in TypeScript files. SubB.js(3,35): error TS8010: Type annotations can only be used in TypeScript files. ==== BaseA.js (0 errors) ==== export default class BaseA { } -==== SubA.js (1 errors) ==== +==== SubA.js (0 errors) ==== import BaseA from './BaseA'; export default class SubA extends BaseA { - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. } ==== BaseB.js (6 errors) ==== import BaseA from './BaseA'; diff --git a/testdata/baselines/reference/submodule/compiler/genericDefaultsJs.errors.txt b/testdata/baselines/reference/submodule/compiler/genericDefaultsJs.errors.txt deleted file mode 100644 index 1703b50e33..0000000000 --- a/testdata/baselines/reference/submodule/compiler/genericDefaultsJs.errors.txt +++ /dev/null @@ -1,98 +0,0 @@ -main.js(19,21): error TS8010: Type annotations can only be used in TypeScript files. -main.js(20,21): error TS8010: Type annotations can only be used in TypeScript files. -main.js(25,21): error TS8010: Type annotations can only be used in TypeScript files. -main.js(43,21): error TS8010: Type annotations can only be used in TypeScript files. -main.js(44,21): error TS8010: Type annotations can only be used in TypeScript files. -main.js(49,21): error TS8010: Type annotations can only be used in TypeScript files. - - -==== decls.d.ts (0 errors) ==== - declare function f0(x?: T): T; - declare function f1(x?: T): [T, U]; - declare class C0 { - y: T; - constructor(x?: T); - } - declare class C1 { - y: [T, U]; - constructor(x?: T); - } -==== main.js (6 errors) ==== - const f0_v0 = f0(); - const f0_v1 = f0(1); - - const f1_c0 = f1(); - const f1_c1 = f1(1); - - const C0_v0 = new C0(); - const C0_v0_y = C0_v0.y; - - const C0_v1 = new C0(1); - const C0_v1_y = C0_v1.y; - - const C1_v0 = new C1(); - const C1_v0_y = C1_v0.y; - - const C1_v1 = new C1(1); - const C1_v1_y = C1_v1.y; - - class C0_B0 extends C0 {} - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - class C0_B1 extends C0 { - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - } - } - class C0_B2 extends C0 { - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(1); - } - } - - const C0_B0_v0 = new C0_B0(); - const C0_B0_v0_y = C0_B0_v0.y; - - const C0_B0_v1 = new C0_B0(1); - const C0_B0_v1_y = C0_B0_v1.y; - - const C0_B1_v0 = new C0_B1(); - const C0_B1_v0_y = C0_B1_v0.y; - - const C0_B2_v0 = new C0_B2(); - const C0_B2_v0_y = C0_B2_v0.y; - - class C1_B0 extends C1 {} - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - class C1_B1 extends C1 { - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - } - } - class C1_B2 extends C1 { - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(1); - } - } - - const C1_B0_v0 = new C1_B0(); - const C1_B0_v0_y = C1_B0_v0.y; - - const C1_B0_v1 = new C1_B0(1); - const C1_B0_v1_y = C1_B0_v1.y; - - const C1_B1_v0 = new C1_B1(); - const C1_B1_v0_y = C1_B1_v0.y; - - const C1_B2_v0 = new C1_B2(); - const C1_B2_v0_y = C1_B2_v0.y; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importDeclFromTypeNodeInJsSource.errors.txt b/testdata/baselines/reference/submodule/compiler/importDeclFromTypeNodeInJsSource.errors.txt deleted file mode 100644 index fd05054d60..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importDeclFromTypeNodeInJsSource.errors.txt +++ /dev/null @@ -1,60 +0,0 @@ -/src/b.js(5,26): error TS8010: Type annotations can only be used in TypeScript files. -/src/b.js(8,27): error TS8010: Type annotations can only be used in TypeScript files. -/src/b.js(11,27): error TS8010: Type annotations can only be used in TypeScript files. -/src/b.js(14,27): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /src/node_modules/@types/node/index.d.ts (0 errors) ==== - /// -==== /src/node_modules/@types/node/events.d.ts (0 errors) ==== - declare module "events" { - namespace EventEmitter { - class EventEmitter { - constructor(); - } - } - export = EventEmitter; - } - declare module "nestNamespaceModule" { - namespace a1.a2 { - class d { } - } - - namespace a1.a2.n3 { - class c { } - } - export = a1.a2; - } - declare module "renameModule" { - namespace a.b { - class c { } - } - import d = a.b; - export = d; - } - -==== /src/b.js (4 errors) ==== - import { EventEmitter } from 'events'; - import { n3, d } from 'nestNamespaceModule'; - import { c } from 'renameModule'; - - export class Foo extends EventEmitter { - ~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class Foo2 extends n3.c { - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class Foo3 extends d { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - } - - export class Foo4 extends c { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt deleted file mode 100644 index ec866483f6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt +++ /dev/null @@ -1,48 +0,0 @@ -/index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /node_modules/tslib/package.json (0 errors) ==== - { - "name": "tslib", - "main": "tslib.js", - "module": "tslib.es6.js", - "jsnext:main": "tslib.es6.js", - "typings": "tslib.d.ts", - "exports": { - ".": { - "module": { - "types": "./modules/index.d.ts", - "default": "./tslib.es6.mjs" - }, - "import": { - "node": "./modules/index.js", - "default": { - "types": "./modules/index.d.ts", - "default": "./tslib.es6.mjs" - } - }, - "default": "./tslib.js" - }, - "./*": "./*", - "./": "./" - } - } - -==== /node_modules/tslib/tslib.d.ts (0 errors) ==== - export declare var __extends: any; - -==== /node_modules/tslib/modules/package.json (0 errors) ==== - { "type": "module" } - -==== /node_modules/tslib/modules/index.d.ts (0 errors) ==== - export {}; - -==== /index.js (1 errors) ==== - class Foo {} - - class Bar extends Foo {} - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - - module.exports = Bar; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt b/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt deleted file mode 100644 index ec866483f6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt +++ /dev/null @@ -1,48 +0,0 @@ -/index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /node_modules/tslib/package.json (0 errors) ==== - { - "name": "tslib", - "main": "tslib.js", - "module": "tslib.es6.js", - "jsnext:main": "tslib.es6.js", - "typings": "tslib.d.ts", - "exports": { - ".": { - "module": { - "types": "./modules/index.d.ts", - "default": "./tslib.es6.mjs" - }, - "import": { - "node": "./modules/index.js", - "default": { - "types": "./modules/index.d.ts", - "default": "./tslib.es6.mjs" - } - }, - "default": "./tslib.js" - }, - "./*": "./*", - "./": "./" - } - } - -==== /node_modules/tslib/tslib.d.ts (0 errors) ==== - export declare var __extends: any; - -==== /node_modules/tslib/modules/package.json (0 errors) ==== - { "type": "module" } - -==== /node_modules/tslib/modules/index.d.ts (0 errors) ==== - export {}; - -==== /index.js (1 errors) ==== - class Foo {} - - class Bar extends Foo {} - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - - module.exports = Bar; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.errors.txt b/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.errors.txt deleted file mode 100644 index 1e63514ebf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/javascriptCommonjsModule.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - class Foo {} - - class Bar extends Foo {} - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - - module.exports = Bar; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.errors.txt b/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.errors.txt deleted file mode 100644 index c2a0afced1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/javascriptThisAssignmentInStaticBlock.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -/src/a.js(10,29): error TS8010: Type annotations can only be used in TypeScript files. - - -==== /src/a.js (1 errors) ==== - class Thing { - static { - this.doSomething = () => {}; - } - } - - Thing.doSomething(); - - // GH#46468 - class ElementsArray extends Array { - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - static { - const superisArray = super.isArray; - const customIsArray = (arg)=> superisArray(arg); - this.isArray = customIsArray; - } - } - - ElementsArray.isArray(new ElementsArray()); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt deleted file mode 100644 index b114779864..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationsInheritedTypes.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -a.js(18,18): error TS8010: Type annotations can only be used in TypeScript files. -a.js(25,18): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (2 errors) ==== - /** - * @typedef A - * @property {string} a - */ - - /** - * @typedef B - * @property {number} b - */ - - class C1 { - /** - * @type {A} - */ - value; - } - - class C2 extends C1 { - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - /** - * @type {A} - */ - value; - } - - class C3 extends C1 { - ~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - /** - * @type {A & B} - */ - value; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEmitIntersectionProperty.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEmitIntersectionProperty.errors.txt deleted file mode 100644 index 4302bd8f7b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsEmitIntersectionProperty.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -index.js(1,34): error TS8010: Type annotations can only be used in TypeScript files. - - -==== globals.d.ts (0 errors) ==== - declare class CoreObject { - static extend< - Statics, - Instance extends B1, - T1, - B1 - >( - this: Statics & { new(): Instance }, - arg1: T1 - ): Readonly & { new(): T1 & Instance }; - - toString(): string; - } - - declare class Mixin { - static create( - args?: T - ): Mixin; - } - declare const Observable: Mixin<{}> - declare class EmberObject extends CoreObject.extend(Observable) {} - declare class CoreView extends EmberObject.extend({}) {} - declare class Component extends CoreView.extend({}) {} - -==== index.js (1 errors) ==== - export class MyComponent extends Component { - ~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt index 56d37e29dd..92901a40cc 100644 --- a/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsExtendsImplicitAny.errors.txt @@ -1,6 +1,4 @@ -/b.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. /b.js(1,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -/b.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. /b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. /b.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. /b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -9,19 +7,15 @@ ==== /a.d.ts (0 errors) ==== declare class A { x: T; } -==== /b.js (6 errors) ==== +==== /b.js (4 errors) ==== class B extends A {} ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new B().x; /** @augments A */ class C extends A { } ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new C().x; diff --git a/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt b/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt index 37a78b9342..6155497229 100644 --- a/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt @@ -1,4 +1,3 @@ -index.js(3,21): error TS8010: Type annotations can only be used in TypeScript files. index.js(3,21): error TS8026: Expected Foo type arguments; provide these with an '@extends' tag. @@ -6,13 +5,11 @@ index.js(3,21): error TS8026: Expected Foo type arguments; provide these with export declare class Foo { prop: T; } -==== index.js (2 errors) ==== +==== index.js (1 errors) ==== import {Foo} from "./somelib"; class MyFoo extends Foo { ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~ !!! error TS8026: Expected Foo type arguments; provide these with an '@extends' tag. constructor() { super(); diff --git a/testdata/baselines/reference/submodule/compiler/superNoModifiersCrash.errors.txt b/testdata/baselines/reference/submodule/compiler/superNoModifiersCrash.errors.txt deleted file mode 100644 index 661a662c48..0000000000 --- a/testdata/baselines/reference/submodule/compiler/superNoModifiersCrash.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -File.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. - - -==== File.js (1 errors) ==== - class Parent { - initialize() { - super.initialize(...arguments) - return this.asdf = '' - } - } - - class Child extends Parent { - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - initialize() { - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt index 3e716a524c..4929a92af4 100644 --- a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt @@ -1,11 +1,9 @@ first.js(10,19): error TS8009: The '?' modifier can only be used in TypeScript files. first.js(16,47): error TS8009: The '?' modifier can only be used in TypeScript files. first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. -first.js(21,19): error TS8010: Type annotations can only be used in TypeScript files. 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(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. -first.js(47,24): error TS8010: Type annotations can only be used in TypeScript files. generic.js(9,23): error TS2507: Type '(flavour: T) => void' is not a constructor function type. generic.js(9,23): error TS8010: Type annotations can only be used in TypeScript files. generic.js(11,21): error TS2339: Property 'flavour' does not exist on type 'Chowder'. @@ -17,7 +15,7 @@ second.ts(14,25): error TS2507: Type '{ (numberOxen: number): void; circle: (wag second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. -==== first.js (8 errors) ==== +==== first.js (6 errors) ==== /** * @constructor * @param {number} numberOxen @@ -45,8 +43,6 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con class Sql extends Wagon { ~~~~~ !!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); // error: not enough arguments this.foonly = 12 @@ -79,8 +75,6 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con class Drakkhen extends Dragon { ~~~~~~ !!! error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. } diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag2.errors.txt deleted file mode 100644 index d2c1642db5..0000000000 --- a/testdata/baselines/reference/submodule/conformance/extendsTag2.errors.txt +++ /dev/null @@ -1,26 +0,0 @@ -foo.js(15,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.js (1 errors) ==== - /** - * @constructor - */ - class A { - constructor() {} - } - - /** - * @extends {A} - */ - - /** - * @constructor - */ - class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag3.errors.txt deleted file mode 100644 index 6bd90e23b8..0000000000 --- a/testdata/baselines/reference/submodule/conformance/extendsTag3.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -foo.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. -foo.js(22,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.js (2 errors) ==== - /** - * @constructor - */ - class A { - constructor() {} - } - - /** - * @extends {A} - * @constructor - */ - class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - } - } - - /** - * @extends { A } - * @constructor - */ - class C extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTag6.errors.txt deleted file mode 100644 index c1a774832b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/extendsTag6.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -foo.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.js (1 errors) ==== - /** - * @constructor - */ - class A { - constructor() {} - } - - /** - * @extends { A } - * @constructor - */ - class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt b/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt index 1b8f34d893..7f2002cbad 100644 --- a/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/extendsTagEmit.errors.txt @@ -1,17 +1,14 @@ main.js(2,15): error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. -main.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. ==== super.js (0 errors) ==== export class B { } -==== main.js (2 errors) ==== +==== main.js (1 errors) ==== import { B } from './super' /** @extends {Mismatch} */ ~~~~~~~~ !!! error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. class C extends B { } - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments3.errors.txt b/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments3.errors.txt deleted file mode 100644 index 718a3a7526..0000000000 --- a/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments3.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (1 errors) ==== - class Base { - constructor() { - this.p = 1 - } - } - class Derived extends Base { - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - m() { - this.p = 1 - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments4.errors.txt b/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments4.errors.txt deleted file mode 100644 index 965544c6ce..0000000000 --- a/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments4.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (1 errors) ==== - class Base { - m() { - this.p = 1 - } - } - class Derived extends Base { - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - m() { - // should be OK, and p should have type number | undefined from its base - this.p = 1 - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments5.errors.txt b/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments5.errors.txt deleted file mode 100644 index d4fe89fced..0000000000 --- a/testdata/baselines/reference/submodule/conformance/inferringClassMembersFromAssignments5.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (1 errors) ==== - class Base { - m() { - this.p = 1 - } - } - class Derived extends Base { - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - // should be OK, and p should have type number from this assignment - this.p = 1 - } - test() { - return this.p - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt deleted file mode 100644 index 3d0fba95ff..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassAccessor.errors.txt +++ /dev/null @@ -1,41 +0,0 @@ -argument.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. - - -==== supplement.d.ts (0 errors) ==== - export { }; - declare module "./argument.js" { - interface Argument { - idlType: any; - default: null; - } - } -==== base.js (0 errors) ==== - export class Base { - constructor() { } - - toJSON() { - const json = { type: undefined, name: undefined, inheritance: undefined }; - return json; - } - } -==== argument.js (1 errors) ==== - import { Base } from "./base.js"; - export class Argument extends Base { - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - /** - * @param {*} tokeniser - */ - static parse(tokeniser) { - return; - } - - get type() { - return "argument"; - } - - /** - * @param {*} defs - */ - *validate(defs) { } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.errors.txt index 6c46284e83..cbb4b6d57d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.errors.txt @@ -1,17 +1,14 @@ -cls.js(6,19): error TS8010: Type annotations can only be used in TypeScript files. cls.js(7,1): error TS2309: An export assignment cannot be used in a module with other exported elements. cls.js(8,16): error TS2339: Property 'Strings' does not exist on type 'typeof Foo'. -==== cls.js (3 errors) ==== +==== cls.js (2 errors) ==== const Bar = require("./bar"); const Strings = { a: "A", b: "B" }; class Foo extends Bar {} - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. module.exports = Foo; ~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic2.errors.txt deleted file mode 100644 index a63f19414e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic2.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -Foo.js(4,26): error TS8010: Type annotations can only be used in TypeScript files. - - -==== Foo.js (1 errors) ==== - class Base { - static foo = ""; - } - export class Foo extends Base {} - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - Foo.foo = "foo"; - -==== Bar.ts (0 errors) ==== - import { Foo } from "./Foo.js"; - - class Bar extends Foo {} - Bar.foo = "foo"; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt index 4856a5e716..2f4d5597f9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt @@ -1,12 +1,7 @@ -index.js(147,24): error TS8010: Type annotations can only be used in TypeScript files. -index.js(149,24): error TS8010: Type annotations can only be used in TypeScript files. -index.js(159,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(173,24): error TS8010: Type annotations can only be used in TypeScript files. -index.js(185,35): error TS8010: Type annotations can only be used in TypeScript files. -index.js(191,37): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (6 errors) ==== +==== index.js (1 errors) ==== export class A {} export class B { @@ -154,12 +149,8 @@ index.js(191,37): error TS8010: Type annotations can only be used in TypeScript } export class L extends K {} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export class M extends null { - ~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { this.prop = 12; } @@ -170,8 +161,6 @@ index.js(191,37): error TS8010: Type annotations can only be used in TypeScript * @template T */ export class N extends L { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** * @param {T} param */ @@ -200,16 +189,12 @@ index.js(191,37): error TS8010: Type annotations can only be used in TypeScript var x = /** @type {*} */(null); export class VariableBase extends x {} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export class HasStatics { static staticMethod() {} } export class ExtendsStatics extends HasStatics { - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. static also() {} } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt index 5269dd50c0..8316b17bbe 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt @@ -5,28 +5,20 @@ index.js(8,27): error TS8010: Type annotations can only be used in TypeScript fi index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,20): error TS8010: Type annotations can only be used in TypeScript files. -index.js(16,24): error TS8010: Type annotations can only be used in TypeScript files. -index.js(18,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(19,20): error TS8010: Type annotations can only be used in TypeScript files. -index.js(22,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(23,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(23,20): error TS8010: Type annotations can only be used in TypeScript files. -index.js(26,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(27,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(28,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(28,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(32,20): error TS8010: Type annotations can only be used in TypeScript files. -index.js(35,24): error TS8010: Type annotations can only be used in TypeScript files. -index.js(38,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(39,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(39,20): error TS8010: Type annotations can only be used in TypeScript files. -index.js(42,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(43,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(43,20): error TS8010: Type annotations can only be used in TypeScript files. -index.js(46,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(47,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(47,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(48,11): error TS8010: Type annotations can only be used in TypeScript files. @@ -35,21 +27,17 @@ index.js(52,11): error TS8010: Type annotations can only be used in TypeScript f index.js(52,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(53,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(53,20): error TS8010: Type annotations can only be used in TypeScript files. -index.js(56,24): error TS8010: Type annotations can only be used in TypeScript files. -index.js(58,25): error TS8010: Type annotations can only be used in TypeScript files. index.js(59,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(59,20): error TS8010: Type annotations can only be used in TypeScript files. -index.js(62,25): error TS8010: Type annotations can only be used in TypeScript files. index.js(63,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(63,20): error TS8010: Type annotations can only be used in TypeScript files. -index.js(66,25): error TS8010: Type annotations can only be used in TypeScript files. index.js(67,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(67,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(68,11): error TS8010: Type annotations can only be used in TypeScript files. index.js(68,20): error TS8010: Type annotations can only be used in TypeScript files. -==== index.js (49 errors) ==== +==== index.js (37 errors) ==== // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), // but we should be able to synthesize declarations from the symbols regardless @@ -80,12 +68,8 @@ index.js(68,20): error TS8010: Type annotations can only be used in TypeScript f } export class P extends O {} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export class Q extends O { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: "ok"; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -94,8 +78,6 @@ index.js(68,20): error TS8010: Type annotations can only be used in TypeScript f } export class R extends O { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: "ok"; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -104,8 +86,6 @@ index.js(68,20): error TS8010: Type annotations can only be used in TypeScript f } export class S extends O { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: "ok"; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -127,13 +107,9 @@ index.js(68,20): error TS8010: Type annotations can only be used in TypeScript f } export class U extends T {} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export class V extends T { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: string; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -142,8 +118,6 @@ index.js(68,20): error TS8010: Type annotations can only be used in TypeScript f } export class W extends T { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: "ok"; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -152,8 +126,6 @@ index.js(68,20): error TS8010: Type annotations can only be used in TypeScript f } export class X extends T { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: string; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -180,12 +152,8 @@ index.js(68,20): error TS8010: Type annotations can only be used in TypeScript f } export class Z extends Y {} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. export class AA extends Y { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: {x: number, y: number}; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -194,8 +162,6 @@ index.js(68,20): error TS8010: Type annotations can only be used in TypeScript f } export class BB extends Y { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: {x: 0, y: 0}; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -204,8 +170,6 @@ index.js(68,20): error TS8010: Type annotations can only be used in TypeScript f } export class CC extends Y { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: {x: number, y: number}; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt deleted file mode 100644 index a8e153abd9..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.errors.txt +++ /dev/null @@ -1,43 +0,0 @@ -index4.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index1.js (0 errors) ==== - export default 12; - -==== index2.js (0 errors) ==== - export default function foo() { - return foo; - } - export const x = foo; - export { foo as bar }; - -==== index3.js (0 errors) ==== - export default class Foo { - a = /** @type {Foo} */(null); - }; - export const X = Foo; - export { Foo as Bar }; - -==== index4.js (1 errors) ==== - import Fab from "./index3"; - class Bar extends Fab { - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - x = /** @type {Bar} */(null); - } - export default Bar; - -==== index5.js (0 errors) ==== - // merge type alias and const (OK) - export default 12; - /** - * @typedef {string | number} default - */ - -==== index6.js (0 errors) ==== - // merge type alias and function (OK) - export default function func() {}; - /** - * @typedef {string | number} default - */ - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js index bafa2fc294..fabe4f7586 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js @@ -113,3 +113,79 @@ export type default = string | number; // merge type alias and function (OK) export default function func(): void; export type default = string | number; + + +//// [DtsFileErrors] + + +out/index5.d.ts(3,1): error TS1128: Declaration or statement expected. +out/index5.d.ts(3,8): error TS2304: Cannot find name 'type'. +out/index5.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. +out/index5.d.ts(3,21): error TS1128: Declaration or statement expected. +out/index5.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. +out/index5.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. +out/index6.d.ts(3,1): error TS1128: Declaration or statement expected. +out/index6.d.ts(3,8): error TS2304: Cannot find name 'type'. +out/index6.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. +out/index6.d.ts(3,21): error TS1128: Declaration or statement expected. +out/index6.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. +out/index6.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. + + +==== out/index1.d.ts (0 errors) ==== + declare const _default: number; + export default _default; + +==== out/index2.d.ts (0 errors) ==== + export default function foo(): typeof foo; + export declare const x: typeof foo; + export { foo as bar }; + +==== out/index3.d.ts (0 errors) ==== + export default class Foo { + a: Foo; + } + export declare const X: typeof Foo; + export { Foo as Bar }; + +==== out/index4.d.ts (0 errors) ==== + import Fab from "./index3"; + declare class Bar extends Fab { + x: Bar; + } + export default Bar; + +==== out/index5.d.ts (6 errors) ==== + declare const _default: number; + export default _default; + export type default = string | number; + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2304: Cannot find name 'type'. + ~~~~~~~ +!!! error TS2457: Type alias name cannot be 'default'. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + +==== out/index6.d.ts (6 errors) ==== + // merge type alias and function (OK) + export default function func(): void; + export type default = string | number; + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~~ +!!! error TS2304: Cannot find name 'type'. + ~~~~~~~ +!!! error TS2457: Type alias name cannot be 'default'. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff index c9e29891cb..913922e847 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.js.diff @@ -81,4 +81,80 @@ -export default func; +// merge type alias and function (OK) +export default function func(): void; -+export type default = string | number; \ No newline at end of file ++export type default = string | number; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/index5.d.ts(3,1): error TS1128: Declaration or statement expected. ++out/index5.d.ts(3,8): error TS2304: Cannot find name 'type'. ++out/index5.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. ++out/index5.d.ts(3,21): error TS1128: Declaration or statement expected. ++out/index5.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. ++out/index5.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. ++out/index6.d.ts(3,1): error TS1128: Declaration or statement expected. ++out/index6.d.ts(3,8): error TS2304: Cannot find name 'type'. ++out/index6.d.ts(3,13): error TS2457: Type alias name cannot be 'default'. ++out/index6.d.ts(3,21): error TS1128: Declaration or statement expected. ++out/index6.d.ts(3,23): error TS2693: 'string' only refers to a type, but is being used as a value here. ++out/index6.d.ts(3,32): error TS2693: 'number' only refers to a type, but is being used as a value here. ++ ++ ++==== out/index1.d.ts (0 errors) ==== ++ declare const _default: number; ++ export default _default; ++ ++==== out/index2.d.ts (0 errors) ==== ++ export default function foo(): typeof foo; ++ export declare const x: typeof foo; ++ export { foo as bar }; ++ ++==== out/index3.d.ts (0 errors) ==== ++ export default class Foo { ++ a: Foo; ++ } ++ export declare const X: typeof Foo; ++ export { Foo as Bar }; ++ ++==== out/index4.d.ts (0 errors) ==== ++ import Fab from "./index3"; ++ declare class Bar extends Fab { ++ x: Bar; ++ } ++ export default Bar; ++ ++==== out/index5.d.ts (6 errors) ==== ++ declare const _default: number; ++ export default _default; ++ export type default = string | number; ++ ~~~~~~ ++!!! error TS1128: Declaration or statement expected. ++ ~~~~ ++!!! error TS2304: Cannot find name 'type'. ++ ~~~~~~~ ++!!! error TS2457: Type alias name cannot be 'default'. ++ ~ ++!!! error TS1128: Declaration or statement expected. ++ ~~~~~~ ++!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ++ ~~~~~~ ++!!! error TS2693: 'number' only refers to a type, but is being used as a value here. ++ ++==== out/index6.d.ts (6 errors) ==== ++ // merge type alias and function (OK) ++ export default function func(): void; ++ export type default = string | number; ++ ~~~~~~ ++!!! error TS1128: Declaration or statement expected. ++ ~~~~ ++!!! error TS2304: Cannot find name 'type'. ++ ~~~~~~~ ++!!! error TS2457: Type alias name cannot be 'default'. ++ ~ ++!!! error TS1128: Declaration or statement expected. ++ ~~~~~~ ++!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ++ ~~~~~~ ++!!! error TS2693: 'number' only refers to a type, but is being used as a value here. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportedClassAliases.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportedClassAliases.errors.txt deleted file mode 100644 index b8da545e26..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportedClassAliases.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -utils/errors.js(1,26): error TS8010: Type annotations can only be used in TypeScript files. - - -==== utils/index.js (0 errors) ==== - // issue arises here on compilation - const errors = require("./errors"); - - module.exports = { - errors - }; -==== utils/errors.js (1 errors) ==== - class FancyError extends Error { - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor(status) { - super(`error with status ${status}`); - } - } - - module.exports = { - FancyError - }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt deleted file mode 100644 index 457e1a0fee..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -index.js(9,26): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - export class Super { - /** - * @param {string} firstArg - * @param {string} secondArg - */ - constructor(firstArg, secondArg) { } - } - - export class Sub extends Super { - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super('first', 'second'); - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt deleted file mode 100644 index 8e79921c1e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsThisTypes.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -index.js(7,35): error TS8010: Type annotations can only be used in TypeScript files. - - -==== index.js (1 errors) ==== - export class A { - /** @returns {this} */ - method() { - return this; - } - } - export default class Base extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - // This method is required to reproduce #35932 - verify() { } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt index 38ae19e627..6386334b80 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt @@ -1,6 +1,4 @@ -jsdocAccessibilityTag.js(48,17): error TS8010: Type annotations can only be used in TypeScript files. jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. -jsdocAccessibilityTag.js(53,17): error TS8010: Type annotations can only be used in TypeScript files. jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. jsdocAccessibilityTag.js(58,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. @@ -12,7 +10,7 @@ jsdocAccessibilityTag.js(61,9): error TS2341: Property 'priv2' is private and on jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. -==== jsdocAccessibilityTag.js (12 errors) ==== +==== jsdocAccessibilityTag.js (10 errors) ==== class A { /** * Ap docs @@ -61,8 +59,6 @@ jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and h() { return this.priv2 } } class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. m() { this.priv + this.prot + this.pub ~~~~ @@ -70,8 +66,6 @@ jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and } } class D extends C { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. n() { this.priv2 + this.prot2 + this.pub2 ~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugmentsMissingType.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugmentsMissingType.errors.txt index 710974ba24..f3a1da2292 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugmentsMissingType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugmentsMissingType.errors.txt @@ -1,15 +1,12 @@ /a.js(2,14): error TS8023: JSDoc '@augments ' does not match the 'extends A' clause. -/a.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== class A { constructor() { this.x = 0; } } /** @augments */ !!! error TS8023: JSDoc '@augments ' does not match the 'extends A' clause. class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. m() { this.x } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_errorInExtendsExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_errorInExtendsExpression.errors.txt index f011935b63..11a7311fc3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_errorInExtendsExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_errorInExtendsExpression.errors.txt @@ -1,13 +1,10 @@ /a.js(3,17): error TS2304: Cannot find name 'err'. -/a.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. -==== /a.js (2 errors) ==== +==== /a.js (1 errors) ==== class A {} /** @augments A */ class B extends err() {} ~~~ !!! error TS2304: Cannot find name 'err'. - ~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt index 306c0c428f..f6d9d88210 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocAugments_nameMismatch.errors.txt @@ -1,8 +1,7 @@ /b.js(4,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. -/b.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. -==== /b.js (2 errors) ==== +==== /b.js (1 errors) ==== class A {} class B {} @@ -10,6 +9,4 @@ ~ !!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. class C extends B {} - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt index 688449403c..d6655383b2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt @@ -1,10 +1,9 @@ -0.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. 0.js(27,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'A'. 0.js(32,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. 0.js(40,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. -==== 0.js (4 errors) ==== +==== 0.js (3 errors) ==== class A { /** @@ -21,8 +20,6 @@ } class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** * @override * @method diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt index f33a0f0a24..5ca40c9e5b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.errors.txt @@ -1,5 +1,4 @@ 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(20,27): error TS8010: Type annotations can only be used in TypeScript files. b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. @@ -14,7 +13,7 @@ b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. ==== a.ts (0 errors) ==== var W: string; -==== b.js (10 errors) ==== +==== b.js (9 errors) ==== // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); @@ -37,8 +36,6 @@ b.js(67,8): error TS2454: Variable 'numOrStr' is used before being assigned. } } class SomeDerived extends SomeBase { - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); this.x = 42; diff --git a/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt deleted file mode 100644 index fe82afac38..0000000000 --- a/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt +++ /dev/null @@ -1,26 +0,0 @@ -a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. - - -==== a.js (1 errors) ==== - class B { - foo (v) {} - fooo (v) {} - } - - class D extends B { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - foo (v) {} - /** @override */ - fooo (v) {} - /** @override */ - bar(v) {} - } - - class C { - foo () {} - /** @override */ - fooo (v) {} - /** @override */ - bar(v) {} - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt index 7940c85f84..2240d94df8 100644 --- a/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt @@ -1,19 +1,16 @@ -a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. a.js(7,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'B'. a.js(11,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'B'. a.js(17,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. a.js(19,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. -==== a.js (5 errors) ==== +==== a.js (4 errors) ==== class B { foo (v) {} fooo (v) {} } class D extends B { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. foo (v) {} ~~~ !!! error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'B'. diff --git a/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt index f2c222a730..6e1d0dae65 100644 --- a/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt @@ -1,16 +1,13 @@ -a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. a.js(7,5): error TS8009: The 'override' modifier can only be used in TypeScript files. -==== a.js (2 errors) ==== +==== a.js (1 errors) ==== class B { foo (v) {} fooo (v) {} } class D extends B { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. override foo (v) {} ~~~~~~~~ !!! error TS8009: The 'override' modifier can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt index defcb06096..0e3d59fcf6 100644 --- a/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt @@ -1,15 +1,12 @@ -a.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. a.js(7,5): error TS4123: This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class 'A'. Did you mean 'doSomething'? -==== a.js (2 errors) ==== +==== a.js (1 errors) ==== class A { doSomething() {} } class B extends A { - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. /** @override */ doSomethang() {} ~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt index 2015d1ee84..e5928e96f1 100644 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt @@ -21,13 +21,8 @@ plainJSGrammarErrors.js(37,9): error TS1049: A 'set' accessor must have exactly plainJSGrammarErrors.js(38,18): error TS1053: A 'set' accessor cannot have rest parameter. plainJSGrammarErrors.js(41,5): error TS18006: Classes may not have a field named 'constructor'. plainJSGrammarErrors.js(43,1): error TS1211: A class declaration without the 'default' modifier must have a name. -plainJSGrammarErrors.js(46,23): error TS8010: Type annotations can only be used in TypeScript files. plainJSGrammarErrors.js(46,25): error TS1172: 'extends' clause already seen. -plainJSGrammarErrors.js(46,33): error TS8010: Type annotations can only be used in TypeScript files. -plainJSGrammarErrors.js(47,23): error TS8010: Type annotations can only be used in TypeScript files. plainJSGrammarErrors.js(47,25): error TS1174: Classes can only extend a single class. -plainJSGrammarErrors.js(47,25): error TS8010: Type annotations can only be used in TypeScript files. -plainJSGrammarErrors.js(47,27): error TS8010: Type annotations can only be used in TypeScript files. plainJSGrammarErrors.js(49,1): error TS18016: Private identifiers are not allowed outside class bodies. plainJSGrammarErrors.js(50,6): error TS18016: Private identifiers are not allowed outside class bodies. plainJSGrammarErrors.js(51,9): error TS18013: Property '#m' is not accessible outside class 'C' because it has a private identifier. @@ -108,7 +103,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (108 errors) ==== +==== plainJSGrammarErrors.js (103 errors) ==== class C { // #private mistakes q = #unbound @@ -201,21 +196,11 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot missingName = true } class Doubler extends C extends C { } - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~~ !!! error TS1172: 'extends' clause already seen. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. class Trebler extends C,C,C { } - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS1174: Classes can only extend a single class. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. // #private mistakes #unrelated ~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/spellingUncheckedJS.errors.txt b/testdata/baselines/reference/submodule/conformance/spellingUncheckedJS.errors.txt deleted file mode 100644 index 1782e82dbe..0000000000 --- a/testdata/baselines/reference/submodule/conformance/spellingUncheckedJS.errors.txt +++ /dev/null @@ -1,55 +0,0 @@ -spellingUncheckedJS.js(19,23): error TS8010: Type annotations can only be used in TypeScript files. - - -==== spellingUncheckedJS.js (1 errors) ==== - export var inModule = 1 - inmodule.toFixed() - - function f() { - var locals = 2 + true - locale.toFixed() - // @ts-expect-error - localf.toExponential() - // @ts-expect-error - "this is fine" - } - class Classe { - non = 'oui' - methode() { - // no error on 'this' references - return this.none - } - } - class Derivee extends Classe { - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - methode() { - // no error on 'super' references - return super.none - } - } - - - var object = { - spaaace: 3 - } - object.spaaaace // error on read - object.spaace = 12 // error on write - object.fresh = 12 // OK - other.puuuce // OK, from another file - new Date().getGMTDate() // OK, from another file - - // No suggestions for globals from other files - const atoc = setIntegral(() => console.log('ok'), 500) - AudioBuffin // etc - Jimmy - Jon - -==== other.js (0 errors) ==== - var Jimmy = 1 - var John = 2 - Jon // error, it's from the same file - var other = { - puuce: 4 - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt b/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt deleted file mode 100644 index b7683bd571..0000000000 --- a/testdata/baselines/reference/submodule/conformance/thisPropertyAssignmentInherited.errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -thisPropertyAssignmentInherited.js(11,34): error TS8010: Type annotations can only be used in TypeScript files. -thisPropertyAssignmentInherited.js(12,34): error TS8010: Type annotations can only be used in TypeScript files. - - -==== thisPropertyAssignmentInherited.js (2 errors) ==== - export class Element { - /** - * @returns {String} - */ - get textContent() { - return '' - } - set textContent(x) {} - cloneNode() { return this} - } - export class HTMLElement extends Element {} - ~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - export class TextElement extends HTMLElement { - ~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - get innerHTML() { return this.textContent; } - set innerHTML(html) { this.textContent = html; } - toString() { - } - } - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisPropertyOverridesAccessors.errors.txt b/testdata/baselines/reference/submodule/conformance/thisPropertyOverridesAccessors.errors.txt deleted file mode 100644 index f49d30f121..0000000000 --- a/testdata/baselines/reference/submodule/conformance/thisPropertyOverridesAccessors.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -bar.js(1,19): error TS8010: Type annotations can only be used in TypeScript files. - - -==== foo.ts (0 errors) ==== - class Foo { - get p() { return 1 } - set p(value) { } - } - -==== bar.js (1 errors) ==== - class Bar extends Foo { - ~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super() - this.p = 2 - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment23.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment23.errors.txt index 39c914fb72..6db0b0a65a 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment23.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment23.errors.txt @@ -1,11 +1,8 @@ -a.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. -a.js(15,17): error TS8010: Type annotations can only be used in TypeScript files. a.js(23,18): error TS2339: Property 'identifier' does not exist on type 'Module'. a.js(24,18): error TS2339: Property 'size' does not exist on type 'Module'. -a.js(26,28): error TS8010: Type annotations can only be used in TypeScript files. -==== a.js (5 errors) ==== +==== a.js (2 errors) ==== class B { constructor () { this.n = 1 @@ -15,16 +12,12 @@ a.js(26,28): error TS8010: Type annotations can only be used in TypeScript files } class C extends B { } - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. // this override should be fine (even if it's a little odd) C.prototype.foo = function() { } class D extends B { } - ~ -!!! error TS8010: Type annotations can only be used in TypeScript files. D.prototype.foo = () => { this.n = 'not checked, so no error' } @@ -40,8 +33,6 @@ a.js(26,28): error TS8010: Type annotations can only be used in TypeScript files !!! error TS2339: Property 'size' does not exist on type 'Module'. class NormalModule extends Module { - ~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. identifier() { return 'normal' } diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment25.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment25.errors.txt index 3ff1b334bf..51003f82a9 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment25.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment25.errors.txt @@ -1,8 +1,7 @@ bug24703.js(7,8): error TS2506: 'O' is referenced directly or indirectly in its own base expression. -bug24703.js(7,26): error TS8010: Type annotations can only be used in TypeScript files. -==== bug24703.js (2 errors) ==== +==== bug24703.js (1 errors) ==== var Common = {}; Common.I = class { constructor() { @@ -12,8 +11,6 @@ bug24703.js(7,26): error TS8010: Type annotations can only be used in TypeScript Common.O = class extends Common.I { ~ !!! error TS2506: 'O' is referenced directly or indirectly in its own base expression. - ~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super() this.o = 2 diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment26.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment26.errors.txt index 6368f7ec18..db005b1254 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment26.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment26.errors.txt @@ -1,9 +1,8 @@ bug24730.js(1,5): error TS7022: 'UI' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. bug24730.js(7,1): error TS7022: 'context' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -bug24730.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. -==== bug24730.js (3 errors) ==== +==== bug24730.js (2 errors) ==== var UI = {} ~~ !!! error TS7022: 'UI' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. @@ -17,8 +16,6 @@ bug24730.js(9,17): error TS8010: Type annotations can only be used in TypeScript !!! error TS7022: 'context' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. class C extends UI.TreeElement { - ~~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. onpopulate() { this.doesNotExist this.treeOutline.doesntExistEither() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt index aab3121bf3..c10ea07ed6 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt @@ -1,30 +1,24 @@ index.js(1,7): error TS2339: Property 'Item' does not exist on type '{}'. index.js(2,8): error TS2339: Property 'Object' does not exist on type '{}'. -index.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. 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,34): error TS8010: Type annotations can only be used in TypeScript files. 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 (8 errors) ==== +==== index.js (6 errors) ==== First.Item = class I {} ~~~~ !!! error TS2339: Property 'Item' does not exist on type '{}'. Common.Object = class extends First.Item {} ~~~~~~ !!! error TS2339: Property 'Object' does not exist on type '{}'. - ~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~ !!! error TS2339: Property 'Item' does not exist on type '{}'. Workspace.Object = class extends Common.Object {} ~~~~~~ !!! error TS2339: Property 'Object' does not exist on type '{}'. - ~~~~~~~~~~~~~ -!!! error TS8010: Type annotations can only be used in TypeScript files. ~~~~~~ !!! error TS2339: Property 'Object' does not exist on type '{}'. diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff deleted file mode 100644 index 1dd778ec76..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInConstructor3_Js.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.argumentsReferenceInConstructor3_Js.errors.txt -+++ new.argumentsReferenceInConstructor3_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class A { -+ get arguments() { -+ return { bar: {} }; -+ } -+ } -+ -+ class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ /** -+ * Constructor -+ * -+ * @param {object} [foo={}] -+ */ -+ constructor(foo = {}) { -+ super(); -+ -+ /** -+ * @type object -+ */ -+ this.foo = foo; -+ -+ /** -+ * @type object -+ */ -+ this.bar = super.arguments.foo; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff deleted file mode 100644 index ea555b1e2b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/argumentsReferenceInMethod3_Js.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.argumentsReferenceInMethod3_Js.errors.txt -+++ new.argumentsReferenceInMethod3_Js.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(7,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (1 errors) ==== -+ class A { -+ get arguments() { -+ return { bar: {} }; -+ } -+ } -+ -+ class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ /** -+ * @param {object} [foo={}] -+ */ -+ m(foo = {}) { -+ /** -+ * @type object -+ */ -+ this.x = foo; -+ -+ /** -+ * @type object -+ */ -+ this.y = super.arguments.bar; -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt.diff index c10024b7b3..09726f841b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkIndexConstraintOfJavascriptClassExpression.errors.txt.diff @@ -4,22 +4,10 @@ +error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. weird.js(1,1): error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? weird.js(1,23): error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. -+weird.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. --==== weird.js (3 errors) ==== +!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -+==== weird.js (4 errors) ==== + ==== weird.js (3 errors) ==== someFunction(function(BaseClass) { - ~~~~~~~~~~~~ - !!! error TS2552: Cannot find name 'someFunction'. Did you mean 'Function'? -@@= skipped -12, +15 lines =@@ - 'use strict'; - const DEFAULT_MESSAGE = "nop!"; - class Hello extends BaseClass { -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - this.foo = "bar"; \ No newline at end of file + ~~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles_noErrorLocation.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles_noErrorLocation.errors.txt.diff deleted file mode 100644 index 9012601bbf..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsFiles_noErrorLocation.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.checkJsFiles_noErrorLocation.errors.txt -+++ new.checkJsFiles_noErrorLocation.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(11,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (1 errors) ==== -+ // @ts-check -+ class A { -+ constructor() { -+ -+ } -+ foo() { -+ return 4; -+ } -+ } -+ -+ class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super(); -+ this.foo = () => 3; -+ } -+ } -+ -+ const i = new B(); -+ i.foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classExtendingAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/classExtendingAny.errors.txt.diff deleted file mode 100644 index c03a7d0f6d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/classExtendingAny.errors.txt.diff +++ /dev/null @@ -1,42 +0,0 @@ ---- old.classExtendingAny.errors.txt -+++ new.classExtendingAny.errors.txt -@@= skipped -0, +0 lines =@@ -- -+b.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.ts (0 errors) ==== -+ declare var Err: any -+ class A extends Err { -+ payload: string -+ constructor() { -+ super(1,2,3,3,4,56) -+ super.unknown -+ super['unknown'] -+ } -+ process() { -+ return this.payload + "!"; -+ } -+ } -+ -+ var o = { -+ m() { -+ super.unknown -+ } -+ } -+==== b.js (1 errors) ==== -+ class B extends Err { -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super() -+ this.wat = 12 -+ } -+ f() { -+ this.wat -+ this.wit -+ this['wot'] -+ super.alsoBad -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff index ea1fba2565..b6cb604258 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs1.errors.txt.diff @@ -2,21 +2,21 @@ +++ new.classFieldSuperAccessibleJs1.errors.txt @@= skipped -0, +0 lines =@@ -index.js(9,23): error TS2565: Property 'blah2' is used before being assigned. -+index.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. - - - ==== index.js (1 errors) ==== -@@= skipped -7, +7 lines =@@ - C.blah2 = 456; - - class D extends C { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - static { - console.log(super.blah1); - console.log(super.blah2); +- +- +-==== index.js (1 errors) ==== +- class C { +- static blah1 = 123; +- } +- C.blah2 = 456; +- +- class D extends C { +- static { +- console.log(super.blah1); +- console.log(super.blah2); - ~~~~~ -!!! error TS2565: Property 'blah2' is used before being assigned. - } - } - \ No newline at end of file +- } +- } +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs2.errors.txt.diff deleted file mode 100644 index 9c48e0906f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperAccessibleJs2.errors.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.classFieldSuperAccessibleJs2.errors.txt -+++ new.classFieldSuperAccessibleJs2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ class C { -+ constructor() { -+ this.foo = () => { -+ console.log("called arrow"); -+ }; -+ } -+ foo() { -+ console.log("called method"); -+ } -+ } -+ -+ class D extends C { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ foo() { -+ console.log("SUPER:"); -+ super.foo(); -+ console.log("THIS:"); -+ this.foo(); -+ } -+ } -+ -+ const obj = new D(); -+ obj.foo(); -+ D.prototype.foo.call(obj); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff index f087625ae6..f8cc61293a 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/classFieldSuperNotAccessibleJs.errors.txt.diff @@ -5,22 +5,15 @@ -index.js(23,22): error TS2855: Class field 'foo' defined by the parent class is not accessible in the child class via super. -index.js(26,22): error TS2855: Class field 'justProp' defined by the parent class is not accessible in the child class via super. -index.js(29,22): error TS2855: Class field ''literalElementAccess'' defined by the parent class is not accessible in the child class via super. -- -- --==== index.js (4 errors) ==== +index.js(7,14): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'. +index.js(9,9): error TS7053: Element implicitly has an 'any' type because expression of type '"literalElementAccess"' can't be used to index type 'YaddaBase'. + Property 'literalElementAccess' does not exist on type 'YaddaBase'. -+index.js(18,28): error TS8010: Type annotations can only be used in TypeScript files. +index.js(26,22): error TS2339: Property 'justProp' does not exist on type 'YaddaBase'. +index.js(29,22): error TS2339: Property 'literalElementAccess' does not exist on type 'YaddaBase'. -+ -+ -+==== index.js (5 errors) ==== - // https://github.com/microsoft/TypeScript/issues/55884 - - class YaddaBase { -@@= skipped -11, +13 lines =@@ + + + ==== index.js (4 errors) ==== +@@= skipped -11, +12 lines =@@ this.roots = "hi"; /** @type number */ this.justProp; @@ -34,12 +27,8 @@ this.b() } -@@= skipped -11, +16 lines =@@ - } - +@@= skipped -13, +18 lines =@@ class DerivedYadda extends YaddaBase { -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. get rootTests() { return super.roots; - ~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt.diff deleted file mode 100644 index d8af22459c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt -+++ new.defaultPropsEmptyCurlyBecomesAnyForJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+component.js(2,28): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== library.d.ts (0 errors) ==== -+ export class Foo { -+ props: T; -+ state: U; -+ constructor(props: T, state: U); -+ } -+ -+==== component.js (1 errors) ==== -+ import { Foo } from "./library"; -+ export class MyFoo extends Foo { -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ member; -+ } -+ -+==== typed_component.ts (0 errors) ==== -+ import { MyFoo } from "./component"; -+ export class TypedFoo extends MyFoo { -+ constructor() { -+ super({x: "string", y: 42}, { value: undefined }); -+ this.props.x; -+ this.props.y; -+ this.state.value; -+ this.member; -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff index e282c4d5f8..8c07440833 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff @@ -5,23 +5,11 @@ BaseB.js(4,25): error TS2304: Cannot find name 'Class'. BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. -SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files. -+SubA.js(2,35): error TS8010: Type annotations can only be used in TypeScript files. +SubB.js(3,35): error TS8010: Type annotations can only be used in TypeScript files. ==== BaseA.js (0 errors) ==== - export default class BaseA { - } --==== SubA.js (0 errors) ==== -+==== SubA.js (1 errors) ==== - import BaseA from './BaseA'; - export default class SubA extends BaseA { -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - } - ==== BaseB.js (6 errors) ==== - import BaseA from './BaseA'; -@@= skipped -34, +37 lines =@@ +@@= skipped -34, +34 lines =@@ import SubA from './SubA'; import BaseB from './BaseB'; export default class SubB extends BaseB { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.errors.txt.diff deleted file mode 100644 index a0a68269c2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/genericDefaultsJs.errors.txt.diff +++ /dev/null @@ -1,102 +0,0 @@ ---- old.genericDefaultsJs.errors.txt -+++ new.genericDefaultsJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+main.js(19,21): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(20,21): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(25,21): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(43,21): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(44,21): error TS8010: Type annotations can only be used in TypeScript files. -+main.js(49,21): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== decls.d.ts (0 errors) ==== -+ declare function f0(x?: T): T; -+ declare function f1(x?: T): [T, U]; -+ declare class C0 { -+ y: T; -+ constructor(x?: T); -+ } -+ declare class C1 { -+ y: [T, U]; -+ constructor(x?: T); -+ } -+==== main.js (6 errors) ==== -+ const f0_v0 = f0(); -+ const f0_v1 = f0(1); -+ -+ const f1_c0 = f1(); -+ const f1_c1 = f1(1); -+ -+ const C0_v0 = new C0(); -+ const C0_v0_y = C0_v0.y; -+ -+ const C0_v1 = new C0(1); -+ const C0_v1_y = C0_v1.y; -+ -+ const C1_v0 = new C1(); -+ const C1_v0_y = C1_v0.y; -+ -+ const C1_v1 = new C1(1); -+ const C1_v1_y = C1_v1.y; -+ -+ class C0_B0 extends C0 {} -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ class C0_B1 extends C0 { -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super(); -+ } -+ } -+ class C0_B2 extends C0 { -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super(1); -+ } -+ } -+ -+ const C0_B0_v0 = new C0_B0(); -+ const C0_B0_v0_y = C0_B0_v0.y; -+ -+ const C0_B0_v1 = new C0_B0(1); -+ const C0_B0_v1_y = C0_B0_v1.y; -+ -+ const C0_B1_v0 = new C0_B1(); -+ const C0_B1_v0_y = C0_B1_v0.y; -+ -+ const C0_B2_v0 = new C0_B2(); -+ const C0_B2_v0_y = C0_B2_v0.y; -+ -+ class C1_B0 extends C1 {} -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ class C1_B1 extends C1 { -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super(); -+ } -+ } -+ class C1_B2 extends C1 { -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super(1); -+ } -+ } -+ -+ const C1_B0_v0 = new C1_B0(); -+ const C1_B0_v0_y = C1_B0_v0.y; -+ -+ const C1_B0_v1 = new C1_B0(1); -+ const C1_B0_v1_y = C1_B0_v1.y; -+ -+ const C1_B1_v0 = new C1_B1(); -+ const C1_B1_v0_y = C1_B1_v0.y; -+ -+ const C1_B2_v0 = new C1_B2(); -+ const C1_B2_v0_y = C1_B2_v0.y; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importDeclFromTypeNodeInJsSource.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/importDeclFromTypeNodeInJsSource.errors.txt.diff deleted file mode 100644 index ce27abcc49..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/importDeclFromTypeNodeInJsSource.errors.txt.diff +++ /dev/null @@ -1,64 +0,0 @@ ---- old.importDeclFromTypeNodeInJsSource.errors.txt -+++ new.importDeclFromTypeNodeInJsSource.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/src/b.js(5,26): error TS8010: Type annotations can only be used in TypeScript files. -+/src/b.js(8,27): error TS8010: Type annotations can only be used in TypeScript files. -+/src/b.js(11,27): error TS8010: Type annotations can only be used in TypeScript files. -+/src/b.js(14,27): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /src/node_modules/@types/node/index.d.ts (0 errors) ==== -+ /// -+==== /src/node_modules/@types/node/events.d.ts (0 errors) ==== -+ declare module "events" { -+ namespace EventEmitter { -+ class EventEmitter { -+ constructor(); -+ } -+ } -+ export = EventEmitter; -+ } -+ declare module "nestNamespaceModule" { -+ namespace a1.a2 { -+ class d { } -+ } -+ -+ namespace a1.a2.n3 { -+ class c { } -+ } -+ export = a1.a2; -+ } -+ declare module "renameModule" { -+ namespace a.b { -+ class c { } -+ } -+ import d = a.b; -+ export = d; -+ } -+ -+==== /src/b.js (4 errors) ==== -+ import { EventEmitter } from 'events'; -+ import { n3, d } from 'nestNamespaceModule'; -+ import { c } from 'renameModule'; -+ -+ export class Foo extends EventEmitter { -+ ~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ } -+ -+ export class Foo2 extends n3.c { -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ } -+ -+ export class Foo3 extends d { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ } -+ -+ export class Foo4 extends c { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt.diff deleted file mode 100644 index d6ebbfb883..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt.diff +++ /dev/null @@ -1,52 +0,0 @@ ---- old.importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt -+++ new.importHelpersCommonJSJavaScript(verbatimmodulesyntax=false).errors.txt -@@= skipped -0, +0 lines =@@ -- -+/index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /node_modules/tslib/package.json (0 errors) ==== -+ { -+ "name": "tslib", -+ "main": "tslib.js", -+ "module": "tslib.es6.js", -+ "jsnext:main": "tslib.es6.js", -+ "typings": "tslib.d.ts", -+ "exports": { -+ ".": { -+ "module": { -+ "types": "./modules/index.d.ts", -+ "default": "./tslib.es6.mjs" -+ }, -+ "import": { -+ "node": "./modules/index.js", -+ "default": { -+ "types": "./modules/index.d.ts", -+ "default": "./tslib.es6.mjs" -+ } -+ }, -+ "default": "./tslib.js" -+ }, -+ "./*": "./*", -+ "./": "./" -+ } -+ } -+ -+==== /node_modules/tslib/tslib.d.ts (0 errors) ==== -+ export declare var __extends: any; -+ -+==== /node_modules/tslib/modules/package.json (0 errors) ==== -+ { "type": "module" } -+ -+==== /node_modules/tslib/modules/index.d.ts (0 errors) ==== -+ export {}; -+ -+==== /index.js (1 errors) ==== -+ class Foo {} -+ -+ class Bar extends Foo {} -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ -+ module.exports = Bar; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt.diff deleted file mode 100644 index a998215641..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt.diff +++ /dev/null @@ -1,52 +0,0 @@ ---- old.importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt -+++ new.importHelpersCommonJSJavaScript(verbatimmodulesyntax=true).errors.txt -@@= skipped -0, +0 lines =@@ -- -+/index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /node_modules/tslib/package.json (0 errors) ==== -+ { -+ "name": "tslib", -+ "main": "tslib.js", -+ "module": "tslib.es6.js", -+ "jsnext:main": "tslib.es6.js", -+ "typings": "tslib.d.ts", -+ "exports": { -+ ".": { -+ "module": { -+ "types": "./modules/index.d.ts", -+ "default": "./tslib.es6.mjs" -+ }, -+ "import": { -+ "node": "./modules/index.js", -+ "default": { -+ "types": "./modules/index.d.ts", -+ "default": "./tslib.es6.mjs" -+ } -+ }, -+ "default": "./tslib.js" -+ }, -+ "./*": "./*", -+ "./": "./" -+ } -+ } -+ -+==== /node_modules/tslib/tslib.d.ts (0 errors) ==== -+ export declare var __extends: any; -+ -+==== /node_modules/tslib/modules/package.json (0 errors) ==== -+ { "type": "module" } -+ -+==== /node_modules/tslib/modules/index.d.ts (0 errors) ==== -+ export {}; -+ -+==== /index.js (1 errors) ==== -+ class Foo {} -+ -+ class Bar extends Foo {} -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ -+ module.exports = Bar; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.errors.txt.diff deleted file mode 100644 index 15db22dcb7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptCommonjsModule.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.javascriptCommonjsModule.errors.txt -+++ new.javascriptCommonjsModule.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(3,19): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ class Foo {} -+ -+ class Bar extends Foo {} -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ -+ module.exports = Bar; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptThisAssignmentInStaticBlock.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/javascriptThisAssignmentInStaticBlock.errors.txt.diff deleted file mode 100644 index 4cd35f6350..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/javascriptThisAssignmentInStaticBlock.errors.txt.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.javascriptThisAssignmentInStaticBlock.errors.txt -+++ new.javascriptThisAssignmentInStaticBlock.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/src/a.js(10,29): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /src/a.js (1 errors) ==== -+ class Thing { -+ static { -+ this.doSomething = () => {}; -+ } -+ } -+ -+ Thing.doSomething(); -+ -+ // GH#46468 -+ class ElementsArray extends Array { -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ static { -+ const superisArray = super.isArray; -+ const customIsArray = (arg)=> superisArray(arg); -+ this.isArray = customIsArray; -+ } -+ } -+ -+ ElementsArray.isArray(new ElementsArray()); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff deleted file mode 100644 index 14b541e491..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationsInheritedTypes.errors.txt.diff +++ /dev/null @@ -1,44 +0,0 @@ ---- old.jsDeclarationsInheritedTypes.errors.txt -+++ new.jsDeclarationsInheritedTypes.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(18,18): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(25,18): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (2 errors) ==== -+ /** -+ * @typedef A -+ * @property {string} a -+ */ -+ -+ /** -+ * @typedef B -+ * @property {number} b -+ */ -+ -+ class C1 { -+ /** -+ * @type {A} -+ */ -+ value; -+ } -+ -+ class C2 extends C1 { -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ /** -+ * @type {A} -+ */ -+ value; -+ } -+ -+ class C3 extends C1 { -+ ~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ /** -+ * @type {A & B} -+ */ -+ value; -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEmitIntersectionProperty.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEmitIntersectionProperty.errors.txt.diff deleted file mode 100644 index 5deb46a77d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEmitIntersectionProperty.errors.txt.diff +++ /dev/null @@ -1,39 +0,0 @@ ---- old.jsEmitIntersectionProperty.errors.txt -+++ new.jsEmitIntersectionProperty.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(1,34): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== globals.d.ts (0 errors) ==== -+ declare class CoreObject { -+ static extend< -+ Statics, -+ Instance extends B1, -+ T1, -+ B1 -+ >( -+ this: Statics & { new(): Instance }, -+ arg1: T1 -+ ): Readonly & { new(): T1 & Instance }; -+ -+ toString(): string; -+ } -+ -+ declare class Mixin { -+ static create( -+ args?: T -+ ): Mixin; -+ } -+ declare const Observable: Mixin<{}> -+ declare class EmberObject extends CoreObject.extend(Observable) {} -+ declare class CoreView extends EmberObject.extend({}) {} -+ declare class Component extends CoreView.extend({}) {} -+ -+==== index.js (1 errors) ==== -+ export class MyComponent extends Component { -+ ~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff index 170c181f4d..e54ee4f87b 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff @@ -1,11 +1,9 @@ --- old.jsExtendsImplicitAny.errors.txt +++ new.jsExtendsImplicitAny.errors.txt @@= skipped -0, +0 lines =@@ -+/b.js(1,17): error TS8010: Type annotations can only be used in TypeScript files. /b.js(1,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. -/b.js(4,15): error TS2314: Generic type 'A' requires 1 type argument(s). -/b.js(8,15): error TS2314: Generic type 'A' requires 1 type argument(s). -+/b.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. +/b.js(5,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +/b.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. +/b.js(9,17): error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -15,11 +13,9 @@ declare class A { x: T; } -==== /b.js (3 errors) ==== -+==== /b.js (6 errors) ==== ++==== /b.js (4 errors) ==== class B extends A {} ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new B().x; @@ -28,8 +24,6 @@ -!!! error TS2314: Generic type 'A' requires 1 type argument(s). class C extends A { } + ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~ +!!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new C().x; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt.diff deleted file mode 100644 index 87400e0683..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt -+++ new.jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt -@@= skipped -0, +0 lines =@@ -+index.js(3,21): error TS8010: Type annotations can only be used in TypeScript files. - index.js(3,21): error TS8026: Expected Foo type arguments; provide these with an '@extends' tag. - - -@@= skipped -4, +5 lines =@@ - export declare class Foo { - prop: T; - } --==== index.js (1 errors) ==== -+==== index.js (2 errors) ==== - import {Foo} from "./somelib"; - - class MyFoo extends Foo { -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~ - !!! error TS8026: Expected Foo type arguments; provide these with an '@extends' tag. - constructor() { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/superNoModifiersCrash.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/superNoModifiersCrash.errors.txt.diff deleted file mode 100644 index 566d191af9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/superNoModifiersCrash.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.superNoModifiersCrash.errors.txt -+++ new.superNoModifiersCrash.errors.txt -@@= skipped -0, +0 lines =@@ -- -+File.js(8,21): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== File.js (1 errors) ==== -+ class Parent { -+ initialize() { -+ super.initialize(...arguments) -+ return this.asdf = '' -+ } -+ } -+ -+ class Child extends Parent { -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ initialize() { -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff index 89737d071c..425e51b45e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff @@ -8,13 +8,11 @@ +first.js(10,19): error TS8009: The '?' modifier can only be used in TypeScript files. +first.js(16,47): error TS8009: The '?' modifier can only be used in TypeScript files. +first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. -+first.js(21,19): error TS8010: Type annotations can only be used in TypeScript files. +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(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"; }'. -+first.js(47,24): error TS8010: Type annotations can only be used in TypeScript files. +generic.js(9,23): error TS2507: Type '(flavour: T) => void' is not a constructor function type. +generic.js(9,23): error TS8010: Type annotations can only be used in TypeScript files. +generic.js(11,21): error TS2339: Property 'flavour' does not exist on type 'Chowder'. @@ -36,11 +34,11 @@ +second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. + + -+==== first.js (8 errors) ==== ++==== first.js (6 errors) ==== /** * @constructor * @param {number} numberOxen -@@= skipped -25, +27 lines =@@ +@@= skipped -25, +25 lines =@@ /** @param {Wagon[]=} wagons */ Wagon.circle = function (wagons) { return wagons ? wagons.length : 3.14; @@ -61,8 +59,6 @@ class Sql extends Wagon { + ~~~~~ +!!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); // error: not enough arguments - ~~~~~ @@ -85,7 +81,7 @@ if (format === "xmlolololol") { throw new Error("please do not use XML. It was a joke."); } -@@= skipped -41, +44 lines =@@ +@@= skipped -41, +42 lines =@@ } var db = new Sql(); db.numberOxen = db.foonly @@ -94,14 +90,7 @@ // error, can't extend a TS constructor function class Drakkhen extends Dragon { - ~~~~~~ - !!! error TS2507: Type '(numberEaten: number) => void' is not a constructor function type. -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - - } - -@@= skipped -25, +29 lines =@@ +@@= skipped -25, +27 lines =@@ } // ok class Conestoga extends Wagon { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag2.errors.txt.diff index 1adc7b6144..9a45cc583d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag2.errors.txt.diff @@ -6,19 +6,24 @@ - -!!! error TS8022: JSDoc '@extends' is not attached to a class. -==== foo.js (0 errors) ==== -+foo.js(15,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (1 errors) ==== - /** - * @constructor - */ -@@= skipped -17, +16 lines =@@ - * @constructor - */ - class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - } \ No newline at end of file +- /** +- * @constructor +- */ +- class A { +- constructor() {} +- } +- +- /** +- * @extends {A} +- */ +- +- /** +- * @constructor +- */ +- class B extends A { +- constructor() { +- super(); +- } +- } +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag3.errors.txt.diff deleted file mode 100644 index 2664119427..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag3.errors.txt.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.extendsTag3.errors.txt -+++ new.extendsTag3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+foo.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. -+foo.js(22,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (2 errors) ==== -+ /** -+ * @constructor -+ */ -+ class A { -+ constructor() {} -+ } -+ -+ /** -+ * @extends {A} -+ * @constructor -+ */ -+ class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super(); -+ } -+ } -+ -+ /** -+ * @extends { A } -+ * @constructor -+ */ -+ class C extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super(); -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag6.errors.txt.diff deleted file mode 100644 index ee67cdaafa..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTag6.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.extendsTag6.errors.txt -+++ new.extendsTag6.errors.txt -@@= skipped -0, +0 lines =@@ -- -+foo.js(12,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.js (1 errors) ==== -+ /** -+ * @constructor -+ */ -+ class A { -+ constructor() {} -+ } -+ -+ /** -+ * @extends { A } -+ * @constructor -+ */ -+ class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super(); -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTagEmit.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTagEmit.errors.txt.diff index c2a305fbe6..c87cc5fa7c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/extendsTagEmit.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/extendsTagEmit.errors.txt.diff @@ -3,19 +3,17 @@ @@= skipped -0, +0 lines =@@ -main.js(2,15): error TS2304: Cannot find name 'Mismatch'. main.js(2,15): error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. -+main.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. ==== super.js (0 errors) ==== -@@= skipped -8, +8 lines =@@ + export class B { } + +-==== main.js (2 errors) ==== ++==== main.js (1 errors) ==== import { B } from './super' /** @extends {Mismatch} */ - ~~~~~~~~ --!!! error TS2304: Cannot find name 'Mismatch'. - ~~~~~~~~ +-!!! error TS2304: Cannot find name 'Mismatch'. + ~~~~~~~~ !!! error TS8023: JSDoc '@extends Mismatch' does not match the 'extends B' clause. - class C extends B { } -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - - \ No newline at end of file + class C extends B { } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments3.errors.txt.diff deleted file mode 100644 index 310839c4fa..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments3.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.inferringClassMembersFromAssignments3.errors.txt -+++ new.inferringClassMembersFromAssignments3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (1 errors) ==== -+ class Base { -+ constructor() { -+ this.p = 1 -+ } -+ } -+ class Derived extends Base { -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ m() { -+ this.p = 1 -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments4.errors.txt.diff deleted file mode 100644 index 99422ec5ce..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments4.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.inferringClassMembersFromAssignments4.errors.txt -+++ new.inferringClassMembersFromAssignments4.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (1 errors) ==== -+ class Base { -+ m() { -+ this.p = 1 -+ } -+ } -+ class Derived extends Base { -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ m() { -+ // should be OK, and p should have type number | undefined from its base -+ this.p = 1 -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments5.errors.txt.diff deleted file mode 100644 index a5216fe6dc..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/inferringClassMembersFromAssignments5.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.inferringClassMembersFromAssignments5.errors.txt -+++ new.inferringClassMembersFromAssignments5.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(6,23): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (1 errors) ==== -+ class Base { -+ m() { -+ this.p = 1 -+ } -+ } -+ class Derived extends Base { -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super(); -+ // should be OK, and p should have type number from this assignment -+ this.p = 1 -+ } -+ test() { -+ return this.p -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff deleted file mode 100644 index 6d9534351f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassAccessor.errors.txt.diff +++ /dev/null @@ -1,45 +0,0 @@ ---- old.jsDeclarationsClassAccessor.errors.txt -+++ new.jsDeclarationsClassAccessor.errors.txt -@@= skipped -0, +0 lines =@@ -- -+argument.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== supplement.d.ts (0 errors) ==== -+ export { }; -+ declare module "./argument.js" { -+ interface Argument { -+ idlType: any; -+ default: null; -+ } -+ } -+==== base.js (0 errors) ==== -+ export class Base { -+ constructor() { } -+ -+ toJSON() { -+ const json = { type: undefined, name: undefined, inheritance: undefined }; -+ return json; -+ } -+ } -+==== argument.js (1 errors) ==== -+ import { Base } from "./base.js"; -+ export class Argument extends Base { -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ /** -+ * @param {*} tokeniser -+ */ -+ static parse(tokeniser) { -+ return; -+ } -+ -+ get type() { -+ return "argument"; -+ } -+ -+ /** -+ * @param {*} defs -+ */ -+ *validate(defs) { } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.errors.txt.diff index 78dcd07dc1..a6219f736e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassExtendsVisibility.errors.txt.diff @@ -2,20 +2,17 @@ +++ new.jsDeclarationsClassExtendsVisibility.errors.txt @@= skipped -0, +0 lines =@@ - -+cls.js(6,19): error TS8010: Type annotations can only be used in TypeScript files. +cls.js(7,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +cls.js(8,16): error TS2339: Property 'Strings' does not exist on type 'typeof Foo'. + + -+==== cls.js (3 errors) ==== ++==== cls.js (2 errors) ==== + const Bar = require("./bar"); + const Strings = { + a: "A", + b: "B" + }; + class Foo extends Bar {} -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + module.exports = Foo; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic2.errors.txt.diff deleted file mode 100644 index 0a767ad09b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassStatic2.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.jsDeclarationsClassStatic2.errors.txt -+++ new.jsDeclarationsClassStatic2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+Foo.js(4,26): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== Foo.js (1 errors) ==== -+ class Base { -+ static foo = ""; -+ } -+ export class Foo extends Base {} -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ Foo.foo = "foo"; -+ -+==== Bar.ts (0 errors) ==== -+ import { Foo } from "./Foo.js"; -+ -+ class Bar extends Foo {} -+ Bar.foo = "foo"; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff index 8fe7861c21..7119e41781 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff @@ -2,15 +2,10 @@ +++ new.jsDeclarationsClasses.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(147,24): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(149,24): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(159,24): error TS8010: Type annotations can only be used in TypeScript files. +index.js(173,24): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(185,35): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(191,37): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (6 errors) ==== ++==== index.js (1 errors) ==== + export class A {} + + export class B { @@ -158,12 +153,8 @@ + } + + export class L extends K {} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + + export class M extends null { -+ ~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + this.prop = 12; + } @@ -174,8 +165,6 @@ + * @template T + */ + export class N extends L { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + /** + * @param {T} param + */ @@ -204,16 +193,12 @@ + var x = /** @type {*} */(null); + + export class VariableBase extends x {} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + + export class HasStatics { + static staticMethod() {} + } + + export class ExtendsStatics extends HasStatics { -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + static also() {} + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff index 2b008b79c1..45ffc52659 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff @@ -9,28 +9,20 @@ index.js(9,12): error TS8010: Type annotations can only be used in TypeScript files. index.js(13,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(13,20): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(16,24): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(18,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(19,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(19,20): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(22,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(23,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(23,20): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(26,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(27,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(27,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(28,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(28,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(32,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(32,20): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(35,24): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(38,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(39,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(39,20): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(42,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(43,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(43,20): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(46,24): error TS8010: Type annotations can only be used in TypeScript files. index.js(47,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(47,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(48,11): error TS8010: Type annotations can only be used in TypeScript files. @@ -39,14 +31,10 @@ +index.js(52,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(53,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(53,20): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(56,24): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(58,25): error TS8010: Type annotations can only be used in TypeScript files. index.js(59,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(59,20): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(62,25): error TS8010: Type annotations can only be used in TypeScript files. index.js(63,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(63,20): error TS8010: Type annotations can only be used in TypeScript files. -+index.js(66,25): error TS8010: Type annotations can only be used in TypeScript files. index.js(67,11): error TS8010: Type annotations can only be used in TypeScript files. +index.js(67,20): error TS8010: Type annotations can only be used in TypeScript files. index.js(68,11): error TS8010: Type annotations can only be used in TypeScript files. @@ -56,11 +44,11 @@ +index.js(68,20): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== index.js (49 errors) ==== ++==== index.js (37 errors) ==== // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), // but we should be able to synthesize declarations from the symbols regardless -@@= skipped -35, +63 lines =@@ +@@= skipped -35, +51 lines =@@ export class N extends M { ~ !!! error TS8004: Type parameter declarations can only be used in TypeScript files. @@ -80,37 +68,28 @@ } export class P extends O {} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - - export class Q extends O { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -8, +10 lines =@@ [idx: string]: "ok"; ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. } export class R extends O { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: "ok"; ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. } export class S extends O { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: "ok"; ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: never; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -127,33 +106,23 @@ } export class U extends T {} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - - - export class V extends T { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -30, +40 lines =@@ [idx: string]: string; ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. } export class W extends T { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: "ok"; ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. } export class X extends T { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: string; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -166,7 +135,7 @@ !!! error TS8010: Type annotations can only be used in TypeScript files. } -@@= skipped -59, +95 lines =@@ +@@= skipped -21, +29 lines =@@ [idx: string]: {x: number}; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. @@ -180,32 +149,23 @@ } export class Z extends Y {} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - - export class AA extends Y { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. +@@= skipped -11, +15 lines =@@ [idx: string]: {x: number, y: number}; ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. } export class BB extends Y { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: number]: {x: 0, y: 0}; ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~~~~~~~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. ++ ~~~~~~~~~~~~ ++!!! error TS8010: Type annotations can only be used in TypeScript files. } export class CC extends Y { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. [idx: string]: {x: number, y: number}; ~~~~~~ !!! error TS8010: Type annotations can only be used in TypeScript files. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff deleted file mode 100644 index 442f4161f3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.errors.txt.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.jsDeclarationsDefault.errors.txt -+++ new.jsDeclarationsDefault.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index4.js(2,19): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index1.js (0 errors) ==== -+ export default 12; -+ -+==== index2.js (0 errors) ==== -+ export default function foo() { -+ return foo; -+ } -+ export const x = foo; -+ export { foo as bar }; -+ -+==== index3.js (0 errors) ==== -+ export default class Foo { -+ a = /** @type {Foo} */(null); -+ }; -+ export const X = Foo; -+ export { Foo as Bar }; -+ -+==== index4.js (1 errors) ==== -+ import Fab from "./index3"; -+ class Bar extends Fab { -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ x = /** @type {Bar} */(null); -+ } -+ export default Bar; -+ -+==== index5.js (0 errors) ==== -+ // merge type alias and const (OK) -+ export default 12; -+ /** -+ * @typedef {string | number} default -+ */ -+ -+==== index6.js (0 errors) ==== -+ // merge type alias and function (OK) -+ export default function func() {}; -+ /** -+ * @typedef {string | number} default -+ */ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportedClassAliases.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportedClassAliases.errors.txt.diff deleted file mode 100644 index c6541ff471..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportedClassAliases.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.jsDeclarationsExportedClassAliases.errors.txt -+++ new.jsDeclarationsExportedClassAliases.errors.txt -@@= skipped -0, +0 lines =@@ -- -+utils/errors.js(1,26): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== utils/index.js (0 errors) ==== -+ // issue arises here on compilation -+ const errors = require("./errors"); -+ -+ module.exports = { -+ errors -+ }; -+==== utils/errors.js (1 errors) ==== -+ class FancyError extends Error { -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor(status) { -+ super(`error with status ${status}`); -+ } -+ } -+ -+ module.exports = { -+ FancyError -+ }; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff deleted file mode 100644 index 0f334f3c76..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt -+++ new.jsDeclarationsSubclassWithExplicitNoArgumentConstructor.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(9,26): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ export class Super { -+ /** -+ * @param {string} firstArg -+ * @param {string} secondArg -+ */ -+ constructor(firstArg, secondArg) { } -+ } -+ -+ export class Sub extends Super { -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super('first', 'second'); -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff deleted file mode 100644 index e005e77d09..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsThisTypes.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsDeclarationsThisTypes.errors.txt -+++ new.jsDeclarationsThisTypes.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(7,35): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== index.js (1 errors) ==== -+ export class A { -+ /** @returns {this} */ -+ method() { -+ return this; -+ } -+ } -+ export default class Base extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ // This method is required to reproduce #35932 -+ verify() { } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff deleted file mode 100644 index 2550410002..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.jsdocAccessibilityTags.errors.txt -+++ new.jsdocAccessibilityTags.errors.txt -@@= skipped -0, +0 lines =@@ -+jsdocAccessibilityTag.js(48,17): error TS8010: Type annotations can only be used in TypeScript files. - jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. -+jsdocAccessibilityTag.js(53,17): error TS8010: Type annotations can only be used in TypeScript files. - jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. - jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. - jsdocAccessibilityTag.js(58,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. -@@= skipped -9, +11 lines =@@ - jsdocAccessibilityTag.js(61,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. - - --==== jsdocAccessibilityTag.js (10 errors) ==== -+==== jsdocAccessibilityTag.js (12 errors) ==== - class A { - /** - * Ap docs -@@= skipped -49, +49 lines =@@ - h() { return this.priv2 } - } - class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - m() { - this.priv + this.prot + this.pub - ~~~~ -@@= skipped -7, +9 lines =@@ - } - } - class D extends C { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - n() { - this.priv2 + this.prot2 + this.pub2 - ~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugmentsMissingType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugmentsMissingType.errors.txt.diff index c62fd06126..0d8dfe2f9e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugmentsMissingType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugmentsMissingType.errors.txt.diff @@ -7,10 +7,9 @@ - - -==== /a.js (3 errors) ==== -+/a.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== /a.js (2 errors) ==== ++==== /a.js (1 errors) ==== class A { constructor() { this.x = 0; } } /** @augments */ @@ -18,8 +17,6 @@ - !!! error TS8023: JSDoc '@augments ' does not match the 'extends A' clause. class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. m() { this.x - ~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_errorInExtendsExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_errorInExtendsExpression.errors.txt.diff deleted file mode 100644 index 896f5141a0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_errorInExtendsExpression.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.jsdocAugments_errorInExtendsExpression.errors.txt -+++ new.jsdocAugments_errorInExtendsExpression.errors.txt -@@= skipped -0, +0 lines =@@ - /a.js(3,17): error TS2304: Cannot find name 'err'. -- -- --==== /a.js (1 errors) ==== -+/a.js(3,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /a.js (2 errors) ==== - class A {} - /** @augments A */ - class B extends err() {} - ~~~ - !!! error TS2304: Cannot find name 'err'. -+ ~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_nameMismatch.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_nameMismatch.errors.txt.diff deleted file mode 100644 index 9fb0bd353d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAugments_nameMismatch.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.jsdocAugments_nameMismatch.errors.txt -+++ new.jsdocAugments_nameMismatch.errors.txt -@@= skipped -0, +0 lines =@@ - /b.js(4,15): error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. -- -- --==== /b.js (1 errors) ==== -+/b.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== /b.js (2 errors) ==== - class A {} - class B {} - -@@= skipped -8, +9 lines =@@ - ~ - !!! error TS8023: JSDoc '@augments A' does not match the 'extends B' clause. - class C extends B {} -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff deleted file mode 100644 index ce5f83de41..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsdocOverrideTag1.errors.txt -+++ new.jsdocOverrideTag1.errors.txt -@@= skipped -0, +0 lines =@@ -+0.js(16,17): error TS8010: Type annotations can only be used in TypeScript files. - 0.js(27,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'A'. - 0.js(32,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. - 0.js(40,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. - - --==== 0.js (3 errors) ==== -+==== 0.js (4 errors) ==== - class A { - - /** -@@= skipped -19, +20 lines =@@ - } - - class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - /** - * @override - * @method \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff index 6d7fbde880..cb553f8687 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.errors.txt.diff @@ -15,7 +15,6 @@ - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. +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(20,27): error TS8010: Type annotations can only be used in TypeScript files. +b.js(45,36): error TS2741: Property 'p' is missing in type 'SomeOther' but required in type 'SomeBase'. +b.js(49,42): error TS2739: Type 'SomeOther' is missing the following properties from type 'SomeDerived': p, x +b.js(51,38): error TS2741: Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. @@ -23,7 +22,13 @@ 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 -25, +18 lines =@@ +@@= skipped -20, +12 lines =@@ + ==== a.ts (0 errors) ==== + var W: string; + +-==== b.js (10 errors) ==== ++==== b.js (9 errors) ==== + // @ts-check var W = /** @type {string} */(/** @type {*} */ (4)); var W = /** @type {string} */(4); // Error @@ -32,16 +37,7 @@ !!! 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 {*} */ -@@= skipped -18, +18 lines =@@ - } - } - class SomeDerived extends SomeBase { -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - constructor() { - super(); - this.x = 42; -@@= skipped -25, +27 lines =@@ +@@= skipped -48, +48 lines =@@ someBase = /** @type {SomeBase} */(someDerived); someBase = /** @type {SomeBase} */(someBase); someBase = /** @type {SomeBase} */(someOther); // Error diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff deleted file mode 100644 index 299f10f006..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.override_js1.errors.txt -+++ new.override_js1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== a.js (1 errors) ==== -+ class B { -+ foo (v) {} -+ fooo (v) {} -+ } -+ -+ class D extends B { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ foo (v) {} -+ /** @override */ -+ fooo (v) {} -+ /** @override */ -+ bar(v) {} -+ } -+ -+ class C { -+ foo () {} -+ /** @override */ -+ fooo (v) {} -+ /** @override */ -+ bar(v) {} -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff deleted file mode 100644 index 55c441fdab..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.override_js2.errors.txt -+++ new.override_js2.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. - a.js(7,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'B'. - a.js(11,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'B'. - a.js(17,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. - a.js(19,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. - - --==== a.js (4 errors) ==== -+==== a.js (5 errors) ==== - class B { - foo (v) {} - fooo (v) {} - } - - class D extends B { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - foo (v) {} - ~~~ - !!! error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'B'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff deleted file mode 100644 index 7ff4fadd64..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.override_js3.errors.txt -+++ new.override_js3.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(6,17): error TS8010: Type annotations can only be used in TypeScript files. - a.js(7,5): error TS8009: The 'override' modifier can only be used in TypeScript files. - - --==== a.js (1 errors) ==== -+==== a.js (2 errors) ==== - class B { - foo (v) {} - fooo (v) {} - } - - class D extends B { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - override foo (v) {} - ~~~~~~~~ - !!! error TS8009: The 'override' modifier can only be used in TypeScript files. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff deleted file mode 100644 index 7793263ccf..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.override_js4.errors.txt -+++ new.override_js4.errors.txt -@@= skipped -0, +0 lines =@@ -+a.js(5,17): error TS8010: Type annotations can only be used in TypeScript files. - a.js(7,5): error TS4123: This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class 'A'. Did you mean 'doSomething'? - - --==== a.js (1 errors) ==== -+==== a.js (2 errors) ==== - class A { - doSomething() {} - } - - class B extends A { -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - /** @override */ - doSomethang() {} - ~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff index ca45a3c9de..e102f571ba 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff @@ -1,20 +1,6 @@ --- old.plainJSGrammarErrors.errors.txt +++ new.plainJSGrammarErrors.errors.txt -@@= skipped -20, +20 lines =@@ - plainJSGrammarErrors.js(38,18): error TS1053: A 'set' accessor cannot have rest parameter. - plainJSGrammarErrors.js(41,5): error TS18006: Classes may not have a field named 'constructor'. - plainJSGrammarErrors.js(43,1): error TS1211: A class declaration without the 'default' modifier must have a name. -+plainJSGrammarErrors.js(46,23): error TS8010: Type annotations can only be used in TypeScript files. - plainJSGrammarErrors.js(46,25): error TS1172: 'extends' clause already seen. -+plainJSGrammarErrors.js(46,33): error TS8010: Type annotations can only be used in TypeScript files. -+plainJSGrammarErrors.js(47,23): error TS8010: Type annotations can only be used in TypeScript files. - plainJSGrammarErrors.js(47,25): error TS1174: Classes can only extend a single class. -+plainJSGrammarErrors.js(47,25): error TS8010: Type annotations can only be used in TypeScript files. -+plainJSGrammarErrors.js(47,27): error TS8010: Type annotations can only be used in TypeScript files. - plainJSGrammarErrors.js(49,1): error TS18016: Private identifiers are not allowed outside class bodies. - plainJSGrammarErrors.js(50,6): error TS18016: Private identifiers are not allowed outside class bodies. - plainJSGrammarErrors.js(51,9): error TS18013: Property '#m' is not accessible outside class 'C' because it has a private identifier. -@@= skipped -45, +50 lines =@@ +@@= skipped -65, +65 lines =@@ plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allowed outside class bodies. plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. @@ -31,33 +17,11 @@ -==== plainJSGrammarErrors.js (102 errors) ==== -+==== plainJSGrammarErrors.js (108 errors) ==== ++==== plainJSGrammarErrors.js (103 errors) ==== class C { // #private mistakes q = #unbound -@@= skipped -93, +93 lines =@@ - missingName = true - } - class Doubler extends C extends C { } -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~~~~~~~ - !!! error TS1172: 'extends' clause already seen. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - class Trebler extends C,C,C { } -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ - !!! error TS1174: Classes can only extend a single class. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. - // #private mistakes - #unrelated - ~~~~~~~~~~ -@@= skipped -152, +162 lines =@@ +@@= skipped -245, +245 lines =@@ cantHaveQuestionMark?: 1, ~ !!! error TS1162: An object member cannot be declared optional. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/spellingUncheckedJS.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/spellingUncheckedJS.errors.txt.diff deleted file mode 100644 index fedd959a81..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/spellingUncheckedJS.errors.txt.diff +++ /dev/null @@ -1,59 +0,0 @@ ---- old.spellingUncheckedJS.errors.txt -+++ new.spellingUncheckedJS.errors.txt -@@= skipped -0, +0 lines =@@ -- -+spellingUncheckedJS.js(19,23): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== spellingUncheckedJS.js (1 errors) ==== -+ export var inModule = 1 -+ inmodule.toFixed() -+ -+ function f() { -+ var locals = 2 + true -+ locale.toFixed() -+ // @ts-expect-error -+ localf.toExponential() -+ // @ts-expect-error -+ "this is fine" -+ } -+ class Classe { -+ non = 'oui' -+ methode() { -+ // no error on 'this' references -+ return this.none -+ } -+ } -+ class Derivee extends Classe { -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ methode() { -+ // no error on 'super' references -+ return super.none -+ } -+ } -+ -+ -+ var object = { -+ spaaace: 3 -+ } -+ object.spaaaace // error on read -+ object.spaace = 12 // error on write -+ object.fresh = 12 // OK -+ other.puuuce // OK, from another file -+ new Date().getGMTDate() // OK, from another file -+ -+ // No suggestions for globals from other files -+ const atoc = setIntegral(() => console.log('ok'), 500) -+ AudioBuffin // etc -+ Jimmy -+ Jon -+ -+==== other.js (0 errors) ==== -+ var Jimmy = 1 -+ var John = 2 -+ Jon // error, it's from the same file -+ var other = { -+ puuce: 4 -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff deleted file mode 100644 index 1640bb88aa..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyAssignmentInherited.errors.txt.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.thisPropertyAssignmentInherited.errors.txt -+++ new.thisPropertyAssignmentInherited.errors.txt -@@= skipped -0, +0 lines =@@ -- -+thisPropertyAssignmentInherited.js(11,34): error TS8010: Type annotations can only be used in TypeScript files. -+thisPropertyAssignmentInherited.js(12,34): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== thisPropertyAssignmentInherited.js (2 errors) ==== -+ export class Element { -+ /** -+ * @returns {String} -+ */ -+ get textContent() { -+ return '' -+ } -+ set textContent(x) {} -+ cloneNode() { return this} -+ } -+ export class HTMLElement extends Element {} -+ ~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ export class TextElement extends HTMLElement { -+ ~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ get innerHTML() { return this.textContent; } -+ set innerHTML(html) { this.textContent = html; } -+ toString() { -+ } -+ } -+ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyOverridesAccessors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyOverridesAccessors.errors.txt.diff deleted file mode 100644 index cffc69bf83..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisPropertyOverridesAccessors.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.thisPropertyOverridesAccessors.errors.txt -+++ new.thisPropertyOverridesAccessors.errors.txt -@@= skipped -0, +0 lines =@@ -- -+bar.js(1,19): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== foo.ts (0 errors) ==== -+ class Foo { -+ get p() { return 1 } -+ set p(value) { } -+ } -+ -+==== bar.js (1 errors) ==== -+ class Bar extends Foo { -+ ~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. -+ constructor() { -+ super() -+ this.p = 2 -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment23.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment23.errors.txt.diff index 8c1f2cd10a..e1c59506b4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment23.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment23.errors.txt.diff @@ -2,14 +2,11 @@ +++ new.typeFromPropertyAssignment23.errors.txt @@= skipped -0, +0 lines =@@ - -+a.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. -+a.js(15,17): error TS8010: Type annotations can only be used in TypeScript files. +a.js(23,18): error TS2339: Property 'identifier' does not exist on type 'Module'. +a.js(24,18): error TS2339: Property 'size' does not exist on type 'Module'. -+a.js(26,28): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== a.js (5 errors) ==== ++==== a.js (2 errors) ==== + class B { + constructor () { + this.n = 1 @@ -19,16 +16,12 @@ + } + + class C extends B { } -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + + // this override should be fine (even if it's a little odd) + C.prototype.foo = function() { + } + + class D extends B { } -+ ~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + D.prototype.foo = () => { + this.n = 'not checked, so no error' + } @@ -44,8 +37,6 @@ +!!! error TS2339: Property 'size' does not exist on type 'Module'. + + class NormalModule extends Module { -+ ~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + identifier() { + return 'normal' + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment25.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment25.errors.txt.diff index 897aca92ee..c427274095 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment25.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment25.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 lines =@@ - +bug24703.js(7,8): error TS2506: 'O' is referenced directly or indirectly in its own base expression. -+bug24703.js(7,26): error TS8010: Type annotations can only be used in TypeScript files. + + -+==== bug24703.js (2 errors) ==== ++==== bug24703.js (1 errors) ==== + var Common = {}; + Common.I = class { + constructor() { @@ -16,8 +15,6 @@ + Common.O = class extends Common.I { + ~ +!!! error TS2506: 'O' is referenced directly or indirectly in its own base expression. -+ ~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + constructor() { + super() + this.o = 2 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment26.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment26.errors.txt.diff index c0fe98cbbb..2f5710bd3e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment26.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignment26.errors.txt.diff @@ -3,15 +3,11 @@ @@= skipped -0, +0 lines =@@ -bug24730.js(11,14): error TS2339: Property 'doesNotExist' does not exist on type 'C'. -bug24730.js(12,26): error TS2339: Property 'doesntExistEither' does not exist on type 'number'. -- -- --==== bug24730.js (2 errors) ==== +bug24730.js(1,5): error TS7022: 'UI' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +bug24730.js(7,1): error TS7022: 'context' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -+bug24730.js(9,17): error TS8010: Type annotations can only be used in TypeScript files. -+ -+ -+==== bug24730.js (3 errors) ==== + + + ==== bug24730.js (2 errors) ==== var UI = {} + ~~ +!!! error TS7022: 'UI' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. @@ -25,8 +21,6 @@ +!!! error TS7022: 'context' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. class C extends UI.TreeElement { -+ ~~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. onpopulate() { this.doesNotExist - ~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff index 67e39fecce..5dfed1d5ae 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff @@ -4,31 +4,25 @@ - +index.js(1,7): error TS2339: Property 'Item' does not exist on type '{}'. +index.js(2,8): error TS2339: Property 'Object' does not exist on type '{}'. -+index.js(2,31): error TS8010: Type annotations can only be used in TypeScript files. +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,34): error TS8010: Type annotations can only be used in TypeScript files. +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 (8 errors) ==== ++==== index.js (6 errors) ==== + First.Item = class I {} + ~~~~ +!!! error TS2339: Property 'Item' does not exist on type '{}'. + Common.Object = class extends First.Item {} + ~~~~~~ +!!! error TS2339: Property 'Object' does not exist on type '{}'. -+ ~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ +!!! error TS2339: Property 'Item' does not exist on type '{}'. + + Workspace.Object = class extends Common.Object {} + ~~~~~~ +!!! error TS2339: Property 'Object' does not exist on type '{}'. -+ ~~~~~~~~~~~~~ -+!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~~~ +!!! error TS2339: Property 'Object' does not exist on type '{}'. + From 60db541a80f9279f7682a6552a5adad638e03a51 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 21 Jul 2025 19:33:09 +0000 Subject: [PATCH 31/31] Fix false positive error on ternary operators in JavaScript files Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/parser/js_diagnostics.go | 6 +- .../compiler/jsFileMethodOverloads.errors.txt | 53 ----------------- .../jsFileMethodOverloads2.errors.txt | 50 ---------------- .../jsFileMethodOverloads.errors.txt.diff | 57 ------------------- .../jsFileMethodOverloads2.errors.txt.diff | 54 ------------------ 5 files changed, 5 insertions(+), 215 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff diff --git a/internal/parser/js_diagnostics.go b/internal/parser/js_diagnostics.go index d2f749dfff..42c8e7b79d 100644 --- a/internal/parser/js_diagnostics.go +++ b/internal/parser/js_diagnostics.go @@ -40,8 +40,12 @@ func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnosticsWorker(node *ast.Node) bo return false } - // Check for question tokens (optional markers) - these are always illegal in JS + // Check for question tokens (optional markers) - but exclude ternary operators if node.Kind == ast.KindQuestionToken { + // Skip if this is part of a conditional expression (ternary operator) - valid in JS + if parent.Kind == ast.KindConditionalExpression { + return false + } // Skip if this is in an object literal method which already gets a grammar error if parent.Kind == ast.KindMethodDeclaration && parent.Parent.Kind == ast.KindObjectLiteralExpression { return false diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt deleted file mode 100644 index 7a57869ffa..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads.errors.txt +++ /dev/null @@ -1,53 +0,0 @@ -jsFileMethodOverloads.js(44,15): error TS8009: The '?' modifier can only be used in TypeScript files. - - -==== jsFileMethodOverloads.js (1 errors) ==== - /** - * @template T - */ - class Example { - /** - * @param {T} value - */ - constructor(value) { - this.value = value; - } - - /** - * @overload - * @param {Example} this - * @returns {'number'} - */ - /** - * @overload - * @param {Example} this - * @returns {'string'} - */ - /** - * @returns {string} - */ - getTypeName() { - return typeof this.value; - } - - /** - * @template U - * @overload - * @param {(y: T) => U} fn - * @returns {U} - */ - /** - * @overload - * @returns {T} - */ - /** - * @param {(y: T) => unknown} [fn] - * @returns {unknown} - */ - transform(fn) { - return fn ? fn(this.value) : this.value; - ~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt deleted file mode 100644 index 78e37a5fdf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.errors.txt +++ /dev/null @@ -1,50 +0,0 @@ -jsFileMethodOverloads2.js(41,15): error TS8009: The '?' modifier can only be used in TypeScript files. - - -==== jsFileMethodOverloads2.js (1 errors) ==== - // Also works if all @overload tags are combined in one comment. - /** - * @template T - */ - class Example { - /** - * @param {T} value - */ - constructor(value) { - this.value = value; - } - - /** - * @overload - * @param {Example} this - * @returns {'number'} - * - * @overload - * @param {Example} this - * @returns {'string'} - * - * @returns {string} - */ - getTypeName() { - return typeof this.value; - } - - /** - * @template U - * @overload - * @param {(y: T) => U} fn - * @returns {U} - * - * @overload - * @returns {T} - * - * @param {(y: T) => unknown} [fn] - * @returns {unknown} - */ - transform(fn) { - return fn ? fn(this.value) : this.value; - ~ -!!! error TS8009: The '?' modifier can only be used in TypeScript files. - } - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff deleted file mode 100644 index 4fbe8b42ce..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads.errors.txt.diff +++ /dev/null @@ -1,57 +0,0 @@ ---- old.jsFileMethodOverloads.errors.txt -+++ new.jsFileMethodOverloads.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsFileMethodOverloads.js(44,15): error TS8009: The '?' modifier can only be used in TypeScript files. -+ -+ -+==== jsFileMethodOverloads.js (1 errors) ==== -+ /** -+ * @template T -+ */ -+ class Example { -+ /** -+ * @param {T} value -+ */ -+ constructor(value) { -+ this.value = value; -+ } -+ -+ /** -+ * @overload -+ * @param {Example} this -+ * @returns {'number'} -+ */ -+ /** -+ * @overload -+ * @param {Example} this -+ * @returns {'string'} -+ */ -+ /** -+ * @returns {string} -+ */ -+ getTypeName() { -+ return typeof this.value; -+ } -+ -+ /** -+ * @template U -+ * @overload -+ * @param {(y: T) => U} fn -+ * @returns {U} -+ */ -+ /** -+ * @overload -+ * @returns {T} -+ */ -+ /** -+ * @param {(y: T) => unknown} [fn] -+ * @returns {unknown} -+ */ -+ transform(fn) { -+ return fn ? fn(this.value) : this.value; -+ ~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ } -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff deleted file mode 100644 index 0a49b2e201..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.errors.txt.diff +++ /dev/null @@ -1,54 +0,0 @@ ---- old.jsFileMethodOverloads2.errors.txt -+++ new.jsFileMethodOverloads2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsFileMethodOverloads2.js(41,15): error TS8009: The '?' modifier can only be used in TypeScript files. -+ -+ -+==== jsFileMethodOverloads2.js (1 errors) ==== -+ // Also works if all @overload tags are combined in one comment. -+ /** -+ * @template T -+ */ -+ class Example { -+ /** -+ * @param {T} value -+ */ -+ constructor(value) { -+ this.value = value; -+ } -+ -+ /** -+ * @overload -+ * @param {Example} this -+ * @returns {'number'} -+ * -+ * @overload -+ * @param {Example} this -+ * @returns {'string'} -+ * -+ * @returns {string} -+ */ -+ getTypeName() { -+ return typeof this.value; -+ } -+ -+ /** -+ * @template U -+ * @overload -+ * @param {(y: T) => U} fn -+ * @returns {U} -+ * -+ * @overload -+ * @returns {T} -+ * -+ * @param {(y: T) => unknown} [fn] -+ * @returns {unknown} -+ */ -+ transform(fn) { -+ return fn ? fn(this.value) : this.value; -+ ~ -+!!! error TS8009: The '?' modifier can only be used in TypeScript files. -+ } -+ } -+ \ No newline at end of file