JavaScript/typescript/类型:修订间差异
来自康健生活
< JavaScript | typescript
| 第20行: | 第20行: | ||
可变参数 | 可变参数 | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="typescript"> | ||
interface HttpFetchInterface { | interface HttpFetchInterface { | ||
fetch(...params: any[]): Promise<object>; | fetch(...params: any[]): Promise<object>; | ||
} | } | ||
async fetch (username:string, password:string, httpMethod?:string): Promise<object>{</syntaxhighlight> | async fetch (username:string, password:string, httpMethod?:string): Promise<object>{</syntaxhighlight> | ||
2020年8月28日 (五) 03:31的最新版本
标题文字
Record<string, unknown>
定义一个任意类型的对象
{[propname:any]:any}
// or
const obj: Record<string | number | symbol, any> = {};
Promise<void>
Promise 返回值设定
new Promise<number>
// or
new Promise((reslove: (value:number)=>void, reject)=>{
// reslove
})
...params: any[]
可变参数
interface HttpFetchInterface {
fetch(...params: any[]): Promise<object>;
}
async fetch (username:string, password:string, httpMethod?:string): Promise<object>{
No categories