node-comment-json
node-comment-json copied to clipboard
TS2411: Property '[Symbol.unscopables]' of type is not assignable
- Node Version:: 16.13.2
- comment-json Version: 4.2.2
When upgrading to package 4.2.2 from 4.1.1 I'm getting the following errors during compile time: I tried commenting out any references to the module but it keeps appearing.
node_modules/typescript/lib/lib.es2015.iterable.d.ts:60:5 - error TS2411: Property '[Symbol.iterator]' of type '() => IterableIterator<TValue>' is not assignable to 'symbol' index type 'CommentToken'.
[Symbol.iterator](): IterableIterator<T>;
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:99:5 - error TS2411: Property '[Symbol.unscopables]' of type '() => { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }' is not assignable to 'symbol' index type 'CommentToken'.
[Symbol.unscopables](): {
copyWithin: boolean;
...
values: boolean;
};
Edit: I just noticed this error confusingly only occurs if you're compiling
.ts
-code using the--build
command line switch, so opening an issue @ TypeScript might be a good idea. Edit 2: Did so: https://github.com/microsoft/TypeScript/issues/49739
As far as I can tell, this version of comment-json
is not usable in TypeScript as described by you.
I'll go write a PR fixing this issue, however there is a workaround you might want to use until my PR is merged:
- Install working
comment-json
type declarations by adding this to thedevDependencies
:"@types/comment-json": "npm:[email protected]"
- Tweak your
tsconfig.json
for making TypeScript load the working types by adding this to thecompilerOptions
:"paths": { "comment-json": [ "./node_modules/@types/comment-json" ] }
This will make typescript load the type declarations from [email protected]
instead of the version currently installed.
Actually, you could use any package name other than @types/comment-json
as an alias for [email protected]
but I think @types/comment-json
speaks for itself better than anything else could do.