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/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/program.go b/internal/compiler/program.go index 1786078277..172ff45943 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -865,6 +865,11 @@ 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 jsSyntacticDiagnostics := sourceFile.JSSyntacticDiagnostics(); len(jsSyntacticDiagnostics) > 0 { + return slices.Concat(jsSyntacticDiagnostics, sourceFile.Diagnostics()) + } return sourceFile.Diagnostics() } diff --git a/internal/parser/js_diagnostics.go b/internal/parser/js_diagnostics.go new file mode 100644 index 0000000000..42c8e7b79d --- /dev/null +++ b/internal/parser/js_diagnostics.go @@ -0,0 +1,469 @@ +package parser + +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 + walkNodeForJSDiagnostics func(node *ast.Node) bool +} + +// getJSSyntacticDiagnosticsForFile returns diagnostics for TypeScript-only constructs in JavaScript files +func getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { + visitor := &jsDiagnosticsVisitor{ + sourceFile: sourceFile, + } + visitor.walkNodeForJSDiagnostics = visitor.walkNodeForJSDiagnosticsWorker + + // Walk the entire AST to find TypeScript-only constructs + sourceFile.ForEachChild(visitor.walkNodeForJSDiagnostics) + + return visitor.diagnostics +} + +// walkNodeForJSDiagnostics walks the AST and collects diagnostics for TypeScript-only constructs +func (v *jsDiagnosticsVisitor) walkNodeForJSDiagnosticsWorker(node *ast.Node) bool { + if node == nil { + 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 false + } + + // 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 + } + 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 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 + // 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: + // 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 + 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 + 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 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 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 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 false + } + + case ast.KindImportEqualsDeclaration: + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.X_import_can_only_be_used_in_TypeScript_files)) + 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 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 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 false + + case ast.KindModuleDeclaration: + moduleKeyword := "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 false + + case ast.KindTypeAliasDeclaration: + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)) + 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 false + + case ast.KindNonNullExpression: + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)) + 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 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 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 false + } + } + + // Check for type parameters, type arguments, and modifiers + v.checkTypeParametersAndModifiers(node) + + // Recursively walk children + node.ForEachChild(v.walkNodeForJSDiagnostics) + + 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) { + // 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)) + } + + // Check type arguments + 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 + v.checkModifiers(node) +} + +// 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 nil + } + + var typeParameters *ast.NodeList + + // 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 { + return nil + } + + // Check if all type parameters are reparsed (JSDoc originated) + // 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 typeParameters // Found non-reparsed type parameters +} + +// 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 +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 + + // 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() + } + + if typeArguments == nil { + return nil + } + + // Check if all type arguments are reparsed (JSDoc originated) + // 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 typeArguments // Found non-reparsed type arguments +} + +// checkModifiers checks for TypeScript-only modifiers on various declaration types +func (v *jsDiagnosticsVisitor) checkModifiers(node *ast.Node) { + modifiers := node.Modifiers() + if modifiers == nil { + return + } + + // Handle different types of nodes with different modifier rules + switch node.Kind { + case ast.KindVariableStatement: + v.checkModifierList(modifiers, true) // const is valid for variable statements + case ast.KindPropertyDeclaration: + v.checkPropertyModifiers(modifiers) + case ast.KindParameter: + v.checkParameterModifiers(modifiers) + default: + v.checkModifierList(modifiers, false) // const is not valid for other declarations + } +} + +// 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 { + // Skip reparsed modifiers (from JSDoc) but continue checking others + 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 { + // Skip reparsed modifiers (from JSDoc) but continue checking others + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + // 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: + // 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))) + } + } +} + +// checkParameterModifiers checks parameter modifiers for TypeScript-only constructs +func (v *jsDiagnosticsVisitor) checkParameterModifiers(modifiers *ast.ModifierList) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Skip reparsed modifiers (from JSDoc) but continue checking others + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + // 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)) + } +} + +// 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, scanner.TokenToString(modifier.Kind))) + case ast.KindStaticKeyword, ast.KindExportKeyword, ast.KindDefaultKeyword, ast.KindAccessorKeyword: + // These are valid in JavaScript + } +} + +// 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...) +} + +// 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/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 { diff --git a/internal/scanner/utilities.go b/internal/scanner/utilities.go index 06ba7cf666..076523ac9e 100644 --- a/internal/scanner/utilities.go +++ b/internal/scanner/utilities.go @@ -65,3 +65,79 @@ 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()) + } + 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()) +} diff --git a/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt new file mode 100644 index 0000000000..0a7a1231e2 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsSyntacticDiagnostics.errors.txt @@ -0,0 +1,223 @@ +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,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: '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'. +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(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(51,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +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,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,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,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. +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,11): 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 { + ~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + name: string; + age: number; + } + + // 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 + } + + // Module declarations should be flagged as errors + module MyModule { + ~~~~~~~~ +!!! error TS8006: 'module' declarations can only be used in TypeScript files. + export var x = 1; + } + + // Namespace declarations should be flagged as errors + namespace MyNamespace { + ~~~~~~~~~~~ +!!! error TS8006: 'namespace' declarations can only be used in TypeScript files. + export var y = 2; + } + + // 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 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; + 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 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; + } + + // 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 { + ~~~~~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + name: string; + } \ 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 index a799d98368..974618352e 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=false).errors.txt @@ -1,5 +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 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. @@ -7,7 +9,7 @@ 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 (2 errors) ==== import { A } from './a.js'; export class B1 extends A { @@ -17,12 +19,16 @@ error TS5055: Cannot write file 'b.js' because it would overwrite input file. } export class B2 extends A { + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } } 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/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt index 1cc1d93aa0..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,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(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. b.js(15,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -9,7 +11,7 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' ==== 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 { @@ -21,6 +23,8 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' } export class B2 extends A { + ~~~~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. constructor() { super(); } @@ -28,6 +32,8 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' 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/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt index ea03590841..bf5a012e3d 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount2(strict=false).errors.txt @@ -1,5 +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(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,7 +9,7 @@ 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 (2 errors) ==== import { A } from './a.js'; /** @extends {A} */ @@ -19,6 +21,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 +30,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..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,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 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,7 +11,7 @@ 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 (4 errors) ==== import { A } from './a.js'; /** @extends {A} */ @@ -23,6 +25,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 +35,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/ambientPropertyDeclarationInJs.errors.txt b/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt index 1ce833f6c1..c23b932b5f 100644 --- a/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/ambientPropertyDeclarationInJs.errors.txt @@ -1,8 +1,10 @@ /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(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 = {}; @@ -11,6 +13,10 @@ } 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/decoratorInJsFile.errors.txt b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt new file mode 100644 index 0000000000..520dc4d9d0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile.errors.txt @@ -0,0 +1,12 @@ +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. + + } + } \ 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..520dc4d9d0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/decoratorInJsFile1.errors.txt @@ -0,0 +1,12 @@ +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. + + } + } \ 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..decd2d3d86 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(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. 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 TS8010: Type annotations can only be used in TypeScript files. ==== BaseA.js (0 errors) ==== @@ -10,24 +14,32 @@ 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 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; } } -==== SubB.js (0 errors) ==== +==== SubB.js (1 errors) ==== import SubA from './SubA'; import BaseB from './BaseB'; export default class SubB extends BaseB { + ~~~~~~~~~~~ +!!! error TS8010: Type annotations 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 82c630fced..92901a40cc 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,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 (4 errors) ==== class B extends A {} ~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. @@ -21,5 +22,7 @@ /** @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/jsFileCompilationAbstractModifier.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt index dd02778d17..fecf44cbf1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt @@ -1,10 +1,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. !!! 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) ==== 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/submodule/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt index 37eb955360..8861140309 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt @@ -1,8 +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,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 (0 errors) ==== - declare var v; \ No newline at end of file +==== 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..c2eefe3d28 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt @@ -0,0 +1,10 @@ +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/jsFileCompilationEnumSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt index c5ff5ff9ac..bf1bafd05c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationEnumSyntax.errors.txt @@ -1,8 +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,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 (0 errors) ==== - enum E { } \ No newline at end of file +==== 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 index f141ba456e..8c14639397 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt @@ -1,8 +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,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 (0 errors) ==== - export = b; \ No newline at end of file +==== 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..1c10528f03 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt @@ -0,0 +1,8 @@ +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/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt index 553b43effa..842119639a 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt @@ -1,8 +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,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 (0 errors) ==== - class C implements D { } \ No newline at end of file +==== 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 index b172ac39e3..062ec765e5 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationImportEqualsSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationImportEqualsSyntax.errors.txt @@ -1,8 +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,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 (0 errors) ==== - import a = b; \ No newline at end of file +==== 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 index e2fb064081..e4d6397f82 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationInterfaceSyntax.errors.txt @@ -1,8 +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,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 (0 errors) ==== - interface I { } \ No newline at end of file +==== 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..470da0781c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt @@ -0,0 +1,10 @@ +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/jsFileCompilationModuleSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt index 06a0de832e..efda02b1ad 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationModuleSyntax.errors.txt @@ -1,8 +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,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 (0 errors) ==== - module M { } \ No newline at end of file +==== 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 index ac3f77f625..32c9cb870e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationNonNullAssertion.errors.txt @@ -1,11 +1,14 @@ error TS5055: Cannot write file '/src/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 TS5102: Option 'outFile' has been removed. Please remove it from your configuration. +/src/a.js(1,1): error TS8013: Non-null assertions can only be used in TypeScript files. !!! error TS5055: Cannot write file '/src/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. !!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== /src/a.js (0 errors) ==== +==== /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/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/compiler/jsFileCompilationOptionalParameter.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalParameter.errors.txt index 4bfa438887..120e92667f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalParameter.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationOptionalParameter.errors.txt @@ -1,8 +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,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 (0 errors) ==== - function F(p?) { } \ No newline at end of file +==== 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/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/jsFileCompilationPublicParameterModifier.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicParameterModifier.errors.txt index c1570e779e..f08d7593a2 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicParameterModifier.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationPublicParameterModifier.errors.txt @@ -1,8 +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,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 (0 errors) ==== - class C { constructor(public x) { }} \ No newline at end of file +==== 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 index a3f6c03f55..d9b9da98fb 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt @@ -1,8 +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,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 (0 errors) ==== - function F(): number { } \ No newline at end of file +==== 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/jsFileCompilationTypeAliasSyntax.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt index d2178618fc..4eb4eea95e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAliasSyntax.errors.txt @@ -1,8 +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,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 (0 errors) ==== - type a = b; \ No newline at end of file +==== 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/jsFileCompilationTypeAssertions.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt index e176d8159b..852f133911 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeAssertions.errors.txt @@ -1,6 +1,7 @@ error TS5055: Cannot write file '/src/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 TS5102: Option 'outFile' has been removed. Please remove it from your configuration. +/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; ~~~~~~ !!! 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 index 555cd30eaa..15ff6e7d06 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeOfParameter.errors.txt @@ -1,8 +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,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 (0 errors) ==== - function F(a: number) { } \ No newline at end of file +==== 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 index 4711eb262c..31366a04b9 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt @@ -1,8 +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,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 (0 errors) ==== - class C { } \ No newline at end of file +==== 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..9adc8c87bb --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt @@ -0,0 +1,8 @@ +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 8c0597d88c..831e7c8003 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt @@ -1,8 +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,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 (0 errors) ==== - function F() { } \ No newline at end of file +==== 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 index 2a6c537beb..80f421c50d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt @@ -1,8 +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,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 (0 errors) ==== - var v: () => number; \ No newline at end of file +==== 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/jsdocTypedefNoCrash2.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt new file mode 100644 index 0000000000..6239c728e6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypedefNoCrash2.errors.txt @@ -0,0 +1,12 @@ +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 {{ + * }} + */ + export const foo = 5; \ 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..993845bad6 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(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'. @@ -112,13 +113,15 @@ 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/thisAssignmentInNamespaceDeclaration1.errors.txt b/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt index 914c08744a..3824bc8325 100644 --- a/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt @@ -1,16 +1,22 @@ +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(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. -==== 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. } -==== 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. 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..4929a92af4 100644 --- a/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt @@ -1,8 +1,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(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,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 +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 (4 errors) ==== +==== first.js (6 errors) ==== /** * @constructor * @param {number} numberOxen @@ -23,12 +26,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() } @@ -105,7 +112,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 +124,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/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/exportSpecifiers_js.errors.txt b/testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt new file mode 100644 index 0000000000..cb436125a0 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/exportSpecifiers_js.errors.txt @@ -0,0 +1,9 @@ +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 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/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/grammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt index 599518b3b4..bf1009be1c 100644 --- a/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/grammarErrors.errors.txt @@ -1,6 +1,8 @@ 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(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,9 +20,13 @@ error TS5056: Cannot write file '/a.js' because it would be overwritten by multi ~~~~~~~~~~~~~~~~ !!! 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..c934c298b2 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/importSpecifiers_js.errors.txt @@ -0,0 +1,11 @@ +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"; + ~~~~~~ +!!! 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 new file mode 100644 index 0000000000..2f4d5597f9 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.errors.txt @@ -0,0 +1,200 @@ +index.js(173,24): error TS8010: Type annotations 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 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 {} + + 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..8316b17bbe --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt @@ -0,0 +1,184 @@ +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,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(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(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(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(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(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(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(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(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(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 (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 + + 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. + } + + export class N extends M { + ~ +!!! error TS8004: Type parameter declarations 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. + } + + 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 {} + + export class Q extends O { + [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 { + [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 { + [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 {} + + + export class V extends T { + [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 { + [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 { + [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 {} + + export class AA extends Y { + [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 { + [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 { + [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/jsDeclarationsEnums.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt new file mode 100644 index 0000000000..05318558dd --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsEnums.errors.txt @@ -0,0 +1,101 @@ +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) ==== + // 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. + Member + } + + 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 + } + + export enum H { + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + A = "a", + B = "b" + } + + export enum I { + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + A = "a", + B = 0, + C + } + + export const enum J { + ~ +!!! error TS8006: 'enum' declarations can only be used in TypeScript files. + A = 1, + B, + C + } + + 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 { + ~ +!!! 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 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/jsDeclarationsExportFormsErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt index 8bc742d706..b62dd98da9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportFormsErr.errors.txt @@ -1,12 +1,18 @@ +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. 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/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/jsDeclarationsInterfaces.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt new file mode 100644 index 0000000000..2e672eb09b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt @@ -0,0 +1,200 @@ +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) ==== + // 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 {} + ~ +!!! 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; + } + + export interface L extends K { + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + y: string; + } + + export interface M { + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + field: T; + } + + export interface N extends M { + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + other: U; + } + + export interface O { + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + [idx: string]: string; + } + + 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"; + } + + export interface R extends O { + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + [idx: number]: "ok"; + } + + 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 { + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + [idx: number]: string; + } + + 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; + } + + export interface W extends T { + ~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + [idx: number]: "ok"; + } + + 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 { + ~ +!!! 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 {} + ~ +!!! 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 { + ~~ +!!! error TS8006: 'interface' declarations can only be used in TypeScript files. + [idx: number]: {x: 0, y: 0}; + } + + 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 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..146844daa3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences4.errors.txt @@ -0,0 +1,23 @@ +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 { + ~ +!!! 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 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/nodeModulesAllowJs1(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJs1(module=node16).errors.txt index 7cbf2626ec..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,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(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(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(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(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(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'? @@ -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(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(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(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(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(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'? @@ -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(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(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(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(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(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'? @@ -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"; @@ -190,24 +223,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // 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 +314,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"; ~~~~~~~~~~~~ @@ -333,24 +388,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // 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 +479,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"; @@ -475,24 +552,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // 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..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,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(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(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(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(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(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'? @@ -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(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(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(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(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(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'? @@ -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(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(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(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(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(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'? @@ -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"; @@ -190,24 +223,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // 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 +314,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"; ~~~~~~~~~~~~ @@ -333,24 +388,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // 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 +479,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"; @@ -475,24 +552,46 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // 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..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,3 +1,14 @@ +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. @@ -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(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. @@ -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(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. @@ -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"; @@ -164,16 +197,38 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // 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 +278,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"; @@ -275,16 +330,38 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // 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 +411,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"; @@ -407,16 +484,38 @@ index.mjs(84,21): error TS2835: Relative import paths need explicit file extensi // 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..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,21 +1,27 @@ 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(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 (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 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 b80fa4321a..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,21 +1,27 @@ 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(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 (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 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 b80fa4321a..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,21 +1,27 @@ 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(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 (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 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 new file mode 100644 index 0000000000..476c47f703 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt @@ -0,0 +1,49 @@ +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. +==== 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..476c47f703 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt @@ -0,0 +1,49 @@ +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. +==== 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..476c47f703 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt @@ -0,0 +1,49 @@ +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. +==== 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..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,33 +1,45 @@ +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(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(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(5,1): 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..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,33 +1,45 @@ +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(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(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(5,1): 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..2a46b9875d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt @@ -0,0 +1,46 @@ +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. + 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/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_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/parserArrowFunctionExpression10.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt index 7982f84869..e157b6aabc 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.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,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'. @@ -8,12 +10,16 @@ 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 (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'. + ~ +!!! 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/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 fdda202361..77c9bc8d38 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt @@ -1,15 +1,21 @@ 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 (2 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'. + ~~~ +!!! 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..5fd3cfa6fe 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt @@ -1,4 +1,9 @@ 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. +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'. @@ -6,10 +11,20 @@ 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 (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. + ~ +!!! 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..27cbfdb997 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt @@ -0,0 +1,14 @@ +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 (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. + +==== 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..5f289ec61a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt @@ -0,0 +1,17 @@ +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 (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. + +==== 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..1f14e32a57 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt @@ -1,6 +1,8 @@ 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. 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'. @@ -8,14 +10,18 @@ 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 (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'. ~ !!! 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/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 1b08565cd6..e5928e96f1 100644 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt @@ -5,11 +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. @@ -26,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. @@ -59,8 +66,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(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. @@ -94,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 (94 errors) ==== +==== plainJSGrammarErrors.js (103 errors) ==== class C { // #private mistakes q = #unbound @@ -131,9 +140,13 @@ 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() { + ~~~~~ +!!! error TS8009: The 'const' modifier can only be used in TypeScript files. ~ !!! error TS1248: A class member cannot have the 'const' keyword. return 12 @@ -148,6 +161,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. @@ -207,15 +222,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. @@ -225,6 +246,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 ~~~~~ @@ -325,12 +348,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. 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/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/typeSatisfaction_js.errors.txt b/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt index c7b421034d..20288daecd 100644 --- a/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeSatisfaction_js.errors.txt @@ -1,11 +1,14 @@ error TS5055: Cannot write file '/src/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 TS5102: Option 'outFile' has been removed. Please remove it from your configuration. +/src/a.js(1,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files. !!! error TS5055: Cannot write file '/src/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. !!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -==== /src/a.js (0 errors) ==== +==== /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/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/ambientPropertyDeclarationInJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff deleted file mode 100644 index 188fc9829d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/ambientPropertyDeclarationInJs.errors.txt.diff +++ /dev/null @@ -1,25 +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(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 =@@ - } - - 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 \ 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 01b25dd180..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 (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 349ad2c6c6..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 (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 4c2ce91c3f..8c07440833 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff @@ -1,48 +1,22 @@ --- 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,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 -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. + 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 TS8010: Type annotations 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 { - } --==== BaseB.js (6 errors) ==== -+==== BaseB.js (3 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; - } - } --==== SubB.js (1 errors) ==== -+==== SubB.js (0 errors) ==== +@@= skipped -34, +34 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/jsExtendsImplicitAny.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsExtendsImplicitAny.errors.txt.diff index 135c21c283..e54ee4f87b 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,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 (4 errors) ==== + class B extends A {} + ~ + !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. new B().x; /** @augments A */ @@ -25,5 +32,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/jsFileCompilationAbstractModifier.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff deleted file mode 100644 index ceba0f9db3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAbstractModifier.errors.txt.diff +++ /dev/null @@ -1,20 +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 (0 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/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt.diff deleted file mode 100644 index b6b3c82d97..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationAmbientVarDeclarationSyntax.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationAmbientVarDeclarationSyntax.errors.txt -+++ new.jsFileCompilationAmbientVarDeclarationSyntax.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 '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) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff deleted file mode 100644 index 6c10af799b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationConstructorOverloadSyntax.errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- 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 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 deleted file mode 100644 index 216b463d40..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationEnumSyntax.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationEnumSyntax.errors.txt -+++ new.jsFileCompilationEnumSyntax.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,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 errors) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt.diff deleted file mode 100644 index 530f0d0ab4..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationExportAssignmentSyntax.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationExportAssignmentSyntax.errors.txt -+++ new.jsFileCompilationExportAssignmentSyntax.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 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) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff deleted file mode 100644 index 0251a5ce1e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationFunctionOverloadSyntax.errors.txt.diff +++ /dev/null @@ -1,12 +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 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/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff deleted file mode 100644 index a710e3349d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationHeritageClauseSyntaxOfClass.errors.txt -+++ new.jsFileCompilationHeritageClauseSyntaxOfClass.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 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 errors) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationImportEqualsSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationImportEqualsSyntax.errors.txt.diff deleted file mode 100644 index 36f4f35e3f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationImportEqualsSyntax.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationImportEqualsSyntax.errors.txt -+++ new.jsFileCompilationImportEqualsSyntax.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 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) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff deleted file mode 100644 index b7090eb786..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationInterfaceSyntax.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationInterfaceSyntax.errors.txt -+++ new.jsFileCompilationInterfaceSyntax.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,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 errors) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff deleted file mode 100644 index f7e96404d2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationMethodOverloadSyntax.errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- 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 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 deleted file mode 100644 index fea4d1f2ef..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationModuleSyntax.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationModuleSyntax.errors.txt -+++ new.jsFileCompilationModuleSyntax.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,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 errors) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationNonNullAssertion.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationNonNullAssertion.errors.txt.diff index 5599398c6c..774688f7f7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationNonNullAssertion.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationNonNullAssertion.errors.txt.diff @@ -1,20 +1,15 @@ --- 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) ==== +error TS5055: Cannot write file '/src/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 TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -+ -+ + /src/a.js(1,1): error TS8013: Non-null assertions can only be used in TypeScript files. + + +!!! error TS5055: Cannot write file '/src/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. +!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -+==== /src/a.js (0 errors) ==== + ==== /src/a.js (1 errors) ==== 0! -- ~~ --!!! error TS8013: Non-null assertions 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/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/compiler/jsFileCompilationOptionalParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalParameter.errors.txt.diff deleted file mode 100644 index 1449369838..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationOptionalParameter.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationOptionalParameter.errors.txt -+++ new.jsFileCompilationOptionalParameter.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,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) ==== -+==== a.js (0 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/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/jsFileCompilationPublicParameterModifier.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicParameterModifier.errors.txt.diff deleted file mode 100644 index 9563e07b1a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationPublicParameterModifier.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationPublicParameterModifier.errors.txt -+++ new.jsFileCompilationPublicParameterModifier.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,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) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff deleted file mode 100644 index 2fbcaadba2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationReturnTypeSyntaxOfFunction.errors.txt -+++ new.jsFileCompilationReturnTypeSyntaxOfFunction.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,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 errors) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff deleted file mode 100644 index c78a471eb3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAliasSyntax.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationTypeAliasSyntax.errors.txt -+++ new.jsFileCompilationTypeAliasSyntax.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,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 errors) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff index 89dc3ac954..c859e79ebe 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeAssertions.errors.txt.diff @@ -1,22 +1,17 @@ --- 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. +error TS5055: Cannot write file '/src/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 TS5102: Option 'outFile' has been removed. Please remove it from your configuration. + /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; - ~~~~~~ - !!! 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 deleted file mode 100644 index caf9b849dc..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeOfParameter.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationTypeOfParameter.errors.txt -+++ new.jsFileCompilationTypeOfParameter.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,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 errors) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff deleted file mode 100644 index cf5851e510..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClass.errors.txt.diff +++ /dev/null @@ -1,15 +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. - - - !!! 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 { } -- ~ --!!! 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 eeb9c0f857..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfClassExpression.errors.txt.diff +++ /dev/null @@ -1,12 +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 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 ccebf9c041..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeParameterSyntaxOfFunction.errors.txt.diff +++ /dev/null @@ -1,15 +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. - - - !!! 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) ==== - 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/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff deleted file mode 100644 index eb1c29ba40..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileCompilationTypeSyntaxOfVar.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.jsFileCompilationTypeSyntaxOfVar.errors.txt -+++ new.jsFileCompilationTypeSyntaxOfVar.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,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 errors) ==== -+==== a.js (0 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/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff index 4d78ec0273..294da8e1b7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypedefNoCrash2.errors.txt.diff @@ -2,21 +2,23 @@ +++ 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 type foo = 5; -- ~~~ ++ ++ ++==== 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/modulePreserve4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/modulePreserve4.errors.txt.diff index 85fd403b08..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,11 @@ /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(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, +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 +57,12 @@ 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/thisAssignmentInNamespaceDeclaration1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff deleted file mode 100644 index 4989352fd0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/thisAssignmentInNamespaceDeclaration1.errors.txt.diff +++ /dev/null @@ -1,27 +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(2,5): error TS2331: 'this' cannot be referenced in a module or namespace body. - - --==== a.js (2 errors) ==== -+==== a.js (1 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. - } - --==== b.js (2 errors) ==== -+==== b.js (1 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 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..425e51b45e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/classCanExtendConstructorFunction.errors.txt.diff @@ -5,6 +5,8 @@ -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(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'. @@ -12,6 +14,7 @@ -generic.js(19,19): error TS2554: Expected 1 arguments, but got 0. -generic.js(20,32): error TS2345: Argument of type 'number' is not assignable to parameter of type '{ claim: "ignorant" | "malicious"; }'. +generic.js(9,23): error TS2507: Type '(flavour: 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,11 +34,26 @@ +second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'. + + -+==== first.js (4 errors) ==== ++==== first.js (6 errors) ==== /** * @constructor * @param {number} numberOxen -@@= skipped -36, +33 lines =@@ +@@= skipped -25, +25 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 { @@ -63,7 +81,7 @@ if (format === "xmlolololol") { throw new Error("please do not use XML. It was a joke."); } -@@= skipped -30, +27 lines =@@ +@@= skipped -41, +42 lines =@@ } var db = new Sql(); db.numberOxen = db.foonly @@ -102,7 +120,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 +130,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/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/exportSpecifiers_js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff deleted file mode 100644 index 51f38d66e6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/exportSpecifiers_js.errors.txt.diff +++ /dev/null @@ -1,13 +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 (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 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/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/grammarErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff deleted file mode 100644 index 30becf83db..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/grammarErrors.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.grammarErrors.errors.txt -+++ new.grammarErrors.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. - 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. - /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' - -@@= skipped -19, +17 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) ==== - 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 { \ 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 13191d59af..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importSpecifiers_js.errors.txt.diff +++ /dev/null @@ -1,15 +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.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/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff new file mode 100644 index 0000000000..7119e41781 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.errors.txt.diff @@ -0,0 +1,204 @@ +--- old.jsDeclarationsClasses.errors.txt ++++ new.jsDeclarationsClasses.errors.txt +@@= skipped -0, +0 lines =@@ +- ++index.js(173,24): error TS8010: Type annotations 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 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 {} ++ ++ 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..45ffc52659 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff @@ -1,140 +1,180 @@ --- 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(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(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(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(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(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(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(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(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(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(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(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(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) ==== -- // 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; -- ~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- } -- -- export class N extends M { -- ~ --!!! error TS8004: Type parameter declarations can only be used in TypeScript files. ++index.js(68,20): error TS8010: Type annotations can only be used in TypeScript files. ++ ++ ++==== 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, +51 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. -- 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. + 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 {} +@@= 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. + } + + export class R extends O { + [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 { + [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 {} +@@= 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. + } + + export class W extends T { + [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 { + [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 -21, +29 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 {} +@@= 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. + } + + export class BB extends Y { + [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 { + [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/jsDeclarationsEnums.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff deleted file mode 100644 index e00f7c667e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsEnums.errors.txt.diff +++ /dev/null @@ -1,105 +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 (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. -- Member -- } -- -- 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 -- } -- -- export enum H { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- A = "a", -- B = "b" -- } -- -- export enum I { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- A = "a", -- B = 0, -- C -- } -- -- export const enum J { -- ~ --!!! error TS8006: 'enum' declarations can only be used in TypeScript files. -- A = 1, -- B, -- C -- } -- -- 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 { -- ~ --!!! 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 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/jsDeclarationsExportFormsErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff index fad73826d0..d387876f66 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportFormsErr.errors.txt.diff @@ -1,23 +1,15 @@ --- 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(2,1): error TS8003: 'export =' 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`. 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) ==== - 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. +@@= skipped -14, +13 lines =@@ + ~~~~~~~~~~~~ + !!! 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/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/jsDeclarationsInterfaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff index 604789c684..d8f703a957 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff @@ -1,216 +1,52 @@ --- 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) ==== -- // 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 {} -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- export { G }; ++==== 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 + +@@= skipped -42, +42 lines =@@ + !!! 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 {} -- ~~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- -- export { HH as H }; + + interface HH {} + ~~ + !!! 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 {} -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- export { I as II }; + + export interface I {} + ~ + !!! 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 {} -- ~ --!!! 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 { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- y: string; -- } -- -- export interface M { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- field: T; -- } -- -- export interface N extends M { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- other: U; -- } -- -- export interface O { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: string]: string; -- } -- -- 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"; -- } -- -- export interface R extends O { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: number]: "ok"; -- } -- -- 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 { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: number]: string; -- } -- -- 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; -- } -- -- export interface W extends T { -- ~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: number]: "ok"; -- } -- -- 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 { -- ~ --!!! 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 {} -- ~ --!!! 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 { -- ~~ --!!! error TS8006: 'interface' declarations can only be used in TypeScript files. -- [idx: number]: {x: 0, y: 0}; -- } -- -- 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 + export interface J {} + ~ + !!! 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 deleted file mode 100644 index a75e868ac2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeReferences4.errors.txt.diff +++ /dev/null @@ -1,27 +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 (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 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/nodeModulesAllowJs1(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff deleted file mode 100644 index e443064e79..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node16).errors.txt.diff +++ /dev/null @@ -1,236 +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(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(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(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(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(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 =@@ - 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(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(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(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(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(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 =@@ - 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(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(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(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(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(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 =@@ - - // 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; -@@= 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 =@@ - - // 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; -@@= 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 =@@ - - // 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; \ 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 aff003ddc2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=node18).errors.txt.diff +++ /dev/null @@ -1,236 +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(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(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(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(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(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 =@@ - 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(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(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(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(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(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 =@@ - 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(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(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(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(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(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 =@@ - - // 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; -@@= 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 =@@ - - // 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; -@@= 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 =@@ - - // 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; \ 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 f3b05ae21c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJs1(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,197 +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(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 =@@ - 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(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 =@@ - 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(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 =@@ - - // 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; -@@= 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 =@@ - - // 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; -@@= 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 =@@ - - // 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; \ 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..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 @@ -4,34 +4,9 @@ -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(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) ==== - // 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) ==== - // 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. - ==== 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 b1a763b122..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 @@ -4,34 +4,9 @@ -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(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) ==== - // 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) ==== - // 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. - ==== 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 29f6faa7d2..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 @@ -4,34 +4,9 @@ -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(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) ==== - // 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) ==== - // 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. - ==== 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 fe0f2883f0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node16).errors.txt.diff +++ /dev/null @@ -1,53 +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. -- -- --==== 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/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 aa38396f6b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=node18).errors.txt.diff +++ /dev/null @@ -1,53 +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. -- -- --==== 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/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 6e1f15e324..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,53 +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. -- -- --==== 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/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 31b8fd889e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt.diff +++ /dev/null @@ -1,52 +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(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. - 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(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"; - ~~~~~~~~~~~~~ - !!! 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 (3 errors) ==== -+==== index.js (1 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"); \ 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 8ab98c1b2e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=node18).errors.txt.diff +++ /dev/null @@ -1,52 +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(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. - 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(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"; - ~~~~~~~~~~~~~ - !!! 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 (3 errors) ==== -+==== index.js (1 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"); \ 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 4c5b8ad1b8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,50 +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. -- -- --==== 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/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_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/parserArrowFunctionExpression10.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff index d76c5a0954..5f12433ec5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff @@ -2,24 +2,21 @@ +++ 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,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 =@@ +@@= skipped -8, +9 lines =@@ fileTs.ts(1,27): error TS2304: Cannot find name 'f'. -==== fileJs.js (5 errors) ==== -+==== fileJs.js (4 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'. -- ~ --!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ - !!! error TS2304: Cannot find name 'd'. - ~ \ No newline at end of file + ~ \ 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 index b4e708c936..16ad2e6db0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff @@ -2,21 +2,20 @@ +++ 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. + 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 (2 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'. -- ~~~ --!!! 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 + ~~~ \ 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..a72ae7ea65 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff @@ -2,30 +2,21 @@ +++ 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,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,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 =@@ ++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 (3 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 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 ++ ~ ++!!! 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 index 7b1e6d7782..49dccdcd87 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff @@ -1,15 +1,15 @@ --- 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,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) ==== -- 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 ++==== 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 index da8b37a944..1da8ce4d72 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff @@ -1,15 +1,18 @@ --- 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,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) ==== -- 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 ++==== 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 index 5d502ccdfd..0ff4576571 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff @@ -2,27 +2,21 @@ +++ 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. - 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 =@@ + 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 (4 errors) ==== ++==== fileJs.js (6 errors) ==== a ? b : (c) : d => e // Not legal JS; "Unexpected token ':'" at last colon ~ !!! error TS2304: Cannot find name 'a'. -@@= skipped -8, +8 lines =@@ ++ ~ ++!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~ !!! 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 'e'. - \ No newline at end of file + ~ \ 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 index 56d5793373..e102f571ba 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff @@ -1,114 +1,44 @@ --- 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, +21 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 -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(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. -@@= skipped -35, +34 lines =@@ + 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 (94 errors) ==== ++==== plainJSGrammarErrors.js (103 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() { -- ~~~~~ --!!! 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 =@@ - 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 =@@ - m?() { return 12 }, - ~ +@@= skipped -245, +245 lines =@@ + cantHaveQuestionMark?: 1, + ~ !!! error TS1162: An object member cannot be declared optional. +- m?() { return 12 }, - ~ --!!! error TS8009: The '?' modifier can only be used in TypeScript files. +-!!! 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/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/typeSatisfaction_js.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff index 05a8be7c26..8dce7333c0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeSatisfaction_js.errors.txt.diff @@ -1,20 +1,15 @@ --- 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 errors) ==== +error TS5055: Cannot write file '/src/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 TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -+ -+ + /src/a.js(1,29): error TS8037: Type satisfaction expressions can only be used in TypeScript files. + + +!!! error TS5055: Cannot write file '/src/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. +!!! error TS5102: Option 'outFile' has been removed. Please remove it from your configuration. -+==== /src/a.js (0 errors) ==== + ==== /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 + ~ \ 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..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 =@@ } 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