Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/
This issue is just to track all of the new features and their implementation state in this project.
As with all releases, we will not necessarily to support all features until closer to the full release when everything the features are stabilised.
Please be patient.
Template Literal Types
typeWorld="world";typeGreeting= `hello ${World}`;//typeColor="red"|"blue";typeQuantity="one"|"two";typeSeussFish= `${Quantity|Color} fish`;//typeVerticalAlignment="top"|"middle"|"bottom";typeHorizontalAlignment="left"|"center"|"right";// Takes// | "top-left" | "top-center" | "top-right"// | "middle-left" | "middle-center" | "middle-right"// | "bottom-left" | "bottom-center" | "bottom-right"declarefunctionsetAlignment(value: `${VerticalAlignment}-${HorizontalAlignment}`):void;typeEnthusiasticGreeting<Textendsstring>= `${Uppercase<T>} - ${Lowercase<T>} - ${Capitalize<T>} - ${Uncapitalize<T>}`;typeHELLO=EnthusiasticGreeting<"heLLo">;// same as// type HELLO = "HELLO - hello - Hello - heLLo";
This will require new AST nodes.
Key Remapping in Mapped Types
typeMappedTypeWithNewKeys<T>={[KinkeyofTasNewKeyType]:T[K]// ^^^^^^^^^^^^^// This is the new syntax!}
This will require AST changes.
Recursive Conditional Types
typeAwaited<T>=TextendsPromiseLike<inferU> ?Awaited<U> :T;
This will require no changes.
Pedantic Index Signature Checks
Example with thenoUncheckedIndexedAccess
compiler option turned on:
functionscreamLines(strs:string[]){// this will have issuesfor(leti=0;i<strs.length;i++){console.log(strs[i].toUpperCase());// ~~~~~~~// error! Object is possibly 'undefined'.}}
This will require no changes (it will just start working and improve existing rules likeno-unnecessary-condition
for free!)
React 17 JSX Factories
This will require a slight tweak to how theparser
passes options toscope-manager
Other changes that have no impact on us:
paths
withoutbaseUrl
checkJs
ImpliesallowJs
Editor Support for the JSDoc
@see
Tagabstract
Members Can’t Be Markedasync
- we don't throw parser errors for invalid syntax (yetParsing: strictly enforce the produced AST matches the spec and enforce most "error recovery" parsing errors #1852)
any
/unknown
Are Propagated in Falsy Positions--declaration
and--outFile
Requires a Package Name Rootresolve
's Parameters Are No Longer Optional inPromise
s