4 ms·
This is demonstrably false. Typescript makes no guarantees about what the output looks like. Take this incredibly simple example: ~: cat test.ts class Fo
by ng12 10y ago
This is demonstrably false. Typescript makes no guarantees about what the output looks like. Take this incredibly simple example:
~: cat test.ts
class Foo {
foo = () => console.log('Foo!')
}
~: tsc --target es6 test.ts && cat test.js
class Foo {
constructor() {
this.foo = () => console.log('Foo!');
}
}
The code is functionally the same but not identical, which like I said earlier can be an issue if you're using other tools which analyze/modify your code. I prefer Typescript over Flow for other reasons but the amount of misinformation in this thread is astounding.
- WorldMaker 10y agoYour class is not syntactically valid ES2015. Typescript is allowing a shorthand that ES2015 doesn't allow and rewrites it to proper ES2015. It's a tiny babel plugin. Maybe a stricter output target should provide a syntax warning here. The source conversion here, based on the implications of the shorthand, shouldn't be a surprising output and looks like perfectly readable, idiomatic JS to me.
- ng12 10y agoCan you turn of those transpilations though? Readable code isn't the problem, equivalence is. Flow will never rewrite anything, which is what I've been saying.
- WorldMaker 10y agoMany of the transpilations you can turn off. The targets system turns off/on many transpilations as a suite. There are flags for several others such as `--noEmitHelpers`, `--preserveConstEnums`, `--jsx Preserve`. If you have a reason to disallow and/or preserve something that TS does not already support, I would think the Typescript team would be interested in hearing about it.
- ng12 10y agoBut the argument I'm making is it's disingenuous to say that Flow and Typescript are both equally "not Javascript". Flow is _strictly_ additive to whatever else your toolchain is. Typescript is a different language.
- WorldMaker 10y agoI never said that Flow and Typescript are "equally" not JavaScript. I think you are getting your arguments crossed here. Though I will state that both are not JavaScript, even if they are "unequally" not JS (for whatever that distinction means to you, though I think it is a moot point). Flow when used purely as comments is JS, sure, but the type annotation syntax is not JS as defined by any ES standard (except maybe ES4) nor any JS accepted by browsers (definitely not ES4). "Strictly additive" isn't a distinction that matters to what constitutes a language, if we want to be pedantic. Finally, I would suggest you refrain from the word "disingenuous". Yes, my opinions differ from your own, but you cannot speak to the candor of my opinions here. I am hoping you did not intend an ad hominem attack, but I don't think a lot of people realize how much "disingenuous" is an ad hominem attack.
- ng12 10y ago> I never said that Flow and Typescript are "equally" not JavaScript. I think you are getting your arguments crossed here. Read the rest of this thread, that is the point at hand. I'd generally suggest doing that before jumping in.
- WorldMaker 10y agoI commented on a specific point you were making. Whether or not I read the rest of the thread is irrelevant to the discussion at hand.
- ng12 10y agoSo it's just an irrelevant interjection then? Your not wrong, I'm not wrong, we're just having two separate conversations.
- spion 10y agoFlow understands this code perfectly well too. https://tryflow.org/?code=Y2xhc3MgRm9vIHsKICBmb28gPSAoKSA9PiBjb25zb2xlLmxvZygnRm9vIScpCn0KCmxldCBmID0gbmV3IEZvbygpCgpmLmZvbygp https://tryflow.org/?code=Y2xhc3MgRm9vIHsKICBmb28gPSAoKSA9Pi... You get no errors. Additionally, TypeScript's stated design goal is to not deviate from current or future EcmaScript [1] You want more control over exactly what gets transpiled i.e. "I don't want to use ES.next, only ES6". Thats a valid point, but really far from your original assessment that there is a fundamental difference between the languages. [1]: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals https://github.com/Microsoft/TypeScript/wiki/TypeScript-Desi... - goal 6