-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
π Search Terms
rewriteRelativeImportExtensions
ts(2876)
π Version & Regression Information
- This changed between versions NA and 5.7.0-dev.20241103 or 5.7.0-beta
β― Playground Link
No response
π» Code
//src/logger/logger.mjs
//File is JS mjs file!
const logger = (message) => {
console.log(message)
}
export default logger;src/database/database.mts
//File is TS mts file!
import logger from '../logger/logger.mjs';// tsconfig.json, fragment
{
"compilerOptions": {
"target": "ESNext",
"lib": [
"esnext"
],
"allowJs": true,
"esModuleInterop": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rewriteRelativeImportExtensions": true,
"resolveJsonModule": true,
}
}// "package.json does not have any type overriding because project explicitly uses the correct filename extensions."
π Actual behavior
import mjs in mts file
TS2876: This relative import path is unsafe to rewrite because it looks like a file name, but actually resolves to "../ logger/ logger. mjs"
But works good
- on import .mjs into mjs files.
- on import .mts files into both, mjs and mts.
π Expected behavior
No error emitted. imported filename and extension is correct.
Additional information about the issue
Reproduced on both, 5.7.0-beta and current ^5.7.0-dev.20241103
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue