orta / vscode-twoslash-queries

VS Code extension which adds support for twoslash queries into typescript projects

Home Page:https://marketplace.visualstudio.com/items?itemName=Orta.vscode-twoslash-queries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add inline option?

wesbos opened this issue · comments

I love this extension, I'd love to see an option where we can inline the type right beside the variable:

pizza; // ? const pizza: Pizza

This is really helpful when teaching and sharing code because you can make the types visible without taking up too much room

strictly speaking this isn't then the official twoslash format (though I guess that can be whatever I want it to be within reason)

I'd be open to <? which I think gets the feel of ^? and should be easy to have a regex for:

abc.b // <?  (property) b whatever

Allowing for:

abc.b // <?  (property) b whatever
//^? const abc

/cc @mattpocock might make a good stream, happy to pair on it sometime

I agree with this suggestion! And yeah this would be a fun stream for sure.

commented

Now I support this method of relative location query, and also support more functions.

left-right-point

by vscode-comment-queries

Another way to approach this could be to annotate all relevant lines, without needing to add any comment. This would be a feature that users could toggle on/off via a palette command.

For example, Error Lens can annotate lines this way:

This would of course use more CPU, but add convenience. That might be an acceptable trade-off for some users.