开始学习!
This commit is contained in:
parent
6adbc5594c
commit
34c2922da7
100
code/ts-practice/.eslintrc.cjs
Normal file
100
code/ts-practice/.eslintrc.cjs
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2022-12-14 15:12:46
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2023-03-06 14:25:14
|
||||
* @FilePath: /ts-practice/.eslintrc.cjs
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: { //需要在 env 中指定运行的环境,这些环境其实就是一组预定义的全局变量,让 ESLint 知道当前环境存在这些全局变量
|
||||
node: true,
|
||||
browser: true,
|
||||
es2021: true,
|
||||
},
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
],
|
||||
// parser: "@babel/eslint-parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: 2021,
|
||||
sourceType: "module",
|
||||
parser: "@babel/eslint-parser",
|
||||
requireConfigFile: false,
|
||||
},
|
||||
rules: {
|
||||
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||
"no-unused-vars": "warn",
|
||||
"semi": ["error", "always",], //控制行尾部分号
|
||||
"quotes": ["error", "double",],
|
||||
"comma-dangle": ["error", {
|
||||
"arrays": "always",
|
||||
"objects": "always",
|
||||
"imports": "never",
|
||||
"exports": "never",
|
||||
"functions": "never",
|
||||
},], //数组和对象键值对最后一个逗号
|
||||
"comma-style": ["error", "last",], //逗号在行位
|
||||
"array-bracket-spacing": ["error", "never",],
|
||||
"no-undef-init": "error",
|
||||
"no-invalid-this": "error",
|
||||
"no-use-before-define": "error",
|
||||
"no-shadow-restricted-names": "error", //禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等
|
||||
"comma-spacing": ["error", { "before": false, "after": true, },],
|
||||
"brace-style": ["error", "allman", { "allowSingleLine": true, },],
|
||||
"prefer-const": "warn",
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ["*.ts",],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
plugins: ["@typescript-eslint",],
|
||||
extends: [
|
||||
"standard-with-typescript",
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
],
|
||||
rules: {
|
||||
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||
"@typescript-eslint/indent": ["error", 4,],
|
||||
"@typescript-eslint/no-extra-semi": "off",
|
||||
"@typescript-eslint/no-inferrable-types": "off",
|
||||
"@typescript-eslint/no-unused-vars": "warn",
|
||||
"@typescript-eslint/ban-ts-comment": "warn",
|
||||
"@typescript-eslint/member-delimiter-style": "off",
|
||||
"@typescript-eslint/semi": ["error", "always",], //控制行尾部分号
|
||||
"@typescript-eslint/brace-style": ["error", "allman", { "allowSingleLine": true, },],
|
||||
"@typescript-eslint/comma-dangle": ["error", {
|
||||
"arrays": "always",
|
||||
"objects": "always",
|
||||
"imports": "never",
|
||||
"exports": "never",
|
||||
"functions": "never",
|
||||
},], //数组和对象键值对最后一个逗号
|
||||
"@typescript-eslint/quotes": ["error", "double",],
|
||||
"@typescript-eslint/space-before-function-paren": "off",
|
||||
"@typescript-eslint/strict-boolean-expressions": ["error", {
|
||||
"allowString": false,
|
||||
},],
|
||||
"comma-style": ["error", "last",], //逗号在行位
|
||||
"array-bracket-spacing": ["error", "never",],
|
||||
"no-undef-init": "error",
|
||||
"no-invalid-this": "error",
|
||||
"no-use-before-define": "error",
|
||||
"no-shadow-restricted-names": "error", //禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等
|
||||
"prefer-const": "warn",
|
||||
"spaced-comment": "error",
|
||||
"space-before-function-paren": "off",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
@ -1,42 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
},
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
Plugin: [
|
||||
"@typescript-eslint", //typescript的语法检查插件
|
||||
],
|
||||
extends: "standard-with-typescript",
|
||||
rules: { // 单项的语法检查规则
|
||||
"no-console": "warn",
|
||||
"quote-props": ["warn", "as-needed",],
|
||||
quotes: ["warn", "double", { allowTemplateLiterals: true, },],
|
||||
indent: ["warn", 4,],
|
||||
"no-unused-vars": "warn",
|
||||
semi: ["error", "always",], // 控制行尾部分号
|
||||
"comma-dangle": ["error", {
|
||||
arrays: "always",
|
||||
objects: "always",
|
||||
imports: "never",
|
||||
exports: "never",
|
||||
functions: "never",
|
||||
},], // 数组和对象键值对最后一个逗号
|
||||
"comma-style": ["error", "last",], // 逗号在行位
|
||||
"array-bracket-spacing": ["error", "never",],
|
||||
"no-undef-init": "error",
|
||||
"no-invalid-this": "error",
|
||||
"no-use-before-define": "error",
|
||||
"no-shadow-restricted-names": "error", // 禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等
|
||||
// "comma-spacing": ["error", { "before": false, "after": true, },],
|
||||
"brace-style": ["error", "allman", { allowSingleLine: true, },],
|
||||
"@typescript-eslint/no-extra-semi": "off",
|
||||
},
|
||||
overrides: [
|
||||
],
|
||||
};
|
20
code/ts-practice/env.d.ts
vendored
Normal file
20
code/ts-practice/env.d.ts
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-03-03 10:07:00
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /task_schedule/env.d.ts
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
interface ImportMetaEnv
|
||||
{
|
||||
readonly VITE_APP_TITLE: string;
|
||||
readonly VITE_URL_VALIDATE_ACCOUNT: string;
|
||||
// 更多环境变量...
|
||||
}
|
||||
|
||||
interface ImportMeta
|
||||
{
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
4956
code/ts-practice/package-lock.json
generated
4956
code/ts-practice/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
code/ts-practice/sfc.d.ts
vendored
Normal file
10
code/ts-practice/sfc.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-03-04 17:21:37
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /task_schedule/sfc.d.ts
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
|
14
code/ts-practice/shims-vue.d.ts
vendored
Normal file
14
code/ts-practice/shims-vue.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-03-04 17:23:02
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /task_schedule/shims-vue.d.ts
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
declare module '*.vue' {
|
||||
import { ComponentOptions } from 'vue';
|
||||
const componentOptions: ComponentOptions;
|
||||
export default componentOptions;
|
||||
}
|
@ -1,2 +1,39 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-03-06 14:20:50
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /ts-practice/src/index.ts
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// 索引类型
|
||||
interface Point
|
||||
{
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
type kes = keyof Point;
|
||||
type name = "name";
|
||||
|
||||
const value: name = "name";
|
||||
|
||||
// 联合类型
|
||||
interface Circle
|
||||
{
|
||||
radius: number;
|
||||
area: number;
|
||||
}
|
||||
|
||||
interface Rectangle
|
||||
{
|
||||
area: number;
|
||||
wdith: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
type Shape = Circle | Rectangle;
|
||||
|
||||
let a: Shape;
|
||||
|
@ -11,8 +11,8 @@ service.interceptors.request.use(
|
||||
{
|
||||
return config;
|
||||
},
|
||||
(error) =>
|
||||
async (error) =>
|
||||
{
|
||||
return Promise.reject(error);
|
||||
return await Promise.reject(error);
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @Author: Kane
|
||||
* @Date: 2023-03-03 11:21:43
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /code_test/tsconfig.json
|
||||
* @FilePath: /ts-practice/tsconfig.json
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
@ -10,7 +10,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"target": "ES2015",
|
||||
"target": "ESNext",
|
||||
"module": "CommonJS",
|
||||
"esModuleInterop": true,
|
||||
"lib": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user