diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 1a6a9d8283..7d7dea31d3 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -1107,6 +1107,26 @@ func (n *Node) ClassName() *Node { panic("Unhandled case in Node.ClassName: " + n.Kind.String()) } +func (n *Node) PostfixToken() *Node { + switch n.Kind { + case KindParameter: + return n.AsParameterDeclaration().QuestionToken + case KindMethodDeclaration: + return n.AsMethodDeclaration().PostfixToken + case KindShorthandPropertyAssignment: + return n.AsShorthandPropertyAssignment().PostfixToken + case KindMethodSignature: + return n.AsMethodSignatureDeclaration().PostfixToken + case KindPropertySignature: + return n.AsPropertySignatureDeclaration().PostfixToken + case KindPropertyAssignment: + return n.AsPropertyAssignment().PostfixToken + case KindPropertyDeclaration: + return n.AsPropertyDeclaration().PostfixToken + } + return nil +} + // Determines if `n` contains `descendant` by walking up the `Parent` pointers from `descendant`. This method panics if // `descendant` or one of its ancestors is not parented except when that node is a `SourceFile`. func (n *Node) Contains(descendant *Node) bool { @@ -10382,6 +10402,7 @@ type SourceFile struct { // Fields set by parser diagnostics []*Diagnostic + jsDiagnostics []*Diagnostic jsdocDiagnostics []*Diagnostic LanguageVariant core.LanguageVariant ScriptKind core.ScriptKind @@ -10469,6 +10490,14 @@ func (node *SourceFile) SetDiagnostics(diags []*Diagnostic) { node.diagnostics = diags } +func (node *SourceFile) JSDiagnostics() []*Diagnostic { + return node.jsDiagnostics +} + +func (node *SourceFile) SetJSDiagnostics(diags []*Diagnostic) { + node.jsDiagnostics = diags +} + func (node *SourceFile) JSDocDiagnostics() []*Diagnostic { return node.jsdocDiagnostics } diff --git a/internal/ast/modifierflags.go b/internal/ast/modifierflags.go index 2d434a04c6..dfc4c21c15 100644 --- a/internal/ast/modifierflags.go +++ b/internal/ast/modifierflags.go @@ -13,7 +13,7 @@ const ( // Syntactic-only modifiers ModifierFlagsExport ModifierFlags = 1 << 5 // Declarations ModifierFlagsAbstract ModifierFlags = 1 << 6 // Class/Method/ConstructSignature - ModifierFlagsAmbient ModifierFlags = 1 << 7 // Declarations + ModifierFlagsAmbient ModifierFlags = 1 << 7 // Declarations (declare keyword) ModifierFlagsStatic ModifierFlags = 1 << 8 // Property/Method ModifierFlagsAccessor ModifierFlags = 1 << 9 // Property ModifierFlagsAsync ModifierFlags = 1 << 10 // Property/Method/Function @@ -21,11 +21,9 @@ const ( ModifierFlagsConst ModifierFlags = 1 << 12 // Const enum ModifierFlagsIn ModifierFlags = 1 << 13 // Contravariance modifier ModifierFlagsOut ModifierFlags = 1 << 14 // Covariance modifier - ModifierFlagsDecorator ModifierFlags = 1 << 15 // Contains a decorator. - ModifierFlagsImmediate ModifierFlags = 1 << 16 // Parameter + ModifierFlagsDecorator ModifierFlags = 1 << 15 // Contains a decorator // JSDoc-only modifiers - ModifierFlagsDeprecated ModifierFlags = 1 << 17 // Deprecated tag. - ModifierFlagsJSDocImmediate ModifierFlags = 1 << 18 // Parameter + ModifierFlagsDeprecated ModifierFlags = 1 << 16 // Deprecated tag // Cache-only JSDoc-modifiers. Should match order of Syntactic/JSDoc modifiers, above. ModifierFlagsJSDocPublic ModifierFlags = 1 << 23 // if this value changes, `selectEffectiveModifierFlags` must change accordingly ModifierFlagsJSDocPrivate ModifierFlags = 1 << 24 @@ -36,10 +34,10 @@ const ( ModifierFlagsHasComputedFlags ModifierFlags = 1 << 29 // Modifier flags have been computed ModifierFlagsSyntacticOrJSDocModifiers = ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected | ModifierFlagsReadonly | ModifierFlagsOverride - ModifierFlagsSyntacticOnlyModifiers = ModifierFlagsExport | ModifierFlagsAmbient | ModifierFlagsAbstract | ModifierFlagsStatic | ModifierFlagsAccessor | ModifierFlagsAsync | ModifierFlagsDefault | ModifierFlagsConst | ModifierFlagsIn | ModifierFlagsOut | ModifierFlagsDecorator | ModifierFlagsImmediate + ModifierFlagsSyntacticOnlyModifiers = ModifierFlagsExport | ModifierFlagsAmbient | ModifierFlagsAbstract | ModifierFlagsStatic | ModifierFlagsAccessor | ModifierFlagsAsync | ModifierFlagsDefault | ModifierFlagsConst | ModifierFlagsIn | ModifierFlagsOut | ModifierFlagsDecorator ModifierFlagsSyntacticModifiers = ModifierFlagsSyntacticOrJSDocModifiers | ModifierFlagsSyntacticOnlyModifiers ModifierFlagsJSDocCacheOnlyModifiers = ModifierFlagsJSDocPublic | ModifierFlagsJSDocPrivate | ModifierFlagsJSDocProtected | ModifierFlagsJSDocReadonly | ModifierFlagsJSDocOverride - ModifierFlagsJSDocOnlyModifiers = ModifierFlagsDeprecated | ModifierFlagsJSDocImmediate + ModifierFlagsJSDocOnlyModifiers = ModifierFlagsDeprecated ModifierFlagsNonCacheOnlyModifiers = ModifierFlagsSyntacticOrJSDocModifiers | ModifierFlagsSyntacticOnlyModifiers | ModifierFlagsJSDocOnlyModifiers ModifierFlagsAccessibilityModifier = ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected @@ -47,8 +45,9 @@ const ( ModifierFlagsParameterPropertyModifier = ModifierFlagsAccessibilityModifier | ModifierFlagsReadonly | ModifierFlagsOverride ModifierFlagsNonPublicAccessibilityModifier = ModifierFlagsPrivate | ModifierFlagsProtected - ModifierFlagsTypeScriptModifier = ModifierFlagsAmbient | ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected | ModifierFlagsReadonly | ModifierFlagsAbstract | ModifierFlagsConst | ModifierFlagsOverride | ModifierFlagsIn | ModifierFlagsOut | ModifierFlagsImmediate + ModifierFlagsTypeScriptModifier = ModifierFlagsAmbient | ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected | ModifierFlagsReadonly | ModifierFlagsAbstract | ModifierFlagsConst | ModifierFlagsOverride | ModifierFlagsIn | ModifierFlagsOut ModifierFlagsExportDefault = ModifierFlagsExport | ModifierFlagsDefault - ModifierFlagsAll = ModifierFlagsExport | ModifierFlagsAmbient | ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected | ModifierFlagsStatic | ModifierFlagsReadonly | ModifierFlagsAbstract | ModifierFlagsAccessor | ModifierFlagsAsync | ModifierFlagsDefault | ModifierFlagsConst | ModifierFlagsDeprecated | ModifierFlagsOverride | ModifierFlagsIn | ModifierFlagsOut | ModifierFlagsImmediate | ModifierFlagsDecorator + ModifierFlagsAll = ModifierFlagsExport | ModifierFlagsAmbient | ModifierFlagsPublic | ModifierFlagsPrivate | ModifierFlagsProtected | ModifierFlagsStatic | ModifierFlagsReadonly | ModifierFlagsAbstract | ModifierFlagsAccessor | ModifierFlagsAsync | ModifierFlagsDefault | ModifierFlagsConst | ModifierFlagsDeprecated | ModifierFlagsOverride | ModifierFlagsIn | ModifierFlagsOut | ModifierFlagsDecorator ModifierFlagsModifier = ModifierFlagsAll & ^ModifierFlagsDecorator + ModifierFlagsJavaScript = ModifierFlagsExport | ModifierFlagsStatic | ModifierFlagsAccessor | ModifierFlagsAsync | ModifierFlagsDefault ) diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index b5ae76d503..1c65dee66c 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -1015,8 +1015,6 @@ func ModifierToFlag(token Kind) ModifierFlags { return ModifierFlagsIn case KindOutKeyword: return ModifierFlagsOut - case KindImmediateKeyword: - return ModifierFlagsImmediate case KindDecorator: return ModifierFlagsDecorator } @@ -2086,10 +2084,7 @@ func IsComputedNonLiteralName(name *Node) bool { } func IsQuestionToken(node *Node) bool { - if node == nil { - return false - } - return node.Kind == KindQuestionToken + return node != nil && node.Kind == KindQuestionToken } func GetTextOfPropertyName(name *Node) string { @@ -3552,23 +3547,7 @@ func ShouldTransformImportCall(fileName string, options *core.CompilerOptions, i } func HasQuestionToken(node *Node) bool { - switch node.Kind { - case KindParameter: - return node.AsParameterDeclaration().QuestionToken != nil - case KindMethodDeclaration: - return IsQuestionToken(node.AsMethodDeclaration().PostfixToken) - case KindShorthandPropertyAssignment: - return IsQuestionToken(node.AsShorthandPropertyAssignment().PostfixToken) - case KindMethodSignature: - return IsQuestionToken(node.AsMethodSignatureDeclaration().PostfixToken) - case KindPropertySignature: - return IsQuestionToken(node.AsPropertySignatureDeclaration().PostfixToken) - case KindPropertyAssignment: - return IsQuestionToken(node.AsPropertyAssignment().PostfixToken) - case KindPropertyDeclaration: - return IsQuestionToken(node.AsPropertyDeclaration().PostfixToken) - } - return false + return IsQuestionToken(node.PostfixToken()) } func IsJsxOpeningLikeElement(node *Node) bool { @@ -3877,3 +3856,7 @@ func IsJSDocNameReferenceContext(node *Node) bool { return IsJSDocNameReference(node) || IsJSDocLinkLike(node) }) != nil } + +func IsImportOrImportEqualsDeclaration(node *Node) bool { + return IsImportDeclaration(node) || IsImportEqualsDeclaration(node) +} diff --git a/internal/checker/checker.go b/internal/checker/checker.go index ba18a4afb0..9844cbc289 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -2097,7 +2097,6 @@ func (c *Checker) checkSourceFile(ctx context.Context, sourceFile *ast.SourceFil c.renamedBindingElementsInTypes = nil c.checkSourceElements(sourceFile.Statements.Nodes) c.checkDeferredNodes(sourceFile) - c.checkJSDocNodes(sourceFile) if ast.IsExternalOrCommonJSModule(sourceFile) { c.checkExternalModuleExports(sourceFile.AsNode()) c.registerForUnusedIdentifiersCheck(sourceFile.AsNode()) @@ -2139,6 +2138,16 @@ func (c *Checker) checkSourceElement(node *ast.Node) bool { } func (c *Checker) checkSourceElementWorker(node *ast.Node) { + if node.Flags&ast.NodeFlagsHasJSDoc != 0 { + for _, jsdoc := range node.JSDoc(nil) { + c.checkJSDocComments(jsdoc) + if tags := jsdoc.AsJSDoc().Tags; tags != nil { + for _, tag := range tags.Nodes { + c.checkJSDocComments(tag) + } + } + } + } kind := node.Kind if kind >= ast.KindFirstStatement && kind <= ast.KindLastStatement { flowNode := node.FlowNodeData().FlowNode @@ -2331,48 +2340,29 @@ func (c *Checker) checkDeferredNode(node *ast.Node) { c.currentNode = saveCurrentNode } -func (c *Checker) checkJSDocNodes(sourceFile *ast.SourceFile) { - // !!! - // This performs minimal checking of JSDoc nodes to ensure that @link references to entities are recorded - // for purposes of checking unused identifiers. We pass down a location node because the binder doesn't currently - // set parent references in JSDoc nodes. - for location, jsdocs := range sourceFile.JSDocCache() { - for _, jsdoc := range jsdocs { - if c.isCanceled() { - return - } - c.checkJSDocComments(jsdoc, location) - tags := jsdoc.AsJSDoc().Tags - if tags != nil { - for _, tag := range tags.Nodes { - c.checkJSDocComments(tag, location) - } - } - } - } -} - -func (c *Checker) checkJSDocComments(node *ast.Node, location *ast.Node) { +func (c *Checker) checkJSDocComments(node *ast.Node) { for _, comment := range node.Comments() { - c.checkJSDocComment(comment, location) + c.checkJSDocComment(comment) } } -func (c *Checker) checkJSDocComment(node *ast.Node, location *ast.Node) { +func (c *Checker) checkJSDocComment(node *ast.Node) { + // This performs minimal checking of JSDoc nodes to ensure that @link references to entities are recorded + // for purposes of checking unused identifiers. switch node.Kind { case ast.KindJSDocLink, ast.KindJSDocLinkCode, ast.KindJSDocLinkPlain: - c.resolveJSDocMemberName(node.Name(), location) + c.resolveJSDocMemberName(node.Name()) } } -func (c *Checker) resolveJSDocMemberName(name *ast.Node, location *ast.Node) *ast.Symbol { +func (c *Checker) resolveJSDocMemberName(name *ast.Node) *ast.Symbol { if name != nil && ast.IsEntityName(name) { meaning := ast.SymbolFlagsType | ast.SymbolFlagsNamespace | ast.SymbolFlagsValue - if symbol := c.resolveEntityName(name, meaning, true /*ignoreErrors*/, true /*dontResolveAlias*/, location); symbol != nil { + if symbol := c.resolveEntityName(name, meaning, true /*ignoreErrors*/, true /*dontResolveAlias*/, nil); symbol != nil { return symbol } if ast.IsQualifiedName(name) { - if symbol := c.resolveJSDocMemberName(name.AsQualifiedName().Left, location); symbol != nil { + if symbol := c.resolveJSDocMemberName(name.AsQualifiedName().Left); symbol != nil { var t *Type if symbol.Flags&ast.SymbolFlagsValue != 0 { proto := c.getPropertyOfType(c.getTypeOfSymbol(symbol), "prototype") @@ -6410,6 +6400,36 @@ func (c *Checker) checkAliasSymbol(node *ast.Node) { // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = c.getMergedSymbol(core.OrElse(symbol.ExportSymbol, symbol)) + // A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within + if ast.IsInJSFile(node) && target.Flags&ast.SymbolFlagsValue == 0 && !ast.IsTypeOnlyImportOrExportDeclaration(node) { + errorNode := core.OrElse(node.PropertyNameOrName(), node) + debug.Assert(node.Kind != ast.KindNamespaceExport) + if ast.IsExportSpecifier(node) { + diag := c.error(errorNode, diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files) + if sourceSymbol := ast.GetSourceFileOfNode(node).AsNode().Symbol(); sourceSymbol != nil { + if alreadyExportedSymbol := sourceSymbol.Exports[node.PropertyNameOrName().Text()]; alreadyExportedSymbol == target { + if exportingDeclaration := core.Find(alreadyExportedSymbol.Declarations, ast.IsJSTypeAliasDeclaration); exportingDeclaration != nil { + diag.AddRelatedInfo(NewDiagnosticForNode(exportingDeclaration, diagnostics.X_0_is_automatically_exported_here, alreadyExportedSymbol.Name)) + } + } + } + } else { + debug.Assert(node.Kind != ast.KindVariableDeclaration) + specifierText := "..." + if importDeclaration := ast.FindAncestor(node, ast.IsImportOrImportEqualsDeclaration); importDeclaration != nil { + if moduleSpecifier := TryGetModuleSpecifierFromDeclaration(importDeclaration); moduleSpecifier != nil { + specifierText = moduleSpecifier.Text() + } + } + identifierText := symbol.Name + if ast.IsIdentifier(errorNode) { + identifierText = errorNode.Text() + } + importText := "import(\"" + specifierText + "\")." + identifierText + c.error(errorNode, diagnostics.X_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, identifierText, importText) + } + return + } targetFlags := c.getSymbolFlags(target) excludedMeanings := core.IfElse(symbol.Flags&(ast.SymbolFlagsValue|ast.SymbolFlagsExportValue) != 0, ast.SymbolFlagsValue, 0) | core.IfElse(symbol.Flags&ast.SymbolFlagsType != 0, ast.SymbolFlagsType, 0) | @@ -30460,7 +30480,7 @@ func (c *Checker) getSymbolOfNameOrPropertyAccessExpression(name *ast.Node) *ast c.checkQualifiedName(name, CheckModeNormal) } if links.resolvedSymbol == nil && isJSDoc && ast.IsQualifiedName(name) { - return c.resolveJSDocMemberName(name, nil) + return c.resolveJSDocMemberName(name) } return links.resolvedSymbol } diff --git a/internal/compiler/program.go b/internal/compiler/program.go index d571f10257..0ae09543f6 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -990,7 +990,7 @@ func (p *Program) getOptionsDiagnosticsOfConfigFile() []*ast.Diagnostic { } func (p *Program) getSyntacticDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { - return sourceFile.Diagnostics() + return core.Concatenate(sourceFile.Diagnostics(), sourceFile.JSDiagnostics()) } func (p *Program) getBindDiagnosticsForFile(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic { diff --git a/internal/execute/tsc/diagnostics.go b/internal/execute/tsc/diagnostics.go index abd3bf887f..a477867417 100644 --- a/internal/execute/tsc/diagnostics.go +++ b/internal/execute/tsc/diagnostics.go @@ -24,16 +24,20 @@ func getFormatOptsOfSys(sys System) *diagnosticwriter.FormattingOptions { type DiagnosticReporter = func(*ast.Diagnostic) func QuietDiagnosticReporter(diagnostic *ast.Diagnostic) {} + func CreateDiagnosticReporter(sys System, w io.Writer, options *core.CompilerOptions) DiagnosticReporter { if options.Quiet.IsTrue() { return QuietDiagnosticReporter } - formatOpts := getFormatOptsOfSys(sys) - writeDiagnostic := core.IfElse(shouldBePretty(sys, options), diagnosticwriter.FormatDiagnosticWithColorAndContext, diagnosticwriter.WriteFormatDiagnostic) + if shouldBePretty(sys, options) { + return func(diagnostic *ast.Diagnostic) { + diagnosticwriter.FormatDiagnosticWithColorAndContext(w, diagnostic, formatOpts) + fmt.Fprint(w, formatOpts.NewLine) + } + } return func(diagnostic *ast.Diagnostic) { - writeDiagnostic(w, diagnostic, formatOpts) - fmt.Fprint(w, formatOpts.NewLine) + diagnosticwriter.WriteFormatDiagnostic(w, diagnostic, formatOpts) } } diff --git a/internal/ls/diagnostics.go b/internal/ls/diagnostics.go index 02088830b3..5eeadfa06a 100644 --- a/internal/ls/diagnostics.go +++ b/internal/ls/diagnostics.go @@ -13,17 +13,14 @@ import ( func (l *LanguageService) ProvideDiagnostics(ctx context.Context, uri lsproto.DocumentUri) (lsproto.DocumentDiagnosticResponse, error) { program, file := l.getProgramAndFile(uri) - diagnostics := make([][]*ast.Diagnostic, 0, 3) - if syntaxDiagnostics := program.GetSyntacticDiagnostics(ctx, file); len(syntaxDiagnostics) != 0 { - diagnostics = append(diagnostics, syntaxDiagnostics) - } else { - diagnostics = append(diagnostics, program.GetSemanticDiagnostics(ctx, file)) - // !!! user preference for suggestion diagnostics; keep only unnecessary/deprecated? - // See: https://github.com/microsoft/vscode/blob/3dbc74129aaae102e5cb485b958fa5360e8d3e7a/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts#L114 - diagnostics = append(diagnostics, program.GetSuggestionDiagnostics(ctx, file)) - if program.Options().GetEmitDeclarations() { - diagnostics = append(diagnostics, program.GetDeclarationDiagnostics(ctx, file)) - } + diagnostics := make([][]*ast.Diagnostic, 0, 4) + diagnostics = append(diagnostics, program.GetSyntacticDiagnostics(ctx, file)) + diagnostics = append(diagnostics, program.GetSemanticDiagnostics(ctx, file)) + // !!! user preference for suggestion diagnostics; keep only unnecessary/deprecated? + // See: https://github.com/microsoft/vscode/blob/3dbc74129aaae102e5cb485b958fa5360e8d3e7a/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts#L114 + diagnostics = append(diagnostics, program.GetSuggestionDiagnostics(ctx, file)) + if program.Options().GetEmitDeclarations() { + diagnostics = append(diagnostics, program.GetDeclarationDiagnostics(ctx, file)) } return lsproto.RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport{ diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 67bb38207c..2a4328863f 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -57,6 +57,7 @@ type Parser struct { scriptKind core.ScriptKind languageVariant core.LanguageVariant diagnostics []*ast.Diagnostic + jsDiagnostics []*ast.Diagnostic jsdocDiagnostics []*ast.Diagnostic token ast.Kind @@ -356,6 +357,9 @@ func (p *Parser) parseSourceFileWorker() *ast.SourceFile { } } collectExternalModuleReferences(result) + if ast.IsInJSFile(node) { + result.SetJSDiagnostics(getJSSyntacticDiagnosticsForFile(result)) + } return result } @@ -6432,3 +6436,112 @@ func parseResolutionMode(mode string, pos int, end int /*reportDiagnostic: Pragm // reportDiagnostic(pos, end - pos, Diagnostics.resolution_mode_should_be_either_require_or_import); // return undefined; } + +func getJSSyntacticDiagnosticsForFile(sourceFile *ast.SourceFile) []*ast.Diagnostic { + var diags []*ast.Diagnostic + + errorAtRange := func(loc core.TextRange, message *diagnostics.Message, args ...any) { + diags = append(diags, ast.NewDiagnostic(sourceFile, core.NewTextRange(scanner.SkipTrivia(sourceFile.Text(), loc.Pos()), loc.End()), message, args...)) + } + + errorAtNode := func(node *ast.Node, message *diagnostics.Message, args ...any) { + diags = append(diags, ast.NewDiagnostic(sourceFile, scanner.GetErrorRangeForNode(sourceFile, node), message, args...)) + } + + var visit func(*ast.Node) bool + visit = func(node *ast.Node) bool { + if node.Flags&ast.NodeFlagsReparsed != 0 || ast.IsTypeNode(node) && !ast.IsExpressionWithTypeArguments(node) { + return false + } + switch node.Kind { + case ast.KindParameter, ast.KindPropertyDeclaration, ast.KindMethodDeclaration: + if token := node.PostfixToken(); token != nil && token.Flags&ast.NodeFlagsReparsed == 0 && ast.IsQuestionToken(token) { + errorAtNode(node.PostfixToken(), diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?") + } + fallthrough + case ast.KindMethodSignature, ast.KindConstructor, ast.KindGetAccessor, ast.KindSetAccessor, ast.KindFunctionExpression, + ast.KindFunctionDeclaration, ast.KindArrowFunction, ast.KindVariableDeclaration: + if t := node.Type(); t != nil && t.Flags&ast.NodeFlagsReparsed == 0 { + errorAtNode(node.Type(), diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files) + } else if ast.IsFunctionLike(node) && node.Body() == nil { + errorAtNode(node, diagnostics.Signature_declarations_can_only_be_used_in_TypeScript_files) + } + case ast.KindImportClause: + if node.IsTypeOnly() { + errorAtNode(node.Parent, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import type") + } + case ast.KindExportDeclaration: + if node.IsTypeOnly() { + errorAtNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export type") + } + case ast.KindImportSpecifier: + if node.IsTypeOnly() { + errorAtNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "import...type") + } + case ast.KindExportSpecifier: + if node.IsTypeOnly() { + errorAtNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "export...type") + } + case ast.KindImportEqualsDeclaration: + errorAtNode(node, diagnostics.X_import_can_only_be_used_in_TypeScript_files) + case ast.KindExportAssignment: + if node.AsExportAssignment().IsExportEquals { + errorAtNode(node, diagnostics.X_export_can_only_be_used_in_TypeScript_files) + } + case ast.KindHeritageClause: + if node.AsHeritageClause().Token == ast.KindImplementsKeyword { + errorAtNode(node, diagnostics.X_implements_clauses_can_only_be_used_in_TypeScript_files) + } + case ast.KindInterfaceDeclaration: + errorAtNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "interface") + return false + case ast.KindModuleDeclaration: + errorAtNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, scanner.TokenToString(node.AsModuleDeclaration().Keyword)) + return false + case ast.KindTypeAliasDeclaration: + errorAtNode(node, diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files) + return false + case ast.KindEnumDeclaration: + errorAtNode(node, diagnostics.X_0_declarations_can_only_be_used_in_TypeScript_files, "enum") + return false + case ast.KindNonNullExpression: + errorAtNode(node, diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files) + return false + case ast.KindAsExpression: + errorAtNode(node.Type(), diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files) + return false + case ast.KindSatisfiesExpression: + errorAtNode(node.Type(), diagnostics.Type_satisfaction_expressions_can_only_be_used_in_TypeScript_files) + return false + } + // Check absence of type parameters, type arguments and non-JavaScript modifiers + switch node.Kind { + case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindMethodDeclaration, ast.KindConstructor, ast.KindGetAccessor, + ast.KindSetAccessor, ast.KindFunctionExpression, ast.KindFunctionDeclaration, ast.KindArrowFunction: + if list := node.TypeParameterList(); list != nil && core.Some(list.Nodes, func(n *ast.Node) bool { return n.Flags&ast.NodeFlagsReparsed == 0 }) { + errorAtRange(list.Loc, diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files) + } + fallthrough + case ast.KindVariableStatement, ast.KindPropertyDeclaration: + if modifiers := node.Modifiers(); modifiers != nil { + for _, modifier := range modifiers.Nodes { + if modifier.Flags&ast.NodeFlagsReparsed == 0 && modifier.Kind != ast.KindDecorator && ast.ModifierToFlag(modifier.Kind)&ast.ModifierFlagsJavaScript == 0 { + errorAtNode(modifier, diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, scanner.TokenToString(modifier.Kind)) + } + } + } + case ast.KindParameter: + if core.Some(node.ModifierNodes(), ast.IsModifier) { + errorAtRange(node.Modifiers().Loc, diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files) + } + case ast.KindCallExpression, ast.KindNewExpression, ast.KindExpressionWithTypeArguments, ast.KindJsxSelfClosingElement, + ast.KindJsxOpeningElement, ast.KindTaggedTemplateExpression: + if list := node.TypeArgumentList(); list != nil && core.Some(list.Nodes, func(n *ast.Node) bool { return n.Flags&ast.NodeFlagsReparsed == 0 }) { + errorAtRange(list.Loc, diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files) + } + } + return node.ForEachChild(visit) + } + sourceFile.ForEachChild(visit) + return diags +} 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/elidedJSImport1.errors.txt b/testdata/baselines/reference/submodule/compiler/elidedJSImport1.errors.txt index 23c27d01ab..0ceca64b81 100644 --- a/testdata/baselines/reference/submodule/compiler/elidedJSImport1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/elidedJSImport1.errors.txt @@ -1,13 +1,16 @@ caller.js(1,21): error TS2307: Cannot find module 'fs' or its corresponding type declarations. +caller.js(2,8): error TS18042: 'TruffleContract' is a type and cannot be imported in JavaScript files. Use 'import("@truffle/contract").TruffleContract' in a JSDoc type annotation. caller.js(4,43): error TS2708: Cannot use namespace 'TruffleContract' as a value. caller.js(4,60): error TS2708: Cannot use namespace 'TruffleContract' as a value. -==== caller.js (3 errors) ==== +==== caller.js (4 errors) ==== import * as fs from 'fs'; ~~~~ !!! error TS2307: Cannot find module 'fs' or its corresponding type declarations. import TruffleContract from '@truffle/contract'; // Runtime err: this import is elided in transform + ~~~~~~~~~~~~~~~ +!!! error TS18042: 'TruffleContract' is a type and cannot be imported in JavaScript files. Use 'import("@truffle/contract").TruffleContract' in a JSDoc type annotation. console.log(fs); console.log('TruffleContract is ', typeof TruffleContract, TruffleContract); // `TruffleContract` is considered 'unused' ~~~~~~~~~~~~~~~ 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/importingExportingTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.errors.txt index 38f2dac63d..85158212b4 100644 --- a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.errors.txt @@ -1,4 +1,8 @@ -/index.js(5,10): error TS2484: Export declaration conflicts with exported declaration of 'JSDocType'. +/index.js(1,21): error TS18042: 'WriteFileOptions' is a type and cannot be imported in JavaScript files. Use 'import("fs").WriteFileOptions' in a JSDoc type annotation. +/index.js(1,39): error TS18042: 'WriteFileOptions' is a type and cannot be imported in JavaScript files. Use 'import("fs").WriteFileOptions' in a JSDoc type annotation. +/index.js(5,10): error TS18043: Types cannot appear in export declarations in JavaScript files. +/index.js(6,10): error TS18043: Types cannot appear in export declarations in JavaScript files. +/index.js(7,10): error TS18043: Types cannot appear in export declarations in JavaScript files. ==== /node_modules/@types/node/index.d.ts (0 errors) ==== @@ -7,14 +11,24 @@ export function writeFile(path: string, data: any, options: WriteFileOptions, callback: (err: Error) => void): void; } -==== /index.js (1 errors) ==== +==== /index.js (5 errors) ==== import { writeFile, WriteFileOptions, WriteFileOptions as OtherName } from "fs"; + ~~~~~~~~~~~~~~~~ +!!! error TS18042: 'WriteFileOptions' is a type and cannot be imported in JavaScript files. Use 'import("fs").WriteFileOptions' in a JSDoc type annotation. + ~~~~~~~~~~~~~~~~ +!!! error TS18042: 'WriteFileOptions' is a type and cannot be imported in JavaScript files. Use 'import("fs").WriteFileOptions' in a JSDoc type annotation. /** @typedef {{ x: any }} JSDocType */ export { JSDocType }; ~~~~~~~~~ -!!! error TS2484: Export declaration conflicts with exported declaration of 'JSDocType'. +!!! error TS18043: Types cannot appear in export declarations in JavaScript files. +!!! related TS18044 /index.js:3:27: 'JSDocType' is automatically exported here. export { JSDocType as ThisIsFine }; + ~~~~~~~~~ +!!! error TS18043: Types cannot appear in export declarations in JavaScript files. +!!! related TS18044 /index.js:3:27: 'JSDocType' is automatically exported here. export { WriteFileOptions }; + ~~~~~~~~~~~~~~~~ +!!! error TS18043: Types cannot appear in export declarations in JavaScript 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/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt index 4fca94994d..161038c9df 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt @@ -4,6 +4,7 @@ file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. +file2.js(1,9): error TS18042: 'myTypes' is a type and cannot be imported in JavaScript files. Use 'import("./file.js").myTypes' in a JSDoc type annotation. file2.js(6,11): error TS2315: Type 'Object' is not generic. file2.js(12,23): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. @@ -42,8 +43,10 @@ file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being !!! error TS2300: Duplicate identifier 'myTypes'. export {myTypes}; -==== file2.js (3 errors) ==== +==== file2.js (4 errors) ==== import {myTypes} from './file.js'; + ~~~~~~~ +!!! error TS18042: 'myTypes' is a type and cannot be imported in JavaScript files. Use 'import("./file.js").myTypes' in a JSDoc type annotation. /** * @namespace testFnTypes 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..d7892e3395 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsInterfaces.errors.txt @@ -0,0 +1,212 @@ +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(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(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(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 (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 }; + ~ +!!! 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 }; + ~~ +!!! 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 }; + ~ +!!! error TS18043: Types cannot appear in export declarations in JavaScript files. + + 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 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/jsxCheckJsxNoTypeArgumentsAllowed.errors.txt b/testdata/baselines/reference/submodule/conformance/jsxCheckJsxNoTypeArgumentsAllowed.errors.txt index 4f93bf75f5..dc6dce045d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsxCheckJsxNoTypeArgumentsAllowed.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsxCheckJsxNoTypeArgumentsAllowed.errors.txt @@ -1,3 +1,4 @@ +file.jsx(1,18): error TS18042: 'Prop' is a type and cannot be imported in JavaScript files. Use 'import("./component").Prop' in a JSDoc type annotation. file.jsx(4,9): error TS2657: JSX expressions must have one parent element. file.jsx(4,16): error TS1003: Identifier expected. file.jsx(4,17): error TS2693: 'Prop' only refers to a type, but is being used as a value here. @@ -17,8 +18,10 @@ file.jsx(5,1): error TS1005: ' a={10} b="hi" />; // error, no type arguments in js 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..b59b8e7543 100644 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors.errors.txt @@ -5,12 +5,15 @@ 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(30,5): error TS1031: 'export' modifier cannot appear on class elements of this kind. +plainJSGrammarErrors.js(34,9): error TS8017: Signature declarations can only be used in TypeScript files. plainJSGrammarErrors.js(34,22): error TS1005: '{' expected. plainJSGrammarErrors.js(35,9): error TS1054: A 'get' accessor cannot have parameters. plainJSGrammarErrors.js(36,9): error TS1049: A 'set' accessor must have exactly one parameter. @@ -26,9 +29,12 @@ 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. @@ -60,6 +66,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 +101,7 @@ plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (94 errors) ==== +==== plainJSGrammarErrors.js (101 errors) ==== class C { // #private mistakes q = #unbound @@ -131,9 +138,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 @@ -155,6 +166,8 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot // accessor mistakes get incorporeal(); + ~~~~~~~~~~~ +!!! error TS8017: Signature declarations can only be used in TypeScript files. ~ !!! error TS1005: '{' expected. get parametric(n) { return 1 } @@ -207,15 +220,21 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot function staticParam(static x = 1) { return x } ~~~~~~ !!! error TS1090: 'static' modifier cannot appear on a parameter. + ~~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. async export function oorder(x = 1) { return x } ~~~~~~ !!! error TS1029: 'export' modifier must precede 'async' modifier. function cantExportParam(export x = 1) { return x } ~~~~~~ !!! error TS1090: 'export' modifier cannot appear on a parameter. + ~~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. function cantAsyncParam(async x = 1) { return x } ~~~~~ !!! error TS1090: 'async' modifier cannot appear on a parameter. + ~~~~~ +!!! error TS8012: Parameter modifiers can only be used in TypeScript files. async async function extremelyAsync() {} ~~~~~ !!! error TS1030: 'async' modifier already seen. @@ -328,6 +347,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/elidedJSImport1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/elidedJSImport1.errors.txt.diff deleted file mode 100644 index 9df0774a37..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/elidedJSImport1.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.elidedJSImport1.errors.txt -+++ new.elidedJSImport1.errors.txt -@@= skipped -0, +0 lines =@@ - caller.js(1,21): error TS2307: Cannot find module 'fs' or its corresponding type declarations. --caller.js(2,8): error TS18042: 'TruffleContract' is a type and cannot be imported in JavaScript files. Use 'import("@truffle/contract").TruffleContract' in a JSDoc type annotation. - caller.js(4,43): error TS2708: Cannot use namespace 'TruffleContract' as a value. - caller.js(4,60): error TS2708: Cannot use namespace 'TruffleContract' as a value. - - --==== caller.js (4 errors) ==== -+==== caller.js (3 errors) ==== - import * as fs from 'fs'; - ~~~~ - !!! error TS2307: Cannot find module 'fs' or its corresponding type declarations. - import TruffleContract from '@truffle/contract'; // Runtime err: this import is elided in transform -- ~~~~~~~~~~~~~~~ --!!! error TS18042: 'TruffleContract' is a type and cannot be imported in JavaScript files. Use 'import("@truffle/contract").TruffleContract' in a JSDoc type annotation. - console.log(fs); - console.log('TruffleContract is ', typeof TruffleContract, TruffleContract); // `TruffleContract` is considered 'unused' - ~~~~~~~~~~~~~~~ \ 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/importingExportingTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importingExportingTypes.errors.txt.diff index be1593b75c..7e8cf2d183 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importingExportingTypes.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importingExportingTypes.errors.txt.diff @@ -1,39 +1,16 @@ --- old.importingExportingTypes.errors.txt +++ new.importingExportingTypes.errors.txt -@@= skipped -0, +0 lines =@@ --/index.js(1,21): error TS18042: 'WriteFileOptions' is a type and cannot be imported in JavaScript files. Use 'import("fs").WriteFileOptions' in a JSDoc type annotation. --/index.js(1,39): error TS18042: 'WriteFileOptions' is a type and cannot be imported in JavaScript files. Use 'import("fs").WriteFileOptions' in a JSDoc type annotation. --/index.js(5,10): error TS18043: Types cannot appear in export declarations in JavaScript files. --/index.js(6,10): error TS18043: Types cannot appear in export declarations in JavaScript files. --/index.js(7,10): error TS18043: Types cannot appear in export declarations in JavaScript files. -+/index.js(5,10): error TS2484: Export declaration conflicts with exported declaration of 'JSDocType'. - - - ==== /node_modules/@types/node/index.d.ts (0 errors) ==== -@@= skipped -10, +6 lines =@@ - export function writeFile(path: string, data: any, options: WriteFileOptions, callback: (err: Error) => void): void; - } - --==== /index.js (5 errors) ==== -+==== /index.js (1 errors) ==== - import { writeFile, WriteFileOptions, WriteFileOptions as OtherName } from "fs"; -- ~~~~~~~~~~~~~~~~ --!!! error TS18042: 'WriteFileOptions' is a type and cannot be imported in JavaScript files. Use 'import("fs").WriteFileOptions' in a JSDoc type annotation. -- ~~~~~~~~~~~~~~~~ --!!! error TS18042: 'WriteFileOptions' is a type and cannot be imported in JavaScript files. Use 'import("fs").WriteFileOptions' in a JSDoc type annotation. - - /** @typedef {{ x: any }} JSDocType */ - +@@= skipped -22, +22 lines =@@ export { JSDocType }; ~~~~~~~~~ --!!! error TS18043: Types cannot appear in export declarations in JavaScript files. + !!! error TS18043: Types cannot appear in export declarations in JavaScript files. -!!! related TS18044 /index.js:3:5: 'JSDocType' is automatically exported here. -+!!! error TS2484: Export declaration conflicts with exported declaration of 'JSDocType'. ++!!! related TS18044 /index.js:3:27: 'JSDocType' is automatically exported here. export { JSDocType as ThisIsFine }; -- ~~~~~~~~~ --!!! error TS18043: Types cannot appear in export declarations in JavaScript files. + ~~~~~~~~~ + !!! error TS18043: Types cannot appear in export declarations in JavaScript files. -!!! related TS18044 /index.js:3:5: 'JSDocType' is automatically exported here. ++!!! related TS18044 /index.js:3:27: 'JSDocType' is automatically exported here. export { WriteFileOptions }; -- ~~~~~~~~~~~~~~~~ --!!! error TS18043: Types cannot appear in export declarations in JavaScript files. - \ No newline at end of file + ~~~~~~~~~~~~~~~~ + !!! error TS18043: Types cannot appear in export declarations in JavaScript 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/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff index 44269de68f..2373080cf8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff @@ -1,16 +1,16 @@ --- old.jsDeclarationsImportAliasExposedWithinNamespace.errors.txt +++ new.jsDeclarationsImportAliasExposedWithinNamespace.errors.txt @@= skipped -0, +0 lines =@@ --file2.js(1,9): error TS18042: 'myTypes' is a type and cannot be imported in JavaScript files. Use 'import("./file.js").myTypes' in a JSDoc type annotation. -- -- --==== file.js (0 errors) ==== +file.js(4,11): error TS2315: Type 'Object' is not generic. +file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. +file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. +file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. + file2.js(1,9): error TS18042: 'myTypes' is a type and cannot be imported in JavaScript files. Use 'import("./file.js").myTypes' in a JSDoc type annotation. +- +- +-==== file.js (0 errors) ==== +file2.js(6,11): error TS2315: Type 'Object' is not generic. +file2.js(12,23): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. @@ -50,12 +50,11 @@ export {myTypes}; -==== file2.js (1 errors) ==== -+==== file2.js (3 errors) ==== ++==== file2.js (4 errors) ==== import {myTypes} from './file.js'; -- ~~~~~~~ --!!! error TS18042: 'myTypes' is a type and cannot be imported in JavaScript files. Use 'import("./file.js").myTypes' in a JSDoc type annotation. - - /** + ~~~~~~~ + !!! error TS18042: 'myTypes' is a type and cannot be imported in JavaScript files. Use 'import("./file.js").myTypes' in a JSDoc type annotation. +@@= skipped -30, +51 lines =@@ * @namespace testFnTypes * @global * @type {Object} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff deleted file mode 100644 index 604789c684..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsInterfaces.errors.txt.diff +++ /dev/null @@ -1,216 +0,0 @@ ---- 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. --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(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(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 (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 }; -- ~ --!!! 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 }; -- ~~ --!!! 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 }; -- ~ --!!! error TS18043: Types cannot appear in export declarations in JavaScript files. -- -- 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 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/jsxCheckJsxNoTypeArgumentsAllowed.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsxCheckJsxNoTypeArgumentsAllowed.errors.txt.diff deleted file mode 100644 index 1694b33ae8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsxCheckJsxNoTypeArgumentsAllowed.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.jsxCheckJsxNoTypeArgumentsAllowed.errors.txt -+++ new.jsxCheckJsxNoTypeArgumentsAllowed.errors.txt -@@= skipped -0, +0 lines =@@ --file.jsx(1,18): error TS18042: 'Prop' is a type and cannot be imported in JavaScript files. Use 'import("./component").Prop' in a JSDoc type annotation. - file.jsx(4,9): error TS2657: JSX expressions must have one parent element. - file.jsx(4,16): error TS1003: Identifier expected. - file.jsx(4,17): error TS2693: 'Prop' only refers to a type, but is being used as a value here. -@@= skipped -17, +16 lines =@@ - b: string - } - --==== file.jsx (7 errors) ==== -+==== file.jsx (6 errors) ==== - import { MyComp, Prop } from "./component"; -- ~~~~ --!!! error TS18042: 'Prop' is a type and cannot be imported in JavaScript files. Use 'import("./component").Prop' in a JSDoc type annotation. - import * as React from "react"; - - let x = a={10} b="hi" />; // error, no type arguments in js \ 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 index 56d5793373..1274e947de 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/plainJSGrammarErrors.errors.txt.diff @@ -1,30 +1,16 @@ --- 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. +@@= skipped -11, +11 lines =@@ 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,9): error TS8017: Signature declarations can only be used in TypeScript files. 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(36,9): error TS1049: A 'set' accessor must have exactly one parameter. +@@= skipped -26, +26 lines =@@ 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. @@ -32,38 +18,16 @@ 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 =@@ +@@= skipped -64, +63 lines =@@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. -==== plainJSGrammarErrors.js (102 errors) ==== -+==== plainJSGrammarErrors.js (94 errors) ==== ++==== plainJSGrammarErrors.js (101 errors) ==== class C { // #private mistakes q = #unbound -@@= skipped -37, +37 lines =@@ - ~~~~~ - !!! error TS1089: 'async' modifier cannot appear on a constructor declaration. - const x = 1 -- ~~~~~ --!!! error TS8009: The 'const' modifier can only be used in TypeScript files. - ~ - !!! error TS1248: A class member cannot have the 'const' keyword. - const y() { -- ~~~~~ --!!! error TS8009: The 'const' modifier can only be used in TypeScript files. - ~ - !!! error TS1248: A class member cannot have the 'const' keyword. - return 12 -@@= skipped -21, +17 lines =@@ +@@= skipped -58, +58 lines =@@ export cantExportProperty = 1 ~~~~~~ !!! error TS1031: 'export' modifier cannot appear on class elements of this kind. @@ -72,29 +36,16 @@ 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 =@@ +@@= skipped -9, +7 lines =@@ + + // accessor mistakes + get incorporeal(); ++ ~~~~~~~~~~~ ++!!! error TS8017: Signature declarations can only be used in TypeScript files. + ~ + !!! error TS1005: '{' expected. + get parametric(n) { return 1 } +@@= skipped -76, +78 lines =@@ async cantAsyncPropert = 1 ~~~~~ !!! error TS1042: 'async' modifier cannot be used here. @@ -102,13 +53,4 @@ -!!! 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 + ~~~~~ \ 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/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js b/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js index 4d14d0d880..687612fe0b 100644 --- a/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js +++ b/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js @@ -116,11 +116,17 @@ Output:: 1 import { Nominal } from '../common/nominal';    ~~~~~~~ +sub-project-2/index.js:1:10 - error TS18042: 'MyNominal' is a type and cannot be imported in JavaScript files. Use 'import("../sub-project/index").MyNominal' in a JSDoc type annotation. -Found 2 errors in 2 files. +1 import { MyNominal } from '../sub-project/index'; +   ~~~~~~~~~ + + +Found 3 errors in 3 files. Errors Files 1 common/nominal.js:5 + 1 sub-project-2/index.js:1 1 sub-project/index.js:1 //// [/home/src/workspaces/lib/common/nominal.d.ts] *new* @@ -238,7 +244,7 @@ function getVar() { } //// [/home/src/workspaces/lib/sub-project-2/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":[4],"fileNames":["lib.d.ts","../common/nominal.d.ts","../sub-project/index.d.ts","../../solution/sub-project-2/index.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n","225285a996cc5c4120877a377890d79e-import { Nominal } from '../common/nominal';\nexport type MyNominal = Nominal;\n/**\n * @typedef {Nominal} MyNominal\n */ \n",{"version":"db2a90e082fd17d65127bda69975a727-import { MyNominal } from '../sub-project/index';\n\nconst variable = {\n key: /** @type {MyNominal} */('value'),\n};\n\n/**\n * @return {keyof typeof variable}\n */\nexport function getVar() {\n return 'key';\n}","signature":"f2cd6630b2dfa04d1fc92179f15d1647-declare const variable: {\n key: Nominal;\n};\n/**\n * @return {keyof typeof variable}\n */\nexport declare function getVar(): keyof typeof variable;\nexport {};\n","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"referencedMap":[[3,1],[4,2]],"latestChangedDtsFile":"./index.d.ts"} +{"version":"FakeTSVersion","root":[4],"fileNames":["lib.d.ts","../common/nominal.d.ts","../sub-project/index.d.ts","../../solution/sub-project-2/index.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n","225285a996cc5c4120877a377890d79e-import { Nominal } from '../common/nominal';\nexport type MyNominal = Nominal;\n/**\n * @typedef {Nominal} MyNominal\n */ \n",{"version":"db2a90e082fd17d65127bda69975a727-import { MyNominal } from '../sub-project/index';\n\nconst variable = {\n key: /** @type {MyNominal} */('value'),\n};\n\n/**\n * @return {keyof typeof variable}\n */\nexport function getVar() {\n return 'key';\n}","signature":"f2cd6630b2dfa04d1fc92179f15d1647-declare const variable: {\n key: Nominal;\n};\n/**\n * @return {keyof typeof variable}\n */\nexport declare function getVar(): keyof typeof variable;\nexport {};\n","impliedNodeFormat":1}],"fileIdsList":[[2],[3]],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"referencedMap":[[3,1],[4,2]],"semanticDiagnosticsPerFile":[[4,[{"pos":9,"end":18,"code":18042,"category":1,"message":"'MyNominal' is a type and cannot be imported in JavaScript files. Use 'import(\"../sub-project/index\").MyNominal' in a JSDoc type annotation."}]]],"latestChangedDtsFile":"./index.d.ts"} //// [/home/src/workspaces/lib/sub-project-2/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", @@ -318,8 +324,22 @@ function getVar() { "../sub-project/index.d.ts" ] }, + "semanticDiagnosticsPerFile": [ + [ + "../../solution/sub-project-2/index.js", + [ + { + "pos": 9, + "end": 18, + "code": 18042, + "category": 1, + "message": "'MyNominal' is a type and cannot be imported in JavaScript files. Use 'import(\"../sub-project/index\").MyNominal' in a JSDoc type annotation." + } + ] + ] + ], "latestChangedDtsFile": "./index.d.ts", - "size": 2085 + "size": 2322 } //// [/home/src/workspaces/lib/sub-project/index.d.ts] *new* import { Nominal } from '../common/nominal'; diff --git a/testdata/baselines/reference/tsc/projectReferences/default-import-interop-uses-referenced-project-settings.js b/testdata/baselines/reference/tsc/projectReferences/default-import-interop-uses-referenced-project-settings.js index 6c55de0c02..6a508b1a77 100644 --- a/testdata/baselines/reference/tsc/projectReferences/default-import-interop-uses-referenced-project-settings.js +++ b/testdata/baselines/reference/tsc/projectReferences/default-import-interop-uses-referenced-project-settings.js @@ -56,9 +56,7 @@ tsgo --p app --pretty false ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: app/src/index.ts(1,8): error TS2613: Module '"/home/src/workspaces/project/app/src/local"' has no default export. Did you mean to use 'import { local } from "/home/src/workspaces/project/app/src/local"' instead? - app/src/index.ts(2,8): error TS2613: Module '"/home/src/workspaces/project/node_modules/esm-package/index"' has no default export. Did you mean to use 'import { esm } from "/home/src/workspaces/project/node_modules/esm-package/index"' instead? - //// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* /// interface Boolean {} diff --git a/testdata/baselines/reference/tsc/projectReferences/importing-const-enum-from-referenced-project-with-preserveConstEnums-and-verbatimModuleSyntax.js b/testdata/baselines/reference/tsc/projectReferences/importing-const-enum-from-referenced-project-with-preserveConstEnums-and-verbatimModuleSyntax.js index 9d78b51615..1bb030b983 100644 --- a/testdata/baselines/reference/tsc/projectReferences/importing-const-enum-from-referenced-project-with-preserveConstEnums-and-verbatimModuleSyntax.js +++ b/testdata/baselines/reference/tsc/projectReferences/importing-const-enum-from-referenced-project-with-preserveConstEnums-and-verbatimModuleSyntax.js @@ -46,7 +46,6 @@ tsgo --p project --pretty false ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: project/index.ts(2,10): error TS2748: Cannot access ambient const enums when 'verbatimModuleSyntax' is enabled. - //// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* /// interface Boolean {} diff --git a/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences1.js b/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences1.js index b30f0e41f5..b0b402f89e 100644 --- a/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences1.js +++ b/testdata/baselines/reference/tsc/projectReferences/rewriteRelativeImportExtensionsProjectReferences1.js @@ -49,7 +49,6 @@ tsgo -p packages/main --pretty false ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: packages/main/src/index.ts(1,16): error TS2878: This import path is unsafe to rewrite because it resolves to another project, and the relative path between the projects' output files is not the same as the relative path between its input files. - //// [/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts] *Lib* /// interface Boolean {}