paidaxing-web / you-don-t-know-ts Goto Github PK
View Code? Open in Web Editor NEW🔥🔥🔥 这是一个专注研究Typescript的网站,🎖🎖🎖在这里你可以全面深入学习Typescript相关知识,通过动画方式讲解TS,还有很多常见问题解答。你还可以挑战相应的题目,快来学习吧。
Home Page: https://youjia.sx.cn/you-dont-know-ts
🔥🔥🔥 这是一个专注研究Typescript的网站,🎖🎖🎖在这里你可以全面深入学习Typescript相关知识,通过动画方式讲解TS,还有很多常见问题解答。你还可以挑战相应的题目,快来学习吧。
Home Page: https://youjia.sx.cn/you-dont-know-ts
//你的答案
type MyReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
//你的答案
type Unshift<T extends unknown[], U> = [U, ...T]
type MyAwaited<T,K>={
[P in K]:T[P]
type MyPick<T, K extends keyof T> ={
[P in K]:T[P]
};
//你的答案
type MyOmit<T, K> = { [P in keyof T as P extends K ? never : P]: T[P] };
/* _____________ 你的代码 _____________ */
type MyAwaited<T> = T extends Promise<infer U>
? MyAwaited<U>
: T extends { then: (p: (arg: infer K) => any) => any }
? K
: T;
/* _____________ 测试用例 _____________ */
import type { Equal, Expect } from '@type-challenges/utils';
type X = Promise<string>;
type Y = Promise<{ field: number }>;
type Z = Promise<Promise<string | number>>;
type Z1 = Promise<Promise<Promise<string | boolean>>>;
type T = { then: (onfulfilled: (arg: number) => any) => any };
type cases = [
Expect<Equal<MyAwaited<X>, string>>,
Expect<Equal<MyAwaited<Y>, { field: number }>>,
Expect<Equal<MyAwaited<Z>, string | number>>,
Expect<Equal<MyAwaited<Z1>, string | boolean>>,
Expect<Equal<MyAwaited<T>, number>>
];
// @ts-expect-error
type error = MyAwaited<number>;
type MyPick<T, K extends keyof T> = {
[P in K]:T[P]
};
type MyReadonly2<T, K extends keyof T = keyof T> = Omit<T, K> & Readonly<T>;
//你的答案
// 你的答案
//你的答案
type MyOmit<T, K> = { [P in keyof T as P extends K ? never : P]: T[P] };
type HelloWorld = string;
//你的答案
type Unshift<T extends unknown[], U> = [U, ...T]
type HelloWorld =string;
//你的答案
type Unshift<T extends unknown[], U> = [U, ...T]
// 你的答案
import './style.css';
import type { Equal, Expect, NotAny } from '@type-challenges/utils';
// Write TypeScript code!
const appDiv: HTMLElement = document.getElementById('app');
appDiv.innerHTML = `<h1>第一题:Hello World</h1><p> 你需要使得14行不会抛出异常</p>`;
// 期望是一个 string 类型
type HelloWorld = string;
//你需要使得如下这行不会抛出异常
type cases = [Expect<NotAny<HelloWorld>>, Expect<Equal<HelloWorld, string>>];
type MyPick<T, K extends keyof T> = {[F in K]:T[F]};
// 你的答案
type HelloWorld = string;
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.