上一页 1 ··· 181 182 183 184 185 186 187 188 189 ··· 498 下一页
摘要: class Foo { bar() {} } const bar = new Foo() console.log(bar instanceof Foo) // true console.log(Object.getPrototypeOf(bar) Foo.prototype) // true cla 阅读全文
posted @ 2020-10-04 01:16 Zhentiw 阅读(114) 评论(0) 推荐(0)
摘要: "Record" repersent key-value pair. type MyRecord<K extend string, T> = { [P in K]: T } Record key should be string. array[0] in javascript, even we gi 阅读全文
posted @ 2020-10-01 19:01 Zhentiw 阅读(203) 评论(0) 推荐(0)
摘要: For example we have interface: interface Person { name: string, age?: number } 'age' is an optional prop. // will have an error since person.age is us 阅读全文
posted @ 2020-10-01 18:50 Zhentiw 阅读(133) 评论(0) 推荐(0)
摘要: type MyPartial<T> = { [P in keyof T]?: T[P] } 'in' like a loop. Usage: function updatePerson(person: Person, prop: MyPartial<Person>) { return {...per 阅读全文
posted @ 2020-10-01 18:42 Zhentiw 阅读(112) 评论(0) 推荐(0)
摘要: interface Person { name: string; age: number; address: {} } // gives error since we didn't define 'address' const person: Person = { name: "Wan", age: 阅读全文
posted @ 2020-10-01 15:04 Zhentiw 阅读(126) 评论(0) 推荐(0)
摘要: interface Person { name: string; age: number; } interface ReadonlyPerson { readonly name: string; readonly age: number; } const person: ReadonlyPerson 阅读全文
posted @ 2020-10-01 14:51 Zhentiw 阅读(148) 评论(0) 推荐(0)
摘要: const person = { name: "wan", age: 28 } type Person = typeof person type PersonKeys = keyof person // "name" | "age" type PersonKTypes = Person[Person 阅读全文
posted @ 2020-09-30 20:20 Zhentiw 阅读(131) 评论(0) 推荐(0)
摘要: In Javascript, you know typeof: typeof [] // object typeof "" // string In Typescript it is more smart: const person = { name: "wan", age: 28 } type P 阅读全文
posted @ 2020-09-30 20:11 Zhentiw 阅读(140) 评论(0) 推荐(0)
摘要: import { compose } from "ramda"; let input = document.getElementById("input"); let inputBroadcaster = (listener) => { input.addEventListener("input", 阅读全文
posted @ 2020-09-30 18:32 Zhentiw 阅读(182) 评论(0) 推荐(0)
摘要: import { compose } from "ramda"; let input = document.getElementById("input"); let inputBroadcaster = (listener) => { input.addEventListener("input", 阅读全文
posted @ 2020-09-30 18:12 Zhentiw 阅读(142) 评论(0) 推荐(0)
上一页 1 ··· 181 182 183 184 185 186 187 188 189 ··· 498 下一页