@flint.fyi/typescript-language 0.0.0 → 0.18.0

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.
Files changed (81) hide show
  1. package/LICENSE.md +20 -0
  2. package/lib/_virtual/_rolldown/runtime.js +13 -0
  3. package/lib/collectReferencedFilePaths.js +9 -10
  4. package/lib/convertTypeScriptDiagnosticToLanguageReport.d.ts +18 -0
  5. package/lib/{convertTypeScriptDiagnosticToLanguageFileDiagnostic.js → convertTypeScriptDiagnosticToLanguageReport.js} +13 -10
  6. package/lib/createTypeScriptServerHost.d.ts +4 -0
  7. package/lib/createTypeScriptServerHost.js +99 -0
  8. package/lib/directives/parseDirectivesFromTypeScriptFile.js +1 -2
  9. package/lib/getFirstEnumValues.js +1 -1
  10. package/lib/getTSNodeRange.js +1 -1
  11. package/lib/getTypeScriptFileCacheImpacts.d.ts +4 -0
  12. package/lib/getTypeScriptFileCacheImpacts.js +9 -0
  13. package/lib/index.d.ts +8 -9
  14. package/lib/index.js +6 -8
  15. package/lib/language.d.ts +211 -5
  16. package/lib/language.js +108 -14
  17. package/lib/nodes.d.ts +3 -1
  18. package/lib/normalizeRange.js +1 -2
  19. package/lib/package.js +7 -0
  20. package/lib/types/ast.d.ts +2 -2
  21. package/lib/utils/createRuleTesterTSConfig.d.ts +8 -0
  22. package/lib/utils/createRuleTesterTSConfig.js +18 -0
  23. package/lib/utils/declarationIncludesGlobal.js +1 -1
  24. package/lib/utils/declarationsIncludeGlobal.js +1 -2
  25. package/lib/utils/getDeclarationsIfGlobal.d.ts +4 -5
  26. package/lib/utils/getDeclarationsIfGlobal.js +1 -2
  27. package/lib/utils/getModifyingReferences.d.ts +1 -3
  28. package/lib/utils/getModifyingReferences.js +13 -11
  29. package/lib/utils/hasSameTokens.d.ts +2 -2
  30. package/lib/utils/hasSameTokens.js +4 -5
  31. package/lib/utils/isBuiltinArrayMethod.d.ts +2 -3
  32. package/lib/utils/isBuiltinArrayMethod.js +1 -2
  33. package/lib/utils/isFunction.d.ts +2 -4
  34. package/lib/utils/isFunction.js +1 -1
  35. package/lib/utils/isGlobalDeclaration.d.ts +2 -4
  36. package/lib/utils/isGlobalDeclaration.js +1 -2
  37. package/lib/utils/isGlobalDeclarationOfName.d.ts +1 -2
  38. package/lib/utils/isGlobalDeclarationOfName.js +1 -2
  39. package/lib/utils/isGlobalVariable.d.ts +2 -5
  40. package/lib/utils/isGlobalVariable.js +1 -2
  41. package/lib/utils/isInlineArrayCreation.d.ts +0 -1
  42. package/lib/utils/isInlineArrayCreation.js +1 -2
  43. package/lib/utils/unwrapParentParenthesizedExpressions.d.ts +2 -2
  44. package/lib/utils/unwrapParentParenthesizedExpressions.js +4 -5
  45. package/lib/utils/unwrapParenthesizedNode.d.ts +7 -0
  46. package/lib/utils/unwrapParenthesizedNode.js +9 -0
  47. package/package.json +45 -52
  48. package/lib/_virtual/rolldown_runtime.js +0 -18
  49. package/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts +0 -18
  50. package/lib/createTypeScriptFileFromProgram.d.ts +0 -12
  51. package/lib/createTypeScriptFileFromProgram.js +0 -41
  52. package/lib/createTypeScriptFileFromProjectService.d.ts +0 -8
  53. package/lib/createTypeScriptFileFromProjectService.js +0 -16
  54. package/lib/lib/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts +0 -2
  55. package/lib/lib/createTypeScriptFileFromProgram.d.ts +0 -5
  56. package/lib/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +0 -2
  57. package/lib/lib/getTSNodeRange.d.ts +0 -3
  58. package/lib/lib/index.d.ts +0 -21
  59. package/lib/lib/language.d.ts +0 -5
  60. package/lib/lib/nodes.d.ts +0 -1
  61. package/lib/lib/prepareTypeScriptBasedLanguage.d.ts +0 -2
  62. package/lib/lib/types/ast.d.ts +0 -2066
  63. package/lib/lib/types/checker.d.ts +0 -23
  64. package/lib/lib/utils/declarationIncludesGlobal.d.ts +0 -1
  65. package/lib/lib/utils/getDeclarationsIfGlobal.d.ts +0 -2
  66. package/lib/lib/utils/getModifyingReferences.d.ts +0 -3
  67. package/lib/lib/utils/hasSameTokens.d.ts +0 -1
  68. package/lib/lib/utils/isBuiltinArrayMethod.d.ts +0 -2
  69. package/lib/lib/utils/isFunction.d.ts +0 -1
  70. package/lib/lib/utils/isGlobalDeclaration.d.ts +0 -1
  71. package/lib/lib/utils/isGlobalDeclarationOfName.d.ts +0 -2
  72. package/lib/lib/utils/isGlobalVariable.d.ts +0 -1
  73. package/lib/lib/utils/isInlineArrayCreation.d.ts +0 -1
  74. package/lib/lib/utils/unwrapParentParenthesizedExpressions.d.ts +0 -1
  75. package/lib/lib/utils/unwrapParenthesizedExpression.d.ts +0 -1
  76. package/lib/prepareTypeScriptBasedLanguage.d.ts +0 -16
  77. package/lib/prepareTypeScriptBasedLanguage.js +0 -55
  78. package/lib/prepareTypeScriptFile.d.ts +0 -14
  79. package/lib/prepareTypeScriptFile.js +0 -18
  80. package/lib/utils/unwrapParenthesizedExpression.d.ts +0 -7
  81. package/lib/utils/unwrapParenthesizedExpression.js +0 -10
package/package.json CHANGED
@@ -1,53 +1,46 @@
1
1
  {
2
- "name": "@flint.fyi/typescript-language",
3
- "version": "0.0.0",
4
- "description": "[Experimental] TypeScript language for Flint.",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/flint-fyi/flint.git",
8
- "directory": "packages/typescript-language"
9
- },
10
- "license": "MIT",
11
- "author": {
12
- "name": "JoshuaKGoldberg",
13
- "email": "npm@joshuakgoldberg.com"
14
- },
15
- "sideEffects": false,
16
- "type": "module",
17
- "exports": {
18
- ".": {
19
- "@flint.fyi/source": "./src/index.ts",
20
- "default": "./lib/index.js"
21
- }
22
- },
23
- "files": [
24
- "lib/",
25
- "!lib/**/*.map"
26
- ],
27
- "scripts": {
28
- "test": "vitest --typecheck --project typescript-language"
29
- },
30
- "dependencies": {
31
- "@flint.fyi/core": "workspace:^",
32
- "@flint.fyi/utils": "workspace:^",
33
- "@typescript-eslint/project-service": "^8.46.2",
34
- "@typescript/vfs": "^1.6.1",
35
- "cached-factory": "^0.1.0",
36
- "debug-for-file": "^0.2.0",
37
- "ts-api-utils": "^2.1.0",
38
- "typescript": "^5.9.0 || ^6.0.0"
39
- },
40
- "devDependencies": {
41
- "tsdown": "0.19.0-beta.2",
42
- "vitest": "4.0.15"
43
- },
44
- "engines": {
45
- "node": ">=24.0.0"
46
- },
47
- "publishConfig": {
48
- "access": "public",
49
- "exports": {
50
- ".": "./lib/index.js"
51
- }
52
- }
53
- }
2
+ "name": "@flint.fyi/typescript-language",
3
+ "version": "0.18.0",
4
+ "description": "[Experimental] TypeScript language for Flint.",
5
+ "homepage": "https://flint.fyi",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/flint-fyi/flint.git",
9
+ "directory": "packages/typescript-language"
10
+ },
11
+ "license": "MIT",
12
+ "author": {
13
+ "name": "JoshuaKGoldberg",
14
+ "email": "npm@joshuakgoldberg.com"
15
+ },
16
+ "sideEffects": true,
17
+ "type": "module",
18
+ "exports": {
19
+ ".": "./lib/index.js"
20
+ },
21
+ "files": [
22
+ "lib/",
23
+ "!lib/**/*.map"
24
+ ],
25
+ "dependencies": {
26
+ "@typescript-eslint/project-service": "^8.53.0",
27
+ "debug-for-file": "^0.3.0",
28
+ "ts-api-utils": "^2.4.0",
29
+ "typescript": "^5.9.0 || ^6.0.0",
30
+ "@flint.fyi/core": "^0.21.0",
31
+ "@flint.fyi/utils": "^0.14.1"
32
+ },
33
+ "devDependencies": {
34
+ "tsdown": "0.21.0",
35
+ "vitest": "4.1.0"
36
+ },
37
+ "engines": {
38
+ "node": ">=24.0.0"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "scripts": {
44
+ "test": "vitest --project typescript-language"
45
+ }
46
+ }
@@ -1,18 +0,0 @@
1
- //#region rolldown:runtime
2
- var __defProp = Object.defineProperty;
3
- var __exportAll = (all, symbols) => {
4
- let target = {};
5
- for (var name in all) {
6
- __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- }
11
- if (symbols) {
12
- __defProp(target, Symbol.toStringTag, { value: "Module" });
13
- }
14
- return target;
15
- };
16
-
17
- //#endregion
18
- export { __exportAll };
@@ -1,18 +0,0 @@
1
- import { LanguageFileDiagnostic, SourceFileWithLineMapAndFileName } from "@flint.fyi/core";
2
- import ts from "typescript";
3
-
4
- //#region src/convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts
5
- interface TSBasedDiagnostic extends TSBasedDiagnosticRelatedInformation {
6
- relatedInformation?: TSBasedDiagnosticRelatedInformation[];
7
- }
8
- interface TSBasedDiagnosticRelatedInformation {
9
- code: number;
10
- file: SourceFileWithLineMapAndFileName | undefined;
11
- length: number | undefined;
12
- messageText: string | ts.DiagnosticMessageChain;
13
- start: number | undefined;
14
- }
15
- declare function convertTypeScriptDiagnosticToLanguageFileDiagnostic(diagnostic: TSBasedDiagnostic): LanguageFileDiagnostic;
16
- //#endregion
17
- export { convertTypeScriptDiagnosticToLanguageFileDiagnostic };
18
- //# sourceMappingURL=convertTypeScriptDiagnosticToLanguageFileDiagnostic.d.ts.map
@@ -1,12 +0,0 @@
1
- import { SourceFile } from "./types/ast.js";
2
- import "./nodes.js";
3
- import "./language.js";
4
- import { LanguageFileCacheImpacts } from "@flint.fyi/core";
5
- import ts from "typescript";
6
-
7
- //#region src/createTypeScriptFileFromProgram.d.ts
8
- declare const NodeSyntaxKinds: typeof ts.SyntaxKind;
9
- declare function collectTypeScriptFileCacheImpacts(program: ts.Program, sourceFile: SourceFile): LanguageFileCacheImpacts;
10
- //#endregion
11
- export { NodeSyntaxKinds, collectTypeScriptFileCacheImpacts };
12
- //# sourceMappingURL=createTypeScriptFileFromProgram.d.ts.map
@@ -1,41 +0,0 @@
1
- import { convertTypeScriptDiagnosticToLanguageFileDiagnostic } from "./convertTypeScriptDiagnosticToLanguageFileDiagnostic.js";
2
- import { collectReferencedFilePaths } from "./collectReferencedFilePaths.js";
3
- import { getFirstEnumValues } from "./getFirstEnumValues.js";
4
- import ts, { SyntaxKind } from "typescript";
5
-
6
- //#region src/createTypeScriptFileFromProgram.ts
7
- const NodeSyntaxKinds = getFirstEnumValues(SyntaxKind);
8
- function collectTypeScriptFileCacheImpacts(program, sourceFile) {
9
- return { dependencies: ["tsconfig.json", ...collectReferencedFilePaths(program, sourceFile)] };
10
- }
11
- function createTypeScriptFileFromProgram(data, program, sourceFile) {
12
- return {
13
- about: {
14
- ...data,
15
- sourceText: sourceFile.text
16
- },
17
- cache: collectTypeScriptFileCacheImpacts(program, sourceFile),
18
- getDiagnostics() {
19
- return ts.getPreEmitDiagnostics(program, sourceFile).map(convertTypeScriptDiagnosticToLanguageFileDiagnostic);
20
- },
21
- runVisitors(options, runtime) {
22
- if (!runtime.visitors) return;
23
- const { visitors } = runtime;
24
- const fileServices = {
25
- options,
26
- program,
27
- sourceFile,
28
- typeChecker: program.getTypeChecker()
29
- };
30
- const visit = (node) => {
31
- visitors[NodeSyntaxKinds[node.kind]]?.(node, fileServices);
32
- node.forEachChild(visit);
33
- };
34
- visit(sourceFile);
35
- }
36
- };
37
- }
38
-
39
- //#endregion
40
- export { NodeSyntaxKinds, collectTypeScriptFileCacheImpacts, createTypeScriptFileFromProgram };
41
- //# sourceMappingURL=createTypeScriptFileFromProgram.js.map
@@ -1,8 +0,0 @@
1
- import type * as ts from "typescript";
2
- import type * as AST from "./types/ast.ts";
3
- export declare function createTypeScriptFileFromProjectService(filePathAbsolute: string, program: ts.Program, service: ts.server.ProjectService): {
4
- program: ts.Program;
5
- sourceFile: AST.SourceFile;
6
- [Symbol.dispose](): void;
7
- };
8
- //# sourceMappingURL=createTypeScriptFileFromProjectService.d.ts.map
@@ -1,16 +0,0 @@
1
- //#region src/createTypeScriptFileFromProjectService.ts
2
- function createTypeScriptFileFromProjectService(filePathAbsolute, program, service) {
3
- const sourceFile = program.getSourceFile(filePathAbsolute);
4
- if (!sourceFile) throw new Error(`Could not retrieve source file for: ${filePathAbsolute}`);
5
- return {
6
- program,
7
- sourceFile,
8
- [Symbol.dispose]() {
9
- service.closeClientFile(filePathAbsolute);
10
- }
11
- };
12
- }
13
-
14
- //#endregion
15
- export { createTypeScriptFileFromProjectService };
16
- //# sourceMappingURL=createTypeScriptFileFromProjectService.js.map
@@ -1,2 +0,0 @@
1
- import { LanguageFileDiagnostic, SourceFileWithLineMapAndFileName } from "@flint.fyi/core";
2
- import ts from "typescript";
@@ -1,5 +0,0 @@
1
- import "./types/ast.js";
2
- import "./nodes.js";
3
- import "./language.js";
4
- import { LanguageFileCacheImpacts } from "@flint.fyi/core";
5
- import ts from "typescript";
@@ -1,2 +0,0 @@
1
- import "../types/ast.js";
2
- import { NormalizedReportRangeObject } from "@flint.fyi/core";
@@ -1,3 +0,0 @@
1
- import "./types/ast.js";
2
- import { CharacterReportRange } from "@flint.fyi/core";
3
- import "typescript";
@@ -1,21 +0,0 @@
1
- import "./convertTypeScriptDiagnosticToLanguageFileDiagnostic.js";
2
- import "./types/ast.js";
3
- import "./nodes.js";
4
- import { Checker } from "./types/checker.js";
5
- import "./language.js";
6
- import "./createTypeScriptFileFromProgram.js";
7
- import "./directives/parseDirectivesFromTypeScriptFile.js";
8
- import "./getTSNodeRange.js";
9
- import "./prepareTypeScriptBasedLanguage.js";
10
- import "./utils/declarationIncludesGlobal.js";
11
- import "./utils/getDeclarationsIfGlobal.js";
12
- import "./utils/getModifyingReferences.js";
13
- import "./utils/hasSameTokens.js";
14
- import "./utils/isBuiltinArrayMethod.js";
15
- import "./utils/isFunction.js";
16
- import "./utils/isGlobalDeclaration.js";
17
- import "./utils/isGlobalDeclarationOfName.js";
18
- import "./utils/isGlobalVariable.js";
19
- import "./utils/isInlineArrayCreation.js";
20
- import "./utils/unwrapParenthesizedExpression.js";
21
- import "./utils/unwrapParentParenthesizedExpressions.js";
@@ -1,5 +0,0 @@
1
- import "./types/ast.js";
2
- import "./nodes.js";
3
- import "./types/checker.js";
4
- import "@flint.fyi/core";
5
- import "typescript";
@@ -1 +0,0 @@
1
- import "./types/ast.js";
@@ -1,2 +0,0 @@
1
- import "./types/ast.js";
2
- import ts from "typescript";