Closed
Description
π Search Terms
rewriteRelativeImportExtensions, monorepo, relative import, file extension
π Version & Regression Information
5.8.3
β― Playground Link
No response
π» Code
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"allowJs": true,
"allowSyntheticDefaultImports": true,
"checkJs": true,
"esModuleInterop": true,
"incremental": true,
"isolatedModules": true,
"lib": [ "dom" ],
"module": "esnext",
"moduleResolution": "bundler",
"noImplicitAny": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strictNullChecks": true,
"verbatimModuleSyntax": true,
"baseUrl": "./src",
"rewriteRelativeImportExtensions": true,
"outDir": "./build",
"target": "es2022",
"resolvePackageJsonExports": true,
"resolvePackageJsonImports": true,
"preserveConstEnums": true,
"useDefineForClassFields": true
},
"files": [β¦],
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
π Actual behavior
TSC errors (and the error is kind of broken):
error TS2877: This import uses a '.ts' extension to resolve to an input TypeScript file, but will not be rewritten during emit because it is not a relative path.
Found 1 error.
π Expected behavior
It should work
Additional information about the issue
This occurs in a monorepo like so:
pkgs/
A
src/β¦
package.json
tsconfig.json
B
src/β¦
package.json
tsconfig.json
Shared
src/β¦
package.json
tsconfig.json (config only for VS Code)
tsconfig.json
package.json
A & B get built and published. Shared does not (it is only ever consumed directly by A or B).
// pkgs/A/src/main.ts
import sql from '../../shared/src/helpers/sql.ts';
running tsc
in pkgs/A
fails, erroneously claiming ../../shared/src/helpers/sql.ts
is not a relative path.
Metadata
Metadata
Assignees
Labels
No labels