Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update typescript.md #1863

Merged
merged 4 commits into from
Oct 27, 2022
Merged

Update typescript.md #1863

merged 4 commits into from
Oct 27, 2022

Conversation

JonghwanWon
Copy link
Contributor

This PR updates typescript.md to Adds a few extra hints.

@ShivamJoker
Copy link

Good work

typescript.md Outdated Show resolved Hide resolved
typescript.md Outdated
Comment on lines 254 to 264
```ts
type GetReturnType<T> = T extends (...args: unknown[]) => infer R
? R
: never;

type Num = GetReturnType<() => number>; // number

type First<T extends Array<any>> = T extends [infer F, ...infer Rest] ? F : never;

type Str = First<['hello', 1, false]>; // 'hello'
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those are two different examples. You may split those.

type GetReturnType<T> = T extends (...args: unknown[]) => infer R
  ? R
  : never;

type Num = GetReturnType<() => number>; // number
type First<T extends Array<any>> = T extends [infer F, ...infer Rest] ? F : never;

type Str = First<['hello', 1, false]>; // 'hello'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
I fixed it.

@rstacruz rstacruz merged commit 6999e94 into rstacruz:master Oct 27, 2022
@JonghwanWon JonghwanWon deleted the typescript branch October 29, 2022 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants