• Vue3+Ts各种错误整理


    解决 Vue3项目编译出现 Could not find a declaration file for module 'module-name'. '/path/to/module-name.js' implicitly has an 'any' type

    1. npm install typescript
    2. npm install @vue/cli-plugin-typescript
    3. tsc init
    4. package.json增加eslint配置
    5. "eslintConfig": {
    6. "root": true,
    7. "env": {
    8. "node": true
    9. },
    10. "extends": [
    11. "plugin:vue/vue3-essential",
    12. "eslint:recommended",
    13. "@vue/typescript/recommended"
    14. ],
    15. "parserOptions": {
    16. "ecmaVersion": 2020
    17. },
    18. "rules": {
    19. "@typescript-eslint/semi": "off",
    20. "@typescript-eslint/camelcase": "off",
    21. "@typescript-eslint/no-explicit-any": ["off"],
    22. "@typescript-eslint/no-unused-vars": ["off"],
    23. "@typescript-eslint/no-non-null-assertion": ["off"]
    24. }
    25. }
    26. 并修改tsconfig.js 内容为如下:
    27. {
    28. "compilerOptions": {
    29. "target": "esnext",
    30. "module": "esnext",
    31. "strict": true,
    32. "jsx": "preserve",
    33. "moduleResolution": "node",
    34. "experimentalDecorators": true,
    35. "skipLibCheck": true,
    36. "esModuleInterop": true,
    37. "allowSyntheticDefaultImports": true,
    38. "forceConsistentCasingInFileNames": true,
    39. "useDefineForClassFields": true,
    40. "sourceMap": true,
    41. "baseUrl": ".",
    42. "types": [
    43. "webpack-env"
    44. ],
    45. "paths": {
    46. "@/*": [
    47. "src/*"
    48. ]
    49. },
    50. "lib": [
    51. "esnext",
    52. "dom",
    53. "dom.iterable",
    54. "scripthost"
    55. ]
    56. },
    57. "include": [
    58. "src/**/*.ts",
    59. "src/**/*.tsx",
    60. "src/**/*.vue",
    61. "tests/**/*.ts",
    62. "tests/**/*.tsx"
    63. ],
    64. "exclude": [
    65. "node_modules"
    66. ]
    67. }
    68. 创建shims-vue.d.js 一定要放在src目录下
    69. /* eslint-disable */
    70. declare module '*.vue' {
    71. import type { DefineComponent } from 'vue'
    72. const component: DefineComponent<{}, {}, any>
    73. export default component
    74. }

  • 相关阅读:
    HJ16 购物单
    shiro授权-SSM
    数据库直连提示 No suitable driver found for jdbc:postgresql
    el7升级Apache模块编译
    Qt 数据库的注册和登录功能
    玩客云Armbian_23.08.0-trunk_Onecloud_bookworm_edge_6.4.14.burn配置
    vscode 连接 GitHub
    y96.第六章 微服务、服务网格及Envoy实战 -- xDS API与动态配置(七)
    LeetCode 0143. 重排链表
    ArcGIS学习(十四)OD分析
  • 原文地址:https://blog.csdn.net/yue7603835/article/details/126177776