-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript 2.7 and 2.8 features #26
Comments
I am on it. Now that I had you here, I think there should be a section of the document for a |
Thanks! As for your comment on I think more importantly, the valid difference is that: TypeScript has both
While Flow only does the first, and needs either But you can also setup TypeScript as a typechecker only, and similarly use |
But Flow is not a language, it have its own syntax, but it's not a language. Typescript have language features, like Enums, Interfaces, to name a few. You have a point regarding that you can compile a Typescript file using Babel 7, but I don't think I would really check for type errors, it just would remove the type code. And, you can use the power of Typescript in plain Javascript, with a magic comment |
I made the PR. I hope you like it. If you fell something is missing, I'll add it. Thanks you. |
Update: I ask for a way to implement a class A {
a: string;
b: string;
}
class B {
a: string;
c: string;
}
type C = Pick<A, Exclude<keyof A, keyof B>>; This work, but is not exact the behavior, as in Flow, this would throw because B have properties that A does not have. Here, the extra properties are just ignored. |
Thanks @michaeljota. I'll have a look at it this week! |
ReturnType, and other predefined conditional types were added microsoft/TypeScript#21847 They also added a feature for folks to make their own conditions types: microsoft/TypeScript#21496 :) |
To my knowledge, the only two places where TypeScript adds a feature that is not just a type annotation are With just these two differences, I don't think its enough to segment TypeScript and Flowtype as different "things" (whether we call both a new language, or a new syntax for an old language). The point of this repo is to show both differences and similarities. While I think it's important to point out these 2 special emit TypeScript features, overall, both projects are essentially: JavaScript with a syntactic extension for typechecking. One more noteworthy difference is that TypeScript includes its own emitter/transpiler, while Flow requires an external one (Babel or flow-strip-types).
Sure, just as Babel doesn't check type errors when compiling Flowtype, it wouldn't check for type errors when compiling TypeScript.
Indeed! This would be great to mention in the readme. The |
This is true in part, because Typescript have aligned itself with a more stricter super set of JavaScript plan, but they did include in the past several features that were not available in plain JavaScript, like modules, and private members.
I think is about semantic here. Flow only purpose is to add type checking to JavaScript, you can use plain JavaScript, and remove the type info with Both of them have its advantage, with Flow and Babel you can use ES proposal in low stages, and with Typescript you would have to wait until the compiler adds them, probably until Stage 3. Typescript is simpler to setup, but still powerful. Anyway, I'm writing this in a blog Typescript vs Flow. |
Yeah, I agree, it's a discussion about semantics. All in all, I think it's important to understand the difference, but at the same time see how TypeScript is two tools in one (typechecker + transpiler).
This is not actually correct, since Flow still needs to support parsing and typechecking for these proposals. The situation is really the same as with TypeScript, and in fact, some low stage proposals (like decorators) have better support in TypeScript than with Flow, which doesn't do any type checking for decorators. |
I see. As I said, I haven't use Flow that much, so my knowledge about it is quite limited. I do have a few |
While I don't think it's such a big deal, TypeScript does allow you to forego Babel as it compiles language features. You can even include the helper library tslib separately using Personally, this isn't a large consideration for me, but it is a distinction that differentiates TypeScript as more of a compiler than simply a type checker. Additionally, you can use TypeScript as a compiler only and if you want to avoid the cost of type-checking in certain scenarios. For example, it's common in Webpack projects to use the TS Loader with |
Absolutely @bfricka. I'd be happy to accept PRs adding & describing these similarities & differences. |
We need to update the readme to add the latest features from TS 2.7 and 2.8.
Help appreciated!
The text was updated successfully, but these errors were encountered: