Live data from Hacker News

ts-blank-space is a fast type-stripping compiler

bloomberg.github.io

11–20 of 49 posts

Re: ts-blank-space is a fast type-stripping compiler

#14

I wish enum was never part of TypeScript. It’s this one odd thing unlike the rest. Am I forgetting any or is it the only feature that actually generates code rather than just being extra annotation?

Agreed. It looks OK on the surface, but if you need enums then TS enums is going to end up in frustration.

Re: ts-blank-space is a fast type-stripping compiler

#15
> We refer to the supported subset as Modern TypeScript because it represents nearly all TypeScript syntax, except for those TypeScript-specific features that may be considered legacy or discouraged in some way

> These unsupported TypeScript features already have preferred alternatives:

> Prefix-style type assertions (value) should be replaced with as-style type assertions.

Am I out of date? Does someone know something I don't?

Re: ts-blank-space is a fast type-stripping compiler

#16

I wish enum was never part of TypeScript. It’s this one odd thing unlike the rest. Am I forgetting any or is it the only feature that actually generates code rather than just being extra annotation?

Lots of TypeScript features generate code: namespace, async/await, yield, decorators, object spread, varargs, etc.*

`const enums` (beyond enums) are especially odd. They rely on type information to emit code.

* Subsequent to their release in TypeScript, EcmaScript versions now support some of these.

Re: ts-blank-space is a fast type-stripping compiler

#18

> We refer to the supported subset as Modern TypeScript because it represents nearly all TypeScript syntax, except for those TypeScript-specific features that may be considered legacy or discouraged in some way > These unsupported TypeScript features already have preferred alternatives: > Prefix-style type assertions ( value) should be replaced with as-style type assertions. Am I out of date? Does someone know someth…

What's not explained by the quoted excerpt?

Instead of writing, e.g. `const n = someValueThatYouKnowIsANumber;`, you should write `const n = someValueThatYouKnowIsANumber as number;`

(well, really, you shouldn't write either, casts are bad. But, yknow.)

Re: ts-blank-space is a fast type-stripping compiler

#19

I wish enum was never part of TypeScript. It’s this one odd thing unlike the rest. Am I forgetting any or is it the only feature that actually generates code rather than just being extra annotation?

Lots of TypeScript features generate code: namespace, async/await, yield, decorators, object spread, varargs, etc.* `const enums` (beyond enums) are especially odd. They rely on type information to emit code. * Subsequent to their release in TypeScript, EcmaScript versions now support some of these.

So, since they're now a part of JS - aside from namespaces and enums (which are discouraged) - none of those features generate code anymore.

Moreover, aside from namespaces and enums (which are discouraged), none of those features were incorporated into TypeScript until they were on track for inclusion into JS. They weren't taken from TypeScript and imported into JS; TypeScript took them from the ECMAScript people.

Being able to compile TypeScript by just stripping types has become a design principle of the language. For better or for worse, the TypeScript team steadfastly refuses to try to innovate on runtime language features at this point.

Re: ts-blank-space is a fast type-stripping compiler

#20

I wish enum was never part of TypeScript. It’s this one odd thing unlike the rest. Am I forgetting any or is it the only feature that actually generates code rather than just being extra annotation?

Namespaces do as well, but I think it's just those two.
Post reply on HN