-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
Demo Repo
https://github.com/FoundTheWOUT/tsc-resolved-non-inclued-file
Which of the following problems are you reporting?
Something else more complicated which I'll explain in more detail
Demonstrate the defect described above with a code sample.
import { name } from "@scope/lib/a"; // should not errorRun tsc --showConfig and paste its output here
{
"compilerOptions": {
"rootDir": "./b",
"outDir": "./dist/b",
"types": [],
"noEmit": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"resolvePackageJsonExports": true,
"resolvePackageJsonImports": true,
"useDefineForClassFields": true
},
"files": [
"./b/index.ts"
],
"include": [
"./b/**/*.ts"
],
"exclude": [
"dist"
]
}Run tsc --traceResolution and paste its output here
sry, too long and file upload is not allowed
Paste the package.json of the importing module, if it exists
/
Paste the package.json of the target module, if it exists
/
Any other comments can go here
File 'x' is not under 'rootDir' 'y'. 'rootDir' is expected to contain all source files.
Our project uses self-references (importing the package itself), but we encountered errors after upgrading TypeScript to 5.7+. We are splitting each feature into an independent folder and bundling/typing them separately. Using self-references makes it easier to configure externals for the bundler.
Project structure
dist/
|- a/
|-- index.d.ts
|-- index.js
|- b/
|-- src/
|--- utils.d.ts
|-- index.d.ts <- we structure declaration file like that
|-- index.js
a/
|- index.ts
b/
|- src/
|-- utils.ts
|- index.ts
tsconfig.b.tmp.json <- generate at build time
// dist/b/index.js
// this is not emit by tsc, we use rollup and set my-pack to external, we use tsc to generate declaration file
import a from "my-pack/a";// package.json
{
"name": "my-pack",
"type": "module",
"exports": {
"./*": {
"types": "./dist/*/index.d.ts",
"import": "./dist/*/index.js"
}
}
}Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug