-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add twoslash support #47
Conversation
src/rules/expect.ts
Outdated
@@ -458,14 +476,36 @@ function getExpectTypeFailures( | |||
const line = lineOfPosition(node.getStart(sourceFile), sourceFile); | |||
const assertion = typeAssertions.get(line); | |||
if (assertion !== undefined) { | |||
const { expected } = assertion; | |||
const { expected, column } = assertion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a line and a column. I want to get the node at that position. Surely there's an easier way than this?!
This should be good to go! I imagine @JoshuaKGoldberg is busy putting the final touches on his book, so no rush on reviewing. But I would love to start using this in my project: https://github.com/danvk/crudely-typed/blob/main/test/type/select.typetest.ts |
Haha you're right, I am a bit swamped this week (sorry!). But I hope to review as soon as I can! |
We're scheduled to go over this on Twitch tomorrow 😎 https://www.twitch.tv/joshuakgoldberg/schedule?seriesID=c53bbfdd-92bd-487b-bb14-1ffc5965c191 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks so much for sending this! ✨
Nothing too major, mostly just requesting changes we talked about on the stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review, Josh! I've addressed all feedback. I think we should be good to go!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wonderful, thanks @danvk! ✨
PR Checklist
^?
) #43status: accepting prs
Overview
Adds support for the following syntax:
Multiline types look like:
A comment line is a continuation of the expected type if it starts with the exact same sequence of spaces and
//
as the^?
line (with^?
replaced with more spaces).This also includes a fixer. I've only enabled it for twoslash-style assertions, but enabling it for
$ExpectType
would be trivial. This might really improve the dev experience for DefinitelyTyped contributors!Here are some GIFs of it in action.
Single line fix:
More complex fix that involves multiple files / a multiline type: