-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
WIP: type-level assertion operator (!) #17948
WIP: type-level assertion operator (!) #17948
Conversation
@tycho01, |
e7dff1b
to
dc4e63f
Compare
dc4e63f
to
7312b32
Compare
@ahejlsberg: I feel a bit stuck on evaluation eagerness here -- my |
@tycho01 While writing type class dictionaries by hand, I got stuck on #14366 as well. So I gave it a shot and got some mileage. Basic functionality is working, but higher order relations, comparability and type inference are missing. I also broke API compatibility, but it's an easy fix. Basically, to make an operator lazy you have to create a new node for it and encode all relations. |
@gcnew: whoa, pretty impressive progress there! I'd initially tried gone the way of adding a new node as well, but after realizing it overlapped with the JSDoc one figured that'd do to give a minimum repro of my issue with generics. I was sorta struggling with elegantly tackling the parser part too -- looks like you handled that fairly well. I should try and incorporate the insights from your branch for the spread in tuple types then. Currently also still struggling with type-level calls though... |
Sorry, I used bad terminology there. My addition of To make something lazy, you have to build an expression, instead of eagerly evaluating the said thing. For example, for |
@gcnew: yeah, I found the code in your branch pretty useful there. Much of it already looked familiar from just searching / plagiarizing existing nodes/types, but I found especially your tests to be a terrific checklist of the different scenarios. :) |
We have discussed this in a few design meetings now, and do not feel that adding a new type operator is the right way to go. Type operators come with a maintainability cost, as well as learning cost by adding a new concept to the language. An alternative here is to always remove |
@tycho01 Nice! I'm very glad you are making steady progress! |
@gcnew: Thanks! You definitely helped me there! 😅 |
Fixes #14366.
I'm just extending the existing
JSDocNullableType
so it's usable outside of JSDoc and gets the functionality of the expression-level non-nullable / assertion operator (!
).This still evaluates too eagerly to deal with generics though.