The simple switch of allowing from y import { x } in addition to import { x } from y so that you have context and intellisense available to select what you want to import is such a simple and elegant fix to a previous inconvenience. Looking forward to this release, great stuff as always.
TypeScript syntax usually leverages implausible language additions, using contextual keywords that have to be placed on the same line. Even the : is a technically-reserved syntax for variants of the language that add static type syntax.
There is maybe one place where JS syntax doesn't work, and that's in something like
a < b > (c)
where that's parsed out as a function call
a(c)
with type arguments
a<b>(c)
instead of comparing 1 and 2, and comparing the result of that (a boolean) to 3.
(a < b) > (c)
In practice, most people don't write code like that for reasons that I hope are obvious. 😄
They try to stay close to the ecmascript syntax, only extending it with types (see typescript design goal: 'Align with current and future ECMAScript proposals'). The syntax that deviates from ecmascript (interfaces, enums, private class fields) tends to be old.
I don't believe they are allowing from y import { x } because TS doesn't like to go against established JS syntax, but they are adding auto-import functionality when you being typing import { which is effectively as helpful.
7
u/AiexReddit May 13 '21
The simple switch of allowing
from y import { x }in addition toimport { x } from yso that you have context and intellisense available to select what you want to import is such a simple and elegant fix to a previous inconvenience. Looking forward to this release, great stuff as always.