Giter Site home page Giter Site logo

paidaxing-web / you-don-t-know-ts Goto Github PK

View Code? Open in Web Editor NEW
39.0 2.0 9.0 69.22 MB

🔥🔥🔥 这是一个专注研究Typescript的网站,🎖🎖🎖在这里你可以全面深入学习Typescript相关知识,通过动画方式讲解TS,还有很多常见问题解答。你还可以挑战相应的题目,快来学习吧。

Home Page: https://youjia.sx.cn/you-dont-know-ts

TypeScript 10.87% Shell 0.03% Vue 9.19% JavaScript 64.30% CSS 9.33% HTML 6.29%
ts typescript typescript-library animation conditional-types generics mapped-types union-types utility-types typescript-interface

you-don-t-know-ts's Introduction

Collection of TypeScript type challenges



目录

Typescript 常用项目技巧汇总

以动画的形式,让你弄清楚 TypeScript 泛型中的 K、T、V 等变量!

帮助您更好地理解内置实用程序类型的工作原理。

掌握 TypeScript 中的类型并了解 TypeScript 系统。让您的 TypeScript 技能更进一步。

用动画来解释。掌握 Type 和 Interface 的异同,了解它们的使用场景。

以动画的形式,让你弄清楚 keyof 运算符在 TypeScript 内置实用类型中的作用。

大多数人在学习 TypeScript 时都会遇到的一个问题,你能想到多少种解决方案?

TypeScript 中函数重载的简单解释,帮助您理解重载签名和实现签名。

欢迎大家 PR 贡献 TS 代码,点个 Star 持续更新中...🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥

you-don-t-know-ts's People

Contributors

artiely avatar paidaxing-web avatar w-hanyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

you-don-t-know-ts's Issues

2-2实现-omit.md

//你的答案
type MyOmit<T, K> = { [P in keyof T as P extends K ? never : P]: T[P] };

1.2.实现Pick

type MyPick<T, K extends keyof T> = {

  [P in K]:T[P]
};

2-3-实现Readonly2.md

type MyReadonly2<T, K extends keyof T = keyof T> = Omit<T, K> & Readonly<T>;
//你的答案

1.2.实现Pick

type MyPick<T, K extends keyof T> ={
[P in K]:T[P]
};

1.3.实现Awaited

/* _____________ 你的代码 _____________ */

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>;

1.1.hello-world

// 你的答案
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>>];

2-2实现-omit.md

//你的答案
type MyOmit<T, K> = { [P in keyof T as P extends K ? never : P]: T[P] };

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.