Open gustofbreak opened 6 years ago
This is actually a limitation in TypeScript's API. The current implementation asks TypeScript where it would look for @types
and uses these paths to exclude any matching files. These paths could be unresolved symlinks while the path of a file is typically the realpath. That's why the files are not excluded by default.
Instead I would like if TypeScript could tell if a given file was found during @types
lookup. I'll open a feature request for that.
My interim fix is to resolve the realpath before matching any files. But that will not work for cases where subfolders or individual files are symlinked.
Some possible workarounds on your side until this is fixed:
-e 'types/next/**'
CLI argumentexclude: 'types/next/**'
in your .wotanrc.yaml
"typeRoots": ["node_modules/@types", "types"]
in your tsconfig.json
instead of a symlink@gustofbreak It turns out the quick fix I had in mind only works if node_modules
or node_modules/@types
is a symlink. It doesn't work if any subdirectory is a symlink.
Therefore I will refrain from adding a useless workaround. I opened https://github.com/Microsoft/TypeScript/issues/26684 to request a new API to solve this issue.
Until this is implemented upstream you could use one of the workarounds from my previous posts.
Thanks for the quick investigation!
BTW, using CLI with -e './types/next/**'
failed so I didn't thought it would work without prefixing ./
.
I tried exclude option in .wotanrc.yaml and it works fine. (I couldn't use typeRoots since it only affects "global declarations".)
I'll left this issue open for future resolution but you can close this if it's preferred.
using CLI with -e './types/next/**' failed so I didn't thought it would work without prefixing ./.
This is fixed by #388 as well.
I'll left this issue open for future resolution
Agreed. Let's leave it open until this is really fixed.
Meta
wotan 0.12.0 tsc 3.0.1
How did you run wotan? CLI
Configuration
Code
I have
@types/next
(with a small modification) installed at<project root>/types/next
and symlink node_modules/@types/next to that path.Running
wotan
ignores othernode_module
s fine, but it complains regarding<project root>/types/next
, no matter how I setexclude
in tsconfig.json.I tried this code:
tsconfig.json
I expected to see this happen: Linting succeeds with ./types/next ignored.
Instead, this happened: