Replies: 5 comments
-
SummaryI had a look through There might be another option though: implement a TSServer like utility to give us access to type checker the way Communication with TSServerCommunication with The rest of documentation is in the form of comments in code. All the available commands are listed in protocol.ts and usually have a simple description atteched to the command arguments object. The corresponding implementation can be found in the session.ts. But looking through the code I did not see a way to access type checker API we need for lint rules. Type checker APIThe API used by Alternative solutionLook into typescript-estree and build something similar in JS, importing typescript directly and exposing an API to load the project, open/close files and access the type checker. This seems doable, but calling methods over IPC might have too much overhead to make it sufficiently fast. We might want to consider using JS code for anything to do with type checker. For example rules could have an associated JS file, that define functions that the rule could call through the IPC interface. The JS function would accept Typescript AST node as input, and perform all the necessary type checking logic on the JS side. So with the |
Beta Was this translation helpful? Give feedback.
-
I have implemented proof-of-concept in a separate repo: https://github.com/valeneiko/typecheck-server It is not a full implementation of the lint rule, just the type checker related logic from it. We can pass an AST node from Rust side to JS side, and access type information about it (on JS side), but that should be enough to implement the rule. Let me know your thoughts! |
Beta Was this translation helpful? Give feedback.
-
@camc314 Are you interested in implementing the rule on our side and integrate it with https://github.com/valeneiko/typecheck-server? |
Beta Was this translation helpful? Give feedback.
-
I'd love to, but my time is stretched very thin currently 😞 . |
Beta Was this translation helpful? Give feedback.
-
For future reference: |
Beta Was this translation helpful? Give feedback.
-
This is a call for help and community effort.
The goal is to get a working draft for typescript-eslint's no-floating-promises or conclude that this is not doable.
To get things working, we are going to neglect all performance impacts.
The idea is that we spawn a node process with the TypeScript server and communicate with it via http or rpc or whatever means necessary. It doesn't really matter how we spawn the server, within Rust or as a standalone server, as long as we can communicate with it.
The core logic from typescript-eslint is here: https://github.com/typescript-eslint/typescript-eslint/blob/a41ad155b5fee9177651439adb1c5131e7e6254f/packages/eslint-plugin/src/rules/no-floating-promises.ts#L221
Update
This direction is not viable, see references
Infra:
Source: https://speakerdeck.com/unvalley/exploring-type-informed-lint-rules-in-rust-based-linters
Beta Was this translation helpful? Give feedback.
All reactions