tsconfig.json shows error: Entry point for implicit type library 'glob'
Asked Answered
D

3

16

I have a Monorepo which uses Typescript. I have a common folder which shows this error on the top of the file -> Entry point for implicit type library 'glob'. I am not sure what is wrong with the configuration.

Screenshot:

enter image description here

tsconfig.json

{
"extends": "../../tsconfig.json",
"compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "jsx": "react-native",
    "lib": [
        "es2021"
    ],
    "moduleResolution": "node",
    "noEmit": false,
    "strict": true,
    "target": "esnext",
    "composite": true,
    "rootDir": ".",
    "outDir": "dist",
    "declaration": true,
    "emitDeclarationOnly": true,
    "declarationMap": true
},
"exclude": [
    "node_modules",
]
}

Any Suggestions?

Dumbwaiter answered 23/6, 2022 at 18:7 Comment(0)
D
38

I just re-started VS Code and the error was gone.

Dumbwaiter answered 26/6, 2022 at 6:20 Comment(3)
lol. thank you very much for this, after finding many solutionsBarrera
And then 3 minutes later, it came back.Carbo
Yes, exactly that!Westerman
B
17

Include "types" in your "compilerOptions" ...

{
  "compilerOptions": {
    "types": [
      // ... your other types
      "node"
    ],
  },
}
Boost answered 4/4, 2023 at 22:57 Comment(4)
Please explain your response. As it is, it neither answers the question nor clarifies anything.Tautomerism
I don't know why but this worked for me.Eolith
I don't even know why i had a similar error in the first place but this worked for me too. brilliantArsenate
This is because Typescript defaults to "all visible ”@types” packages are included in your compilation. Packages in node_modules/@types of any enclosing folder are considered visible. For example, that means packages within ./node_modules/@types/, ../node_modules/@types/, ../../node_modules/@types/, and so on." By restricting types to "node" it does not traverse all node_modules directories. See typescriptlang.org/tsconfig#typesScandinavia
M
0

Remember that types are for npm projects that weren't written in Typescript.

So if the library is migrated to Typescript you can uninstall the types.

I just had the same issue with marked in an Angular project. Marked is now written in Typescript so doesn't need @types.

npm uninstall @types/marked

A big clue this may have happened is if the version under @types differs greatly from the project itself.

Meanwhile answered 25/10, 2023 at 18:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.