wearemothership / dicom.ts

A small, fast, javascript DICOM renderer
Other
35 stars 13 forks source link

Cannot resolve the types #77

Closed kresli closed 2 weeks ago

kresli commented 1 month ago

Typescript 5.2.2

Seem like there is an issue importing types as the package has multiple exports require, browser, default

Could not find a declaration file for module 'dicom.ts'. '/Users/x/y/z/node_modules/dicom.ts/dist/index.modern.mjs' implicitly has an 'any' type.
  There are types at '/Users/x/y/z/node_modules/dicom.ts/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'dicom.ts' library may need to update its package.json or typings.

I believe there must be a .d.ts per export

{
...
  "main": "./dist/index.common.js",
  "module": "./dist/index.mjs",
  "exports": {
    ".": {
      "import": {
        "types": "./dist/types/index.d.mts",
        "default": "./dist/index.mjs"
      },
      "require": {
        "types": "./dist/types/index.d.ts",
        "default": "./dist/index.common.js"
      }
    }
  },
  "types": "./dist/types/index.d.ts",
...
}

You can find more info about the issue here https://github.com/microsoft/TypeScript/issues/52363

tsconfig

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "moduleDetection": "force",
    "noEmit": true,

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true
  },
  "include": ["src"]
}
nickhingston commented 2 weeks ago

thanks for report, this is now delivered in 1.2.0