在 .ts 文件中可以校验
在.vue 的文件中未出现校验 并且在 鼠标 悬浮在 声明的类型上 也不会有提示
只在 yarn run serve 运行的时候出现校验报错
eslintrc 配置
tsconfig.json 配置
`
{
"include": [
"src/*.ts",
"src/**/*.ts",
"src/**/*.vue"
],
"exclude": [
"node_modules"
],
// 编译选项
"compilerOptions": {
// 输出目录
"outDir": "./output",
// 是否包含可以用于 debug 的 sourceMap
"sourceMap": true,
// 定义this
"noImplicitThis": false,
// 以严格模式解析
"strict": true,
// 采用的模块系统
"module": "esnext",
// 如何处理模块
"moduleResolution": "node",
// 无需要设定默认值
"strictPropertyInitialization": false,
// 允许从没有设置默认导出的模块中默认导入
"allowSyntheticDefaultImports": true,
// 将每个文件作为单独的模块
"isolatedModules": false,
// 启用装饰器
"experimentalDecorators": true,
// 启用设计类型元数据(用于反射)
"emitDecoratorMetadata": true,
// 在表达式和声明上有隐含的any类型时报错
"noImplicitAny": false,
// 不是函数的所有返回路径都有返回值时报错。
"noImplicitReturns": true,
// 从 tslib 导入外部帮助库: 比如__extends,__rest等
"importHelpers": true,
// 编译过程中打印文件名
"listFiles": true,
// 移除注释
"removeComments": true,
"suppressImplicitAnyIndexErrors": true,
// 允许编译javascript文件
"allowJs": true,
// 解析非相对模块名的基准目录
"baseUrl": "./",
// 指定特殊模块的路径
"paths": {
"@/*": ["src/*"], // 这里 只建议使用 @/ 使用其他的别名可能不会生效
},
// 编译输出目标 ES 版本
"target": "es5",
// 编译过程中需要引入的库文件的列表
"lib": ["es2015", "es2017", "dom"]
}
}`
tslint-vue 插件装一下试试