dagda1
dagda1

Reputation: 28940

vscode/eslint complaining Parsing error: Only declares and type imports are allowed inside declare module

I have the following index.d.ts file:

declare module 'mytypes' {
  interface Constructor<T> {
    new (...args: any[]): T;
  }

  //etc.

VSCode highlights the interface keyword:

enter image description here

Parsing error: Only declares and type imports are allowed inside declare module

  1 | declare module 'someproject' {
> 2 |   interface Constructor<T> {
    |   ^
  3 |     new (...args: any[]): T;
  4 |   }
  5 |eslint

Looks like an eslint error but I cannot tell which from the error message

Upvotes: 8

Views: 8653

Answers (1)

Sunday9787
Sunday9787

Reputation: 391

You can add .eslintignore

/**/*.d.ts

The eslint rule mistakenly treats d.ts as js

Upvotes: 39

Related Questions