@flint.fyi/typescript-language 0.18.2 → 0.18.4

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 (70) hide show
  1. package/lib/collectReferencedFilePaths.d.ts +0 -1
  2. package/lib/collectReferencedFilePaths.js +1 -3
  3. package/lib/convertTypeScriptDiagnosticToLanguageReport.d.ts +2 -3
  4. package/lib/convertTypeScriptDiagnosticToLanguageReport.js +3 -4
  5. package/lib/createTypeScriptServerHost.d.ts +1 -2
  6. package/lib/createTypeScriptServerHost.js +1 -3
  7. package/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +1 -2
  8. package/lib/directives/parseDirectivesFromTypeScriptFile.js +2 -4
  9. package/lib/getFirstEnumValues.d.ts +0 -1
  10. package/lib/getFirstEnumValues.js +0 -2
  11. package/lib/getTSNodeRange.d.ts +2 -3
  12. package/lib/getTSNodeRange.js +0 -2
  13. package/lib/getTypeScriptFileCacheImpacts.d.ts +0 -1
  14. package/lib/getTypeScriptFileCacheImpacts.js +5 -3
  15. package/lib/index.d.ts +8 -3
  16. package/lib/index.js +5 -1
  17. package/lib/language.d.ts +393 -201
  18. package/lib/language.js +2 -4
  19. package/lib/nodes.d.ts +1 -2
  20. package/lib/normalizeRange.d.ts +0 -1
  21. package/lib/normalizeRange.js +0 -2
  22. package/lib/orderTypeScriptFilePaths.d.ts +0 -1
  23. package/lib/orderTypeScriptFilePaths.js +0 -2
  24. package/lib/package.js +1 -3
  25. package/lib/scope/identifierReferences.d.ts +3 -0
  26. package/lib/scope/identifierReferences.js +89 -0
  27. package/lib/scope/scopeManager.d.ts +14 -0
  28. package/lib/scope/scopeManager.js +153 -0
  29. package/lib/scope/scopes.d.ts +7 -0
  30. package/lib/scope/scopes.js +64 -0
  31. package/lib/scope/types.d.ts +45 -0
  32. package/lib/types/ast.d.ts +2 -2
  33. package/lib/types/checker.d.ts +1 -2
  34. package/lib/utils/containsGlobalDeclarations.d.ts +6 -0
  35. package/lib/utils/containsGlobalDeclarations.js +17 -0
  36. package/lib/utils/createRuleTesterTSConfig.d.ts +1 -2
  37. package/lib/utils/createRuleTesterTSConfig.js +0 -2
  38. package/lib/utils/declarationIncludesGlobal.d.ts +1 -2
  39. package/lib/utils/declarationIncludesGlobal.js +0 -2
  40. package/lib/utils/declarationsIncludeGlobal.d.ts +0 -1
  41. package/lib/utils/declarationsIncludeGlobal.js +0 -2
  42. package/lib/utils/forEachChild.d.ts +7 -0
  43. package/lib/utils/forEachChild.js +5 -0
  44. package/lib/utils/getDeclarationsIfGlobal.d.ts +2 -5
  45. package/lib/utils/getDeclarationsIfGlobal.js +0 -2
  46. package/lib/utils/getModifyingReferences.d.ts +2 -7
  47. package/lib/utils/getModifyingReferences.js +5 -27
  48. package/lib/utils/hasSameTokens.d.ts +1 -2
  49. package/lib/utils/hasSameTokens.js +0 -2
  50. package/lib/utils/isBuiltinArrayMethod.d.ts +1 -2
  51. package/lib/utils/isBuiltinArrayMethod.js +0 -2
  52. package/lib/utils/isFunction.d.ts +1 -2
  53. package/lib/utils/isFunction.js +0 -2
  54. package/lib/utils/isGlobalDeclaration.d.ts +1 -2
  55. package/lib/utils/isGlobalDeclaration.js +0 -2
  56. package/lib/utils/isGlobalDeclarationOfName.d.ts +1 -2
  57. package/lib/utils/isGlobalDeclarationOfName.js +0 -2
  58. package/lib/utils/isGlobalVariable.d.ts +1 -2
  59. package/lib/utils/isGlobalVariable.js +0 -2
  60. package/lib/utils/isInlineArrayCreation.d.ts +1 -2
  61. package/lib/utils/isInlineArrayCreation.js +0 -2
  62. package/lib/utils/isStaticString.d.ts +5 -0
  63. package/lib/utils/isStaticString.js +7 -0
  64. package/lib/utils/isStringRawNoSubstitution.d.ts +7 -0
  65. package/lib/utils/isStringRawNoSubstitution.js +9 -0
  66. package/lib/utils/unwrapParentParenthesizedExpressions.d.ts +1 -2
  67. package/lib/utils/unwrapParentParenthesizedExpressions.js +0 -2
  68. package/lib/utils/unwrapParenthesizedNode.d.ts +1 -2
  69. package/lib/utils/unwrapParenthesizedNode.js +0 -2
  70. package/package.json +5 -6
@@ -1,4 +1,3 @@
1
1
  import ts from "typescript";
2
2
  import type * as AST from "./types/ast.ts";
3
3
  export declare function collectReferencedFilePaths(program: ts.Program, sourceFile: AST.SourceFile): string[];
4
- //# sourceMappingURL=collectReferencedFilePaths.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import ts from "typescript";
2
- import { nullThrows } from "@flint.fyi/utils";
3
2
  import * as tsutils from "ts-api-utils";
3
+ import { nullThrows } from "@flint.fyi/utils";
4
4
  import * as path$1 from "node:path";
5
5
  //#region src/collectReferencedFilePaths.ts
6
6
  function collectReferencedFilePaths(program, sourceFile) {
@@ -36,5 +36,3 @@ function isImportTypeNode(node) {
36
36
  }
37
37
  //#endregion
38
38
  export { collectReferencedFilePaths };
39
-
40
- //# sourceMappingURL=collectReferencedFilePaths.js.map
@@ -1,5 +1,5 @@
1
- import { LanguageReport, SourceFileWithLineMapAndFileName } from "@flint.fyi/core";
2
1
  import ts from "typescript";
2
+ import { LanguageReport, SourceFileWithLineMapAndFileName } from "@flint.fyi/core";
3
3
 
4
4
  //#region src/convertTypeScriptDiagnosticToLanguageReport.d.ts
5
5
  interface TSDiagnostic extends TSDiagnosticRelatedInformation {
@@ -14,5 +14,4 @@ interface TSDiagnosticRelatedInformation {
14
14
  }
15
15
  declare function convertTypeScriptDiagnosticToLanguageReport(diagnostic: TSDiagnostic): LanguageReport;
16
16
  //#endregion
17
- export { convertTypeScriptDiagnosticToLanguageReport };
18
- //# sourceMappingURL=convertTypeScriptDiagnosticToLanguageReport.d.ts.map
17
+ export { TSDiagnostic, convertTypeScriptDiagnosticToLanguageReport };
@@ -1,9 +1,10 @@
1
- import { getColumnAndLineOfPosition, getPositionOfColumnAndLine } from "@flint.fyi/core";
2
1
  import ts from "typescript";
2
+ import { getColumnAndLineOfPosition, getPositionOfColumnAndLine } from "@flint.fyi/core";
3
3
  //#region src/convertTypeScriptDiagnosticToLanguageReport.ts
4
4
  function convertTypeScriptDiagnosticToLanguageReport(diagnostic) {
5
5
  return {
6
6
  code: `TS${diagnostic.code}`,
7
+ source: "typescript",
7
8
  text: formatReport(diagnostic),
8
9
  ...diagnostic.file !== void 0 && diagnostic.start !== void 0 && { range: {
9
10
  begin: diagnostic.start,
@@ -68,7 +69,7 @@ function formatCodeSpan(file, start, length, indent, squiggleColor) {
68
69
  for (let i = firstLine; i <= lastLine; i++) {
69
70
  context += "\n";
70
71
  if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
71
- context += indent + color(ellipsis.padStart(gutterWidth), gutterStyleSequence) + gutterSeparator + "\n";
72
+ context += indent + color(ellipsis.padStart(gutterWidth), gutterStyleSequence) + " \n";
72
73
  i = lastLine - 1;
73
74
  }
74
75
  const lineStart = getPositionOfColumnAndLine(file, {
@@ -109,5 +110,3 @@ function formatLocation(file, start) {
109
110
  }
110
111
  //#endregion
111
112
  export { convertTypeScriptDiagnosticToLanguageReport };
112
-
113
- //# sourceMappingURL=convertTypeScriptDiagnosticToLanguageReport.js.map
@@ -1,4 +1,3 @@
1
- import { type LinterHost } from "@flint.fyi/core";
2
1
  import ts from "typescript";
2
+ import { type LinterHost } from "@flint.fyi/core";
3
3
  export declare function createTypeScriptServerHost(host: LinterHost): ts.server.ServerHost;
4
- //# sourceMappingURL=createTypeScriptServerHost.d.ts.map
@@ -1,5 +1,5 @@
1
- import { commonlyIgnoredPaths } from "@flint.fyi/core";
2
1
  import ts from "typescript";
2
+ import { commonlyIgnoredPaths } from "@flint.fyi/core";
3
3
  import { FlintAssertionError, assert } from "@flint.fyi/utils";
4
4
  import fs from "node:fs";
5
5
  import timers from "node:timers";
@@ -99,5 +99,3 @@ function createTypeScriptServerHost(host) {
99
99
  }
100
100
  //#endregion
101
101
  export { createTypeScriptServerHost };
102
-
103
- //# sourceMappingURL=createTypeScriptServerHost.js.map
@@ -9,5 +9,4 @@ interface ExtractedDirective {
9
9
  }
10
10
  declare function extractDirectivesFromTypeScriptFile(sourceFile: SourceFile): ExtractedDirective[];
11
11
  //#endregion
12
- export { ExtractedDirective, extractDirectivesFromTypeScriptFile };
13
- //# sourceMappingURL=parseDirectivesFromTypeScriptFile.d.ts.map
12
+ export { ExtractedDirective, extractDirectivesFromTypeScriptFile };
@@ -1,8 +1,8 @@
1
1
  import { normalizeRange } from "../normalizeRange.js";
2
- import { DirectivesCollector } from "@flint.fyi/core";
3
2
  import ts from "typescript";
4
- import { nullThrows } from "@flint.fyi/utils";
3
+ import { DirectivesCollector } from "@flint.fyi/core";
5
4
  import * as tsutils from "ts-api-utils";
5
+ import { nullThrows } from "@flint.fyi/utils";
6
6
  //#region src/directives/parseDirectivesFromTypeScriptFile.ts
7
7
  function extractDirectivesFromTypeScriptFile(sourceFile) {
8
8
  const directives = [];
@@ -62,5 +62,3 @@ function extendRangeToNextCodeLine(sourceFile, range) {
62
62
  }
63
63
  //#endregion
64
64
  export { extractDirectivesFromTypeScriptFile, parseDirectivesFromTypeScriptFile };
65
-
66
- //# sourceMappingURL=parseDirectivesFromTypeScriptFile.js.map
@@ -33,4 +33,3 @@
33
33
  * ```
34
34
  */
35
35
  export declare function getFirstEnumValues<Keys extends string, Values extends number, Original extends Record<Keys | Values, Keys | Values>>(original: Original): Original;
36
- //# sourceMappingURL=getFirstEnumValues.d.ts.map
@@ -44,5 +44,3 @@ function getFirstEnumValues(original) {
44
44
  }
45
45
  //#endregion
46
46
  export { getFirstEnumValues };
47
-
48
- //# sourceMappingURL=getFirstEnumValues.js.map
@@ -1,9 +1,8 @@
1
1
  import { SourceFile } from "./types/ast.js";
2
- import { CharacterReportRange } from "@flint.fyi/core";
3
2
  import * as ts$1 from "typescript";
3
+ import { CharacterReportRange } from "@flint.fyi/core";
4
4
 
5
5
  //#region src/getTSNodeRange.d.ts
6
6
  declare function getTSNodeRange(node: ts$1.Node, sourceFile: SourceFile): CharacterReportRange;
7
7
  //#endregion
8
- export { getTSNodeRange };
9
- //# sourceMappingURL=getTSNodeRange.d.ts.map
8
+ export { getTSNodeRange };
@@ -7,5 +7,3 @@ function getTSNodeRange(node, sourceFile) {
7
7
  }
8
8
  //#endregion
9
9
  export { getTSNodeRange };
10
-
11
- //# sourceMappingURL=getTSNodeRange.js.map
@@ -1,4 +1,3 @@
1
1
  import type { LanguageFile, LanguageFileCacheImpacts } from "@flint.fyi/core";
2
2
  import type { TypeScriptFileServices } from "./language.ts";
3
3
  export declare function getTypeScriptFileCacheImpacts(file: LanguageFile<TypeScriptFileServices>): LanguageFileCacheImpacts;
4
- //# sourceMappingURL=getTypeScriptFileCacheImpacts.d.ts.map
@@ -1,9 +1,11 @@
1
1
  import { collectReferencedFilePaths } from "./collectReferencedFilePaths.js";
2
+ import { containsGlobalDeclarations } from "./utils/containsGlobalDeclarations.js";
2
3
  //#region src/getTypeScriptFileCacheImpacts.ts
3
4
  function getTypeScriptFileCacheImpacts(file) {
4
- return { dependencies: ["tsconfig.json", ...collectReferencedFilePaths(file.services.program, file.services.sourceFile)] };
5
+ return {
6
+ dependencies: ["tsconfig.json", ...collectReferencedFilePaths(file.services.program, file.services.sourceFile)],
7
+ invalidatesCache: containsGlobalDeclarations(file.services.sourceFile)
8
+ };
5
9
  }
6
10
  //#endregion
7
11
  export { getTypeScriptFileCacheImpacts };
8
-
9
- //# sourceMappingURL=getTypeScriptFileCacheImpacts.js.map
package/lib/index.d.ts CHANGED
@@ -1,21 +1,26 @@
1
- import { convertTypeScriptDiagnosticToLanguageReport } from "./convertTypeScriptDiagnosticToLanguageReport.js";
1
+ import { TSDiagnostic, convertTypeScriptDiagnosticToLanguageReport } from "./convertTypeScriptDiagnosticToLanguageReport.js";
2
2
  import { ast_d_exports } from "./types/ast.js";
3
3
  import { ExtractedDirective, extractDirectivesFromTypeScriptFile } from "./directives/parseDirectivesFromTypeScriptFile.js";
4
4
  import { getTSNodeRange } from "./getTSNodeRange.js";
5
5
  import { TypeScriptNodeVisitors, TypeScriptNodesByName } from "./nodes.js";
6
6
  import { Checker } from "./types/checker.js";
7
7
  import { NodeSyntaxKinds, TypeScriptFileServices, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage } from "./language.js";
8
+ import { FunctionWithParameters, Scope, ScopeDefinition, ScopeDefinitionKind, ScopeManager, ScopeReference, ScopeVariable } from "./scope/types.js";
9
+ import { createScopeManager, getScopeManager } from "./scope/scopeManager.js";
8
10
  import { createRuleTesterTSConfig } from "./utils/createRuleTesterTSConfig.js";
9
11
  import { declarationIncludesGlobal } from "./utils/declarationIncludesGlobal.js";
12
+ import { forEachChild } from "./utils/forEachChild.js";
10
13
  import { getDeclarationsIfGlobal } from "./utils/getDeclarationsIfGlobal.js";
11
14
  import { getModifyingReferences } from "./utils/getModifyingReferences.js";
12
15
  import { hasSameTokens } from "./utils/hasSameTokens.js";
13
- import { isBuiltinArrayMethod } from "./utils/isBuiltinArrayMethod.js";
16
+ import { BuiltInArrayMethodNode, isBuiltinArrayMethod } from "./utils/isBuiltinArrayMethod.js";
14
17
  import { isFunction } from "./utils/isFunction.js";
15
18
  import { isGlobalDeclaration } from "./utils/isGlobalDeclaration.js";
16
19
  import { isGlobalDeclarationOfName } from "./utils/isGlobalDeclarationOfName.js";
17
20
  import { isGlobalVariable } from "./utils/isGlobalVariable.js";
18
21
  import { isInlineArrayCreation } from "./utils/isInlineArrayCreation.js";
22
+ import { isStaticString } from "./utils/isStaticString.js";
23
+ import { isStringRawNoSubstitution } from "./utils/isStringRawNoSubstitution.js";
19
24
  import { unwrapParenthesizedNode } from "./utils/unwrapParenthesizedNode.js";
20
25
  import { unwrapParentParenthesizedExpressions } from "./utils/unwrapParentParenthesizedExpressions.js";
21
- export { type ast_d_exports as AST, type Checker, type ExtractedDirective, NodeSyntaxKinds, TypeScriptFileServices, TypeScriptNodeVisitors, type TypeScriptNodesByName, convertTypeScriptDiagnosticToLanguageReport, createRuleTesterTSConfig, declarationIncludesGlobal, extractDirectivesFromTypeScriptFile, getDeclarationsIfGlobal, getModifyingReferences, getTSNodeRange, hasSameTokens, isBuiltinArrayMethod, isFunction, isGlobalDeclaration, isGlobalDeclarationOfName, isGlobalVariable, isInlineArrayCreation, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage, unwrapParentParenthesizedExpressions, unwrapParenthesizedNode };
26
+ export { type ast_d_exports as AST, type BuiltInArrayMethodNode, type Checker, type ExtractedDirective, type FunctionWithParameters, NodeSyntaxKinds, type Scope, type ScopeDefinition, type ScopeDefinitionKind, type ScopeManager, type ScopeReference, type ScopeVariable, type TSDiagnostic, type TypeScriptFileServices, type TypeScriptNodeVisitors, type TypeScriptNodesByName, convertTypeScriptDiagnosticToLanguageReport, createRuleTesterTSConfig, createScopeManager, declarationIncludesGlobal, extractDirectivesFromTypeScriptFile, forEachChild, getDeclarationsIfGlobal, getModifyingReferences, getScopeManager, getTSNodeRange, hasSameTokens, isBuiltinArrayMethod, isFunction, isGlobalDeclaration, isGlobalDeclarationOfName, isGlobalVariable, isInlineArrayCreation, isStaticString, isStringRawNoSubstitution, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage, unwrapParentParenthesizedExpressions, unwrapParenthesizedNode };
package/lib/index.js CHANGED
@@ -2,6 +2,8 @@ import { convertTypeScriptDiagnosticToLanguageReport } from "./convertTypeScript
2
2
  import { extractDirectivesFromTypeScriptFile } from "./directives/parseDirectivesFromTypeScriptFile.js";
3
3
  import { getTSNodeRange } from "./getTSNodeRange.js";
4
4
  import { NodeSyntaxKinds, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage } from "./language.js";
5
+ import { forEachChild } from "./utils/forEachChild.js";
6
+ import { createScopeManager, getScopeManager } from "./scope/scopeManager.js";
5
7
  import { createRuleTesterTSConfig } from "./utils/createRuleTesterTSConfig.js";
6
8
  import { declarationIncludesGlobal } from "./utils/declarationIncludesGlobal.js";
7
9
  import { getDeclarationsIfGlobal } from "./utils/getDeclarationsIfGlobal.js";
@@ -14,5 +16,7 @@ import { isGlobalDeclaration } from "./utils/isGlobalDeclaration.js";
14
16
  import { isGlobalDeclarationOfName } from "./utils/isGlobalDeclarationOfName.js";
15
17
  import { isGlobalVariable } from "./utils/isGlobalVariable.js";
16
18
  import { isInlineArrayCreation } from "./utils/isInlineArrayCreation.js";
19
+ import { isStaticString } from "./utils/isStaticString.js";
20
+ import { isStringRawNoSubstitution } from "./utils/isStringRawNoSubstitution.js";
17
21
  import { unwrapParentParenthesizedExpressions } from "./utils/unwrapParentParenthesizedExpressions.js";
18
- export { NodeSyntaxKinds, convertTypeScriptDiagnosticToLanguageReport, createRuleTesterTSConfig, declarationIncludesGlobal, extractDirectivesFromTypeScriptFile, getDeclarationsIfGlobal, getModifyingReferences, getTSNodeRange, hasSameTokens, isBuiltinArrayMethod, isFunction, isGlobalDeclaration, isGlobalDeclarationOfName, isGlobalVariable, isInlineArrayCreation, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage, unwrapParentParenthesizedExpressions, unwrapParenthesizedNode };
22
+ export { NodeSyntaxKinds, convertTypeScriptDiagnosticToLanguageReport, createRuleTesterTSConfig, createScopeManager, declarationIncludesGlobal, extractDirectivesFromTypeScriptFile, forEachChild, getDeclarationsIfGlobal, getModifyingReferences, getScopeManager, getTSNodeRange, hasSameTokens, isBuiltinArrayMethod, isFunction, isGlobalDeclaration, isGlobalDeclarationOfName, isGlobalVariable, isInlineArrayCreation, isStaticString, isStringRawNoSubstitution, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage, unwrapParentParenthesizedExpressions, unwrapParenthesizedNode };