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..41acb70b20 --- /dev/null +++ b/internal/parser/js_diagnostics.go @@ -0,0 +1,522 @@ +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 + } + + // Handle specific parent-child relationships first + switch parent.Kind { + case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: + // Check for question token (optional markers) + if parent.Kind == ast.KindParameter && parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().QuestionToken == node { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) + return false + } + if parent.Kind == ast.KindPropertyDeclaration && parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().PostfixToken == node { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) + return false + } + if parent.Kind == ast.KindMethodDeclaration && parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().PostfixToken == node { + if node.Kind == ast.KindExclamationToken && parent.Parent.Kind == ast.KindObjectLiteralExpression { + // This already gets a grammar error. + return false + } + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.Kind))) + return false + } + fallthrough + case ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, + ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindVariableDeclaration: + // Check for type annotations + if v.isTypeAnnotation(parent, node) { + v.diagnostics = append(v.diagnostics, v.createDiagnosticForNode(node, diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)) + 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 +} + +// isTypeAnnotation checks if a node is a type annotation in relation to its parent +func (v *jsDiagnosticsVisitor) isTypeAnnotation(parent *ast.Node, node *ast.Node) bool { + switch parent.Kind { + case ast.KindFunctionDeclaration: + return parent.AsFunctionDeclaration() != nil && parent.AsFunctionDeclaration().Type == node + case ast.KindFunctionExpression: + return parent.AsFunctionExpression() != nil && parent.AsFunctionExpression().Type == node + case ast.KindArrowFunction: + return parent.AsArrowFunction() != nil && parent.AsArrowFunction().Type == node + case ast.KindMethodDeclaration: + return parent.AsMethodDeclaration() != nil && parent.AsMethodDeclaration().Type == node + case ast.KindGetAccessor: + return parent.AsGetAccessorDeclaration() != nil && parent.AsGetAccessorDeclaration().Type == node + case ast.KindSetAccessor: + return parent.AsSetAccessorDeclaration() != nil && parent.AsSetAccessorDeclaration().Type == node + case ast.KindConstructor: + return parent.AsConstructorDeclaration() != nil && parent.AsConstructorDeclaration().Type == node + case ast.KindVariableDeclaration: + return parent.AsVariableDeclaration() != nil && parent.AsVariableDeclaration().Type == node + case ast.KindParameter: + return parent.AsParameterDeclaration() != nil && parent.AsParameterDeclaration().Type == node + case ast.KindPropertyDeclaration: + return parent.AsPropertyDeclaration() != nil && parent.AsPropertyDeclaration().Type == node + } + return false +} + +// isSignatureDeclaration checks if a node is a signature declaration (function without body) +func (v *jsDiagnosticsVisitor) isSignatureDeclaration(node *ast.Node) bool { + switch node.Kind { + case ast.KindFunctionDeclaration: + return node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Body == nil + case ast.KindMethodDeclaration: + return node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Body == nil + case ast.KindConstructor: + return node.AsConstructorDeclaration() != nil && node.AsConstructorDeclaration().Body == nil + } + return false +} + +// checkTypeParametersAndModifiers checks for type parameters, type arguments, and modifiers +func (v *jsDiagnosticsVisitor) checkTypeParametersAndModifiers(node *ast.Node) { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return + } + + // Check type parameters + if 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 + switch node.Kind { + case ast.KindClassDeclaration: + if node.AsClassDeclaration() != nil { + typeParameters = node.AsClassDeclaration().TypeParameters + } + case ast.KindClassExpression: + if node.AsClassExpression() != nil { + typeParameters = node.AsClassExpression().TypeParameters + } + case ast.KindMethodDeclaration: + if node.AsMethodDeclaration() != nil { + typeParameters = node.AsMethodDeclaration().TypeParameters + } + case ast.KindConstructor: + if node.AsConstructorDeclaration() != nil { + typeParameters = node.AsConstructorDeclaration().TypeParameters + } + case ast.KindGetAccessor: + if node.AsGetAccessorDeclaration() != nil { + typeParameters = node.AsGetAccessorDeclaration().TypeParameters + } + case ast.KindSetAccessor: + if node.AsSetAccessorDeclaration() != nil { + typeParameters = node.AsSetAccessorDeclaration().TypeParameters + } + case ast.KindFunctionExpression: + if node.AsFunctionExpression() != nil { + typeParameters = node.AsFunctionExpression().TypeParameters + } + case ast.KindFunctionDeclaration: + if node.AsFunctionDeclaration() != nil { + typeParameters = node.AsFunctionDeclaration().TypeParameters + } + case ast.KindArrowFunction: + if node.AsArrowFunction() != nil { + typeParameters = node.AsArrowFunction().TypeParameters + } + default: + return nil + } + + if typeParameters == nil { + return nil + } + + // Check if all type parameters are reparsed (JSDoc originated) + for _, tp := range typeParameters.Nodes { + if tp.Flags&ast.NodeFlagsReparsed == 0 { + return typeParameters // Found a non-reparsed type parameter, so return the type parameters + } + } + + return nil // All type parameters are reparsed (JSDoc originated), so this is valid in JS +} + +// hasTypeParameters checks if a node has type parameters +func (v *jsDiagnosticsVisitor) hasTypeParameters(node *ast.Node) bool { + return v.getTypeParameters(node) != nil +} + +// getTypeArguments returns the type arguments for a node if it has any +func (v *jsDiagnosticsVisitor) getTypeArguments(node *ast.Node) *ast.NodeList { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return nil + } + + var typeArguments *ast.NodeList + switch node.Kind { + case ast.KindCallExpression: + if node.AsCallExpression() != nil { + typeArguments = node.AsCallExpression().TypeArguments + } + case ast.KindNewExpression: + if node.AsNewExpression() != nil { + typeArguments = node.AsNewExpression().TypeArguments + } + case ast.KindExpressionWithTypeArguments: + if node.AsExpressionWithTypeArguments() != nil { + typeArguments = node.AsExpressionWithTypeArguments().TypeArguments + } + case ast.KindJsxSelfClosingElement: + if node.AsJsxSelfClosingElement() != nil { + typeArguments = node.AsJsxSelfClosingElement().TypeArguments + } + case ast.KindJsxOpeningElement: + if node.AsJsxOpeningElement() != nil { + typeArguments = node.AsJsxOpeningElement().TypeArguments + } + case ast.KindTaggedTemplateExpression: + if node.AsTaggedTemplateExpression() != nil { + typeArguments = node.AsTaggedTemplateExpression().TypeArguments + } + } + + if typeArguments == nil { + return nil + } + + // Check if all type arguments are reparsed (JSDoc originated) + for _, ta := range typeArguments.Nodes { + if ta.Flags&ast.NodeFlagsReparsed == 0 { + return typeArguments // Found a non-reparsed type argument, so return the type arguments + } + } + + return nil // All type arguments are reparsed (JSDoc originated), so this is valid in JS +} + +// hasTypeArguments checks if a node has type arguments +func (v *jsDiagnosticsVisitor) hasTypeArguments(node *ast.Node) bool { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return false + } + + var typeArguments *ast.NodeList + switch node.Kind { + case ast.KindCallExpression: + if node.AsCallExpression() != nil { + typeArguments = node.AsCallExpression().TypeArguments + } + case ast.KindNewExpression: + if node.AsNewExpression() != nil { + typeArguments = node.AsNewExpression().TypeArguments + } + case ast.KindExpressionWithTypeArguments: + if node.AsExpressionWithTypeArguments() != nil { + typeArguments = node.AsExpressionWithTypeArguments().TypeArguments + } + case ast.KindJsxSelfClosingElement: + if node.AsJsxSelfClosingElement() != nil { + typeArguments = node.AsJsxSelfClosingElement().TypeArguments + } + case ast.KindJsxOpeningElement: + if node.AsJsxOpeningElement() != nil { + typeArguments = node.AsJsxOpeningElement().TypeArguments + } + case ast.KindTaggedTemplateExpression: + if node.AsTaggedTemplateExpression() != nil { + typeArguments = node.AsTaggedTemplateExpression().TypeArguments + } + } + + if typeArguments == nil { + return false + } + + // Check if all type arguments are reparsed (JSDoc originated) + for _, ta := range typeArguments.Nodes { + if ta.Flags&ast.NodeFlagsReparsed == 0 { + return true // Found a non-reparsed type argument, so this is a TypeScript-only construct + } + } + + return false // All type arguments are reparsed (JSDoc originated), so this is valid in JS +} + +// checkModifiers checks for TypeScript-only modifiers on various declaration types +func (v *jsDiagnosticsVisitor) checkModifiers(node *ast.Node) { + // Bail out early if this node has NodeFlagsReparsed + if node.Flags&ast.NodeFlagsReparsed != 0 { + return + } + + // Check for TypeScript-only modifiers on various declaration types + switch node.Kind { + case ast.KindVariableStatement: + if node.AsVariableStatement() != nil && node.AsVariableStatement().Modifiers() != nil { + v.checkModifierList(node.AsVariableStatement().Modifiers(), true) + } + case ast.KindPropertyDeclaration: + if node.AsPropertyDeclaration() != nil && node.AsPropertyDeclaration().Modifiers() != nil { + v.checkPropertyModifiers(node.AsPropertyDeclaration().Modifiers()) + } + case ast.KindParameter: + if node.AsParameterDeclaration() != nil && node.AsParameterDeclaration().Modifiers() != nil { + v.checkParameterModifiers(node.AsParameterDeclaration().Modifiers()) + } + case ast.KindClassDeclaration: + if node.AsClassDeclaration() != nil && node.AsClassDeclaration().Modifiers() != nil { + v.checkModifierList(node.AsClassDeclaration().Modifiers(), false) + } + case ast.KindMethodDeclaration: + if node.AsMethodDeclaration() != nil && node.AsMethodDeclaration().Modifiers() != nil { + v.checkModifierList(node.AsMethodDeclaration().Modifiers(), false) + } + case ast.KindFunctionDeclaration: + if node.AsFunctionDeclaration() != nil && node.AsFunctionDeclaration().Modifiers() != nil { + v.checkModifierList(node.AsFunctionDeclaration().Modifiers(), false) + } + } +} + +// checkModifierList checks a list of modifiers for TypeScript-only constructs +func (v *jsDiagnosticsVisitor) checkModifierList(modifiers *ast.ModifierList, isConstValid bool) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + v.checkModifier(modifier, isConstValid) + } +} + +// checkPropertyModifiers checks property modifiers for TypeScript-only constructs +func (v *jsDiagnosticsVisitor) checkPropertyModifiers(modifiers *ast.ModifierList) { + if modifiers == nil { + return + } + + for _, modifier := range modifiers.Nodes { + // Bail out early if this modifier has NodeFlagsReparsed + if modifier.Flags&ast.NodeFlagsReparsed != 0 { + continue + } + // Property modifiers allow static and accessor, but 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 { + // Bail out early if this modifier has NodeFlagsReparsed + 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 + } +} + +// 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..7e0c1775a3 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,27): error TS8011: Type arguments can only be used in TypeScript files. +b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. !!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. @@ -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 TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); } } export class B3 extends A { + ~~~~~~~~~~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); } diff --git a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt index 1cc1d93aa0..3d32450ed8 100644 --- a/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt +++ b/testdata/baselines/reference/compiler/superCallInJSWithWrongBaseTypeArgumentCount1(strict=true).errors.txt @@ -1,7 +1,9 @@ error TS5055: Cannot write file 'b.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. b.js(3,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +b.js(9,27): error TS8011: Type arguments can only be used in TypeScript files. b.js(15,25): error TS8026: Expected A type arguments; provide these with an '@extends' tag. +b.js(15,27): error TS8011: Type arguments can only be used in TypeScript files. !!! error TS5055: Cannot write file 'b.js' because it would overwrite input file. @@ -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 TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); } @@ -29,6 +33,8 @@ b.js(15,25): error TS8026: Expected A type arguments; provide these with an ' export class B3 extends A { ~~~~~~~~~~~~~~~~~ !!! error TS8026: Expected A type arguments; provide these with an '@extends' tag. + ~~~~~~~~~~~~~~ +!!! error TS8011: Type arguments can only be used in TypeScript files. constructor() { super(); } diff --git a/testdata/baselines/reference/submodule/compiler/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..a4e9026a3a 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,41): error TS8011: Type arguments 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 TS8011: Type arguments can only be used in TypeScript files. constructor() { super(SubA); } diff --git a/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt b/testdata/baselines/reference/submodule/compiler/jsFileCompilationAbstractModifier.errors.txt index 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/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/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/jsDeclarationsClassesErr.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt new file mode 100644 index 0000000000..548135e903 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassesErr.errors.txt @@ -0,0 +1,136 @@ +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 (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. + ~ +!!! 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 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/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/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/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/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..fca3c29810 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression10.errors.txt @@ -1,5 +1,6 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. 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 +9,14 @@ fileTs.ts(1,17): error TS2304: Cannot find name 'd'. fileTs.ts(1,27): error TS2304: Cannot find name 'f'. -==== fileJs.js (4 errors) ==== +==== fileJs.js (5 errors) ==== a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon ~ !!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'c'. + ~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'd'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt index fdda202361..cfe16ee6c8 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression13.errors.txt @@ -1,15 +1,18 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. fileJs.js(1,11): error TS2304: Cannot find name 'a'. +fileJs.js(1,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 (3 errors) ==== a ? () => a() : (): any => null; // Not legal JS; "Unexpected token ')'" at last paren ~ !!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'a'. + ~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ==== fileTs.ts (2 errors) ==== a ? () => a() : (): any => null; diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt index a604d5e706..8908dde1bc 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression14.errors.txt @@ -1,4 +1,8 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. +fileJs.js(1,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 +10,18 @@ fileTs.ts(1,40): error TS2304: Cannot find name 'd'. fileTs.ts(1,46): error TS2304: Cannot find name 'e'. -==== fileJs.js (3 errors) ==== +==== fileJs.js (7 errors) ==== a() ? (b: number, c?: string): void => d() : e; // Not legal JS; "Unexpected token ':'" at first colon ~ !!! error TS2304: Cannot find name 'a'. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. + ~~~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. + ~~~~ +!!! error TS8010: Type annotations can only be used in TypeScript files. ~ !!! error TS2304: Cannot find name 'd'. ~ diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt new file mode 100644 index 0000000000..8cacfbe684 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression15.errors.txt @@ -0,0 +1,11 @@ +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 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..237f9839c1 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression16.errors.txt @@ -0,0 +1,11 @@ +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 diff --git a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt index 4d437b6b6c..28091b1745 100644 --- a/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserArrowFunctionExpression17.errors.txt @@ -1,6 +1,7 @@ fileJs.js(1,1): error TS2304: Cannot find name 'a'. fileJs.js(1,5): error TS2304: Cannot find name 'b'. fileJs.js(1,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,7 +9,7 @@ fileTs.ts(1,15): error TS2304: Cannot find name 'd'. fileTs.ts(1,20): error TS2304: Cannot find name 'e'. -==== fileJs.js (4 errors) ==== +==== fileJs.js (5 errors) ==== a ? b : (c) : d => e // Not legal JS; "Unexpected token ':'" at last colon ~ !!! error TS2304: Cannot find name 'a'. @@ -16,6 +17,8 @@ fileTs.ts(1,20): error TS2304: Cannot find name 'e'. !!! 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/plainJSGrammarErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt index 1b08565cd6..b92bd5df1b 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. @@ -60,6 +67,7 @@ plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allow plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. +plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. @@ -94,7 +102,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (94 errors) ==== +==== plainJSGrammarErrors.js (102 errors) ==== class C { // #private mistakes q = #unbound @@ -131,9 +139,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 +160,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 +221,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 +245,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 ~~~~~ @@ -328,6 +350,8 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot m?() { return 12 }, ~ !!! error TS1162: An object member cannot be declared optional. + ~ +!!! error TS8009: The '?' modifier can only be used in TypeScript files. definitely!, ~ !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. diff --git a/testdata/baselines/reference/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/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 deleted file mode 100644 index 4c2ce91c3f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/fillInMissingTypeArgsOnJSConstructCalls.errors.txt.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- old.fillInMissingTypeArgsOnJSConstructCalls.errors.txt -+++ new.fillInMissingTypeArgsOnJSConstructCalls.errors.txt -@@= skipped -0, +0 lines =@@ --BaseB.js(2,24): error TS8004: Type parameter declarations can only be used in TypeScript files. - BaseB.js(2,25): error TS1005: ',' expected. - BaseB.js(3,14): error TS2304: Cannot find name 'Class'. --BaseB.js(3,14): error TS8010: Type annotations can only be used in TypeScript files. - BaseB.js(4,25): error TS2304: Cannot find name 'Class'. --BaseB.js(4,25): error TS8010: Type annotations can only be used in TypeScript files. --SubB.js(3,41): error TS8011: Type arguments can only be used in TypeScript files. - - - ==== 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) ==== - import SubA from './SubA'; - import BaseB from './BaseB'; - export default class SubB extends BaseB { -- ~~~~ --!!! error TS8011: Type arguments can only be used in TypeScript files. - constructor() { - super(SubA); - } \ No newline at end of file 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/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/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/jsDeclarationsClassesErr.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff deleted file mode 100644 index 9ae89ec417..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClassesErr.errors.txt.diff +++ /dev/null @@ -1,140 +0,0 @@ ---- old.jsDeclarationsClassesErr.errors.txt -+++ new.jsDeclarationsClassesErr.errors.txt -@@= skipped -0, +0 lines =@@ --index.js(4,16): error TS8004: Type parameter declarations can only be used in TypeScript files. --index.js(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 (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. -- ~ --!!! 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 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/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/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/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/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 deleted file mode 100644 index d76c5a0954..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression10.errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.parserArrowFunctionExpression10.errors.txt -+++ new.parserArrowFunctionExpression10.errors.txt -@@= skipped -0, +0 lines =@@ - fileJs.js(1,1): error TS2304: Cannot find name 'a'. - fileJs.js(1,11): error TS2304: Cannot find name 'c'. --fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. - fileJs.js(1,17): error TS2304: Cannot find name 'd'. - fileJs.js(1,27): error TS2304: Cannot find name 'f'. - fileTs.ts(1,1): error TS2304: Cannot find name 'a'. -@@= skipped -8, +7 lines =@@ - fileTs.ts(1,27): error TS2304: Cannot find name 'f'. - - --==== fileJs.js (5 errors) ==== -+==== fileJs.js (4 errors) ==== - a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon - ~ - !!! error TS2304: Cannot find name 'a'. - ~ - !!! error TS2304: Cannot find name 'c'. -- ~ --!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ - !!! error TS2304: Cannot find name 'd'. - ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff deleted file mode 100644 index b4e708c936..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression13.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.parserArrowFunctionExpression13.errors.txt -+++ new.parserArrowFunctionExpression13.errors.txt -@@= skipped -0, +0 lines =@@ - fileJs.js(1,1): error TS2304: Cannot find name 'a'. - fileJs.js(1,11): error TS2304: Cannot find name 'a'. --fileJs.js(1,21): error TS8010: Type annotations can only be used in TypeScript files. - fileTs.ts(1,1): error TS2304: Cannot find name 'a'. - fileTs.ts(1,11): error TS2304: Cannot find name 'a'. - - --==== fileJs.js (3 errors) ==== -+==== fileJs.js (2 errors) ==== - a ? () => a() : (): any => null; // Not legal JS; "Unexpected token ')'" at last paren - ~ - !!! error TS2304: Cannot find name 'a'. - ~ - !!! error TS2304: Cannot find name 'a'. -- ~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. - - ==== fileTs.ts (2 errors) ==== - a ? () => a() : (): any => null; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff deleted file mode 100644 index c4705940d8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression14.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.parserArrowFunctionExpression14.errors.txt -+++ new.parserArrowFunctionExpression14.errors.txt -@@= skipped -0, +0 lines =@@ - fileJs.js(1,1): error TS2304: Cannot find name 'a'. --fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files. --fileJs.js(1,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 =@@ - fileTs.ts(1,46): error TS2304: Cannot find name 'e'. - - --==== fileJs.js (7 errors) ==== -+==== fileJs.js (3 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 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff deleted file mode 100644 index 7b1e6d7782..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression15.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.parserArrowFunctionExpression15.errors.txt -+++ new.parserArrowFunctionExpression15.errors.txt -@@= skipped -0, +0 lines =@@ --fileJs.js(1,18): error TS8010: Type annotations can only be used in TypeScript files. -- -- --==== fileJs.js (1 errors) ==== -- false ? (param): string => param : null // Not legal JS; "Unexpected token ':'" at last colon -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- --==== fileTs.ts (0 errors) ==== -- false ? (param): string => param : null -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff deleted file mode 100644 index da8b37a944..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression16.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.parserArrowFunctionExpression16.errors.txt -+++ new.parserArrowFunctionExpression16.errors.txt -@@= skipped -0, +0 lines =@@ --fileJs.js(1,25): error TS8010: Type annotations can only be used in TypeScript files. -- -- --==== fileJs.js (1 errors) ==== -- true ? false ? (param): string => param : null : null // Not legal JS; "Unexpected token ':'" at last colon -- ~~~~~~ --!!! error TS8010: Type annotations can only be used in TypeScript files. -- --==== fileTs.ts (0 errors) ==== -- true ? false ? (param): string => param : null : null -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff deleted file mode 100644 index 5d502ccdfd..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/parserArrowFunctionExpression17.errors.txt.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.parserArrowFunctionExpression17.errors.txt -+++ new.parserArrowFunctionExpression17.errors.txt -@@= skipped -0, +0 lines =@@ - fileJs.js(1,1): error TS2304: Cannot find name 'a'. - fileJs.js(1,5): error TS2304: Cannot find name 'b'. - fileJs.js(1,15): error TS2304: Cannot find name 'd'. --fileJs.js(1,15): error TS8010: Type annotations can only be used in TypeScript files. - fileJs.js(1,20): error TS2304: Cannot find name 'e'. - fileTs.ts(1,1): error TS2304: Cannot find name 'a'. - fileTs.ts(1,5): error TS2304: Cannot find name 'b'. -@@= skipped -8, +7 lines =@@ - fileTs.ts(1,20): error TS2304: Cannot find name 'e'. - - --==== fileJs.js (5 errors) ==== -+==== fileJs.js (4 errors) ==== - a ? b : (c) : d => e // Not legal JS; "Unexpected token ':'" at last colon - ~ - !!! error TS2304: Cannot find name 'a'. -@@= skipped -8, +8 lines =@@ - !!! error TS2304: Cannot find name 'b'. - ~ - !!! error TS2304: Cannot find name 'd'. -- ~ --!!! error TS8010: Type annotations can only be used in TypeScript files. - ~ - !!! error TS2304: Cannot find name 'e'. - \ 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 deleted file mode 100644 index 56d5793373..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff +++ /dev/null @@ -1,114 +0,0 @@ ---- 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 =@@ - plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. - plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. - plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. --plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. - plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. - plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. - plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. -@@= skipped -35, +34 lines =@@ - plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. - - --==== plainJSGrammarErrors.js (102 errors) ==== -+==== plainJSGrammarErrors.js (94 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 }, - ~ - !!! error TS1162: An object member cannot be declared optional. -- ~ --!!! error TS8009: The '?' modifier can only be used in TypeScript files. - definitely!, - ~ - !!! error TS1255: A definite assignment assertion '!' is not permitted in this context. \ No newline at end of file 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/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