init
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
interface SquareConfig {
|
||||
color?: string;
|
||||
width?: number;
|
||||
}
|
||||
|
||||
function createSquare(config: SquareConfig): { color: string; area: number } {
|
||||
return {
|
||||
color: config.color || 'red',
|
||||
area: config.width ? config.width * config.width : 20
|
||||
};
|
||||
}
|
||||
let config = { colour: 'red', width: 100 };
|
||||
|
||||
let mySquare = createSquare(config);
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
declare type RecordAny = Record<string, any>;
|
||||
declare type RecordNever = Record<never, never>;
|
||||
declare type RecordAnyOrNever = RecordAny | RecordNever;
|
||||
|
||||
/**
|
||||
* 基础类型接口
|
||||
*/
|
||||
declare type BaseType = boolean | number | string | undefined | null;
|
||||
|
||||
/**
|
||||
* 环境变量类型转义函数接口
|
||||
*/
|
||||
declare type ParseType<T extends BaseType = string> = (value: string) => T;
|
||||
|
||||
/**
|
||||
* 一个类的类型
|
||||
*/
|
||||
declare type ClassType<T> = new (...args: any[]) => T;
|
||||
|
||||
/**
|
||||
* 嵌套对象全部可选
|
||||
*/
|
||||
declare type RePartial<T> = {
|
||||
[P in keyof T]?: T[P] extends (infer U)[] | undefined
|
||||
? RePartial<U>[]
|
||||
: T[P] extends object | undefined
|
||||
? T[P] extends ((...args: any[]) => any) | ClassType<T[P]> | undefined
|
||||
? T[P]
|
||||
: RePartial<T[P]>
|
||||
: T[P];
|
||||
}
|
||||
|
||||
/**
|
||||
* 防止swc下循环依赖报错
|
||||
*/
|
||||
declare type WrapperType<T> = T;
|
||||
Reference in New Issue
Block a user