mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.23k stars 210 forks source link

Unable to resolve types with TypeScript 5.3.3 / TSC 9.2.0 #628

Closed NicoFraenzel closed 5 months ago

NicoFraenzel commented 7 months ago

Hi there, I'm trying to use the Mermaid CLI via TypeScript and getting the following error:

Could not find a declaration file for module '@mermaid-js/mermaid-cli'. 'C:/path-to-project/node_modules/@mermaid-js/mermaid-cli/src/index.js' implicitly has an 'any' type.
  There are types at 'C:/path-to-project/node_modules/@mermaid-js/mermaid-cli/dist-types/src/index.d.ts', but this result could not be resolved when respecting 
package.json "exports". The '@mermaid-js/mermaid-cli' library may need to update its package.json or typings.

My TS config:

{
    "compilerOptions": {
        "module": "NodeNext",
        "target": "ES2022",
        "strict": true,
        "sourceMap": true,
        "outDir": "./dist",
        "moduleResolution": "NodeNext",
        "esModuleInterop": true
    },
    "include": [ "src/**/*" ]
}

It seems like TypeScript needs the type declarations to be referenced in the "export" property as well. Is there something I can do on my part to make it compatible? Maybe a slightly different configuration?

andrewshawcare commented 6 months ago

https://arethetypeswrong.github.io/?p=%40mermaid-js%2Fmermaid-cli%4010.6.1