代码之家  ›  专栏  ›  技术社区  ›  marcelotokarnia

无法导入非类型化npm模块

  •  0
  • marcelotokarnia  · 技术社区  · 6 年前

    我补充说 paths baseUrl 给我的 tsconfig.json

    {
        "compilerOptions": {
            "outDir": "./built/",
            "sourceMap": true,
            "baseUrl": ".",
            "paths": {
              "*": [ "./typings/*" ]
            },
            "strict": true,
            "noImplicitReturns": true,
            "module": "es2015",
            "moduleResolution": "node",
            "target": "es5"
        },
        "include": [
            "./src/**/*"
        ]
    }
    

    我是打字新手,我真的看过了,但没能解决我的问题。

    我想:

    --index.ts
    import * as VueGoogleMaps from "vue2-google-maps"
    Vue.use(VueGoogleMaps, {
     load: {
       key: GMAPS_KEY,
       libraries: 'places',
     }
    }
    

    我不断地发现错误: TS2345: Argument of type 'typeof 'vue2-google-maps'' is not assignable to parameter of type 'PluginObject<any> | PluginFunction<any>'.

    我试了很多东西 ./typings/index.d.ts

    但我错过了基本面,我知道 VueGoogleMaps 应该有一个PluginObject类型,但是我不知道声明它的语法。

    我试过:

    declare module 'vue2-google-maps' {
      import _Vue from 'vue'
      import { PluginObject, PluginFunction } from "vue/types/plugin"
      export default class GMaps<T> implements PluginObject<T> {
        install(Vue: typeof _Vue, options?: T): void
      }
    }
    

    如有任何帮助,我们将不胜感激

    0 回复  |  直到 6 年前