rootDir warning even when set to './src'
See original GitHub issueCurrent Behavior
It complains that rootDir
is set to ./
when it’s not
Expected behavior
It should not complain about it since rootDir
is correctly set to ./src
Additional context
[tsdx]: Your rootDir is currently set to "./". Please change your rootDir to "./src".
TSDX has deprecated setting tsconfig.compilerOptions.rootDir to "./" as it caused buggy output for declarationMaps and occassionally for type declarations themselves.
You may also need to change your include to remove "test", which also caused declarations to be unnecessarily created for test files.
tsconfig.json:
{
"include": ["src", "types"],
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"lib": ["esnext", "dom"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./src",
"noImplicitAny": false,
"noImplicitThis": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"baseUrl": "./",
"esModuleInterop": true,
"resolveJsonModule": true
},
"exclude": ["node_modules", "**/*.spec.ts"]
}
Your environment
Software | Version(s) |
---|---|
TSDX | ^0.13.1 |
TypeScript | ^3.8.3 |
Browser | - |
npm/Yarn | -/1.22.4 |
Node | v12.16.1 |
Operating System | WSL 2 Ubuntu 18.04 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:8
Top Results From Across the Web
error TS6059: File is not under 'rootDir' .. 'rootDir' is expected ...
One fix is to just remove "rootDir": "src" from compiler options, so it gets set automatically. Caution: rootDir will then consider both ...
Read more >File is not under 'rootDir' error in TypeScript | bobbyhadz
The "File is not under 'rootDir'" error occurs when we try to import something from a file that is not located under the...
Read more >Support for roots and modulePaths in jest.config.js files
It makes the red underline and yellow exclamation mark warning go away. But I still cannot navigate to the source import file with...
Read more >Solving warning: “Experimental support for decorators is a ...
“outDir”: Basically where the builded files will be placed. Probably before they go to production environment. · “rootDir”: You should fill this out...
Read more >Understanding TypeScript Configuration Options
TypeScript will compile all files under src/ directory, but if you want to include ... The rootDir setting, if not explicitly set, defaults...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well you already had
src
,src/*
isn’t really any different except that it avoids this error. Usingfiles
means only things that are actually imported are compiled, which is even better. It’s also in yourtsconfig.build.json
and you only want to includesrc
when building. If you include files that aren’t insrc
, TS will type-check, compile, and create declarations for those files too. In the past that has meant erroneously adding tests’ or examples’ declarations intodist
, which shouldn’t be there as library users don’t use those (and that causes bloating as well as potential side-effects due to how TS merges declarations)@gustavopch thanks for the repro. Very weird, it is indeed creating a
dist/src/
directory even though you don’t have asrc/src/
directory. There are no other directories created either, so doesn’t seem like you’re importing from another directory. 🤔The check is here, which is inside a deprecated function that moves type declarations from
dist/src/
to justdist/
: https://github.com/formium/tsdx/blob/f0963cb2d77f00bcd8606f8e4b99250972d81b02/src/deprecated.ts#L13-L21I’m pretty confused as to why that’s happening, maybe related to new TS version you’re using. However, I was able to workaround the issue by using
"files": ["./src/index.ts"]
instead of the"include": ["./src"]