effective-typescript icon indicating copy to clipboard operation
effective-typescript copied to clipboard

TypeScript Splits the Atom!

Open danvk opened this issue 2 years ago • 6 comments

TypeScript Splits the Atom!

https://effectivetypescript.com/2020/11/05/template-literal-types/

danvk avatar Mar 01 '22 15:03 danvk

Comment by Bob on 2020-11-22 12:53:

Where does Capitalize come from?

danvk avatar Mar 01 '22 15:03 danvk

Comment by danvdk on 2020-11-22 01:50:

It's one of four new built-in generics in TS 4.1: Uppercase, Lowercase, Capitalize and Uncapitalize. Take a look at the TypeScript 4.1 release post.

danvk avatar Mar 01 '22 15:03 danvk

Comment by Pomar81 (pomar81) on 2020-11-22 06:51:

Unfortunately type OnString = `on${string}` gives an error in playgroud

https://www.typescriptlang....

danvk avatar Mar 01 '22 15:03 danvk

Comment by danvdk on 2020-11-22 07:17:

You're on the 4.1 beta for the playground. Try it on the 4.1 release (4.1.2) or a nightly, it'll work: https://www.typescriptlang....

danvk avatar Mar 01 '22 15:03 danvk

Comment by Pomar81 (pomar81) on 2020-11-23 05:13:

it will be great if we can type something like
type WithData = {[key: `data-${string}`]: string}

danvk avatar Mar 01 '22 15:03 danvk

Comment by Tomás Fox (tom_s_fox) on 2021-09-02 01:51:

This is now possible in 4.4: https://devblogs.microsoft....

danvk avatar Mar 01 '22 15:03 danvk