@typeswicg-file-system-access breaks when using typeRoots in typescript 5 - Stack Overflow

admin2025-04-18  2

Spending some time to investigate problem: Migrating from typescript 4.9 to 5.7 causes issue with @types/wicg-file-system-access when using typeRoots

Because library uses typesVersions to define different typings for different typescript versions typeRoots ignores that defintion in libraries package.json

.json

    "types": "index",
    "typesVersions": {
        "<=5.0": {
            "*": [
                "ts5.0/*"
            ]
        }
    },
{
  "compilerOptions": {
    "typeRoots": ["libs/sdk/types", "node_modules/@types"],
    "types": [
            "node",
            "typelevel",
            "react-util-types",
            "browser-compat",
            "@types/wicg-file-system-access",
            "office-js"
        ],
  }
}

not working anymore and causes error when loading typings

Spending some time to investigate problem: Migrating from typescript 4.9 to 5.7 causes issue with @types/wicg-file-system-access when using typeRoots

Because library uses typesVersions to define different typings for different typescript versions typeRoots ignores that defintion in libraries package.json

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/wicg-file-system-access/package.json

    "types": "index",
    "typesVersions": {
        "<=5.0": {
            "*": [
                "ts5.0/*"
            ]
        }
    },
{
  "compilerOptions": {
    "typeRoots": ["libs/sdk/types", "node_modules/@types"],
    "types": [
            "node",
            "typelevel",
            "react-util-types",
            "browser-compat",
            "@types/wicg-file-system-access",
            "office-js"
        ],
  }
}

not working anymore and causes error when loading typings

Share Improve this question edited Jan 29 at 15:14 Andrew asked Jan 29 at 15:08 AndrewAndrew 3613 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

to solve problem change tsconfig like that

{
  "compilerOptions": {
    "typeRoots": ["libs/sdk/types", "node_modules/@types", "node_modules/@types/wicg-file-system-access"],
    "types": [
            "node",
            "typelevel",
            "react-util-types",
            "browser-compat",
            "ts5.0", // @types/wicg-file-system-access for 5.x typescript
            "office-js"
        ],
  }
}
转载请注明原文地址:http://anycun.com/QandA/1744957976a90028.html