What's New in TypeScript 3.5
The open source, cross-platform language was even said to be "exploding" in popularity in an analyst report earlier this month.
Other improvements in the compiler/language department as detailed by program manager Daniel Rosenwasser include:
Omit helper type: This lets developers omit certain properties from an object, such as creating a Person type without a location property. See more here.
- Improved excess property checks in union types: This improves excess property checking in object literals, a feature used to detect typos for when a type isn't expecting a specific property in a union of two constructs. For example, a const created from a union of a Point and Label now will be flagged if it tries to assign a boolean to a property expecting a string. See more here.
--allowUmdGlobalAccess flag: "In TypeScript 3.5, you can now reference UMD global declarations like
export as namespace foo;
from anywhere -- even modules -- using the new
--allowUmdGlobalAccess flag." See more here.
- Smarter union type checking: This improves upon union type checking that was previously compared each constitutent type in isolation. Now it digs deeper to see if a type is allowable. It stems from a pull request titled "Relate source types covered by a target discriminated union." See more here.
- Higher order type inference from generic constructors: This stems from a pull request to "support higher order inferences for constructor functions and to permit function type arguments to higher order composition functions to have other members in addition to their single call signature." See more here.
In the editor tooling department, Rosenwasser called out:
- Smart Select: "TypeScript 3.5 provides an API for editors to expand text selections farther and farther outward in a way that is syntactically aware -- in other words, the editor knows which constructs it should expand out to. This feature is called Smart Select, and the result is that editors don't have to resort to heuristics like brace-matching, and you can expect selection expansion in editors like Visual Studio Code to 'just work"'." See more here.
- Extract to type alias: Coming from an open source contributor, this is described by Rosenwasser as "a useful new refactoring to extract types to local type aliases." See more here.
Going forward, developers can expect a v3.6 beta on July 12, with the final version set for Aug. 23. It will include expected work items ranging from strongly typed iterators and generators (in the language department) to APIs for --incremental builds and project references (in the compiler department) to a release overhaul (in the infrastructure department) to "Await feedback for more completion priority improvements" (in the editor features department). All of this and much more is detailed in the TypeScript 3.6 iteration plan.
Looking further down the road, the laundry list of new features in the TypeScript road map includes:
- Variadic types
- Investigate nominal typing support
- Flattening declarations
- Implement ES Decorator proposal
- Implement ES Private Fields
- Investigate Ambient, Deprecated, and Conditional decorators
- Investigate partial type argument inference
- Quick fix to Scaffold local @types packages
- Investigate error messages in haiku or iambic pentameter
- Decorators for function expressions/arrow functions
Note that the possibility of providing error messages in haiku or iambic parameter is still a hot item, with our own .NET expert columnist Peter Vogel offering up the following nugget in a comment on an earlier article that mentioned the poetic PR:
Reference is null.
Reflect: Cold nature also
Abhors a vacuum.
However, Rosenwasser has said the issue has taken a back seat to more important issues, even throwing some shade on the original idea: "Besides, we'd probably do limericks first anyway. A haiku doesn't even rhyme."
David Ramel is the editor of Visual Studio Magazine.