飞跃高山与大洋的鱼飞跃高山与大洋的鱼
首页
先看
计算机
  • 数学
  • Linux
  • Arch
  • Manjaro
  • Ubuntu
  • CentOS
  • Kubernetes
  • Web
  • JavaScript
  • TypeScript
  • CSS
  • Canvas
  • Vue
  • Vite
  • NuxtJS
  • Webpack
  • Flutter
  • D3
  • Jest
  • WeApp
  • Utils
  • Nodejs
  • Nestjs
  • Golang
  • Nginx
  • Traefik
  • MySQL
  • MongoDB
  • Redis
  • Docker
算法
  • 像素风
  • Git
  • Github
  • VSCode
  • Chrome
  • Google
  • Bookmark scripts
  • 导航 🎉
  • VuePress 侧边栏插件
  • VuePress 官网
🚇 开往
首页
先看
计算机
  • 数学
  • Linux
  • Arch
  • Manjaro
  • Ubuntu
  • CentOS
  • Kubernetes
  • Web
  • JavaScript
  • TypeScript
  • CSS
  • Canvas
  • Vue
  • Vite
  • NuxtJS
  • Webpack
  • Flutter
  • D3
  • Jest
  • WeApp
  • Utils
  • Nodejs
  • Nestjs
  • Golang
  • Nginx
  • Traefik
  • MySQL
  • MongoDB
  • Redis
  • Docker
算法
  • 像素风
  • Git
  • Github
  • VSCode
  • Chrome
  • Google
  • Bookmark scripts
  • 导航 🎉
  • VuePress 侧边栏插件
  • VuePress 官网
🚇 开往
  • TYPESCRIPT

    • 更好维护的 TypeScript
    • 修改 axios response 返回类型
    • ESLint 在 TypeScript 未能好好工作
      • enum is defined but never used
      • Cannot read property 'loc' of undefined
      • Cannot read property 'body' of null
    • 扩展 Vue Router Meta 信息
    • TypeScript 类型挑战
    • TypeScript 常见问题

ESLint 在 TypeScript 未能好好工作

ESLint 的提示在 TypeScript 下没有好好工作。

enum is defined but never used

// xxx is defined but never used. eslint(no-unused-vars)
export enum UserRole {
  USER = 'user',
  ADMIN = 'admin',
}

这时该使用 TypeScript 的规则取而代之:

module.exports = {
  // ...
  rules: {
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': 'error'
  }
}

Cannot read property 'loc' of undefined

参考 Cannot read property 'loc' of undefined 修改:

module.exports = {
  // ...
  rules: {
    'indent': 'off',
    '@typescript-eslint/indent': [
      'error',
      2
    ]
  }
}

Cannot read property 'body' of null

module.exports = {
  // ...
  rules: {
    'no-useless-constructor': 'off',
    '@typescript-eslint/no-useless-constructor': 'error'
  }
}
编辑文档!
上次更新:
贡献者: shanyuhai123
Prev
修改 axios response 返回类型
Next
扩展 Vue Router Meta 信息