Typescript Tips
  • Typescript Tips
  • docs
    • Contributor Covenant Code of Conduct
    • Contribution Guidelines
    • Deploy to Github Page Typescript Tips | typescript-tips
  • notes
    • Carlillo - 1591148366070747347
    • Steve8708 - 1605322303319199744
    • erikras - 1457999235564154882
    • housecor - 1581638360543600640
    • housecor - 1586865516395876359
    • housecor - 1596861970170671104
    • kulkarniankita9 - 1594154991148597250
    • mattpocockuk - 1506607945445949446
    • mattpocockuk - 1509850662795989005
    • mattpocockuk - 1509964736275927042
    • mattpocockuk - 1512388535692652547
    • mattpocockuk - 1536670032360611840
    • mattpocockuk - 1542079199543975937
    • mattpocockuk - 1590333383501979649
    • mattpocockuk - 1591047557702389760
    • mattpocockuk - 1592130978234900484
    • mattpocockuk - 1593584053042630657
    • mattpocockuk - 1598708710523772929
    • mattpocockuk - 1638562171863834625
    • mgechev - 1309379618034642946
    • mgechev - 1361186013029269506
    • mgechev - 1462654597059817481
    • sebastienlorber - 1512420374201446405
    • stackblitz - 1325818478675304448
    • stackblitz - 1328353096179789824
    • stackblitz - 1330890655351123968
    • sulco - 1160890708615716864
    • sulco - 1222507593287028736
    • wesbos - 1524040757518258176
    • wesbos - 1582803702225989637
    • wesbos - 1583093975359315968
    • wesbos - 1584905090628034560
    • wesbos - 1585258976421224450
    • wesbos - 1585641232155348992
    • wesbos - 1587082842110033926
    • wesbos - 1615777112408866832
Powered by GitBook
On this page
  • 🏠 Homepage
  • ✨ Gitbook
  • Contents
  • Tips
  • Matt Pocock
  • Wes Bos
  • Erik Rasmussen
  • Carlos Caballero
  • Ankita Kulkarni
  • Minko Gechev
  • Cory House
  • Tomek Sułkowski
  • Sebastien Lorber
  • Steve (Builder.io)
  • StackBlitz
  • Extending existing types
  • Built-in types
  • Contribute
  • Twitter to markdown file
  • Credits
  • Open Source
  • Tech Twitter
  • Author
  • Show your support
  • Stargazers over time

Typescript Tips

Nextdocs

Last updated 1 year ago

A curated list of awesome 🔥 TypeScript Tips 🔥

If you enjoy TypeScript and really want to use Typesafe, you can check

🏠

✨

Contents

Tips

Matt Pocock

Wes Bos

Erik Rasmussen

Carlos Caballero

Ankita Kulkarni

Minko Gechev

Cory House

Tomek Sułkowski

Sebastien Lorber

Steve (Builder.io)

StackBlitz

Extending existing types

Built-in types

There are many advanced types most users don't know about.

Contribute

Twitter to markdown file

# .envrc
export TTM_API_KEY=YOUR_API_KEY
 direnv allow .

And, generate markdown from a twitter url

npx tweet-to-markdown -p notes https://twitter.com/mattpocockuk/status/1509964736275927042\?s\=20\&t\=sA-g5MNM5TPjN6Ozs1qxgA

Then save video if available

npx twt-dl-cli@latest https://twitter.com/mattpocockuk/status/1592130978234900484
[Thread by @USERNAME on Threadify Reader App](https://threadify.productsway.com/thread/STATUS_ID)

Credits

This project is made by community and especially the wonderful people and projects listed in this document

Open Source

Tech Twitter

Author

👤 Huynh Duc Dung

  • Website: https://productsway.com/

Show your support

Give a ⭐️ if this project helped you!

Stargazers over time

- There are a lot of tools that place extra configurations inside the package.json file. You can extend PackageJson to support these additional configurations.

- Make all properties in T optional.

- Make all properties in T required.

- Make all properties in T readonly.

- From T, pick a set of properties whose keys are in the union K.

- Construct a type with a set of properties K of type T.

- Exclude from T those types that are assignable to U.

- Extract from T those types that are assignable to U.

- Exclude null and undefined from T.

- Obtain the parameters of a function type in a tuple.

- Obtain the parameters of a constructor function type in a tuple.

- Obtain the return type of a function type.

- Obtain the instance type of a constructor function type.

- Constructs a type by picking all properties from T and then removing K.

- Transforms every character in a string into uppercase.

- Transforms every character in a string into lowercase.

- Transforms the first character in a string into uppercase.

- Transforms the first character in a string into lowercase.

You can find some examples in the .

Contributions welcome! Read the first.

Create .envrc and fill the value then Use

Then run the command

Finally, add the at the end with below format.

NOTE: I have sent a pull request about this step to tweet-to-markdown repository: Might not need this step if this PR is accepted.

: for 2 sections (Extending existing type, Built-in types)

: A command line tool to convert Tweets to Markdown.

: ThreadifyPlus is a simple and easy-to-use tool that helps users read and share Twitter threads with ease. (WIP)

: The easiest way to download any Twitter video

Twitter:

Github:

TypeScript Tips Series
LooseAutocomplete
Normal union, a discriminated union, and a type predicate
Enter satisfies()() 👀
Use Object.freeze to ensure your objects are readonly at the type level AND the runtime level
Inversion of control
Ultimate TypeScript Thread
Expose type to global with declare global
Use generics to dynamically specify the number, and type, of arguments to functions
Adding things to the global scope in TypeScript
Using 'as const' over enums
Use assertion functions inside classes
Compound Components in React are SUPER easy to type in TS
Four ways to define an object type in TypeScript
The difference between any and unknown
Use TypeScript's never for making sure you hit every scenario
Use TypeScript's never to enforce "one or the other" properties on a type
Type Guard in TypeScript by using the is keyword in a functions return type
VSCode - quickly add all properties to a typed object in TypeScript with the ts-quickfixes
VSCode - refactoring your codebase
4 TypeScript tips in context of when you would use them. as const, typeof, keyof and template string types
Passing around unique identifiers of objects, select the type of the identifier right off of the object type
Use look up tables instead of "if"
Typescript 4.9 satisfies operator - check if the type matches one of these listed type
Enum vs const enums
Use labeled tuple elements to get better hints from your text editor
Use as const after literals
Avoid making a property optional when the property isn’t valid in a certain case
Alias the type's name when conflicts with an existing identifier
Many optional properties are a code smell
Extract it from a component using the handy ComponentProps
Use keyof gets a union type of all properties of the given object
No need to import DOM event handler types
The satisfies operator in TypeScript 4.9 is a game changer
Infers array's type as const
How to use extends
How to use readonly
PackageJson
Partial<T>
Required<T>
Readonly<T>
Pick<T, K>
Record<K, T>
Exclude<T, U>
Extract<T, U>
NonNullable<T>
Parameters<T>
ConstructorParameters<T>
ReturnType<T>
InstanceType<T>
Omit<T, K>
Uppercase<S extends string>
Lowercase<S extends string>
Capitalize<S extends string>
Uncapitalize<S extends string>
TypeScript docs
contribution guidelines
tweet-to-markdown
direnv
Thread Reader App
feat: add Thread Reader App link and the end #19
sindresorhus/type-fest
kbravh/tweet-to-markdown
jellydn/threadify-plus
egoist/download-twitter-video
Matt Pocock ✈️ Modern Frontends
Wes Bos
Erik Rasmussen
Carlos Caballero
Ankita Kulkarni
Minko Gechev (@mgechev@mstdn.social)
Cory House
Tomek Sułkowski
Sebastien Lorber
Steve (Builder.io)
StackBlitz
@jellydn
@jellydn
awesome-typesafe
Homepage
Gitbook
Tips
Matt Pocock
Wes Bos
Erik Rasmussen
Carlos Caballero
Ankita Kulkarni
Minko Gechev
Cory House
Tomek Sułkowski
Sebastien Lorber
Steve (Builder.io)
StackBlitz
Extending existing types
Built-in types
Contribute
Twitter to markdown file
Credits