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

Vue3 + TypeScript = TS7016: Could not find a declaration file for module 'vue-yandex-maps' #356

Closed
crazy-tosser opened this issue Feb 9, 2022 · 5 comments

Comments

@crazy-tosser
Copy link

При попытке в компоненте сделать

import { yandexMap } from 'vue-yandex-maps'
Получаю ошибку

TS7016: Could not find a declaration file for module 'vue-yandex-maps'. {{path_to_project}}/node_modules/vue-yandex-maps/dist/vue-yandex-maps.umd.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/vue-yandex-maps` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-yandex-maps';`

package.json

"dependencies": {
    "@vueuse/core": "^6.9.0",
    "axios": "^0.21.4",
    "vee-validate": "^4.5.4",
    "vue": "^3.0.0",
    "vue-class-component": "^8.0.0-0",
    "vue-router": "^4.0.12",
    "vue-yandex-maps": "^0.12.3",
    "vuex": "^4.0.2"
  },
"devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.18.0",
    "@typescript-eslint/parser": "^4.18.0",
    "@vue/cli-plugin-babel": "^4.5.15",
    "@vue/cli-plugin-eslint": "^4.5.15",
    "@vue/cli-plugin-typescript": "^4.5.15",
    "@vue/cli-service": "^4.5.15",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-typescript": "^7.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^7.20.0",
    "sass": "^1.43.4",
    "sass-loader": "^10.0.3",
    "typescript": "~4.1.5"
  },
@PNKBizz
Copy link
Member

PNKBizz commented Feb 10, 2022

Скоро будет бета-версия плагина на TS для Vue3. Дописываю документацию

@rodial
Copy link

rodial commented May 10, 2022

You can create file vue-yandex-maps.d.ts with

declare module 'vue-yandex-maps';

@Goryyn
Copy link

Goryyn commented May 12, 2022

@rodial Please, can you be more specific?

@rodial
Copy link

rodial commented May 14, 2022

@Goryyn
In src/ create file vue-yandex-maps.d.ts with one line

declare module 'vue-yandex-maps';

It's not good solution, but removes the error and I used it

After it, if you don't want to see warnings like "Unknown html tag ymap-marker" use

import {yandexMap as YandexMap, ymapMarker as YmapMarker} from "vue-yandex-maps";

Also you can try to declare export, like

declare module 'vue-yandex-maps' {
  import {Component} from "vue";
  export const yandexMap: Component
  ...
}

...but I was too lazy for it

Information about it

@daniluk4000
Copy link
Member

Fixed with 1.x/2.x

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

No branches or pull requests

6 participants
@daniluk4000 @rodial @PNKBizz @crazy-tosser @Goryyn and others