JavaScript/typescript

来自康健生活
Kangkk​(留言 | 贡献)2021年3月7日 (日) 12:10的版本 (→操作符)

引言

类型

类型

关键字

回调函数 --strict 示例
示例 示例 示例
示例 示例 示例

操作符

typeof 示例 示例
示例 示例 示例
示例 示例 示例

工具类型

Pick 示例 示例
示例 示例 示例
示例 示例 示例

eslint

 
npm install eslint typescript --save-dev
npm install --save-dev @typescript-eslint/parser
npm install --save-dev @typescript-eslint/eslint-plugin

配置

AlloyTeam ESLint

 
npm install --save-dev eslint-config-alloy

部署配置

.eslintrc.js
module.exports = {
    extends: [
        'alloy',
        'alloy/typescript',
    ],
    env: {
        // 您的环境变量(包含多个预定义的全局变量)
        // Your environments (which contains several predefined global variables)
        //
        // browser: true,
        // node: true,
        // mocha: true,
        // jest: true,
        // jquery: true
    },
    globals: {
        // 您的全局变量(设置为 false 表示它不允许被重新赋值)
        // Your global variables (setting to false means it's not allowed to be reassigned)
        //
        // myGlobal: false
    },
    rules: {
        // 自定义您的规则
        // Customize your rules
    }
};

其他

as const 断言 示例
示例 示例 示例
示例 示例 示例

规范

error

  • TypeError: The 'request' argument must be string. Received type undefined
  • Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string'
  • TS2339: Property '$axios' does not exist on type 'NetworkAuth'.
  • Error:(7, 40) TS2691: An import path cannot end with a '.ts' extension. Consider importing '@@/api/httpInterface' instead.


error