highlightjs / vue-plugin

Highlight.js Vue Plugin
BSD 3-Clause "New" or "Revised" License
200 stars 28 forks source link

Could not find a declaration file for module '@highlightjs/vue-plugin' #7

Closed mioe closed 3 years ago

mioe commented 3 years ago

изображение

Could not find a declaration file for module '@highlightjs/vue-plugin'. 'c:/Users/misha/.mi/vite-ts-template/node_modules/@highlightjs/vue-plugin/dist/highlightjs-vue.min.js' implicitly has an 'any' type. Try npm i --save-dev @types/highlightjs__vue-plugin if it exists or add a new declaration (.d.ts) file containing declare module '@highlightjs/vue-plugin';ts(7016)

tsconfig.sjon:

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "lib": ["esnext", "dom"],
    "types": [
      "vite/client",
      "@intlify/vite-plugin-vue-i18n/client"
    ],
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["./src/**/*.ts", "./src/**/*.d.ts", "./src/**/*.tsx", "./src/**/*.vue"]
}

package.json:

"dependencies": {
    "@highlightjs/vue-plugin": "^2.0.0",
    "@vueuse/core": "^4.11.1",
    "@vueuse/head": "^0.5.1",
    "axios": "^0.21.1",
    "highlight.js": "^11.0.0",
    "vue": "^3.0.11",
    "vue-i18n": "^9.1.6",
    "vue-router": "^4.0.8"
  },
  "devDependencies": {
    "@iconify/json": "^1.1.348",
    "@intlify/vite-plugin-vue-i18n": "^2.1.2",
    "@types/node": "^15.3.1",
    "@typescript-eslint/eslint-plugin": "^4.25.0",
    "@typescript-eslint/parser": "^4.25.0",
    "@vitejs/plugin-vue": "^1.2.2",
    "@vue/compiler-sfc": "^3.0.11",
    "@vue/eslint-config-typescript": "^7.0.0",
    "eslint": "^7.27.0",
    "eslint-plugin-vue": "^7.9.0",
    "sass": "^1.32.12",
    "typescript": "^4.2.4",
    "vite": "^2.3.4",
    "vite-plugin-components": "^0.10.2",
    "vite-plugin-icons": "^0.5.1",
    "vite-plugin-windicss": "^0.16.0"
  }
joshgoebel commented 3 years ago

Someone from TS land may have to jump in here... there is a vue.ts.d file and package.json has a types key... or is the problem again perhaps just the pesky files key?

Trinovantes commented 3 years ago

That's my fault, I copy&pasted the filenames in package.json but forgot tsc generates vue.d.ts instead of highlightjs-vue.d.ts

joshgoebel commented 3 years ago

tsc generates vue.d.ts instead of highlightjs-vue.d.ts

Why the naming discrepancy, that seems a bit strange, no?

Trinovantes commented 3 years ago

tsc generates based on the source file name (vue.ts) whereas the js file is named by rollup

Maybe the source file should be renamed?

joshgoebel commented 3 years ago

If that's the only way to do it... I think optimally I'd prefer to just tell it "hey rename this type file when you output it" however that is done, if that is possible. :)

Trinovantes commented 3 years ago

Don't think it's possible because tsc needs to generate a 1:1 mapping with the source files

Want me to update the current open PR with the filename change?

mioe commented 3 years ago

That's my fault, I copy&pasted the filenames in package.json but forgot tsc generates vue.d.ts instead of highlightjs-vue.d.ts

изображение

mioe commented 3 years ago

yes it's all fixed, thanks)

joshgoebel commented 3 years ago

Want me to update the current open PR with the filename change?

Not sure that's necessary if we just update the reference... lets see how that holds up. After your PR should I issue a 2.0.1 probably? @Trinovantes

Trinovantes commented 3 years ago

Yes, please release a 2.0.1 with the corrected type filename

joshgoebel commented 3 years ago

Done.