Home > database >  Typescript upgrade and chrome types conflict
Typescript upgrade and chrome types conflict

Time:10-26

I have just upgraded from Typescript 4.2.4 to Typescript 4.8.4 and am now getting errors because the types in node_modules/typescript/lib/lib.dom.d.ts conflict with the types node_modules/@types/filesystem/index.d.ts which is used by the "chrome" type in the types entry of the tsconfig file.

The errors are:

node_modules/@types/filesystem/index.d.ts:107:5 - error TS2687: All declarations of 'name' must have identical modifiers.

107     name: string;
        ~~~~

node_modules/@types/filesystem/index.d.ts:113:5 - error TS2687: All declarations of 'root' must have identical modifiers.

113     root: DirectoryEntry;
        ~~~~

node_modules/@types/filesystem/index.d.ts:113:5 - error TS2717: Subsequent property declarations must have the same type.  Property 'root' must be of type 'FileSystemDirectoryEntry', but here has type 'DirectoryEntry'.

113     root: DirectoryEntry;
        ~~~~

  node_modules/typescript/lib/lib.dom.d.ts:5248:14
    5248     readonly root: FileSystemDirectoryEntry;
                      ~~~~
    'root' was also declared here.

node_modules/@types/filesystem/index.d.ts:369:11 - error TS2304: Cannot find name 'DOMError'.

369     (err: DOMError): void;
              ~~~~~~~~

node_modules/typescript/lib/lib.dom.d.ts:5247:14 - error TS2687: All declarations of 'name' must have identical modifiers.

5247     readonly name: string;
                  ~~~~

node_modules/typescript/lib/lib.dom.d.ts:5248:14 - error TS2687: All declarations of 'root' must have identical modifiers.

Apart from the missing "DomError" the errors are occurring because FileSystem is declared differently in the 2 declaration files.

filesystem.index.d.ts has an interface called FileSystem

interface FileSystem {
    /**
     * This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems.
     * @readonly
     */
    name: string;

    /**
     * The root directory of the file system.
     * @readonly
     */
    root: DirectoryEntry;
}

lib/lib.dom.d.ts also has an interface called FileSystem that looks like this:

interface FileSystem {
    readonly name: string;
    readonly root: FileSystemDirectoryEntry;
}

How do I fix this?

CodePudding user response:

The FileSystem types are embedded in dom.d.ts since 4.4.

You don't need @types/filesystem anymore.

CodePudding user response:

Upgrading to the latest @types/filesystem fixed this.

CodePudding user response:

Check out this answer: https://stackoverflow.com/a/45744513/12800045

it says that you can skip typechecking libraries in your compiler options

  • Related