@flint.fyi/typescript-language 0.18.3 → 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.
- package/lib/collectReferencedFilePaths.d.ts +0 -1
- package/lib/collectReferencedFilePaths.js +0 -2
- package/lib/convertTypeScriptDiagnosticToLanguageReport.d.ts +1 -2
- package/lib/convertTypeScriptDiagnosticToLanguageReport.js +1 -3
- package/lib/createTypeScriptServerHost.d.ts +0 -1
- package/lib/createTypeScriptServerHost.js +0 -2
- package/lib/directives/parseDirectivesFromTypeScriptFile.d.ts +1 -2
- package/lib/directives/parseDirectivesFromTypeScriptFile.js +0 -2
- package/lib/getFirstEnumValues.d.ts +0 -1
- package/lib/getFirstEnumValues.js +0 -2
- package/lib/getTSNodeRange.d.ts +1 -2
- package/lib/getTSNodeRange.js +0 -2
- package/lib/getTypeScriptFileCacheImpacts.d.ts +0 -1
- package/lib/getTypeScriptFileCacheImpacts.js +5 -3
- package/lib/index.d.ts +2 -2
- package/lib/language.d.ts +2 -4
- package/lib/language.js +0 -2
- package/lib/nodes.d.ts +1 -2
- package/lib/normalizeRange.d.ts +0 -1
- package/lib/normalizeRange.js +0 -2
- package/lib/orderTypeScriptFilePaths.d.ts +0 -1
- package/lib/orderTypeScriptFilePaths.js +0 -2
- package/lib/package.js +1 -3
- package/lib/scope/identifierReferences.d.ts +0 -1
- package/lib/scope/identifierReferences.js +0 -2
- package/lib/scope/scopeManager.d.ts +2 -3
- package/lib/scope/scopeManager.js +20 -16
- package/lib/scope/scopes.d.ts +0 -1
- package/lib/scope/scopes.js +0 -2
- package/lib/scope/types.d.ts +8 -2
- package/lib/types/ast.d.ts +1 -2
- package/lib/types/checker.d.ts +1 -2
- package/lib/utils/containsGlobalDeclarations.d.ts +6 -0
- package/lib/utils/containsGlobalDeclarations.js +17 -0
- package/lib/utils/createRuleTesterTSConfig.d.ts +1 -2
- package/lib/utils/createRuleTesterTSConfig.js +0 -2
- package/lib/utils/declarationIncludesGlobal.d.ts +1 -2
- package/lib/utils/declarationIncludesGlobal.js +0 -2
- package/lib/utils/declarationsIncludeGlobal.d.ts +0 -1
- package/lib/utils/declarationsIncludeGlobal.js +0 -2
- package/lib/utils/forEachChild.d.ts +1 -2
- package/lib/utils/forEachChild.js +0 -2
- package/lib/utils/getDeclarationsIfGlobal.d.ts +2 -5
- package/lib/utils/getDeclarationsIfGlobal.js +0 -2
- package/lib/utils/getModifyingReferences.d.ts +1 -2
- package/lib/utils/getModifyingReferences.js +0 -2
- package/lib/utils/hasSameTokens.d.ts +1 -2
- package/lib/utils/hasSameTokens.js +0 -2
- package/lib/utils/isBuiltinArrayMethod.d.ts +1 -2
- package/lib/utils/isBuiltinArrayMethod.js +0 -2
- package/lib/utils/isFunction.d.ts +1 -2
- package/lib/utils/isFunction.js +0 -2
- package/lib/utils/isGlobalDeclaration.d.ts +1 -2
- package/lib/utils/isGlobalDeclaration.js +0 -2
- package/lib/utils/isGlobalDeclarationOfName.d.ts +1 -2
- package/lib/utils/isGlobalDeclarationOfName.js +0 -2
- package/lib/utils/isGlobalVariable.d.ts +1 -2
- package/lib/utils/isGlobalVariable.js +0 -2
- package/lib/utils/isInlineArrayCreation.d.ts +1 -2
- package/lib/utils/isInlineArrayCreation.js +0 -2
- package/lib/utils/isStaticString.d.ts +1 -2
- package/lib/utils/isStaticString.js +0 -2
- package/lib/utils/isStringRawNoSubstitution.d.ts +1 -2
- package/lib/utils/isStringRawNoSubstitution.js +0 -2
- package/lib/utils/unwrapParentParenthesizedExpressions.d.ts +1 -2
- package/lib/utils/unwrapParentParenthesizedExpressions.js +0 -2
- package/lib/utils/unwrapParenthesizedNode.d.ts +1 -2
- package/lib/utils/unwrapParenthesizedNode.js +0 -2
- package/package.json +5 -6
|
@@ -14,5 +14,4 @@ interface TSDiagnosticRelatedInformation {
|
|
|
14
14
|
}
|
|
15
15
|
declare function convertTypeScriptDiagnosticToLanguageReport(diagnostic: TSDiagnostic): LanguageReport;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { TSDiagnostic, convertTypeScriptDiagnosticToLanguageReport };
|
|
18
|
-
//# sourceMappingURL=convertTypeScriptDiagnosticToLanguageReport.d.ts.map
|
|
17
|
+
export { TSDiagnostic, convertTypeScriptDiagnosticToLanguageReport };
|
|
@@ -69,7 +69,7 @@ function formatCodeSpan(file, start, length, indent, squiggleColor) {
|
|
|
69
69
|
for (let i = firstLine; i <= lastLine; i++) {
|
|
70
70
|
context += "\n";
|
|
71
71
|
if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
|
|
72
|
-
context += indent + color(ellipsis.padStart(gutterWidth), gutterStyleSequence) +
|
|
72
|
+
context += indent + color(ellipsis.padStart(gutterWidth), gutterStyleSequence) + " \n";
|
|
73
73
|
i = lastLine - 1;
|
|
74
74
|
}
|
|
75
75
|
const lineStart = getPositionOfColumnAndLine(file, {
|
|
@@ -110,5 +110,3 @@ function formatLocation(file, start) {
|
|
|
110
110
|
}
|
|
111
111
|
//#endregion
|
|
112
112
|
export { convertTypeScriptDiagnosticToLanguageReport };
|
|
113
|
-
|
|
114
|
-
//# sourceMappingURL=convertTypeScriptDiagnosticToLanguageReport.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 };
|
package/lib/getTSNodeRange.d.ts
CHANGED
|
@@ -5,5 +5,4 @@ import { CharacterReportRange } from "@flint.fyi/core";
|
|
|
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 };
|
package/lib/getTSNodeRange.js
CHANGED
|
@@ -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 {
|
|
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
|
@@ -5,7 +5,7 @@ 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, ScopeManager, ScopeReference, ScopeVariable } from "./scope/types.js";
|
|
8
|
+
import { FunctionWithParameters, Scope, ScopeDefinition, ScopeDefinitionKind, ScopeManager, ScopeReference, ScopeVariable } from "./scope/types.js";
|
|
9
9
|
import { createScopeManager, getScopeManager } from "./scope/scopeManager.js";
|
|
10
10
|
import { createRuleTesterTSConfig } from "./utils/createRuleTesterTSConfig.js";
|
|
11
11
|
import { declarationIncludesGlobal } from "./utils/declarationIncludesGlobal.js";
|
|
@@ -23,4 +23,4 @@ import { isStaticString } from "./utils/isStaticString.js";
|
|
|
23
23
|
import { isStringRawNoSubstitution } from "./utils/isStringRawNoSubstitution.js";
|
|
24
24
|
import { unwrapParenthesizedNode } from "./utils/unwrapParenthesizedNode.js";
|
|
25
25
|
import { unwrapParentParenthesizedExpressions } from "./utils/unwrapParentParenthesizedExpressions.js";
|
|
26
|
-
export { type ast_d_exports as AST, type BuiltInArrayMethodNode, type Checker, type ExtractedDirective, type FunctionWithParameters, NodeSyntaxKinds, type Scope, 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 };
|
|
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/language.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { AnyKeyword, ArrayBindingPattern, ArrayLiteralExpression, ArrayTypeNode,
|
|
|
2
2
|
import { TypeScriptNodeVisitors } from "./nodes.js";
|
|
3
3
|
import { Checker } from "./types/checker.js";
|
|
4
4
|
import * as ts$1 from "typescript";
|
|
5
|
-
import * as _flint_fyi_core0 from "@flint.fyi/core";
|
|
6
5
|
import { AnyOptionalSchema, FileAboutData, InferredOutputObject, LanguageFile, LanguageFileDefinition, LanguageReports, RuleRuntime } from "@flint.fyi/core";
|
|
7
6
|
|
|
8
7
|
//#region src/language.d.ts
|
|
@@ -20,7 +19,7 @@ type VolarLanguageFileDefinition = LanguageFileDefinition<object> & {
|
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
21
|
declare function setVolarCreateFile(create: VolarCreateFile): void;
|
|
23
|
-
declare const typescriptLanguage:
|
|
22
|
+
declare const typescriptLanguage: import("@flint.fyi/core").Language<{
|
|
24
23
|
AnyKeyword: AnyKeyword;
|
|
25
24
|
ArrayBindingPattern: ArrayBindingPattern;
|
|
26
25
|
ArrayLiteralExpression: ArrayLiteralExpression;
|
|
@@ -412,5 +411,4 @@ declare const typescriptLanguage: _flint_fyi_core0.Language<{
|
|
|
412
411
|
}, TypeScriptFileServices>;
|
|
413
412
|
declare function throwUnknownLanguageExtension(filename: string): never;
|
|
414
413
|
//#endregion
|
|
415
|
-
export { NodeSyntaxKinds, TypeScriptFileServices, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage };
|
|
416
|
-
//# sourceMappingURL=language.d.ts.map
|
|
414
|
+
export { NodeSyntaxKinds, TypeScriptFileServices, setVolarCreateFile, throwUnknownLanguageExtension, typescriptLanguage };
|
package/lib/language.js
CHANGED
package/lib/nodes.d.ts
CHANGED
|
@@ -200,5 +200,4 @@ interface TypeScriptNodesByName {
|
|
|
200
200
|
}
|
|
201
201
|
type TypeScriptNodeVisitors = WithExitKeys<TypeScriptNodesByName>;
|
|
202
202
|
//#endregion
|
|
203
|
-
export { TypeScriptNodeVisitors, TypeScriptNodesByName };
|
|
204
|
-
//# sourceMappingURL=nodes.d.ts.map
|
|
203
|
+
export { TypeScriptNodeVisitors, TypeScriptNodesByName };
|
package/lib/normalizeRange.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { type CharacterReportRange, type NormalizedReportRangeObject } from "@flint.fyi/core";
|
|
2
2
|
import type * as AST from "./types/ast.ts";
|
|
3
3
|
export declare function normalizeRange(original: CharacterReportRange, sourceFile: AST.SourceFile): NormalizedReportRangeObject;
|
|
4
|
-
//# sourceMappingURL=normalizeRange.d.ts.map
|
package/lib/normalizeRange.js
CHANGED
package/lib/package.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyNode, Identifier, SourceFile } from "../types/ast.js";
|
|
2
|
-
import { FunctionWithParameters, Scope, ScopeInternal, ScopeManager, ScopeReference, ScopeVariable } from "./types.js";
|
|
2
|
+
import { FunctionWithParameters, Scope, ScopeDefinition, ScopeDefinitionKind, ScopeInternal, ScopeManager, ScopeReference, ScopeVariable } from "./types.js";
|
|
3
3
|
|
|
4
4
|
//#region src/scope/scopeManager.d.ts
|
|
5
5
|
declare function createScopeManager(sourceFile: SourceFile): {
|
|
@@ -11,5 +11,4 @@ declare function createScopeManager(sourceFile: SourceFile): {
|
|
|
11
11
|
};
|
|
12
12
|
declare function getScopeManager(sourceFile: SourceFile): ScopeManager;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { createScopeManager, getScopeManager };
|
|
15
|
-
//# sourceMappingURL=scopeManager.d.ts.map
|
|
14
|
+
export { createScopeManager, getScopeManager };
|
|
@@ -9,37 +9,38 @@ function createScopeManager(sourceFile) {
|
|
|
9
9
|
const declaredVariablesByNode = /* @__PURE__ */ new WeakMap();
|
|
10
10
|
const nodeScopes = /* @__PURE__ */ new WeakMap();
|
|
11
11
|
const globalScope = createScope(sourceFile, void 0);
|
|
12
|
-
function addBindingName(scope, name, node) {
|
|
13
|
-
if (name.kind === SyntaxKind.Identifier) return [addVariable(scope, name, node)];
|
|
12
|
+
function addBindingName(scope, name, node, kind) {
|
|
13
|
+
if (name.kind === SyntaxKind.Identifier) return [addVariable(scope, name, node, kind)];
|
|
14
14
|
const variables = [];
|
|
15
|
-
for (const element of name.elements) if (element.kind !== SyntaxKind.OmittedExpression) variables.push(...addBindingName(scope, element.name, node));
|
|
15
|
+
for (const element of name.elements) if (element.kind !== SyntaxKind.OmittedExpression) variables.push(...addBindingName(scope, element.name, node, kind));
|
|
16
16
|
return variables;
|
|
17
17
|
}
|
|
18
18
|
function addImportVariables(scope, node) {
|
|
19
19
|
if (!node.importClause || node.importClause.isTypeOnly) return;
|
|
20
|
-
if (node.importClause.name) addVariable(scope, node.importClause.name, node);
|
|
20
|
+
if (node.importClause.name) addVariable(scope, node.importClause.name, node, "import");
|
|
21
21
|
const { namedBindings } = node.importClause;
|
|
22
22
|
if (!namedBindings) return;
|
|
23
23
|
if (namedBindings.kind === SyntaxKind.NamespaceImport) {
|
|
24
|
-
addVariable(scope, namedBindings.name, node);
|
|
24
|
+
addVariable(scope, namedBindings.name, node, "import");
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
for (const element of namedBindings.elements) {
|
|
28
28
|
if (element.isTypeOnly) continue;
|
|
29
|
-
addVariable(scope, element.name, node);
|
|
29
|
+
addVariable(scope, element.name, node, "import");
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function addParameters(scope, node) {
|
|
33
33
|
for (const parameter of node.parameters) {
|
|
34
|
-
const variables = addBindingName(scope, parameter.name, node);
|
|
34
|
+
const variables = addBindingName(scope, parameter.name, node, "parameter");
|
|
35
35
|
declaredVariablesByNode.set(parameter, variables);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
function addVariable(scope, identifier, node) {
|
|
38
|
+
function addVariable(scope, identifier, node, kind) {
|
|
39
39
|
let variable = scope.variablesByName.get(identifier.text);
|
|
40
40
|
if (!variable) {
|
|
41
41
|
variable = {
|
|
42
42
|
declarations: [],
|
|
43
|
+
definitions: [],
|
|
43
44
|
name: identifier.text,
|
|
44
45
|
references: [],
|
|
45
46
|
scope
|
|
@@ -48,6 +49,11 @@ function createScopeManager(sourceFile) {
|
|
|
48
49
|
scope.variables.push(variable);
|
|
49
50
|
}
|
|
50
51
|
variable.declarations.push(identifier);
|
|
52
|
+
variable.definitions.push({
|
|
53
|
+
identifier,
|
|
54
|
+
kind,
|
|
55
|
+
node
|
|
56
|
+
});
|
|
51
57
|
declarationVariablesByIdentifier.set(identifier, variable);
|
|
52
58
|
const declaredVariables = declaredVariablesByNode.get(node) ?? [];
|
|
53
59
|
declaredVariables.push(variable);
|
|
@@ -66,20 +72,20 @@ function createScopeManager(sourceFile) {
|
|
|
66
72
|
addParameters(nodeScope, node);
|
|
67
73
|
break;
|
|
68
74
|
case SyntaxKind.CatchClause:
|
|
69
|
-
if (node.variableDeclaration) addBindingName(nodeScope, node.variableDeclaration.name, node);
|
|
75
|
+
if (node.variableDeclaration) addBindingName(nodeScope, node.variableDeclaration.name, node, "catch");
|
|
70
76
|
break;
|
|
71
77
|
case SyntaxKind.ClassDeclaration:
|
|
72
|
-
if (node.name) addVariable(nodeScope, node.name, node);
|
|
78
|
+
if (node.name) addVariable(nodeScope, node.name, node, "class");
|
|
73
79
|
break;
|
|
74
80
|
case SyntaxKind.ClassExpression:
|
|
75
|
-
if (node.name) addVariable(nodeScope, node.name, node);
|
|
81
|
+
if (node.name) addVariable(nodeScope, node.name, node, "class");
|
|
76
82
|
break;
|
|
77
83
|
case SyntaxKind.FunctionDeclaration:
|
|
78
|
-
if (node.name) addVariable(scope, node.name, node);
|
|
84
|
+
if (node.name) addVariable(scope, node.name, node, "function");
|
|
79
85
|
addParameters(nodeScope, node);
|
|
80
86
|
break;
|
|
81
87
|
case SyntaxKind.FunctionExpression:
|
|
82
|
-
if (node.name) addVariable(nodeScope, node.name, node);
|
|
88
|
+
if (node.name) addVariable(nodeScope, node.name, node, "function");
|
|
83
89
|
addParameters(nodeScope, node);
|
|
84
90
|
break;
|
|
85
91
|
case SyntaxKind.ImportDeclaration:
|
|
@@ -92,7 +98,7 @@ function createScopeManager(sourceFile) {
|
|
|
92
98
|
});
|
|
93
99
|
return;
|
|
94
100
|
}
|
|
95
|
-
addBindingName(getVariableDeclarationScope(node, nodeScope), node.name, node);
|
|
101
|
+
addBindingName(getVariableDeclarationScope(node, nodeScope), node.name, node, "variable");
|
|
96
102
|
break;
|
|
97
103
|
}
|
|
98
104
|
forEachChild(node, (child) => {
|
|
@@ -145,5 +151,3 @@ function getScopeManager(sourceFile) {
|
|
|
145
151
|
}
|
|
146
152
|
//#endregion
|
|
147
153
|
export { createScopeManager, getScopeManager };
|
|
148
|
-
|
|
149
|
-
//# sourceMappingURL=scopeManager.js.map
|
package/lib/scope/scopes.d.ts
CHANGED
|
@@ -5,4 +5,3 @@ export declare function getReferencesInScope(scope: ScopeInternal): import("./ty
|
|
|
5
5
|
export declare function getVariableDeclarationScope(node: AST.VariableDeclaration, scope: ScopeInternal): ScopeInternal;
|
|
6
6
|
export declare function isScopeBoundary(node: AST.AnyNode): boolean;
|
|
7
7
|
export declare function resolveVariable(scope: ScopeInternal, name: string): ScopeVariable | undefined;
|
|
8
|
-
//# sourceMappingURL=scopes.d.ts.map
|
package/lib/scope/scopes.js
CHANGED
package/lib/scope/types.d.ts
CHANGED
|
@@ -9,6 +9,12 @@ interface Scope {
|
|
|
9
9
|
upper: Scope | undefined;
|
|
10
10
|
variables: ScopeVariable[];
|
|
11
11
|
}
|
|
12
|
+
interface ScopeDefinition {
|
|
13
|
+
identifier: Identifier;
|
|
14
|
+
kind: ScopeDefinitionKind;
|
|
15
|
+
node: AnyNode;
|
|
16
|
+
}
|
|
17
|
+
type ScopeDefinitionKind = "catch" | "class" | "function" | "import" | "parameter" | "variable";
|
|
12
18
|
interface ScopeInternal extends Scope {
|
|
13
19
|
childScopes: ScopeInternal[];
|
|
14
20
|
upper: ScopeInternal | undefined;
|
|
@@ -30,10 +36,10 @@ interface ScopeReference {
|
|
|
30
36
|
}
|
|
31
37
|
interface ScopeVariable {
|
|
32
38
|
declarations: Identifier[];
|
|
39
|
+
definitions: ScopeDefinition[];
|
|
33
40
|
name: string;
|
|
34
41
|
references: ScopeReference[];
|
|
35
42
|
scope: Scope;
|
|
36
43
|
}
|
|
37
44
|
//#endregion
|
|
38
|
-
export { FunctionWithParameters, Scope, ScopeInternal, ScopeManager, ScopeReference, ScopeVariable };
|
|
39
|
-
//# sourceMappingURL=types.d.ts.map
|
|
45
|
+
export { FunctionWithParameters, Scope, ScopeDefinition, ScopeDefinitionKind, ScopeInternal, ScopeManager, ScopeReference, ScopeVariable };
|
package/lib/types/ast.d.ts
CHANGED
|
@@ -2067,5 +2067,4 @@ type ModifierParent = AccessorDeclaration | ArrowFunction | ClassDeclaration | C
|
|
|
2067
2067
|
type StatementParent = Block | CaseOrDefaultClause | IfStatement | IterationStatement | LabeledStatement | ModuleBlock | SourceFile | WithStatement;
|
|
2068
2068
|
type TypeNodeParent = AccessorDeclaration | ArrayTypeNode | ArrowFunction | AsExpression | CallExpression | CallSignatureDeclaration | ConditionalTypeNode | ConstructorDeclaration | ConstructSignatureDeclaration | FunctionDeclaration | FunctionExpression | FunctionOrConstructorTypeNodeBase | IndexedAccessTypeNode | IndexSignatureDeclaration | IntersectionTypeNode | JSDocFunctionType | JSDocNamepathType | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocTypeExpression | JSDocVariadicType | JsxOpeningElement | JsxSelfClosingElement | MappedTypeNode | MethodDeclaration | MethodSignature | NamedTupleMember | NewExpression | NodeWithTypeArguments | OptionalTypeNode | ParameterDeclaration | ParenthesizedTypeNode | PropertyDeclaration | PropertySignature | RestTypeNode | SatisfiesExpression | TaggedTemplateExpression | TemplateLiteralTypeSpan | TupleTypeNode | TypeAliasDeclaration | TypeAssertion | TypeOperatorNode | TypeParameterDeclaration | TypePredicateNode | UnionTypeNode | VariableDeclaration;
|
|
2069
2069
|
//#endregion
|
|
2070
|
-
export { AnyKeyword, AnyNode, ArrayBindingPattern, ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AwaitExpression, BigIntKeyword, BigIntLiteral, BinaryExpression, BindingElement, Block, BooleanKeyword, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseClause, CatchClause, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, CommaListExpression, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, DebuggerStatement, Decorator, DefaultClause, DeleteExpression, DoStatement, ElementAccessExpression, EmptyStatement, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, Expression, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, FalseLiteral, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportExpression, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, IntrinsicKeyword, JSDocAllType, JSDocFunctionType, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocMemberName, JSDocNamepathType, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocParameterTag, JSDocPropertyTag, JSDocReturnTag, JSDocSignature, JSDocTemplateTag, JSDocText, JSDocTypeExpression, JSDocTypeLiteral, JSDocUnknownType, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxClosingFragment, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, JsxSpreadAttribute, JsxText, LabeledStatement, LeftHandSideExpressionParent, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignature, MissingDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NeverKeyword, NewExpression, NoSubstitutionTemplateLiteral, NonNullExpression, NotEmittedStatement, NotEmittedTypeElement, NullLiteral, NumberKeyword, NumericLiteral, ObjectBindingPattern, ObjectKeyword, ObjectLiteralExpression, OmittedExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignature, QualifiedName, RegularExpressionLiteral, RestTypeNode, ReturnStatement, SatisfiesExpression, SemicolonClassElement, SetAccessorDeclaration, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StringKeyword, StringLiteral, SuperExpression, SwitchStatement, SymbolKeyword, SyntheticExpression, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateMiddle, TemplateSpan, TemplateTail, ThisExpression, ThisTypeNode, ThrowStatement, TrueLiteral, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UndefinedKeyword, UnionTypeNode, UnknownKeyword, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, VoidKeyword, WhileStatement, WithStatement, YieldExpression, ast_d_exports };
|
|
2071
|
-
//# sourceMappingURL=ast.d.ts.map
|
|
2070
|
+
export { AnyKeyword, AnyNode, ArrayBindingPattern, ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AwaitExpression, BigIntKeyword, BigIntLiteral, BinaryExpression, BindingElement, Block, BooleanKeyword, BreakStatement, CallExpression, CallSignatureDeclaration, CaseBlock, CaseClause, CatchClause, ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, CommaListExpression, ComputedPropertyName, ConditionalExpression, ConditionalTypeNode, ConstructSignatureDeclaration, ConstructorDeclaration, ConstructorTypeNode, ContinueStatement, DebuggerStatement, Decorator, DefaultClause, DeleteExpression, DoStatement, ElementAccessExpression, EmptyStatement, EnumDeclaration, EnumMember, ExportAssignment, ExportDeclaration, ExportSpecifier, Expression, ExpressionStatement, ExpressionWithTypeArguments, ExternalModuleReference, FalseLiteral, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, IfStatement, ImportAttribute, ImportAttributes, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportExpression, ImportSpecifier, ImportTypeNode, IndexSignatureDeclaration, IndexedAccessTypeNode, InferTypeNode, InterfaceDeclaration, IntersectionTypeNode, IntrinsicKeyword, JSDocAllType, JSDocFunctionType, JSDocLink, JSDocLinkCode, JSDocLinkPlain, JSDocMemberName, JSDocNamepathType, JSDocNonNullableType, JSDocNullableType, JSDocOptionalType, JSDocParameterTag, JSDocPropertyTag, JSDocReturnTag, JSDocSignature, JSDocTemplateTag, JSDocText, JSDocTypeExpression, JSDocTypeLiteral, JSDocUnknownType, JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxClosingFragment, JsxElement, JsxExpression, JsxFragment, JsxNamespacedName, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, JsxSpreadAttribute, JsxText, LabeledStatement, LeftHandSideExpressionParent, LiteralTypeNode, MappedTypeNode, MetaProperty, MethodDeclaration, MethodSignature, MissingDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NeverKeyword, NewExpression, NoSubstitutionTemplateLiteral, NonNullExpression, NotEmittedStatement, NotEmittedTypeElement, NullLiteral, NumberKeyword, NumericLiteral, ObjectBindingPattern, ObjectKeyword, ObjectLiteralExpression, OmittedExpression, OptionalTypeNode, ParameterDeclaration, ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, PropertySignature, QualifiedName, RegularExpressionLiteral, RestTypeNode, ReturnStatement, SatisfiesExpression, SemicolonClassElement, SetAccessorDeclaration, ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StringKeyword, StringLiteral, SuperExpression, SwitchStatement, SymbolKeyword, SyntheticExpression, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateLiteralTypeNode, TemplateLiteralTypeSpan, TemplateMiddle, TemplateSpan, TemplateTail, ThisExpression, ThisTypeNode, ThrowStatement, TrueLiteral, TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UndefinedKeyword, UnionTypeNode, UnknownKeyword, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, VoidKeyword, WhileStatement, WithStatement, YieldExpression, ast_d_exports };
|
package/lib/types/checker.d.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
//#region src/utils/containsGlobalDeclarations.ts
|
|
3
|
+
/**
|
|
4
|
+
* Inspects top-level statements of a TS source file to determine
|
|
5
|
+
* if it introduces or modifies entities in the global scope.
|
|
6
|
+
*/
|
|
7
|
+
function containsGlobalDeclarations(sourceFileNode) {
|
|
8
|
+
const isModule = ts.isExternalModule(sourceFileNode);
|
|
9
|
+
return sourceFileNode.statements.some((statement) => {
|
|
10
|
+
if (ts.isModuleDeclaration(statement) && statement.name.text === "global") return true;
|
|
11
|
+
if (isModule) return false;
|
|
12
|
+
if (!ts.canHaveModifiers(statement)) return false;
|
|
13
|
+
return ts.getModifiers(statement)?.some((mod) => mod.kind === ts.SyntaxKind.DeclareKeyword);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { containsGlobalDeclarations };
|
|
@@ -3,5 +3,4 @@ import ts from "typescript";
|
|
|
3
3
|
//#region src/utils/declarationIncludesGlobal.d.ts
|
|
4
4
|
declare function declarationIncludesGlobal(declaration: ts.Declaration): boolean;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { declarationIncludesGlobal };
|
|
7
|
-
//# sourceMappingURL=declarationIncludesGlobal.d.ts.map
|
|
6
|
+
export { declarationIncludesGlobal };
|
|
@@ -4,5 +4,4 @@ import ts from "typescript";
|
|
|
4
4
|
//#region src/utils/forEachChild.d.ts
|
|
5
5
|
declare const forEachChild: <T>(node: AnyNode, cbNode: (node: AnyNode) => T | undefined, cbNodes?: (nodes: ts.NodeArray<AnyNode>) => T | undefined) => T | undefined;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { forEachChild };
|
|
8
|
-
//# sourceMappingURL=forEachChild.d.ts.map
|
|
7
|
+
export { forEachChild };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Expression } from "../types/ast.js";
|
|
2
2
|
import { Checker } from "../types/checker.js";
|
|
3
|
-
import * as typescript from "typescript";
|
|
4
|
-
|
|
5
3
|
//#region src/utils/getDeclarationsIfGlobal.d.ts
|
|
6
|
-
declare function getDeclarationsIfGlobal(node: Expression, typeChecker: Checker): typescript.Declaration[] | undefined;
|
|
4
|
+
declare function getDeclarationsIfGlobal(node: Expression, typeChecker: Checker): import("typescript").Declaration[] | undefined;
|
|
7
5
|
//#endregion
|
|
8
|
-
export { getDeclarationsIfGlobal };
|
|
9
|
-
//# sourceMappingURL=getDeclarationsIfGlobal.d.ts.map
|
|
6
|
+
export { getDeclarationsIfGlobal };
|
|
@@ -7,5 +7,4 @@ import { Identifier, SourceFile } from "../types/ast.js";
|
|
|
7
7
|
*/
|
|
8
8
|
declare function getModifyingReferences(identifier: Identifier, sourceFile: SourceFile): Identifier[];
|
|
9
9
|
//#endregion
|
|
10
|
-
export { getModifyingReferences };
|
|
11
|
-
//# sourceMappingURL=getModifyingReferences.d.ts.map
|
|
10
|
+
export { getModifyingReferences };
|
|
@@ -3,5 +3,4 @@ import { AnyNode, SourceFile } from "../types/ast.js";
|
|
|
3
3
|
//#region src/utils/hasSameTokens.d.ts
|
|
4
4
|
declare function hasSameTokens(nodeA: AnyNode, nodeB: AnyNode, sourceFile: SourceFile): boolean;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { hasSameTokens };
|
|
7
|
-
//# sourceMappingURL=hasSameTokens.d.ts.map
|
|
6
|
+
export { hasSameTokens };
|
|
@@ -10,5 +10,4 @@ type BuiltInArrayMethodNode = CallExpression & {
|
|
|
10
10
|
};
|
|
11
11
|
declare function isBuiltinArrayMethod(name: string, node: CallExpression, typeChecker: Checker): node is BuiltInArrayMethodNode;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { BuiltInArrayMethodNode, isBuiltinArrayMethod };
|
|
14
|
-
//# sourceMappingURL=isBuiltinArrayMethod.d.ts.map
|
|
13
|
+
export { BuiltInArrayMethodNode, isBuiltinArrayMethod };
|
|
@@ -3,5 +3,4 @@ import { Checker } from "../types/checker.js";
|
|
|
3
3
|
//#region src/utils/isFunction.d.ts
|
|
4
4
|
declare function isFunction(node: Expression, typeChecker: Checker): boolean;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { isFunction };
|
|
7
|
-
//# sourceMappingURL=isFunction.d.ts.map
|
|
6
|
+
export { isFunction };
|
package/lib/utils/isFunction.js
CHANGED
|
@@ -3,5 +3,4 @@ import { Checker } from "../types/checker.js";
|
|
|
3
3
|
//#region src/utils/isGlobalDeclaration.d.ts
|
|
4
4
|
declare function isGlobalDeclaration(node: Expression, typeChecker: Checker): boolean;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { isGlobalDeclaration };
|
|
7
|
-
//# sourceMappingURL=isGlobalDeclaration.d.ts.map
|
|
6
|
+
export { isGlobalDeclaration };
|
|
@@ -7,5 +7,4 @@ import ts from "typescript";
|
|
|
7
7
|
*/
|
|
8
8
|
declare function isGlobalDeclarationOfName(node: ts.Node, name: string, typeChecker: Checker): boolean;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { isGlobalDeclarationOfName };
|
|
11
|
-
//# sourceMappingURL=isGlobalDeclarationOfName.d.ts.map
|
|
10
|
+
export { isGlobalDeclarationOfName };
|
|
@@ -2,5 +2,4 @@ import { Expression, NoSubstitutionTemplateLiteral, StringLiteral } from "../typ
|
|
|
2
2
|
//#region src/utils/isStaticString.d.ts
|
|
3
3
|
declare function isStaticString(node: Expression): node is NoSubstitutionTemplateLiteral | StringLiteral;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { isStaticString };
|
|
6
|
-
//# sourceMappingURL=isStaticString.d.ts.map
|
|
5
|
+
export { isStaticString };
|
|
@@ -4,5 +4,4 @@ declare function isStringRawNoSubstitution(node: Expression): node is TaggedTemp
|
|
|
4
4
|
template: NoSubstitutionTemplateLiteral;
|
|
5
5
|
};
|
|
6
6
|
//#endregion
|
|
7
|
-
export { isStringRawNoSubstitution };
|
|
8
|
-
//# sourceMappingURL=isStringRawNoSubstitution.d.ts.map
|
|
7
|
+
export { isStringRawNoSubstitution };
|
|
@@ -3,5 +3,4 @@ import { BinaryExpression, LeftHandSideExpressionParent, ParenthesizedExpression
|
|
|
3
3
|
//#region src/utils/unwrapParentParenthesizedExpressions.d.ts
|
|
4
4
|
declare function unwrapParentParenthesizedExpressions(node: BinaryExpression | ParenthesizedExpression): LeftHandSideExpressionParent;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { unwrapParentParenthesizedExpressions };
|
|
7
|
-
//# sourceMappingURL=unwrapParentParenthesizedExpressions.d.ts.map
|
|
6
|
+
export { unwrapParentParenthesizedExpressions };
|
|
@@ -3,5 +3,4 @@ import { AnyNode } from "../types/ast.js";
|
|
|
3
3
|
//#region src/utils/unwrapParenthesizedNode.d.ts
|
|
4
4
|
declare function unwrapParenthesizedNode(node: AnyNode): AnyNode;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { unwrapParenthesizedNode };
|
|
7
|
-
//# sourceMappingURL=unwrapParenthesizedNode.d.ts.map
|
|
6
|
+
export { unwrapParenthesizedNode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flint.fyi/typescript-language",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.4",
|
|
4
4
|
"description": "[Experimental] TypeScript language for Flint.",
|
|
5
5
|
"homepage": "https://flint.fyi",
|
|
6
6
|
"repository": {
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
".": "./lib/index.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"lib/"
|
|
23
|
-
"!lib/**/*.map"
|
|
22
|
+
"lib/"
|
|
24
23
|
],
|
|
25
24
|
"dependencies": {
|
|
26
25
|
"@typescript-eslint/project-service": "^8.53.0",
|
|
@@ -28,11 +27,11 @@
|
|
|
28
27
|
"pathe": "^2.0.3",
|
|
29
28
|
"ts-api-utils": "^2.4.0",
|
|
30
29
|
"typescript": "^5.9.0 || ^6.0.0",
|
|
31
|
-
"@flint.fyi/
|
|
32
|
-
"@flint.fyi/
|
|
30
|
+
"@flint.fyi/utils": "^0.14.1",
|
|
31
|
+
"@flint.fyi/core": "^0.23.1"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"tsdown": "0.
|
|
34
|
+
"tsdown": "0.22.2",
|
|
36
35
|
"vitest": "4.1.0"
|
|
37
36
|
},
|
|
38
37
|
"engines": {
|