typescript-to-lua 1.25.2 → 1.26.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.
- package/dist/CompilerOptions.js +2 -2
- package/dist/LuaAST.js +76 -77
- package/dist/LuaLib.js +12 -12
- package/dist/LuaPrinter.js +2 -2
- package/dist/cli/information.js +2 -2
- package/dist/cli/parse.js +3 -3
- package/dist/cli/report.d.ts +4 -4
- package/dist/cli/report.js +2 -2
- package/dist/cli/tsconfig.js +3 -4
- package/dist/lualib/5.0/Set.lua +58 -0
- package/dist/lualib/5.0/lualib_bundle.lua +58 -0
- package/dist/lualib/5.0/lualib_module_info.json +2 -1
- package/dist/lualib/universal/Set.lua +58 -0
- package/dist/lualib/universal/lualib_bundle.lua +58 -0
- package/dist/lualib/universal/lualib_module_info.json +2 -1
- package/dist/lualib-build/plugin.d.ts +1 -1
- package/dist/lualib-build/util.js +8 -9
- package/dist/measure-performance.js +7 -8
- package/dist/transformation/builtins/array.js +3 -4
- package/dist/transformation/builtins/console.js +1 -2
- package/dist/transformation/builtins/function.js +2 -3
- package/dist/transformation/builtins/global.js +1 -2
- package/dist/transformation/builtins/index.js +4 -5
- package/dist/transformation/builtins/map.js +1 -2
- package/dist/transformation/builtins/math.js +2 -3
- package/dist/transformation/builtins/number.js +3 -4
- package/dist/transformation/builtins/object.js +2 -3
- package/dist/transformation/builtins/promise.js +4 -5
- package/dist/transformation/builtins/string.js +3 -4
- package/dist/transformation/builtins/symbol.js +1 -2
- package/dist/transformation/context/context.d.ts +0 -3
- package/dist/transformation/index.js +2 -3
- package/dist/transformation/pre-transformers/using-transformer.js +1 -2
- package/dist/transformation/utils/annotations.js +5 -5
- package/dist/transformation/utils/assignment-validation.js +1 -2
- package/dist/transformation/utils/export.js +14 -14
- package/dist/transformation/utils/function-context.js +3 -3
- package/dist/transformation/utils/language-extensions.js +10 -10
- package/dist/transformation/utils/lua-ast.js +12 -12
- package/dist/transformation/utils/lualib.js +3 -3
- package/dist/transformation/utils/preceding-statements.js +1 -2
- package/dist/transformation/utils/safe-names.js +3 -3
- package/dist/transformation/utils/scope.js +11 -11
- package/dist/transformation/utils/symbols.js +4 -5
- package/dist/transformation/utils/typescript/index.js +13 -14
- package/dist/transformation/utils/typescript/nodes.js +8 -9
- package/dist/transformation/utils/typescript/types.js +10 -11
- package/dist/transformation/visitors/access.js +4 -4
- package/dist/transformation/visitors/async-await.js +3 -3
- package/dist/transformation/visitors/binary-expression/assignments.js +5 -6
- package/dist/transformation/visitors/binary-expression/bit.js +3 -3
- package/dist/transformation/visitors/binary-expression/compound.js +3 -3
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +3 -4
- package/dist/transformation/visitors/binary-expression/index.js +4 -4
- package/dist/transformation/visitors/block.js +3 -3
- package/dist/transformation/visitors/call.js +6 -6
- package/dist/transformation/visitors/class/decorators.js +6 -7
- package/dist/transformation/visitors/class/index.js +14 -3
- package/dist/transformation/visitors/class/members/accessors.js +1 -2
- package/dist/transformation/visitors/class/members/constructor.js +3 -4
- package/dist/transformation/visitors/class/members/fields.js +2 -3
- package/dist/transformation/visitors/class/members/method.js +3 -4
- package/dist/transformation/visitors/class/setup.js +2 -3
- package/dist/transformation/visitors/class/utils.js +5 -6
- package/dist/transformation/visitors/conditional.js +3 -3
- package/dist/transformation/visitors/enum.js +2 -2
- package/dist/transformation/visitors/expression-list.js +4 -5
- package/dist/transformation/visitors/expression-statement.js +2 -2
- package/dist/transformation/visitors/function.js +9 -9
- package/dist/transformation/visitors/identifier.js +4 -4
- package/dist/transformation/visitors/language-extensions/call-extension.js +2 -2
- package/dist/transformation/visitors/language-extensions/identifier.js +2 -3
- package/dist/transformation/visitors/language-extensions/iterable.js +3 -4
- package/dist/transformation/visitors/language-extensions/multi.js +8 -9
- package/dist/transformation/visitors/language-extensions/range.js +3 -4
- package/dist/transformation/visitors/language-extensions/table.js +2 -2
- package/dist/transformation/visitors/language-extensions/vararg.js +2 -3
- package/dist/transformation/visitors/literal.js +3 -3
- package/dist/transformation/visitors/loops/utils.js +4 -5
- package/dist/transformation/visitors/modules/export.js +0 -3
- package/dist/transformation/visitors/modules/import.js +2 -2
- package/dist/transformation/visitors/namespace.js +3 -3
- package/dist/transformation/visitors/optional-chaining.js +6 -7
- package/dist/transformation/visitors/return.js +3 -3
- package/dist/transformation/visitors/spread.js +2 -2
- package/dist/transformation/visitors/typeof.js +2 -2
- package/dist/transformation/visitors/unary-expression.js +2 -2
- package/dist/transformation/visitors/variable-declaration.js +6 -6
- package/dist/transpilation/bundle.js +3 -3
- package/dist/transpilation/find-lua-requires.js +1 -2
- package/dist/transpilation/index.js +5 -6
- package/dist/transpilation/output-collector.js +1 -2
- package/dist/transpilation/plugins.js +1 -2
- package/dist/transpilation/resolve.js +1 -2
- package/dist/transpilation/transformers.js +2 -2
- package/dist/transpilation/transpile.js +1 -2
- package/dist/transpilation/transpiler.js +6 -6
- package/dist/transpilation/utils.js +2 -2
- package/dist/utils.js +9 -9
- package/package.json +6 -7
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isPromiseClass = isPromiseClass;
|
|
4
|
+
exports.createPromiseIdentifier = createPromiseIdentifier;
|
|
5
|
+
exports.transformPromiseConstructorCall = transformPromiseConstructorCall;
|
|
6
|
+
exports.createStaticPromiseFunctionAccessor = createStaticPromiseFunctionAccessor;
|
|
4
7
|
const lua = require("../../LuaAST");
|
|
5
8
|
const diagnostics_1 = require("../utils/diagnostics");
|
|
6
9
|
const lualib_1 = require("../utils/lualib");
|
|
@@ -12,11 +15,9 @@ function isPromiseClass(context, node) {
|
|
|
12
15
|
const type = context.checker.getTypeAtLocation(node);
|
|
13
16
|
return (0, typescript_1.isStandardLibraryType)(context, type, undefined);
|
|
14
17
|
}
|
|
15
|
-
exports.isPromiseClass = isPromiseClass;
|
|
16
18
|
function createPromiseIdentifier(original) {
|
|
17
19
|
return lua.createIdentifier("__TS__Promise", original);
|
|
18
20
|
}
|
|
19
|
-
exports.createPromiseIdentifier = createPromiseIdentifier;
|
|
20
21
|
function transformPromiseConstructorCall(context, node, calledMethod) {
|
|
21
22
|
const signature = context.checker.getResolvedSignature(node);
|
|
22
23
|
const params = (0, call_1.transformArguments)(context, node.arguments, signature);
|
|
@@ -40,9 +41,7 @@ function transformPromiseConstructorCall(context, node, calledMethod) {
|
|
|
40
41
|
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(calledMethod.name, "Promise", expressionName));
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
exports.transformPromiseConstructorCall = transformPromiseConstructorCall;
|
|
44
44
|
function createStaticPromiseFunctionAccessor(functionName, node) {
|
|
45
45
|
return lua.createTableIndexExpression(lua.createIdentifier("__TS__Promise"), lua.createStringLiteral(functionName), node);
|
|
46
46
|
}
|
|
47
|
-
exports.createStaticPromiseFunctionAccessor = createStaticPromiseFunctionAccessor;
|
|
48
47
|
//# sourceMappingURL=promise.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.transformStringPrototypeCall = transformStringPrototypeCall;
|
|
4
|
+
exports.transformStringConstructorCall = transformStringConstructorCall;
|
|
5
|
+
exports.transformStringProperty = transformStringProperty;
|
|
4
6
|
const CompilerOptions_1 = require("../../CompilerOptions");
|
|
5
7
|
const lua = require("../../LuaAST");
|
|
6
8
|
const diagnostics_1 = require("../utils/diagnostics");
|
|
@@ -110,7 +112,6 @@ function transformStringPrototypeCall(context, node, calledMethod) {
|
|
|
110
112
|
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(calledMethod.name, "string", expressionName));
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
|
-
exports.transformStringPrototypeCall = transformStringPrototypeCall;
|
|
114
115
|
function transformStringConstructorCall(context, node, calledMethod) {
|
|
115
116
|
const signature = context.checker.getResolvedSignature(node);
|
|
116
117
|
const params = (0, call_1.transformArguments)(context, node.arguments, signature);
|
|
@@ -122,7 +123,6 @@ function transformStringConstructorCall(context, node, calledMethod) {
|
|
|
122
123
|
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(calledMethod.name, "String", expressionName));
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
exports.transformStringConstructorCall = transformStringConstructorCall;
|
|
126
126
|
function transformStringProperty(context, node) {
|
|
127
127
|
switch (node.name.text) {
|
|
128
128
|
case "length":
|
|
@@ -138,5 +138,4 @@ function transformStringProperty(context, node) {
|
|
|
138
138
|
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(node.name, "string", node.name.text));
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
exports.transformStringProperty = transformStringProperty;
|
|
142
141
|
//# sourceMappingURL=string.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformSymbolConstructorCall =
|
|
3
|
+
exports.transformSymbolConstructorCall = transformSymbolConstructorCall;
|
|
4
4
|
const lua = require("../../LuaAST");
|
|
5
5
|
const diagnostics_1 = require("../utils/diagnostics");
|
|
6
6
|
const lualib_1 = require("../utils/lualib");
|
|
@@ -20,5 +20,4 @@ function transformSymbolConstructorCall(context, node, calledMethod) {
|
|
|
20
20
|
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(calledMethod.name, "Symbol", methodName));
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
exports.transformSymbolConstructorCall = transformSymbolConstructorCall;
|
|
24
23
|
//# sourceMappingURL=symbol.js.map
|
|
@@ -8,7 +8,6 @@ import { Scope, ScopeType } from "../utils/scope";
|
|
|
8
8
|
export declare const tempSymbolId: lua.SymbolId;
|
|
9
9
|
export interface AllAccessorDeclarations {
|
|
10
10
|
firstAccessor: ts.AccessorDeclaration;
|
|
11
|
-
secondAccessor: ts.AccessorDeclaration | undefined;
|
|
12
11
|
getAccessor: ts.GetAccessorDeclaration | undefined;
|
|
13
12
|
setAccessor: ts.SetAccessorDeclaration | undefined;
|
|
14
13
|
}
|
|
@@ -16,8 +15,6 @@ export interface EmitResolver {
|
|
|
16
15
|
isValueAliasDeclaration(node: ts.Node): boolean;
|
|
17
16
|
isReferencedAliasDeclaration(node: ts.Node, checkChildren?: boolean): boolean;
|
|
18
17
|
isTopLevelValueImportEqualsWithEntityName(node: ts.ImportEqualsDeclaration): boolean;
|
|
19
|
-
moduleExportsSomeValue(moduleReferenceExpression: ts.Expression): boolean;
|
|
20
|
-
getAllAccessorDeclarations(declaration: ts.AccessorDeclaration): AllAccessorDeclarations;
|
|
21
18
|
}
|
|
22
19
|
export interface TypeCheckerWithEmitResolver extends ts.TypeChecker {
|
|
23
20
|
getEmitResolver(sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken): EmitResolver;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createVisitorMap = createVisitorMap;
|
|
4
|
+
exports.transformSourceFile = transformSourceFile;
|
|
4
5
|
const ts = require("typescript");
|
|
5
6
|
const utils_1 = require("../utils");
|
|
6
7
|
const context_1 = require("./context");
|
|
@@ -25,7 +26,6 @@ function createVisitorMap(customVisitors) {
|
|
|
25
26
|
}
|
|
26
27
|
return result;
|
|
27
28
|
}
|
|
28
|
-
exports.createVisitorMap = createVisitorMap;
|
|
29
29
|
function transformSourceFile(program, sourceFile, visitorMap) {
|
|
30
30
|
const context = new context_1.TransformationContext(program, sourceFile, visitorMap);
|
|
31
31
|
// TS -> TS pre-transformation
|
|
@@ -35,5 +35,4 @@ function transformSourceFile(program, sourceFile, visitorMap) {
|
|
|
35
35
|
const [file] = context.transformNode(result.transformed[0]);
|
|
36
36
|
return { file, diagnostics: context.diagnostics };
|
|
37
37
|
}
|
|
38
|
-
exports.transformSourceFile = transformSourceFile;
|
|
39
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.usingTransformer =
|
|
3
|
+
exports.usingTransformer = usingTransformer;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const lualib_1 = require("../utils/lualib");
|
|
6
6
|
function usingTransformer(context) {
|
|
@@ -31,7 +31,6 @@ function usingTransformer(context) {
|
|
|
31
31
|
return ts.visitEachChild(sourceFile, visit, ctx);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
exports.usingTransformer = usingTransformer;
|
|
35
34
|
function isUsingDeclarationList(node) {
|
|
36
35
|
return ts.isVariableStatement(node) && (node.declarationList.flags & ts.NodeFlags.Using) !== 0;
|
|
37
36
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AnnotationKind = void 0;
|
|
4
|
+
exports.getSymbolAnnotations = getSymbolAnnotations;
|
|
5
|
+
exports.getTypeAnnotations = getTypeAnnotations;
|
|
6
|
+
exports.getNodeAnnotations = getNodeAnnotations;
|
|
7
|
+
exports.getFileAnnotations = getFileAnnotations;
|
|
4
8
|
const ts = require("typescript");
|
|
5
9
|
var AnnotationKind;
|
|
6
10
|
(function (AnnotationKind) {
|
|
@@ -35,7 +39,6 @@ function getSymbolAnnotations(symbol) {
|
|
|
35
39
|
symbolAnnotations.set(symbol, annotationsMap);
|
|
36
40
|
return annotationsMap;
|
|
37
41
|
}
|
|
38
|
-
exports.getSymbolAnnotations = getSymbolAnnotations;
|
|
39
42
|
function getTypeAnnotations(type) {
|
|
40
43
|
// types are not frequently repeatedly polled for annotations, so it's not worth caching them
|
|
41
44
|
const annotationsMap = new Map();
|
|
@@ -51,7 +54,6 @@ function getTypeAnnotations(type) {
|
|
|
51
54
|
}
|
|
52
55
|
return annotationsMap;
|
|
53
56
|
}
|
|
54
|
-
exports.getTypeAnnotations = getTypeAnnotations;
|
|
55
57
|
const nodeAnnotations = new WeakMap();
|
|
56
58
|
function getNodeAnnotations(node) {
|
|
57
59
|
const known = nodeAnnotations.get(node);
|
|
@@ -62,7 +64,6 @@ function getNodeAnnotations(node) {
|
|
|
62
64
|
nodeAnnotations.set(node, annotationsMap);
|
|
63
65
|
return annotationsMap;
|
|
64
66
|
}
|
|
65
|
-
exports.getNodeAnnotations = getNodeAnnotations;
|
|
66
67
|
function collectAnnotationsFromTags(annotationsMap, tags) {
|
|
67
68
|
for (const tag of tags) {
|
|
68
69
|
const tagName = annotationValues.get(tag.tagName.text.toLowerCase());
|
|
@@ -91,7 +92,6 @@ function getFileAnnotations(sourceFile) {
|
|
|
91
92
|
fileAnnotations.set(sourceFile, annotationsMap);
|
|
92
93
|
return annotationsMap;
|
|
93
94
|
}
|
|
94
|
-
exports.getFileAnnotations = getFileAnnotations;
|
|
95
95
|
function getTagArgsFromComment(tag) {
|
|
96
96
|
if (tag.comment) {
|
|
97
97
|
if (typeof tag.comment === "string") {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateAssignment =
|
|
3
|
+
exports.validateAssignment = validateAssignment;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const diagnostics_1 = require("./diagnostics");
|
|
@@ -64,7 +64,6 @@ function validateAssignment(context, node, fromType, toType, toName) {
|
|
|
64
64
|
validateAssignment(context, node, fromMemberType, toMemberType, toName ? `${toName}.${memberName}` : memberName);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
exports.validateAssignment = validateAssignment;
|
|
68
67
|
function validateFunctionAssignment(context, node, fromType, toType, toName) {
|
|
69
68
|
const fromContext = (0, function_context_1.getFunctionContextType)(context, fromType);
|
|
70
69
|
const toContext = (0, function_context_1.getFunctionContextType)(context, toType);
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createDefaultExportStringLiteral = void 0;
|
|
4
|
+
exports.hasDefaultExportModifier = hasDefaultExportModifier;
|
|
5
|
+
exports.hasExportModifier = hasExportModifier;
|
|
6
|
+
exports.getExportedSymbolDeclaration = getExportedSymbolDeclaration;
|
|
7
|
+
exports.getSymbolFromIdentifier = getSymbolFromIdentifier;
|
|
8
|
+
exports.getIdentifierExportScope = getIdentifierExportScope;
|
|
9
|
+
exports.getSymbolExportScope = getSymbolExportScope;
|
|
10
|
+
exports.getExportedSymbolsFromScope = getExportedSymbolsFromScope;
|
|
11
|
+
exports.getDependenciesOfSymbol = getDependenciesOfSymbol;
|
|
12
|
+
exports.isSymbolExported = isSymbolExported;
|
|
13
|
+
exports.isSymbolExportedFromScope = isSymbolExportedFromScope;
|
|
14
|
+
exports.addExportToIdentifier = addExportToIdentifier;
|
|
15
|
+
exports.createExportedIdentifier = createExportedIdentifier;
|
|
16
|
+
exports.createDefaultExportExpression = createDefaultExportExpression;
|
|
4
17
|
const ts = require("typescript");
|
|
5
18
|
const lua = require("../../LuaAST");
|
|
6
19
|
const namespace_1 = require("../visitors/namespace");
|
|
@@ -12,13 +25,11 @@ function hasDefaultExportModifier(node) {
|
|
|
12
25
|
return (ts.canHaveModifiers(node) &&
|
|
13
26
|
((_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.some(modifier => modifier.kind === ts.SyntaxKind.DefaultKeyword)) === true);
|
|
14
27
|
}
|
|
15
|
-
exports.hasDefaultExportModifier = hasDefaultExportModifier;
|
|
16
28
|
function hasExportModifier(node) {
|
|
17
29
|
var _a;
|
|
18
30
|
return (ts.canHaveModifiers(node) &&
|
|
19
31
|
((_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.some(modifier => modifier.kind === ts.SyntaxKind.ExportKeyword)) === true);
|
|
20
32
|
}
|
|
21
|
-
exports.hasExportModifier = hasExportModifier;
|
|
22
33
|
const createDefaultExportStringLiteral = (original) => lua.createStringLiteral("default", original);
|
|
23
34
|
exports.createDefaultExportStringLiteral = createDefaultExportStringLiteral;
|
|
24
35
|
function getExportedSymbolDeclaration(symbol) {
|
|
@@ -27,7 +38,6 @@ function getExportedSymbolDeclaration(symbol) {
|
|
|
27
38
|
return declarations.find(d => (ts.getCombinedModifierFlags(d) & ts.ModifierFlags.Export) !== 0);
|
|
28
39
|
}
|
|
29
40
|
}
|
|
30
|
-
exports.getExportedSymbolDeclaration = getExportedSymbolDeclaration;
|
|
31
41
|
function getSymbolFromIdentifier(context, identifier) {
|
|
32
42
|
if (identifier.symbolId !== undefined) {
|
|
33
43
|
const symbolInfo = (0, symbols_1.getSymbolInfo)(context, identifier.symbolId);
|
|
@@ -36,7 +46,6 @@ function getSymbolFromIdentifier(context, identifier) {
|
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
|
-
exports.getSymbolFromIdentifier = getSymbolFromIdentifier;
|
|
40
49
|
function getIdentifierExportScope(context, identifier) {
|
|
41
50
|
const symbol = getSymbolFromIdentifier(context, identifier);
|
|
42
51
|
if (!symbol) {
|
|
@@ -44,7 +53,6 @@ function getIdentifierExportScope(context, identifier) {
|
|
|
44
53
|
}
|
|
45
54
|
return getSymbolExportScope(context, symbol);
|
|
46
55
|
}
|
|
47
|
-
exports.getIdentifierExportScope = getIdentifierExportScope;
|
|
48
56
|
function isGlobalAugmentation(module) {
|
|
49
57
|
return (module.flags & ts.NodeFlags.GlobalAugmentation) !== 0;
|
|
50
58
|
}
|
|
@@ -65,7 +73,6 @@ function getSymbolExportScope(context, symbol) {
|
|
|
65
73
|
}
|
|
66
74
|
return scope;
|
|
67
75
|
}
|
|
68
|
-
exports.getSymbolExportScope = getSymbolExportScope;
|
|
69
76
|
function getExportedSymbolsFromScope(context, scope) {
|
|
70
77
|
const scopeSymbol = context.checker.getSymbolAtLocation(ts.isSourceFile(scope) ? scope : scope.name);
|
|
71
78
|
if ((scopeSymbol === null || scopeSymbol === void 0 ? void 0 : scopeSymbol.exports) === undefined) {
|
|
@@ -75,29 +82,24 @@ function getExportedSymbolsFromScope(context, scope) {
|
|
|
75
82
|
const it = { [Symbol.iterator]: () => scopeSymbol.exports.values() };
|
|
76
83
|
return [...it];
|
|
77
84
|
}
|
|
78
|
-
exports.getExportedSymbolsFromScope = getExportedSymbolsFromScope;
|
|
79
85
|
function getDependenciesOfSymbol(context, originalSymbol) {
|
|
80
86
|
return getExportedSymbolsFromScope(context, context.sourceFile).filter(exportSymbol => {
|
|
81
87
|
var _a;
|
|
82
88
|
return (_a = exportSymbol.declarations) === null || _a === void 0 ? void 0 : _a.filter(ts.isExportSpecifier).map(context.checker.getExportSpecifierLocalTargetSymbol).includes(originalSymbol);
|
|
83
89
|
});
|
|
84
90
|
}
|
|
85
|
-
exports.getDependenciesOfSymbol = getDependenciesOfSymbol;
|
|
86
91
|
function isSymbolExported(context, symbol) {
|
|
87
92
|
return (getExportedSymbolDeclaration(symbol) !== undefined ||
|
|
88
93
|
// Symbol may have been exported separately (e.g. 'const foo = "bar"; export { foo }')
|
|
89
94
|
isSymbolExportedFromScope(context, symbol, context.sourceFile));
|
|
90
95
|
}
|
|
91
|
-
exports.isSymbolExported = isSymbolExported;
|
|
92
96
|
function isSymbolExportedFromScope(context, symbol, scope) {
|
|
93
97
|
return getExportedSymbolsFromScope(context, scope).includes(symbol);
|
|
94
98
|
}
|
|
95
|
-
exports.isSymbolExportedFromScope = isSymbolExportedFromScope;
|
|
96
99
|
function addExportToIdentifier(context, identifier) {
|
|
97
100
|
const exportScope = getIdentifierExportScope(context, identifier);
|
|
98
101
|
return exportScope ? createExportedIdentifier(context, identifier, exportScope) : identifier;
|
|
99
102
|
}
|
|
100
|
-
exports.addExportToIdentifier = addExportToIdentifier;
|
|
101
103
|
function createExportedIdentifier(context, identifier, exportScope) {
|
|
102
104
|
if (!identifier.exportable) {
|
|
103
105
|
return identifier;
|
|
@@ -107,9 +109,7 @@ function createExportedIdentifier(context, identifier, exportScope) {
|
|
|
107
109
|
: (0, lua_ast_1.createExportsIdentifier)();
|
|
108
110
|
return lua.createTableIndexExpression(exportTable, lua.createStringLiteral(identifier.text));
|
|
109
111
|
}
|
|
110
|
-
exports.createExportedIdentifier = createExportedIdentifier;
|
|
111
112
|
function createDefaultExportExpression(node) {
|
|
112
113
|
return lua.createTableIndexExpression((0, lua_ast_1.createExportsIdentifier)(), (0, exports.createDefaultExportStringLiteral)(node), node);
|
|
113
114
|
}
|
|
114
|
-
exports.createDefaultExportExpression = createDefaultExportExpression;
|
|
115
115
|
//# sourceMappingURL=export.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ContextType = void 0;
|
|
4
|
+
exports.getCallContextType = getCallContextType;
|
|
5
|
+
exports.getFunctionContextType = getFunctionContextType;
|
|
4
6
|
const ts = require("typescript");
|
|
5
7
|
const annotations_1 = require("./annotations");
|
|
6
8
|
const typescript_1 = require("./typescript");
|
|
@@ -56,7 +58,6 @@ function getCallContextType(context, callExpression) {
|
|
|
56
58
|
callContextTypes.set(callExpression, contextType);
|
|
57
59
|
return contextType;
|
|
58
60
|
}
|
|
59
|
-
exports.getCallContextType = getCallContextType;
|
|
60
61
|
const signatureDeclarationContextTypes = new WeakMap();
|
|
61
62
|
function getSignatureContextType(context, signatureDeclaration) {
|
|
62
63
|
const known = signatureDeclarationContextTypes.get(signatureDeclaration);
|
|
@@ -180,7 +181,6 @@ function getFunctionContextType(context, type) {
|
|
|
180
181
|
typeContextTypes.set(type, contextType);
|
|
181
182
|
return contextType;
|
|
182
183
|
}
|
|
183
|
-
exports.getFunctionContextType = getFunctionContextType;
|
|
184
184
|
function computeFunctionContextType(context, type) {
|
|
185
185
|
if (type.isTypeParameter()) {
|
|
186
186
|
const constraint = type.getConstraint();
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.methodExtensionKinds = exports.IterableExtensionKind = exports.ExtensionKind = void 0;
|
|
4
|
+
exports.getExtensionKindForType = getExtensionKindForType;
|
|
5
|
+
exports.getExtensionKindForNode = getExtensionKindForNode;
|
|
6
|
+
exports.getExtensionKindForSymbol = getExtensionKindForSymbol;
|
|
7
|
+
exports.isLuaIterable = isLuaIterable;
|
|
8
|
+
exports.getIterableExtensionTypeForType = getIterableExtensionTypeForType;
|
|
9
|
+
exports.getIterableExtensionKindForNode = getIterableExtensionKindForNode;
|
|
10
|
+
exports.getNaryCallExtensionArgs = getNaryCallExtensionArgs;
|
|
11
|
+
exports.getUnaryCallExtensionArg = getUnaryCallExtensionArg;
|
|
12
|
+
exports.getBinaryCallExtensionArgs = getBinaryCallExtensionArgs;
|
|
4
13
|
const ts = require("typescript");
|
|
5
14
|
const diagnostics_1 = require("./diagnostics");
|
|
6
15
|
var ExtensionKind;
|
|
@@ -65,7 +74,6 @@ function getExtensionKindForType(context, type) {
|
|
|
65
74
|
return value;
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
|
-
exports.getExtensionKindForType = getExtensionKindForType;
|
|
69
77
|
const excludedTypeFlags = ((1 << 18) - 1) | // All flags from Any...Never
|
|
70
78
|
ts.TypeFlags.Index |
|
|
71
79
|
ts.TypeFlags.NonPrimitive;
|
|
@@ -87,12 +95,10 @@ function getExtensionKindForNode(context, node) {
|
|
|
87
95
|
}
|
|
88
96
|
return getExtensionKindForType(context, type);
|
|
89
97
|
}
|
|
90
|
-
exports.getExtensionKindForNode = getExtensionKindForNode;
|
|
91
98
|
function getExtensionKindForSymbol(context, symbol) {
|
|
92
99
|
const type = context.checker.getTypeOfSymbolAtLocation(symbol, context.sourceFile);
|
|
93
100
|
return getExtensionKindForType(context, type);
|
|
94
101
|
}
|
|
95
|
-
exports.getExtensionKindForSymbol = getExtensionKindForSymbol;
|
|
96
102
|
var IterableExtensionKind;
|
|
97
103
|
(function (IterableExtensionKind) {
|
|
98
104
|
IterableExtensionKind["Iterable"] = "Iterable";
|
|
@@ -102,19 +108,16 @@ var IterableExtensionKind;
|
|
|
102
108
|
function isLuaIterable(context, type) {
|
|
103
109
|
return getPropertyValue(context, type, "__tstlIterable") !== undefined;
|
|
104
110
|
}
|
|
105
|
-
exports.isLuaIterable = isLuaIterable;
|
|
106
111
|
function getIterableExtensionTypeForType(context, type) {
|
|
107
112
|
const value = getPropertyValue(context, type, "__tstlIterable");
|
|
108
113
|
if (value && value in IterableExtensionKind) {
|
|
109
114
|
return value;
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
|
-
exports.getIterableExtensionTypeForType = getIterableExtensionTypeForType;
|
|
113
117
|
function getIterableExtensionKindForNode(context, node) {
|
|
114
118
|
const type = context.checker.getTypeAtLocation(node);
|
|
115
119
|
return getIterableExtensionTypeForType(context, type);
|
|
116
120
|
}
|
|
117
|
-
exports.getIterableExtensionKindForNode = getIterableExtensionKindForNode;
|
|
118
121
|
exports.methodExtensionKinds = new Set(Object.values(ExtensionKind).filter(key => key.endsWith("Method")));
|
|
119
122
|
function getNaryCallExtensionArgs(context, node, kind, numArgs) {
|
|
120
123
|
let expressions;
|
|
@@ -142,17 +145,14 @@ function getNaryCallExtensionArgs(context, node, kind, numArgs) {
|
|
|
142
145
|
}
|
|
143
146
|
return expressions;
|
|
144
147
|
}
|
|
145
|
-
exports.getNaryCallExtensionArgs = getNaryCallExtensionArgs;
|
|
146
148
|
function getUnaryCallExtensionArg(context, node, kind) {
|
|
147
149
|
var _a;
|
|
148
150
|
return (_a = getNaryCallExtensionArgs(context, node, kind, 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
149
151
|
}
|
|
150
|
-
exports.getUnaryCallExtensionArg = getUnaryCallExtensionArg;
|
|
151
152
|
function getBinaryCallExtensionArgs(context, node, kind) {
|
|
152
153
|
const expressions = getNaryCallExtensionArgs(context, node, kind, 2);
|
|
153
154
|
if (expressions === undefined)
|
|
154
155
|
return undefined;
|
|
155
156
|
return [expressions[0], expressions[1]];
|
|
156
157
|
}
|
|
157
|
-
exports.getBinaryCallExtensionArgs = getBinaryCallExtensionArgs;
|
|
158
158
|
//# sourceMappingURL=language-extensions.js.map
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNaN =
|
|
3
|
+
exports.createNaN = void 0;
|
|
4
|
+
exports.unwrapVisitorResult = unwrapVisitorResult;
|
|
5
|
+
exports.createSelfIdentifier = createSelfIdentifier;
|
|
6
|
+
exports.createExportsIdentifier = createExportsIdentifier;
|
|
7
|
+
exports.addToNumericExpression = addToNumericExpression;
|
|
8
|
+
exports.getNumberLiteralValue = getNumberLiteralValue;
|
|
9
|
+
exports.createUnpackCall = createUnpackCall;
|
|
10
|
+
exports.isUnpackCall = isUnpackCall;
|
|
11
|
+
exports.wrapInTable = wrapInTable;
|
|
12
|
+
exports.wrapInToStringForConcat = wrapInToStringForConcat;
|
|
13
|
+
exports.createHoistableVariableDeclarationStatement = createHoistableVariableDeclarationStatement;
|
|
14
|
+
exports.createLocalOrExportedOrGlobalDeclaration = createLocalOrExportedOrGlobalDeclaration;
|
|
4
15
|
const ts = require("typescript");
|
|
5
16
|
const CompilerOptions_1 = require("../../CompilerOptions");
|
|
6
17
|
const lua = require("../../LuaAST");
|
|
@@ -12,15 +23,12 @@ const LuaLib_1 = require("../../LuaLib");
|
|
|
12
23
|
function unwrapVisitorResult(result) {
|
|
13
24
|
return result === undefined ? [] : (0, utils_1.castArray)(result);
|
|
14
25
|
}
|
|
15
|
-
exports.unwrapVisitorResult = unwrapVisitorResult;
|
|
16
26
|
function createSelfIdentifier(tsOriginal) {
|
|
17
27
|
return lua.createIdentifier("self", tsOriginal, undefined, "this");
|
|
18
28
|
}
|
|
19
|
-
exports.createSelfIdentifier = createSelfIdentifier;
|
|
20
29
|
function createExportsIdentifier() {
|
|
21
30
|
return lua.createIdentifier("____exports");
|
|
22
31
|
}
|
|
23
|
-
exports.createExportsIdentifier = createExportsIdentifier;
|
|
24
32
|
function addToNumericExpression(expression, change) {
|
|
25
33
|
if (change === 0)
|
|
26
34
|
return expression;
|
|
@@ -41,7 +49,6 @@ function addToNumericExpression(expression, change) {
|
|
|
41
49
|
? lua.createBinaryExpression(expression, lua.createNumericLiteral(change), lua.SyntaxKind.AdditionOperator)
|
|
42
50
|
: lua.createBinaryExpression(expression, lua.createNumericLiteral(-change), lua.SyntaxKind.SubtractionOperator);
|
|
43
51
|
}
|
|
44
|
-
exports.addToNumericExpression = addToNumericExpression;
|
|
45
52
|
function getNumberLiteralValue(expression) {
|
|
46
53
|
if (!expression)
|
|
47
54
|
return undefined;
|
|
@@ -54,7 +61,6 @@ function getNumberLiteralValue(expression) {
|
|
|
54
61
|
}
|
|
55
62
|
return undefined;
|
|
56
63
|
}
|
|
57
|
-
exports.getNumberLiteralValue = getNumberLiteralValue;
|
|
58
64
|
function createUnpackCall(context, expression, tsOriginal) {
|
|
59
65
|
if (context.luaTarget === CompilerOptions_1.LuaTarget.Universal) {
|
|
60
66
|
return (0, lualib_1.transformLuaLibFunction)(context, LuaLib_1.LuaLibFeature.Unpack, tsOriginal, expression);
|
|
@@ -66,16 +72,13 @@ function createUnpackCall(context, expression, tsOriginal) {
|
|
|
66
72
|
: lua.createTableIndexExpression(lua.createIdentifier("table"), lua.createStringLiteral("unpack"));
|
|
67
73
|
return lua.setNodeFlags(lua.createCallExpression(unpack, [expression], tsOriginal), lua.NodeFlags.TableUnpackCall);
|
|
68
74
|
}
|
|
69
|
-
exports.createUnpackCall = createUnpackCall;
|
|
70
75
|
function isUnpackCall(node) {
|
|
71
76
|
return lua.isCallExpression(node) && (node.flags & lua.NodeFlags.TableUnpackCall) !== 0;
|
|
72
77
|
}
|
|
73
|
-
exports.isUnpackCall = isUnpackCall;
|
|
74
78
|
function wrapInTable(...expressions) {
|
|
75
79
|
const fields = expressions.map(e => lua.createTableFieldExpression(e));
|
|
76
80
|
return lua.createTableExpression(fields);
|
|
77
81
|
}
|
|
78
|
-
exports.wrapInTable = wrapInTable;
|
|
79
82
|
function wrapInToStringForConcat(expression) {
|
|
80
83
|
if (lua.isStringLiteral(expression) ||
|
|
81
84
|
lua.isNumericLiteral(expression) ||
|
|
@@ -84,7 +87,6 @@ function wrapInToStringForConcat(expression) {
|
|
|
84
87
|
}
|
|
85
88
|
return lua.createCallExpression(lua.createIdentifier("tostring"), [expression]);
|
|
86
89
|
}
|
|
87
|
-
exports.wrapInToStringForConcat = wrapInToStringForConcat;
|
|
88
90
|
function createHoistableVariableDeclarationStatement(context, identifier, initializer, tsOriginal) {
|
|
89
91
|
const declaration = lua.createVariableDeclarationStatement(identifier, initializer, tsOriginal);
|
|
90
92
|
if (identifier.symbolId !== undefined) {
|
|
@@ -94,7 +96,6 @@ function createHoistableVariableDeclarationStatement(context, identifier, initia
|
|
|
94
96
|
}
|
|
95
97
|
return declaration;
|
|
96
98
|
}
|
|
97
|
-
exports.createHoistableVariableDeclarationStatement = createHoistableVariableDeclarationStatement;
|
|
98
99
|
function hasMultipleReferences(scope, identifiers) {
|
|
99
100
|
const scopeSymbols = scope.referencedSymbols;
|
|
100
101
|
if (!scopeSymbols) {
|
|
@@ -180,7 +181,6 @@ function createLocalOrExportedOrGlobalDeclaration(context, lhs, rhs, tsOriginal,
|
|
|
180
181
|
return [];
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
|
-
exports.createLocalOrExportedOrGlobalDeclaration = createLocalOrExportedOrGlobalDeclaration;
|
|
184
184
|
/**
|
|
185
185
|
* Apply JSDoc comments to the newly-created Lua statement, if present.
|
|
186
186
|
* https://stackoverflow.com/questions/47429792/is-it-possible-to-get-comments-as-nodes-in-the-ast-using-the-typescript-compiler
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LuaLibFeature = void 0;
|
|
4
|
+
exports.importLuaLibFeature = importLuaLibFeature;
|
|
5
|
+
exports.transformLuaLibFunction = transformLuaLibFunction;
|
|
4
6
|
const lua = require("../../LuaAST");
|
|
5
7
|
const LuaLib_1 = require("../../LuaLib");
|
|
6
8
|
Object.defineProperty(exports, "LuaLibFeature", { enumerable: true, get: function () { return LuaLib_1.LuaLibFeature; } });
|
|
7
9
|
function importLuaLibFeature(context, feature) {
|
|
8
10
|
context.usedLuaLibFeatures.add(feature);
|
|
9
11
|
}
|
|
10
|
-
exports.importLuaLibFeature = importLuaLibFeature;
|
|
11
12
|
function transformLuaLibFunction(context, feature, tsParent, ...params) {
|
|
12
13
|
importLuaLibFeature(context, feature);
|
|
13
14
|
const functionIdentifier = lua.createIdentifier(`__TS__${feature}`);
|
|
14
15
|
return lua.createCallExpression(functionIdentifier, params, tsParent);
|
|
15
16
|
}
|
|
16
|
-
exports.transformLuaLibFunction = transformLuaLibFunction;
|
|
17
17
|
//# sourceMappingURL=lualib.js.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformInPrecedingStatementScope =
|
|
3
|
+
exports.transformInPrecedingStatementScope = transformInPrecedingStatementScope;
|
|
4
4
|
function transformInPrecedingStatementScope(context, transformer) {
|
|
5
5
|
context.pushPrecedingStatements();
|
|
6
6
|
const statementOrStatements = transformer();
|
|
7
7
|
const precedingStatements = context.popPrecedingStatements();
|
|
8
8
|
return { precedingStatements, result: statementOrStatements };
|
|
9
9
|
}
|
|
10
|
-
exports.transformInPrecedingStatementScope = transformInPrecedingStatementScope;
|
|
11
10
|
//# sourceMappingURL=preceding-statements.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSafeName = exports.
|
|
3
|
+
exports.createSafeName = exports.isUnsafeName = exports.luaKeywords = exports.isValidLuaIdentifier = exports.shouldAllowUnicode = void 0;
|
|
4
|
+
exports.hasUnsafeSymbolName = hasUnsafeSymbolName;
|
|
5
|
+
exports.hasUnsafeIdentifierName = hasUnsafeIdentifierName;
|
|
4
6
|
const __1 = require("../..");
|
|
5
7
|
const diagnostics_1 = require("./diagnostics");
|
|
6
8
|
const export_1 = require("./export");
|
|
@@ -79,14 +81,12 @@ function hasUnsafeSymbolName(context, symbol, tsOriginal) {
|
|
|
79
81
|
// only unsafe when non-ambient and not exported
|
|
80
82
|
return (0, exports.isUnsafeName)(symbol.name, context.options) && !isAmbient && !(0, export_1.isSymbolExported)(context, symbol);
|
|
81
83
|
}
|
|
82
|
-
exports.hasUnsafeSymbolName = hasUnsafeSymbolName;
|
|
83
84
|
function hasUnsafeIdentifierName(context, identifier, symbol) {
|
|
84
85
|
if (symbol) {
|
|
85
86
|
return hasUnsafeSymbolName(context, symbol, identifier);
|
|
86
87
|
}
|
|
87
88
|
return checkName(context, identifier.text, identifier);
|
|
88
89
|
}
|
|
89
|
-
exports.hasUnsafeIdentifierName = hasUnsafeIdentifierName;
|
|
90
90
|
const fixInvalidLuaIdentifier = (name) => name.replace(/[^a-zA-Z0-9_]/g, c => `_${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
91
91
|
const createSafeName = (name) => "____" + fixInvalidLuaIdentifier(name);
|
|
92
92
|
exports.createSafeName = createSafeName;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LoopContinued = exports.ScopeType = void 0;
|
|
4
|
+
exports.walkScopesUp = walkScopesUp;
|
|
5
|
+
exports.markSymbolAsReferencedInCurrentScopes = markSymbolAsReferencedInCurrentScopes;
|
|
6
|
+
exports.peekScope = peekScope;
|
|
7
|
+
exports.findScope = findScope;
|
|
8
|
+
exports.addScopeVariableDeclaration = addScopeVariableDeclaration;
|
|
9
|
+
exports.hasReferencedUndefinedLocalFunction = hasReferencedUndefinedLocalFunction;
|
|
10
|
+
exports.hasReferencedSymbol = hasReferencedSymbol;
|
|
11
|
+
exports.isFunctionScopeWithDefinition = isFunctionScopeWithDefinition;
|
|
12
|
+
exports.separateHoistedStatements = separateHoistedStatements;
|
|
13
|
+
exports.performHoisting = performHoisting;
|
|
4
14
|
const ts = require("typescript");
|
|
5
15
|
const lua = require("../../LuaAST");
|
|
6
16
|
const utils_1 = require("../../utils");
|
|
@@ -30,7 +40,6 @@ function* walkScopesUp(context) {
|
|
|
30
40
|
yield scope;
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
|
-
exports.walkScopesUp = walkScopesUp;
|
|
34
43
|
function markSymbolAsReferencedInCurrentScopes(context, symbolId, identifier) {
|
|
35
44
|
for (const scope of context.scopeStack) {
|
|
36
45
|
if (!scope.referencedSymbols) {
|
|
@@ -40,14 +49,12 @@ function markSymbolAsReferencedInCurrentScopes(context, symbolId, identifier) {
|
|
|
40
49
|
references.push(identifier);
|
|
41
50
|
}
|
|
42
51
|
}
|
|
43
|
-
exports.markSymbolAsReferencedInCurrentScopes = markSymbolAsReferencedInCurrentScopes;
|
|
44
52
|
function peekScope(context) {
|
|
45
53
|
const scopeStack = context.scopeStack;
|
|
46
54
|
const scope = scopeStack[scopeStack.length - 1];
|
|
47
55
|
(0, utils_1.assert)(scope);
|
|
48
56
|
return scope;
|
|
49
57
|
}
|
|
50
|
-
exports.peekScope = peekScope;
|
|
51
58
|
function findScope(context, scopeTypes) {
|
|
52
59
|
for (let i = context.scopeStack.length - 1; i >= 0; --i) {
|
|
53
60
|
const scope = context.scopeStack[i];
|
|
@@ -56,14 +63,12 @@ function findScope(context, scopeTypes) {
|
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
|
-
exports.findScope = findScope;
|
|
60
66
|
function addScopeVariableDeclaration(scope, declaration) {
|
|
61
67
|
if (!scope.variableDeclarations) {
|
|
62
68
|
scope.variableDeclarations = [];
|
|
63
69
|
}
|
|
64
70
|
scope.variableDeclarations.push(declaration);
|
|
65
71
|
}
|
|
66
|
-
exports.addScopeVariableDeclaration = addScopeVariableDeclaration;
|
|
67
72
|
function isHoistableFunctionDeclaredInScope(symbol, scopeNode) {
|
|
68
73
|
var _a;
|
|
69
74
|
return (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(d => ts.isFunctionDeclaration(d) && (0, typescript_1.findFirstNodeAbove)(d, (n) => n === scopeNode));
|
|
@@ -85,7 +90,6 @@ function hasReferencedUndefinedLocalFunction(context, scope) {
|
|
|
85
90
|
}
|
|
86
91
|
return false;
|
|
87
92
|
}
|
|
88
|
-
exports.hasReferencedUndefinedLocalFunction = hasReferencedUndefinedLocalFunction;
|
|
89
93
|
function hasReferencedSymbol(context, scope, symbol) {
|
|
90
94
|
if (!scope.referencedSymbols) {
|
|
91
95
|
return;
|
|
@@ -97,11 +101,9 @@ function hasReferencedSymbol(context, scope, symbol) {
|
|
|
97
101
|
}
|
|
98
102
|
return false;
|
|
99
103
|
}
|
|
100
|
-
exports.hasReferencedSymbol = hasReferencedSymbol;
|
|
101
104
|
function isFunctionScopeWithDefinition(scope) {
|
|
102
105
|
return scope.node !== undefined && ts.isFunctionLike(scope.node);
|
|
103
106
|
}
|
|
104
|
-
exports.isFunctionScopeWithDefinition = isFunctionScopeWithDefinition;
|
|
105
107
|
function separateHoistedStatements(context, statements) {
|
|
106
108
|
const scope = peekScope(context);
|
|
107
109
|
const allHoistedStatments = [];
|
|
@@ -119,7 +121,6 @@ function separateHoistedStatements(context, statements) {
|
|
|
119
121
|
hoistedIdentifiers: allHoistedIdentifiers,
|
|
120
122
|
};
|
|
121
123
|
}
|
|
122
|
-
exports.separateHoistedStatements = separateHoistedStatements;
|
|
123
124
|
function performHoisting(context, statements) {
|
|
124
125
|
const result = separateHoistedStatements(context, statements);
|
|
125
126
|
const modifiedStatements = [...result.hoistedStatements, ...result.statements];
|
|
@@ -128,7 +129,6 @@ function performHoisting(context, statements) {
|
|
|
128
129
|
}
|
|
129
130
|
return modifiedStatements;
|
|
130
131
|
}
|
|
131
|
-
exports.performHoisting = performHoisting;
|
|
132
132
|
function shouldHoistSymbol(context, symbolId, scope) {
|
|
133
133
|
// Always hoist in top-level of switch statements
|
|
134
134
|
if (scope.type === ScopeType.Switch) {
|