-
Notifications
You must be signed in to change notification settings - Fork 38
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
When possible, reuse existing syntax from typescript or flow, if applicable #7
Comments
Thanks for your input! The reason I had in mind for the syntax differences was that there are a LOT more developers familiar with JS syntax than TypeScript syntax, and I wanted to err on the side of familiarity for the majority of developers. That said, you are right that the community seems to be converging on a recognizable set of standards for type support, and that set has the restriction of being embedded in JavaScript, so if we go our own way, there will be two completely different syntax sets for types, and that's probably even more confusing to JS devs. That said, starting right now, a core design goal will be to pave the cowpaths and try to be as familiar as possible to users who are familiar with other type systems in the JS ecosystem... TypeScript being the standard bearer. That said, I am far from a TypeScript expert, because if it suited my needs, I wouldn't be working on this project in the first place. I'd just use TypeScript, instead. So I'm going to need some help from the TypeScript community to stay on track.
How does the TS intersection work? For instance, how would you model the deep property merge from
Which function signatures are those? AFAIK, both TypeScript and Rtype use |
[#7] Use `|` for union types, like TypeScript
The safe changes are merged. More discussion is needed on intersection types. AFAIK, we are compatible with TypeScript return type notation already. Closing for now. Feel free to open more tickets for specific problems. Thanks a lot. =) |
About function return type signatures, in typescript, a colon is used in class or interface methods, but function expression are expressed with a fat arrow. In this example, both types are equivalent: This might be specific to typescript, and as I said before, it would be nice to have the same syntax for things that are already the same in different tools. |
Why is there a difference? |
I don't know, btw it's the same in scala |
I'm not very familiar with TypeScript, yet. I thought I was following their lead, but I have trouble understanding how TS disambiguates between return type notation and creating a new function when you're annotating a function inline. Can you explain how that disambiguation works? |
I'm just a TypeScript user, I do not know the internals, sorry. |
I dislike the proposed convention of lowercase type aliases - the argument that you won't need to scan backwards through the code looking for a type declaration is moot, since, with static typing, I'd more likely just hover the mouse over the name to see what's what. Also, the Typescript/C# convention of using a leading capital T (or a single capital letter) to me is actually less visually ambiguous, as the lowercase letter resembles a var name. |
@mindplay-dk If you mean type variables, we're intentionally deviating from TypeScript here in order to better support higher order functions and generics. We're going to add support for Haskell style type constructors, which means we can do things like this: Functor F ~> map(a => b) => F(a) => F(b) Where It's difficult/impossible to represent that readably in TypeScript, which is the primary reason for this deviation. We haven't documented that in the official spec yet because I'm still experimenting with the new syntax. The squiggly arrow is basically saying |
BTW, we've had lots of discussions RE: how TypeScript/Java et al... handle generics and to what extent we should or should not support it. Haskell's solution is simple and elegant by way of comparison. |
It seems like the javascript and strong typing community are using an emerging standard for type annotations (typescript, flow, babel... maybe sound script ?)
As of today, a big part of rtype syntax looks like those annotations, but there are small differences.
It would be nice to have the same syntax for the shared features, to increase the chance of using multiple tools, each of them for there usage, with the minimum requirements.
Some examples of differences:
The text was updated successfully, but these errors were encountered: