Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types for typescript are not available #17

Open
suterma opened this issue Sep 10, 2023 · 2 comments
Open

Types for typescript are not available #17

suterma opened this issue Sep 10, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@suterma
Copy link
Owner

suterma commented Sep 10, 2023

Currently I did not yet manage to properly build typescript types for the vue-peaks component and include them is the npm package in a usable manner.

You currently get the warning:

Could not find a declaration file for module 'vue-peaks'. '/..../node_modules/vue-peaks/dist/vue-peaks.js' implicitly has an 'any' type.
Try npm i --save-dev @types/vue-peaks if it exists or add a new declaration (.d.ts) file containing declare module 'vue-peaks';ts(7016)

Workaround: If this causes a problem, follow the suggestion and create the declaration, which just works.

I would gladly accept some guidance here, as various efforts did not yet lead to success. Please comment or contact me otherwise.

@suterma suterma added the enhancement New feature or request label Sep 10, 2023
@tofi86
Copy link

tofi86 commented Jan 9, 2025

We tried using the alternative approach to import typescript types:

alternative: The package does not currently properly export types, see issue #17. To get TypeScript support, you can also directly include the vue component as SFC:

However, this didn't work because the types aren't exported in your package.json:

"exports": {
    ".": {
      "import": "./dist/vue-peaks.js",
      "require": "./dist/vue-peaks.umd.cjs",
    },
    "./dist/style.css": {
      "import": "./dist/style.css",
      "require": "./dist/style.css"
    }
  },
  "types": "./dist/src/index.d.ts",

However, what worked for us in a manual test was changing your package.json in our node_modules folder to the following:

"exports": {
    ".": {
      "import": "./dist/vue-peaks.js",
      "require": "./dist/vue-peaks.umd.cjs",
      "types": "./dist/src/index.d.ts"
    },
    "./dist/style.css": {
      "import": "./dist/style.css",
      "require": "./dist/style.css"
    }
  },
  "types": "./dist/src/index.d.ts",

Just to let you know... Meaybe this helps fixing other issues...

Thanks for maintaining this project! Keep up the good work! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants