jetsly / alleria Goto Github PK
View Code? Open in Web Editor NEWa loose collection of plugins
License: MIT License
a loose collection of plugins
License: MIT License
基础写法
interface IPerson {
name: string;
age: number;
}
type Person = {
name: string;
age: number;
};
继承
type PartPerson = {
age: number;
};
interface IPartPerson {
age: number;
}
type Person = {
name: string;
} & PartPerson;
interface IPerson extends IPartPerson {
name: string;
}
联合类型
type PartPerson = {
name: number;
};
interface IPartPerson {
name: string;
}
type Person = IPartPerson | PartPerson;
属性名字约束
type Person = {
[k in 'age'|'name']: any;
};
只读属性
type Person = Readonly<{
age: number;
name: string;
}>;
interface _IPerson {
age: number;
name: string;
}
interface IPerson extends Readonly<_IPerson> {}
可选属性
type Person = Partial<{
age: number;
name: string;
}>;
interface _IPerson {
age: number;
name: string;
}
interface IPerson extends Partial<_IPerson> {}
非空属性
type Person = Required<{
age?: number;
name?: string;
}>;
interface _IPerson {
age: number;
name: string;
}
interface IPerson extends Required<_IPerson> {}
推导类型,用于继承
type TArray = Array<string | number>;
type ElementOf<T> = T extends Array<infer E> ? E : never;
ElementOf<TArray> === string | number
获取属性名
type Person = keyof {
age: number;
name: string;
};
interface _IPerson {
age: number;
name: string;
}
type IPerson = keyof _IPerson;
选取属性
type Person = Pick<{
age: number;
name: string;
},'name'>;
interface _IPerson {
age: number;
name: string;
}
interface IPerson extends Pick<_IPerson,'name'> {}
排除属性
type Person = Omit<{
age: number;
name: string;
},'age'>;
interface _IPerson {
age: number;
name: string;
}
interface IPerson extends Omit<_IPerson,'age'> {}
实例类型
class _Person {
name: string;
age: number;
}
type Person =InstanceType<typeof _Person>
构造函数参数类型
class _Person {
constructor(person:{name: string, age: number}) {}
}
type Person = ConstructorParameters<typeof _Person>;
返回类型
function _Person():{ name:string, age:number }{
return ....
}
type Person =ReturnType<typeof _Person>
参数类型
function _Person(person:{name: string, age: number}) {
return ..
}
type Person = Parameters<typeof _Person>;
加载groovy文件
configFileProvider([configFile(fileId: 'fileName', variable: 'filePath')]){
script {
def cfg = load(filePath)
}
}
#!/usr/bin/expect
set timeout 30
spawn ssh -p [lindex $argv 0] [lindex $argv 1]@[lindex $argv 2]
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "[password]\n"}
}
interact
xxx/xxx.sh [port] [username] [ip]
创建空白分支
git checkout --orphan [branchName]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.