Description
I want a public API for TypeScript language service plugin ( this is related to #254 (comment) ).
API proposal
Signature
parseForESLintFromSourceFile(
sourceFile: ts.sourceFile,
options?: ParserOptions | null,
): ParseForESLintResult
Expected behavior
This new function should works almost the same as parseForESLint
. However, the following points are different:
result.ast
should be converted by@typescript-eslint/typescript-estree/src/ast-converter
directly.result.services.program
should be undefined ( I want to skip to callcreateProgram
)
Motivation
I develop a TypeScript language service plugin to integrate tsserver and ESLint, https://github.com/Quramy/typescript-eslint-language-service.
In tsserver, ts.LanguageService does:
- tokenize source text and create an AST node. And the parsing is so fast because of ts.IncrementalParser.
- provide ts.Program ( So ts-estree don't need call createProgram )
Of course, I can provide a language service plugin using only public @typescript-eslint/parser
APIs. But they accept only string text. So source code's text would be tokenized twice if using these public APIs. It's so silly.
Now I use some internal APIs ( see https://github.com/Quramy/typescript-eslint-language-service/blob/v1.2.3/src/ast-converter.ts#L187 ) for the above performance reason. But depending on them is too fragile.
Please consider it.
Quramy