Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS2411: Property '[Symbol.unscopables]' of type is not assignable #34

Closed
DaanV2 opened this issue Mar 10, 2022 · 1 comment · Fixed by #35
Closed

TS2411: Property '[Symbol.unscopables]' of type is not assignable #34

DaanV2 opened this issue Mar 10, 2022 · 1 comment · Fixed by #35
Labels

Comments

@DaanV2
Copy link

DaanV2 commented Mar 10, 2022

  • 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;
       };
@DaanV2 DaanV2 added the bug label Mar 10, 2022
@manuth
Copy link
Contributor

manuth commented Jun 29, 2022

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: microsoft/TypeScript#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:

  1. Install working comment-json type declarations by adding this to the devDependencies:
    "@types/comment-json": "npm:comment-json@4.1.1"
    
  2. Tweak your tsconfig.json for making TypeScript load the working types by adding this to the compilerOptions:
    "paths": {
      "comment-json": [
        "./node_modules/@types/comment-json"
      ]
    }
    

This will make typescript load the type declarations from comment-json@4.1.1 instead of the version currently installed.

Actually, you could use any package name other than @types/comment-json as an alias for comment-json@4.1.1 but I think @types/comment-json speaks for itself better than anything else could do.

manuth added a commit to manuth/node-comment-json that referenced this issue Jun 29, 2022
manuth added a commit to manuth/node-comment-json that referenced this issue Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants