简单看了下 typescript 官网的语法,就想借助一个项目实战下。这里选用了 vue-admin-element附上源码地址:vue-element-admin-ts,欢迎 star 或 fork遇到的问题及解决方案Q: error TS7017: Index signature of object type implicitly has an ‘any’ typeA: https://stackoverflow.com/que…或者在 tsconfig.json文件的 compilerOptions选项中添加"noImplicitAny": falseQ: error TS2339: Property ‘webkitURL’ does not exist on type ‘Window’A:https://stackoverflow.com/que…interface Window { webkitURL?: any; } declare var window: Window;Q: Property ‘context’ does not exist on type ‘NodeRequire’.A:https://github.com/rails/webp…npm i -D @types/webpack-envQ: ’this’ implicitly has type ‘any’ because it does not have a type annotationA: https://stackoverflow.com/que...Q: 导入 .vue 时,为什么会报错,即使所写的路径并没有问题?A: 在 TypeScript 中,它仅识别 js/ts/jsx/tsx 文件,为了让它识别 .vue 文件,我们需要显式告诉 TypeScript,vue 文件存在,并且指定导出 VueConstructor:declare module ‘*.vue’ { import Vue from ‘vue’ export default Vue}Q: TS2345: Argument of type ‘string’ is not assignable to parameter of type ’never’.A: 空的数组添加数据的时候,会有这个提示,解决方案:https://github.com/Microsoft/…Q: Property ‘basePath’ has no initializer and is not definitely assigned in the constructor. 59 | @Prop({required: true, default: {}}) public item: Route; 60 | @Prop({default: false}) public isNest: boolean; > 61 | @Prop({default: ‘’}) public basePath: string;A: https://github.com/kaorun343/...Q: Object is possibly ‘undefined’.A: https://stackoverflow.com/que...Q:Property ‘$refs’ does not exist on type ‘Element | Element[] | Vue | Vue[]’. Property ‘$refs’ does not exist on type ‘Element’.A: https://github.com/vuejs/vue-...https://juejin.im/post/5bd698...https://www.leevii.com/2018/1