@flint.fyi/typescript-language 0.0.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +20 -0
- package/lib/_virtual/_rolldown/runtime.js +13 -0
- package/lib/collectReferencedFilePaths.js +9 -10
- package/lib/convertTypeScriptDiagnosticToLanguageReport.d.ts +18 -0
- package/lib/{convertTypeScriptDiagnosticToLanguageFileDiagnostic.js → convertTypeScriptDiagnosticToLanguageReport.js} +13 -10
- package/lib/createTypeScriptServerHost.d.ts +4 -0
- package/lib/createTypeScriptServerHost.js +99 -0
- package/lib/directives/parseDirectivesFromTypeScriptFile.js +33 -3
- package/lib/getFirstEnumValues.js +1 -1
- package/lib/getTSNodeRange.js +1 -1
- package/lib/getTypeScriptFileCacheImpacts.d.ts +4 -0
- package/lib/getTypeScriptFileCacheImpacts.js +9 -0
- package/lib/index.d.ts +8 -9
- package/lib/index.js +6 -8
- package/lib/language.d.ts +211 -5
- package/lib/language.js +108 -14
- package/lib/nodes.d.ts +3 -1
- package/lib/normalizeRange.js +1 -2
- package/lib/package.js +7 -0
- package/lib/types/ast.d.ts +2 -2
- package/lib/utils/createRuleTesterTSConfig.d.ts +8 -0
- package/lib/utils/createRuleTesterTSConfig.js +18 -0
- package/lib/utils/declarationIncludesGlobal.js +1 -1
- package/lib/utils/declarationsIncludeGlobal.js +1 -2
- package/lib/utils/getDeclarationsIfGlobal.d.ts +4 -5
- package/lib/utils/getDeclarationsIfGlobal.js +1 -2
- package/lib/utils/getModifyingReferences.d.ts +1 -3
- package/lib/utils/getModifyingReferences.js +13 -11
- package/lib/utils/hasSameTokens.d.ts +2 -2
- package/lib/utils/hasSameTokens.js +4 -5
- package/lib/utils/isBuiltinArrayMethod.d.ts +2 -3
- package/lib/utils/isBuiltinArrayMethod.js +1 -2
- package/lib/utils/isFunction.d.ts +2 -4
- package/lib/utils/isFunction.js +1 -1
- package/lib/utils/isGlobalDeclaration.d.ts +2 -4
- package/lib/utils/isGlobalDeclaration.js +1 -2
- package/lib/utils/isGlobalDeclarationOfName.d.ts +1 -2
- package/lib/utils/isGlobalDeclarationOfName.js +1 -2
- package/lib/utils/isGlobalVariable.d.ts +2 -5
- package/lib/utils/isGlobalVariable.js +1 -2
- package/lib/utils/isInlineArrayCreation.d.ts +0 -1
- package/lib/utils/isInlineArrayCreation.js +1 -2
- package/lib/utils/unwrapParentParenthesizedExpressions.d.ts +2 -2
- package/lib/utils/unwrapParentParenthesizedExpressions.js +4 -5
- package/lib/utils/unwrapParenthesizedNode.d.ts +7 -0
- package/lib/utils/unwrapParenthesizedNode.js +9 -0
- package/package.json +45 -52
- package/lib/_virtual/rolldown_runtime.js +0 -18
- package/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts +0 -18
- package/lib/createTypeScriptFileFromProgram.d.ts +0 -12
- package/lib/createTypeScriptFileFromProgram.js +0 -41
- package/lib/createTypeScriptFileFromProjectService.d.ts +0 -8
- package/lib/createTypeScriptFileFromProjectService.js +0 -16
- package/lib/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts +0 -2
- package/lib/lib/createTypeScriptFileFromProgram.d.ts +0 -5
- package/lib/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +0 -2
- package/lib/lib/getTSNodeRange.d.ts +0 -3
- package/lib/lib/index.d.ts +0 -21
- package/lib/lib/language.d.ts +0 -5
- package/lib/lib/nodes.d.ts +0 -1
- package/lib/lib/prepareTypeScriptBasedLanguage.d.ts +0 -2
- package/lib/lib/types/ast.d.ts +0 -2066
- package/lib/lib/types/checker.d.ts +0 -23
- package/lib/lib/utils/declarationIncludesGlobal.d.ts +0 -1
- package/lib/lib/utils/getDeclarationsIfGlobal.d.ts +0 -2
- package/lib/lib/utils/getModifyingReferences.d.ts +0 -3
- package/lib/lib/utils/hasSameTokens.d.ts +0 -1
- package/lib/lib/utils/isBuiltinArrayMethod.d.ts +0 -2
- package/lib/lib/utils/isFunction.d.ts +0 -1
- package/lib/lib/utils/isGlobalDeclaration.d.ts +0 -1
- package/lib/lib/utils/isGlobalDeclarationOfName.d.ts +0 -2
- package/lib/lib/utils/isGlobalVariable.d.ts +0 -1
- package/lib/lib/utils/isInlineArrayCreation.d.ts +0 -1
- package/lib/lib/utils/unwrapParentParenthesizedExpressions.d.ts +0 -1
- package/lib/lib/utils/unwrapParenthesizedExpression.d.ts +0 -1
- package/lib/prepareTypeScriptBasedLanguage.d.ts +0 -16
- package/lib/prepareTypeScriptBasedLanguage.js +0 -55
- package/lib/prepareTypeScriptFile.d.ts +0 -14
- package/lib/prepareTypeScriptFile.js +0 -18
- package/lib/utils/unwrapParenthesizedExpression.d.ts +0 -7
- package/lib/utils/unwrapParenthesizedExpression.js +0 -10
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { CallExpression, Decorator, JsxOpeningElement, JsxSelfClosingElement, NewExpression, TaggedTemplateExpression } from "./ast.js";
|
|
2
|
-
import ts, { Node, Signature, TupleTypeReference, Type, TypeChecker, TypeReference } from "typescript";
|
|
3
|
-
|
|
4
|
-
//#region lib/types/checker.d.ts
|
|
5
|
-
type Checker = CheckerOverrides & Omit<TypeChecker, keyof CheckerOverrides>;
|
|
6
|
-
interface CheckerOverrides {
|
|
7
|
-
getResolvedSignature(node: CallExpression | Decorator | JsxOpeningElement | JsxSelfClosingElement | NewExpression | TaggedTemplateExpression | ts.CallLikeExpression): Signature | undefined;
|
|
8
|
-
/** Improve narrowing, borrow from typescript-eslint */
|
|
9
|
-
isArrayType(type: Type): type is TypeReference;
|
|
10
|
-
isTupleType(type: Type): type is TupleTypeReference;
|
|
11
|
-
/**
|
|
12
|
-
* TS internal api
|
|
13
|
-
* Return the type of the given property in the given type, or undefined if no such property exists
|
|
14
|
-
*/
|
|
15
|
-
getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* TS internal api
|
|
18
|
-
*/
|
|
19
|
-
getContextualTypeForArgumentAtIndex(node: Node, argIndex: number): Type;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { Checker };
|
|
23
|
-
//# sourceMappingURL=checker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../types/ast.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../index.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../index.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../index.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "typescript";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../types/ast.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../types/ast.js";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { SourceFile } from "./types/ast.js";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
//#region src/prepareTypeScriptBasedLanguage.d.ts
|
|
5
|
-
interface TypeScriptBasedLanguageFile extends Partial<Disposable> {
|
|
6
|
-
program: ts.Program;
|
|
7
|
-
sourceFile: SourceFile;
|
|
8
|
-
}
|
|
9
|
-
interface TypeScriptBasedLanguageFileFactoryDefinition {
|
|
10
|
-
createFromDisk(filePathAbsolute: string): TypeScriptBasedLanguageFile;
|
|
11
|
-
createFromVirtual(filePathAbsolute: string, sourceText: string): TypeScriptBasedLanguageFile;
|
|
12
|
-
}
|
|
13
|
-
declare function prepareTypeScriptBasedLanguage(): TypeScriptBasedLanguageFileFactoryDefinition;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { TypeScriptBasedLanguageFile, TypeScriptBasedLanguageFileFactoryDefinition, prepareTypeScriptBasedLanguage };
|
|
16
|
-
//# sourceMappingURL=prepareTypeScriptBasedLanguage.d.ts.map
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { createTypeScriptFileFromProjectService } from "./createTypeScriptFileFromProjectService.js";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { createFSBackedSystem, createVirtualTypeScriptEnvironment } from "@typescript/vfs";
|
|
5
|
-
import { createProjectService } from "@typescript-eslint/project-service";
|
|
6
|
-
import { CachedFactory } from "cached-factory";
|
|
7
|
-
import { debugForFile } from "debug-for-file";
|
|
8
|
-
|
|
9
|
-
//#region src/prepareTypeScriptBasedLanguage.ts
|
|
10
|
-
const projectRoot = path.join(import.meta.dirname, "../..");
|
|
11
|
-
const log = debugForFile(import.meta.filename);
|
|
12
|
-
function prepareTypeScriptBasedLanguage() {
|
|
13
|
-
const { service } = createProjectService();
|
|
14
|
-
const seenPrograms = /* @__PURE__ */ new Set();
|
|
15
|
-
const environments = new CachedFactory((filePathAbsolute) => {
|
|
16
|
-
return createVirtualTypeScriptEnvironment(createFSBackedSystem(new Map([[filePathAbsolute, "// ..."]]), projectRoot, ts), [filePathAbsolute], ts, {
|
|
17
|
-
skipLibCheck: true,
|
|
18
|
-
target: ts.ScriptTarget.ESNext
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
const servicePrograms = new CachedFactory((filePathAbsolute) => {
|
|
22
|
-
log("Opening client file:", filePathAbsolute);
|
|
23
|
-
service.openClientFile(filePathAbsolute);
|
|
24
|
-
log("Retrieving client services:", filePathAbsolute);
|
|
25
|
-
const scriptInfo = service.getScriptInfo(filePathAbsolute);
|
|
26
|
-
if (!scriptInfo) throw new Error(`Could not find script info for file: ${filePathAbsolute}`);
|
|
27
|
-
const defaultProject = service.getDefaultProjectForFile(scriptInfo.fileName, true);
|
|
28
|
-
if (!defaultProject) throw new Error(`Could not find default project for file: ${filePathAbsolute}`);
|
|
29
|
-
const program = defaultProject.getLanguageService(true).getProgram();
|
|
30
|
-
if (!program) throw new Error(`Could not retrieve program for file: ${filePathAbsolute}`);
|
|
31
|
-
return program;
|
|
32
|
-
});
|
|
33
|
-
return {
|
|
34
|
-
createFromDisk: (filePathAbsolute) => {
|
|
35
|
-
const program = servicePrograms.get(filePathAbsolute);
|
|
36
|
-
seenPrograms.add(program);
|
|
37
|
-
return createTypeScriptFileFromProjectService(filePathAbsolute, program, service);
|
|
38
|
-
},
|
|
39
|
-
createFromVirtual: (filePathAbsolute, sourceText) => {
|
|
40
|
-
const environment = environments.get(filePathAbsolute);
|
|
41
|
-
environment.updateFile(filePathAbsolute, sourceText);
|
|
42
|
-
const sourceFile = environment.getSourceFile(filePathAbsolute);
|
|
43
|
-
const program = environment.languageService.getProgram();
|
|
44
|
-
seenPrograms.add(program);
|
|
45
|
-
return {
|
|
46
|
-
program,
|
|
47
|
-
sourceFile
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
|
-
export { prepareTypeScriptBasedLanguage };
|
|
55
|
-
//# sourceMappingURL=prepareTypeScriptBasedLanguage.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { FileAboutData } from "@flint.fyi/core";
|
|
2
|
-
import type { TypeScriptBasedLanguageFile } from "./prepareTypeScriptBasedLanguage.ts";
|
|
3
|
-
export declare function prepareTypeScriptFile(data: FileAboutData, file: TypeScriptBasedLanguageFile): {
|
|
4
|
-
file: {
|
|
5
|
-
about: import("@flint.fyi/core").FileDiskData;
|
|
6
|
-
cache?: import("@flint.fyi/core").LanguageFileCacheImpacts;
|
|
7
|
-
getDiagnostics?(): import("@flint.fyi/core").LanguageDiagnostics;
|
|
8
|
-
runVisitors<OptionsSchema extends import("@flint.fyi/core").AnyOptionalSchema | undefined = import("@flint.fyi/core").AnyOptionalSchema | undefined>(options: import("@flint.fyi/core").InferredOutputObject<OptionsSchema>, runtime: import("@flint.fyi/core").RuleRuntime<import("./nodes.ts").TypeScriptNodesByName, import("./language.ts").TypeScriptFileServices>): void;
|
|
9
|
-
[Symbol.dispose]?: () => void;
|
|
10
|
-
};
|
|
11
|
-
directives: import("@flint.fyi/core").CommentDirective[];
|
|
12
|
-
reports: import("@flint.fyi/core").FileReport[];
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=prepareTypeScriptFile.d.ts.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createTypeScriptFileFromProgram } from "./createTypeScriptFileFromProgram.js";
|
|
2
|
-
import { parseDirectivesFromTypeScriptFile } from "./directives/parseDirectivesFromTypeScriptFile.js";
|
|
3
|
-
|
|
4
|
-
//#region src/prepareTypeScriptFile.ts
|
|
5
|
-
function prepareTypeScriptFile(data, file) {
|
|
6
|
-
const { program, sourceFile, [Symbol.dispose]: onDispose } = file;
|
|
7
|
-
return {
|
|
8
|
-
...parseDirectivesFromTypeScriptFile(sourceFile),
|
|
9
|
-
file: {
|
|
10
|
-
...onDispose != null && { [Symbol.dispose]: onDispose },
|
|
11
|
-
...createTypeScriptFileFromProgram(data, program, sourceFile)
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { prepareTypeScriptFile };
|
|
18
|
-
//# sourceMappingURL=prepareTypeScriptFile.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ConciseBody, Expression } from "../types/ast.js";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/unwrapParenthesizedExpression.d.ts
|
|
4
|
-
declare function unwrapParenthesizedExpression(expression: ConciseBody | Expression): ConciseBody | Expression;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { unwrapParenthesizedExpression };
|
|
7
|
-
//# sourceMappingURL=unwrapParenthesizedExpression.d.ts.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SyntaxKind } from "typescript";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/unwrapParenthesizedExpression.ts
|
|
4
|
-
function unwrapParenthesizedExpression(expression) {
|
|
5
|
-
return expression.kind === SyntaxKind.ParenthesizedExpression ? unwrapParenthesizedExpression(expression.expression) : expression;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { unwrapParenthesizedExpression };
|
|
10
|
-
//# sourceMappingURL=unwrapParenthesizedExpression.js.map
|