smastrom / notivue

🔔 Powerful toast notification system for Vue and Nuxt.
https://notivue.smastrom.io
MIT License
632 stars 7 forks source link

Types are missing from exports field #12

Closed luxterful closed 11 months ago

luxterful commented 11 months ago

I have installed the library and tried to use it in the main.ts.

But i get a typescript issue:

Could not find a declaration file for module 'notivue'. 
'/Users/user/Projects/my-project/node_modules/notivue/dist/index.mjs' implicitly has an 'any' type.
There are types at '/Users/user/Projects/my-project/node_modules/notivue/dist/index.d.ts', but this result could not be resolved
when respecting package.json "exports". The 'notivue' library may need to update its package.json or typings.
ts(7016)
smastrom commented 11 months ago

Hi @luxterful, in any of my setups, types can be imported correctly. But I trust that you're having issues. This is because the types import is missing in the package.json exports field, which is where your tsconfig is looking for.

I'm about to release a new version that adds those types also in the exports field, and you should be able to import them.

luxterful commented 11 months ago

WOW! Many thanks for the superfast reply and fix! Amazing

smastrom commented 11 months ago

@luxterful, in the meanwhile, could you please share with me your tsconfig.json? Thanks.

luxterful commented 11 months ago

Ok. So my setup is a npm monorepo.

Here are the tsconfig files

tsconfig.json

{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.node.json"
    },
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.vitest.json"
    }
  ]
}

tsconfig.node.json

{
  "extends": "@tsconfig/node18/tsconfig.json",
  "include": ["vite.config.*", "vitest.config.*", "cypress.config.*"],
  "compilerOptions": {
    "composite": true,
    "module": "ESNext",
    "types": ["node"]
  }
}

tsconfig.app.json

{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "include": [
    "env.d.ts",
    ".env",
    "src/**/*",
    "src/**/*.vue",
    "src/**/*.json",
  ],
  "exclude": [
    "src/**/__tests__/*"
  ],
  "compilerOptions": {
    "composite": true,
    "types": [
      "node",
      "vite/client"
    ],
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "./src/*"
      ],
    }
  }
}
smastrom commented 11 months ago

Thank you @luxterful, I just released Notivue 1.1.4. Install it with:

npm i notivue@latest

I've also created a working example on StackBlitz with your same tsconfig and the new version installed.

Feel free to close the issue if everything is working as expected.

luxterful commented 11 months ago

Amazing! Thx for the fix!