Fix false positive rewriteRelativeImportExtensions error on non-TS extensions (#60415)
This commit is contained in:
Родитель
131f673c20
Коммит
82a04b29b4
|
@ -4306,7 +4306,7 @@ export function tryGetImportFromModuleSpecifier(node: StringLiteralLike): AnyVal
|
|||
|
||||
/** @internal */
|
||||
export function shouldRewriteModuleSpecifier(specifier: string, compilerOptions: CompilerOptions): boolean {
|
||||
return !!compilerOptions.rewriteRelativeImportExtensions && pathIsRelative(specifier) && !isDeclarationFileName(specifier);
|
||||
return !!compilerOptions.rewriteRelativeImportExtensions && pathIsRelative(specifier) && !isDeclarationFileName(specifier) && hasTSFileExtension(specifier);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
//// [tests/cases/conformance/externalModules/rewriteRelativeImportExtensions/nonTSExtensions.ts] ////
|
||||
|
||||
//// [example.json]
|
||||
{}
|
||||
|
||||
//// [styles.d.css.ts]
|
||||
export {};
|
||||
|
||||
//// [index.mts]
|
||||
import {} from "./example.json" with { type: "json" }; // Ok
|
||||
import {} from "./styles.css"; // Ok
|
||||
|
||||
//// [index.mjs]
|
||||
export {};
|
|
@ -0,0 +1,15 @@
|
|||
// @module: nodenext
|
||||
// @rewriteRelativeImportExtensions: true
|
||||
// @allowArbitraryExtensions: true
|
||||
// @resolveJsonModule: true
|
||||
// @noTypesAndSymbols: true
|
||||
|
||||
// @Filename: example.json
|
||||
{}
|
||||
|
||||
// @Filename: styles.d.css.ts
|
||||
export {};
|
||||
|
||||
// @Filename: index.mts
|
||||
import {} from "./example.json" with { type: "json" }; // Ok
|
||||
import {} from "./styles.css"; // Ok
|
Загрузка…
Ссылка в новой задаче