typescript-to-lua 0.41.2 → 1.1.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/CHANGELOG.md +46 -0
- package/dist/CompilerOptions.d.ts +4 -3
- package/dist/LuaAST.js +4 -4
- package/dist/LuaLib.d.ts +7 -0
- package/dist/LuaLib.js +41 -5
- package/dist/LuaPrinter.d.ts +6 -2
- package/dist/LuaPrinter.js +25 -16
- package/dist/cli/diagnostics.js +2 -2
- package/dist/cli/report.js +1 -1
- package/dist/cli/tsconfig.js +4 -4
- package/dist/lualib/ArrayJoin.lua +2 -4
- package/dist/lualib/Await.lua +59 -0
- package/dist/lualib/Iterator.lua +1 -5
- package/dist/lualib/NumberToString.lua +4 -8
- package/dist/lualib/OptionalMethodCall.lua +3 -1
- package/dist/lualib/ParseInt.lua +1 -3
- package/dist/lualib/Promise.lua +172 -0
- package/dist/lualib/PromiseAll.lua +44 -0
- package/dist/lualib/PromiseAllSettled.lua +48 -0
- package/dist/lualib/PromiseAny.lua +41 -0
- package/dist/lualib/PromiseRace.lua +28 -0
- package/dist/lualib/SourceMapTraceBack.lua +18 -8
- package/dist/lualib/StringConcat.lua +1 -1
- package/dist/lualib/StringPadEnd.lua +7 -11
- package/dist/lualib/StringPadStart.lua +8 -12
- package/dist/lualib/StringReplace.lua +8 -13
- package/dist/lualib/StringReplaceAll.lua +35 -0
- package/dist/lualib/StringSubstring.lua +1 -1
- package/dist/lualib/lualib_bundle.lua +660 -239
- package/dist/transformation/builtins/array.js +29 -29
- package/dist/transformation/builtins/console.js +2 -2
- package/dist/transformation/builtins/function.js +9 -9
- package/dist/transformation/builtins/global.js +8 -8
- package/dist/transformation/builtins/index.js +35 -32
- package/dist/transformation/builtins/math.js +4 -4
- package/dist/transformation/builtins/number.js +7 -7
- package/dist/transformation/builtins/object.js +11 -11
- package/dist/transformation/builtins/promise.d.ts +7 -0
- package/dist/transformation/builtins/promise.js +46 -0
- package/dist/transformation/builtins/string.js +32 -30
- package/dist/transformation/builtins/symbol.js +3 -3
- package/dist/transformation/context/context.js +5 -5
- package/dist/transformation/index.js +1 -1
- package/dist/transformation/utils/annotations.d.ts +1 -4
- package/dist/transformation/utils/annotations.js +1 -32
- package/dist/transformation/utils/assignment-validation.js +8 -7
- package/dist/transformation/utils/diagnostics.d.ts +3 -0
- package/dist/transformation/utils/diagnostics.js +6 -5
- package/dist/transformation/utils/export.js +4 -4
- package/dist/transformation/utils/function-context.js +19 -13
- package/dist/transformation/utils/lua-ast.js +18 -19
- package/dist/transformation/utils/lualib.js +1 -1
- package/dist/transformation/utils/safe-names.js +5 -5
- package/dist/transformation/utils/scope.d.ts +6 -0
- package/dist/transformation/utils/scope.js +70 -40
- package/dist/transformation/utils/symbols.js +6 -6
- package/dist/transformation/utils/transform.js +3 -3
- package/dist/transformation/utils/typescript/nodes.d.ts +2 -0
- package/dist/transformation/utils/typescript/nodes.js +21 -1
- package/dist/transformation/visitors/access.js +25 -19
- package/dist/transformation/visitors/async-await.d.ts +6 -0
- package/dist/transformation/visitors/async-await.js +38 -0
- package/dist/transformation/visitors/binary-expression/assignments.js +32 -31
- package/dist/transformation/visitors/binary-expression/bit.js +4 -4
- package/dist/transformation/visitors/binary-expression/compound.js +18 -18
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +17 -17
- package/dist/transformation/visitors/binary-expression/index.js +22 -20
- package/dist/transformation/visitors/block.js +6 -6
- package/dist/transformation/visitors/break-continue.js +4 -9
- package/dist/transformation/visitors/call.js +38 -38
- package/dist/transformation/visitors/class/decorators.js +3 -3
- package/dist/transformation/visitors/class/index.js +34 -34
- package/dist/transformation/visitors/class/members/accessors.js +6 -6
- package/dist/transformation/visitors/class/members/constructor.js +7 -7
- package/dist/transformation/visitors/class/members/fields.js +6 -6
- package/dist/transformation/visitors/class/members/method.js +6 -6
- package/dist/transformation/visitors/class/new.js +13 -13
- package/dist/transformation/visitors/class/setup.js +11 -11
- package/dist/transformation/visitors/class/utils.js +2 -2
- package/dist/transformation/visitors/conditional.js +6 -6
- package/dist/transformation/visitors/delete.js +4 -4
- package/dist/transformation/visitors/enum.js +8 -8
- package/dist/transformation/visitors/errors.js +30 -31
- package/dist/transformation/visitors/expression-statement.js +10 -6
- package/dist/transformation/visitors/function.js +33 -21
- package/dist/transformation/visitors/identifier.js +25 -19
- package/dist/transformation/visitors/index.js +4 -2
- package/dist/transformation/visitors/language-extensions/iterable.js +7 -7
- package/dist/transformation/visitors/language-extensions/multi.d.ts +2 -1
- package/dist/transformation/visitors/language-extensions/multi.js +8 -4
- package/dist/transformation/visitors/language-extensions/operators.js +6 -6
- package/dist/transformation/visitors/language-extensions/range.js +6 -6
- package/dist/transformation/visitors/language-extensions/table.js +5 -5
- package/dist/transformation/visitors/literal.d.ts +1 -2
- package/dist/transformation/visitors/literal.js +19 -42
- package/dist/transformation/visitors/loops/do-while.js +2 -2
- package/dist/transformation/visitors/loops/for-in.js +4 -4
- package/dist/transformation/visitors/loops/for-of.js +13 -13
- package/dist/transformation/visitors/loops/for.js +3 -3
- package/dist/transformation/visitors/loops/utils.js +9 -9
- package/dist/transformation/visitors/modules/export.js +13 -13
- package/dist/transformation/visitors/modules/import.js +10 -10
- package/dist/transformation/visitors/namespace.js +13 -13
- package/dist/transformation/visitors/return.d.ts +1 -0
- package/dist/transformation/visitors/return.js +41 -49
- package/dist/transformation/visitors/sourceFile.js +8 -8
- package/dist/transformation/visitors/spread.js +16 -13
- package/dist/transformation/visitors/switch.js +132 -30
- package/dist/transformation/visitors/template.js +5 -5
- package/dist/transformation/visitors/typeof.js +2 -2
- package/dist/transformation/visitors/typescript.js +1 -1
- package/dist/transformation/visitors/unary-expression.js +9 -9
- package/dist/transformation/visitors/variable-declaration.js +29 -30
- package/dist/transformation/visitors/void.d.ts +6 -0
- package/dist/transformation/visitors/void.js +23 -0
- package/dist/transpilation/bundle.d.ts +3 -0
- package/dist/transpilation/bundle.js +56 -13
- package/dist/transpilation/diagnostics.js +3 -3
- package/dist/transpilation/index.js +2 -2
- package/dist/transpilation/output-collector.js +2 -2
- package/dist/transpilation/plugins.js +1 -1
- package/dist/transpilation/resolve.js +28 -14
- package/dist/transpilation/transformers.d.ts +1 -0
- package/dist/transpilation/transformers.js +61 -25
- package/dist/transpilation/transpile.js +7 -7
- package/dist/transpilation/transpiler.js +13 -11
- package/dist/transpilation/utils.js +3 -2
- package/dist/tstl.js +9 -9
- package/dist/utils.js +2 -2
- package/package.json +16 -13
- package/dist/transformation/visitors/jsx/jsx.d.ts +0 -9
- package/dist/transformation/visitors/jsx/jsx.js +0 -237
- package/dist/transformation/visitors/jsx/xhtml.d.ts +0 -3
- package/dist/transformation/visitors/jsx/xhtml.js +0 -260
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.noImplicitSelfTransformer = exports.getTransformers = void 0;
|
|
3
|
+
exports.stripParenthesisExpressionsTransformer = exports.noImplicitSelfTransformer = exports.getTransformers = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
// TODO: Don't depend on CLI?
|
|
6
6
|
const cliDiagnostics = require("../cli/diagnostics");
|
|
@@ -28,6 +28,7 @@ function getTransformers(program, diagnostics, customTransformers, onSourceFile)
|
|
|
28
28
|
...((_d = transformersFromOptions.before) !== null && _d !== void 0 ? _d : []),
|
|
29
29
|
...((_e = transformersFromOptions.after) !== null && _e !== void 0 ? _e : []),
|
|
30
30
|
...((_f = customTransformers.after) !== null && _f !== void 0 ? _f : []),
|
|
31
|
+
exports.stripParenthesisExpressionsTransformer,
|
|
31
32
|
luaTransformer,
|
|
32
33
|
],
|
|
33
34
|
};
|
|
@@ -44,6 +45,27 @@ const noImplicitSelfTransformer = () => node => {
|
|
|
44
45
|
: transformSourceFile(node);
|
|
45
46
|
};
|
|
46
47
|
exports.noImplicitSelfTransformer = noImplicitSelfTransformer;
|
|
48
|
+
const stripParenthesisExpressionsTransformer = context => sourceFile => {
|
|
49
|
+
// Remove parenthesis expressions before transforming to Lua, so transpiler is not hindered by extra ParenthesizedExpression nodes
|
|
50
|
+
function unwrapParentheses(node) {
|
|
51
|
+
while (ts.isParenthesizedExpression(node)) {
|
|
52
|
+
node = node.expression;
|
|
53
|
+
}
|
|
54
|
+
return node;
|
|
55
|
+
}
|
|
56
|
+
function visit(node) {
|
|
57
|
+
// For now only call expressions strip their expressions of parentheses, there could be more cases where this is required
|
|
58
|
+
if (ts.isCallExpression(node)) {
|
|
59
|
+
return ts.factory.updateCallExpression(node, unwrapParentheses(node.expression), node.typeArguments, node.arguments);
|
|
60
|
+
}
|
|
61
|
+
else if (ts.isVoidExpression(node)) {
|
|
62
|
+
return ts.factory.updateVoidExpression(node, unwrapParentheses(node.expression));
|
|
63
|
+
}
|
|
64
|
+
return ts.visitEachChild(node, visit, context);
|
|
65
|
+
}
|
|
66
|
+
return ts.visitNode(sourceFile, visit);
|
|
67
|
+
};
|
|
68
|
+
exports.stripParenthesisExpressionsTransformer = stripParenthesisExpressionsTransformer;
|
|
47
69
|
function loadTransformersFromOptions(program, diagnostics) {
|
|
48
70
|
const customTransformers = {
|
|
49
71
|
before: [],
|
|
@@ -51,32 +73,46 @@ function loadTransformersFromOptions(program, diagnostics) {
|
|
|
51
73
|
afterDeclarations: [],
|
|
52
74
|
};
|
|
53
75
|
const options = program.getCompilerOptions();
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
if (options.plugins) {
|
|
77
|
+
for (const [index, transformerImport] of options.plugins.entries()) {
|
|
78
|
+
if (!("transform" in transformerImport))
|
|
79
|
+
continue;
|
|
80
|
+
const optionName = `compilerOptions.plugins[${index}]`;
|
|
81
|
+
const { error: resolveError, result: factory } = (0, utils_1.resolvePlugin)("transformer", `${optionName}.transform`, (0, utils_1.getConfigDirectory)(options), transformerImport.transform, transformerImport.import);
|
|
82
|
+
if (resolveError)
|
|
83
|
+
diagnostics.push(resolveError);
|
|
84
|
+
if (factory === undefined)
|
|
85
|
+
continue;
|
|
86
|
+
const { error: loadError, transformer } = loadTransformer(optionName, program, factory, transformerImport);
|
|
87
|
+
if (loadError)
|
|
88
|
+
diagnostics.push(loadError);
|
|
89
|
+
if (transformer === undefined)
|
|
90
|
+
continue;
|
|
91
|
+
if (transformer.before) {
|
|
92
|
+
customTransformers.before.push(transformer.before);
|
|
93
|
+
}
|
|
94
|
+
if (transformer.after) {
|
|
95
|
+
customTransformers.after.push(transformer.after);
|
|
96
|
+
}
|
|
97
|
+
if (transformer.afterDeclarations) {
|
|
98
|
+
customTransformers.afterDeclarations.push(transformer.afterDeclarations);
|
|
99
|
+
}
|
|
78
100
|
}
|
|
79
101
|
}
|
|
102
|
+
if (options.jsx === ts.JsxEmit.React) {
|
|
103
|
+
customTransformers.before.push(context => {
|
|
104
|
+
// if target < ES2017, typescript generates some unnecessary additional transformations in transformJSX.
|
|
105
|
+
// We can't control the target compiler option, so we override here.
|
|
106
|
+
const patchedContext = {
|
|
107
|
+
...context,
|
|
108
|
+
getCompilerOptions: () => ({
|
|
109
|
+
...context.getCompilerOptions(),
|
|
110
|
+
target: ts.ScriptTarget.ESNext,
|
|
111
|
+
}),
|
|
112
|
+
};
|
|
113
|
+
return ts.transformJsx(patchedContext);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
80
116
|
return customTransformers;
|
|
81
117
|
}
|
|
82
118
|
function loadTransformer(optionPath, program, factory, { transform, after = false, afterDeclarations = false, type = "program", ...extraOptions }) {
|
|
@@ -14,7 +14,7 @@ function getProgramTranspileResult(emitHost, writeFileResult, { program, sourceF
|
|
|
14
14
|
if (options.tstlVerbose) {
|
|
15
15
|
console.log("Parsing project settings");
|
|
16
16
|
}
|
|
17
|
-
const diagnostics = CompilerOptions_1.validateOptions(options);
|
|
17
|
+
const diagnostics = (0, CompilerOptions_1.validateOptions)(options);
|
|
18
18
|
let transpiledFiles = [];
|
|
19
19
|
if (options.noEmitOnError) {
|
|
20
20
|
const preEmitDiagnostics = [
|
|
@@ -39,17 +39,17 @@ function getProgramTranspileResult(emitHost, writeFileResult, { program, sourceF
|
|
|
39
39
|
return { diagnostics: preEmitDiagnostics, transpiledFiles };
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
const plugins = plugins_1.getPlugins(program, diagnostics, customPlugins);
|
|
42
|
+
const plugins = (0, plugins_1.getPlugins)(program, diagnostics, customPlugins);
|
|
43
43
|
if (options.tstlVerbose) {
|
|
44
44
|
console.log(`Successfully loaded ${plugins.length} plugins`);
|
|
45
45
|
}
|
|
46
|
-
const visitorMap = transformation_1.createVisitorMap(plugins.map(p => p.visitors).filter(utils_1.isNonNull));
|
|
47
|
-
const printer = LuaPrinter_1.createPrinter(plugins.map(p => p.printer).filter(utils_1.isNonNull));
|
|
46
|
+
const visitorMap = (0, transformation_1.createVisitorMap)(plugins.map(p => p.visitors).filter(utils_1.isNonNull));
|
|
47
|
+
const printer = (0, LuaPrinter_1.createPrinter)(plugins.map(p => p.printer).filter(utils_1.isNonNull));
|
|
48
48
|
const processSourceFile = (sourceFile) => {
|
|
49
49
|
if (options.tstlVerbose) {
|
|
50
50
|
console.log(`Transforming ${sourceFile.fileName}`);
|
|
51
51
|
}
|
|
52
|
-
const { file, diagnostics: transformDiagnostics } = transformation_1.transformSourceFile(program, sourceFile, visitorMap);
|
|
52
|
+
const { file, diagnostics: transformDiagnostics } = (0, transformation_1.transformSourceFile)(program, sourceFile, visitorMap);
|
|
53
53
|
diagnostics.push(...transformDiagnostics);
|
|
54
54
|
if (!options.noEmit && !options.emitDeclarationOnly) {
|
|
55
55
|
if (options.tstlVerbose) {
|
|
@@ -64,7 +64,7 @@ function getProgramTranspileResult(emitHost, writeFileResult, { program, sourceF
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
const transformers = transformers_1.getTransformers(program, diagnostics, customTransformers, processSourceFile);
|
|
67
|
+
const transformers = (0, transformers_1.getTransformers)(program, diagnostics, customTransformers, processSourceFile);
|
|
68
68
|
const isEmittableJsonFile = (sourceFile) => sourceFile.flags & ts.NodeFlags.JsonFile &&
|
|
69
69
|
!options.emitDeclarationOnly &&
|
|
70
70
|
!program.isSourceFileFromExternalLibrary(sourceFile);
|
|
@@ -72,7 +72,7 @@ function getProgramTranspileResult(emitHost, writeFileResult, { program, sourceF
|
|
|
72
72
|
const oldNoEmit = options.noEmit;
|
|
73
73
|
options.noEmit = false;
|
|
74
74
|
const writeFile = (fileName, ...rest) => {
|
|
75
|
-
if (!fileName.endsWith(".js") && !fileName.endsWith(".js.map")) {
|
|
75
|
+
if (!fileName.endsWith(".js") && !fileName.endsWith(".js.map") && !fileName.endsWith(".json")) {
|
|
76
76
|
writeFileResult(fileName, ...rest);
|
|
77
77
|
}
|
|
78
78
|
};
|
|
@@ -17,7 +17,7 @@ class Transpiler {
|
|
|
17
17
|
var _a;
|
|
18
18
|
const { program, writeFile = this.emitHost.writeFile } = emitOptions;
|
|
19
19
|
const verbose = program.getCompilerOptions().tstlVerbose;
|
|
20
|
-
const { diagnostics, transpiledFiles: freshFiles } = transpile_1.getProgramTranspileResult(this.emitHost, writeFile, emitOptions);
|
|
20
|
+
const { diagnostics, transpiledFiles: freshFiles } = (0, transpile_1.getProgramTranspileResult)(this.emitHost, writeFile, emitOptions);
|
|
21
21
|
const { emitPlan } = this.getEmitPlan(program, diagnostics, freshFiles);
|
|
22
22
|
if (verbose) {
|
|
23
23
|
console.log("Emitting output");
|
|
@@ -26,7 +26,7 @@ class Transpiler {
|
|
|
26
26
|
const emitBOM = (_a = options.emitBOM) !== null && _a !== void 0 ? _a : false;
|
|
27
27
|
for (const { outputPath, code, sourceMap, sourceFiles } of emitPlan) {
|
|
28
28
|
if (verbose) {
|
|
29
|
-
console.log(`Emitting ${utils_1.normalizeSlashes(outputPath)}`);
|
|
29
|
+
console.log(`Emitting ${(0, utils_1.normalizeSlashes)(outputPath)}`);
|
|
30
30
|
}
|
|
31
31
|
writeFile(outputPath, code, emitBOM, undefined, sourceFiles);
|
|
32
32
|
if (options.sourceMap && sourceMap !== undefined) {
|
|
@@ -43,21 +43,23 @@ class Transpiler {
|
|
|
43
43
|
if (options.tstlVerbose) {
|
|
44
44
|
console.log("Constructing emit plan");
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
// Resolve imported modules and modify output Lua requires
|
|
47
|
+
const resolutionResult = (0, resolve_1.resolveDependencies)(program, files, this.emitHost);
|
|
48
|
+
diagnostics.push(...resolutionResult.diagnostics);
|
|
49
|
+
const lualibRequired = resolutionResult.resolvedFiles.some(f => f.fileName === "lualib_bundle");
|
|
47
50
|
if (lualibRequired) {
|
|
51
|
+
// Remove lualib placeholders from resolution result
|
|
52
|
+
resolutionResult.resolvedFiles = resolutionResult.resolvedFiles.filter(f => f.fileName !== "lualib_bundle");
|
|
48
53
|
if (options.tstlVerbose) {
|
|
49
54
|
console.log("Including lualib bundle");
|
|
50
55
|
}
|
|
51
56
|
// Add lualib bundle to source dir 'virtually', will be moved to correct output dir in emitPlan
|
|
52
|
-
const fileName = utils_1.normalizeSlashes(path.resolve(getSourceDir(program), "lualib_bundle.lua"));
|
|
53
|
-
|
|
57
|
+
const fileName = (0, utils_1.normalizeSlashes)(path.resolve(getSourceDir(program), "lualib_bundle.lua"));
|
|
58
|
+
resolutionResult.resolvedFiles.unshift({ fileName, code: (0, LuaLib_1.getLuaLibBundle)(this.emitHost) });
|
|
54
59
|
}
|
|
55
|
-
// Resolve imported modules and modify output Lua requires
|
|
56
|
-
const resolutionResult = resolve_1.resolveDependencies(program, files, this.emitHost);
|
|
57
|
-
diagnostics.push(...resolutionResult.diagnostics);
|
|
58
60
|
let emitPlan;
|
|
59
|
-
if (CompilerOptions_1.isBundleEnabled(options)) {
|
|
60
|
-
const [bundleDiagnostics, bundleFile] = bundle_1.getBundleResult(program, resolutionResult.resolvedFiles);
|
|
61
|
+
if ((0, CompilerOptions_1.isBundleEnabled)(options)) {
|
|
62
|
+
const [bundleDiagnostics, bundleFile] = (0, bundle_1.getBundleResult)(program, resolutionResult.resolvedFiles);
|
|
61
63
|
diagnostics.push(...bundleDiagnostics);
|
|
62
64
|
emitPlan = [bundleFile];
|
|
63
65
|
}
|
|
@@ -88,7 +90,7 @@ function getEmitPathRelativeToOutDir(fileName, program) {
|
|
|
88
90
|
emitPathSplits[0] = "lua_modules";
|
|
89
91
|
}
|
|
90
92
|
// Make extension lua
|
|
91
|
-
emitPathSplits[emitPathSplits.length - 1] = utils_1.trimExtension(emitPathSplits[emitPathSplits.length - 1]) + ".lua";
|
|
93
|
+
emitPathSplits[emitPathSplits.length - 1] = (0, utils_1.trimExtension)(emitPathSplits[emitPathSplits.length - 1]) + ".lua";
|
|
92
94
|
return path.join(...emitPathSplits);
|
|
93
95
|
}
|
|
94
96
|
exports.getEmitPathRelativeToOutDir = getEmitPathRelativeToOutDir;
|
|
@@ -12,12 +12,13 @@ function resolvePlugin(kind, optionName, basedir, query, importName = "default")
|
|
|
12
12
|
if (typeof query !== "string") {
|
|
13
13
|
return { error: cliDiagnostics.compilerOptionRequiresAValueOfType(optionName, "string") };
|
|
14
14
|
}
|
|
15
|
+
const isModuleNotFoundError = (error) => error.code === "MODULE_NOT_FOUND";
|
|
15
16
|
let resolved;
|
|
16
17
|
try {
|
|
17
18
|
resolved = resolve.sync(query, { basedir, extensions: [".js", ".ts", ".tsx"] });
|
|
18
19
|
}
|
|
19
20
|
catch (err) {
|
|
20
|
-
if (err
|
|
21
|
+
if (!isModuleNotFoundError(err))
|
|
21
22
|
throw err;
|
|
22
23
|
return { error: diagnosticFactories.couldNotResolveFrom(kind, query, basedir) };
|
|
23
24
|
}
|
|
@@ -29,7 +30,7 @@ function resolvePlugin(kind, optionName, basedir, query, importName = "default")
|
|
|
29
30
|
tsNode.register({ transpileOnly: true });
|
|
30
31
|
}
|
|
31
32
|
catch (err) {
|
|
32
|
-
if (err
|
|
33
|
+
if (!isModuleNotFoundError(err))
|
|
33
34
|
throw err;
|
|
34
35
|
return { error: diagnosticFactories.toLoadItShouldBeTranspiled(kind, query) };
|
|
35
36
|
}
|
package/dist/tstl.js
CHANGED
|
@@ -10,9 +10,9 @@ const report_1 = require("./cli/report");
|
|
|
10
10
|
const tsconfig_1 = require("./cli/tsconfig");
|
|
11
11
|
const CompilerOptions_1 = require("./CompilerOptions");
|
|
12
12
|
const shouldBePretty = ({ pretty } = {}) => { var _a, _b, _c; return pretty !== undefined ? pretty : (_c = (_b = (_a = ts.sys).writeOutputIsTTY) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : false; };
|
|
13
|
-
let reportDiagnostic = report_1.createDiagnosticReporter(false);
|
|
13
|
+
let reportDiagnostic = (0, report_1.createDiagnosticReporter)(false);
|
|
14
14
|
function updateReportDiagnostic(options) {
|
|
15
|
-
reportDiagnostic = report_1.createDiagnosticReporter(shouldBePretty(options));
|
|
15
|
+
reportDiagnostic = (0, report_1.createDiagnosticReporter)(shouldBePretty(options));
|
|
16
16
|
}
|
|
17
17
|
function createWatchStatusReporter(options) {
|
|
18
18
|
return ts.createWatchStatusReporter(ts.sys, shouldBePretty(options));
|
|
@@ -24,7 +24,7 @@ function executeCommandLine(args) {
|
|
|
24
24
|
return performBuild(args.slice(1));
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
const commandLine = parse_1.parseCommandLine(args);
|
|
27
|
+
const commandLine = (0, parse_1.parseCommandLine)(args);
|
|
28
28
|
if (commandLine.options.build) {
|
|
29
29
|
reportDiagnostic(cliDiagnostics.optionBuildMustBeFirstCommandLineArgument());
|
|
30
30
|
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
|
@@ -41,17 +41,17 @@ function executeCommandLine(args) {
|
|
|
41
41
|
}
|
|
42
42
|
if (commandLine.options.help) {
|
|
43
43
|
console.log(information_1.versionString);
|
|
44
|
-
console.log(information_1.getHelpString());
|
|
44
|
+
console.log((0, information_1.getHelpString)());
|
|
45
45
|
return ts.sys.exit(ts.ExitStatus.Success);
|
|
46
46
|
}
|
|
47
|
-
const configFileName = tsconfig_1.locateConfigFile(commandLine);
|
|
47
|
+
const configFileName = (0, tsconfig_1.locateConfigFile)(commandLine);
|
|
48
48
|
if (typeof configFileName === "object") {
|
|
49
49
|
reportDiagnostic(configFileName);
|
|
50
50
|
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
|
51
51
|
}
|
|
52
52
|
const commandLineOptions = commandLine.options;
|
|
53
53
|
if (configFileName) {
|
|
54
|
-
const configParseResult = tsconfig_1.parseConfigFileWithSystem(configFileName, commandLineOptions);
|
|
54
|
+
const configParseResult = (0, tsconfig_1.parseConfigFileWithSystem)(configFileName, commandLineOptions);
|
|
55
55
|
updateReportDiagnostic(configParseResult.options);
|
|
56
56
|
if (configParseResult.options.watch) {
|
|
57
57
|
createWatchOfConfigFile(configFileName, commandLineOptions);
|
|
@@ -87,7 +87,7 @@ function performCompilation(rootNames, projectReferences, options, configFilePar
|
|
|
87
87
|
...transpileDiagnostics,
|
|
88
88
|
]);
|
|
89
89
|
diagnostics.forEach(reportDiagnostic);
|
|
90
|
-
const exitCode = diagnostics.length === 0
|
|
90
|
+
const exitCode = diagnostics.filter(d => d.category === ts.DiagnosticCategory.Error).length === 0
|
|
91
91
|
? ts.ExitStatus.Success
|
|
92
92
|
: emitSkipped
|
|
93
93
|
? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped
|
|
@@ -106,14 +106,14 @@ function createWatchOfFilesAndCompilerOptions(rootFiles, options) {
|
|
|
106
106
|
}
|
|
107
107
|
function updateWatchCompilationHost(host, optionsToExtend) {
|
|
108
108
|
let hadErrorLastTime = true;
|
|
109
|
-
const updateConfigFile = tsconfig_1.createConfigFileUpdater(optionsToExtend);
|
|
109
|
+
const updateConfigFile = (0, tsconfig_1.createConfigFileUpdater)(optionsToExtend);
|
|
110
110
|
const transpiler = new tstl.Transpiler();
|
|
111
111
|
host.afterProgramCreate = builderProgram => {
|
|
112
112
|
const program = builderProgram.getProgram();
|
|
113
113
|
const options = builderProgram.getCompilerOptions();
|
|
114
114
|
const configFileParsingDiagnostics = updateConfigFile(options);
|
|
115
115
|
let sourceFiles;
|
|
116
|
-
if (!CompilerOptions_1.isBundleEnabled(options) && !hadErrorLastTime) {
|
|
116
|
+
if (!(0, CompilerOptions_1.isBundleEnabled)(options) && !hadErrorLastTime) {
|
|
117
117
|
sourceFiles = [];
|
|
118
118
|
while (true) {
|
|
119
119
|
const currentFile = builderProgram.getSemanticDiagnosticsOfNextAffectedFile();
|
package/dist/utils.js
CHANGED
|
@@ -12,7 +12,7 @@ const intersperse = (values, separator) => values.flatMap((value, index) => (ind
|
|
|
12
12
|
exports.intersperse = intersperse;
|
|
13
13
|
const union = (...values) => [...new Set(...values)];
|
|
14
14
|
exports.union = union;
|
|
15
|
-
const intersection = (first, ...rest) => exports.union(first).filter(x => rest.every(r => r.includes(x)));
|
|
15
|
+
const intersection = (first, ...rest) => (0, exports.union)(first).filter(x => rest.every(r => r.includes(x)));
|
|
16
16
|
exports.intersection = intersection;
|
|
17
17
|
const createDiagnosticFactoryWithCode = (code, create) => Object.assign((...args) => ({
|
|
18
18
|
file: undefined,
|
|
@@ -25,7 +25,7 @@ const createDiagnosticFactoryWithCode = (code, create) => Object.assign((...args
|
|
|
25
25
|
}), { code });
|
|
26
26
|
exports.createDiagnosticFactoryWithCode = createDiagnosticFactoryWithCode;
|
|
27
27
|
let serialDiagnosticCodeCounter = 100000;
|
|
28
|
-
const createSerialDiagnosticFactory = (create) => exports.createDiagnosticFactoryWithCode(serialDiagnosticCodeCounter++, create);
|
|
28
|
+
const createSerialDiagnosticFactory = (create) => (0, exports.createDiagnosticFactoryWithCode)(serialDiagnosticCodeCounter++, create);
|
|
29
29
|
exports.createSerialDiagnosticFactory = createSerialDiagnosticFactory;
|
|
30
30
|
const normalizeSlashes = (filePath) => filePath.replace(/\\/g, "/");
|
|
31
31
|
exports.normalizeSlashes = normalizeSlashes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-to-lua",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",
|
|
5
5
|
"repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
|
|
6
6
|
"homepage": "https://typescripttolua.github.io/",
|
|
@@ -41,11 +41,13 @@
|
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=12.13.0"
|
|
43
43
|
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"typescript": "~4.4.4"
|
|
46
|
+
},
|
|
44
47
|
"dependencies": {
|
|
45
48
|
"enhanced-resolve": "^5.8.2",
|
|
46
49
|
"resolve": "^1.15.1",
|
|
47
|
-
"source-map": "^0.7.3"
|
|
48
|
-
"typescript": "~4.3.2"
|
|
50
|
+
"source-map": "^0.7.3"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
53
|
"@types/fs-extra": "^8.1.0",
|
|
@@ -53,19 +55,20 @@
|
|
|
53
55
|
"@types/jest": "^25.1.3",
|
|
54
56
|
"@types/node": "^13.7.7",
|
|
55
57
|
"@types/resolve": "1.14.0",
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
57
|
-
"@typescript-eslint/parser": "^4.
|
|
58
|
-
"eslint": "^7.
|
|
59
|
-
"eslint-plugin-import": "^2.
|
|
60
|
-
"eslint-plugin-jest": "^
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^4.31.0",
|
|
59
|
+
"@typescript-eslint/parser": "^4.31.0",
|
|
60
|
+
"eslint": "^7.32.0",
|
|
61
|
+
"eslint-plugin-import": "^2.24.2",
|
|
62
|
+
"eslint-plugin-jest": "^24.4.0",
|
|
61
63
|
"fs-extra": "^8.1.0",
|
|
62
64
|
"javascript-stringify": "^2.0.1",
|
|
63
|
-
"jest": "^
|
|
64
|
-
"jest-circus": "^
|
|
65
|
-
"lua-types": "
|
|
65
|
+
"jest": "^27.3.0",
|
|
66
|
+
"jest-circus": "^27.3.0",
|
|
67
|
+
"lua-types": "2.10.1",
|
|
66
68
|
"lua-wasm-bindings": "^0.2.2",
|
|
67
69
|
"prettier": "^2.3.2",
|
|
68
|
-
"ts-jest": "^
|
|
69
|
-
"ts-node": "^
|
|
70
|
+
"ts-jest": "^27.0.7",
|
|
71
|
+
"ts-node": "^10.3.0",
|
|
72
|
+
"typescript": "~4.4.4"
|
|
70
73
|
}
|
|
71
74
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Visitors } from "../../context";
|
|
2
|
-
/**
|
|
3
|
-
* Format a string in the value position of a JSX prop.
|
|
4
|
-
*
|
|
5
|
-
* Use the same implementation as convertAttribute from
|
|
6
|
-
* babel-helper-builder-react-jsx.
|
|
7
|
-
*/
|
|
8
|
-
export declare function formatJSXStringValueLiteral(text: string): string;
|
|
9
|
-
export declare const jsxVisitors: Visitors;
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jsxVisitors = exports.formatJSXStringValueLiteral = void 0;
|
|
4
|
-
const ts = require("typescript");
|
|
5
|
-
const lua = require("../../../LuaAST");
|
|
6
|
-
const literal_1 = require("../literal");
|
|
7
|
-
const xhtml_1 = require("./xhtml");
|
|
8
|
-
const annotations_1 = require("../../utils/annotations");
|
|
9
|
-
function findAnnotationByType(node, fileAnnotation) {
|
|
10
|
-
const annotation = annotations_1.getFileAnnotations(node.getSourceFile()).get(fileAnnotation);
|
|
11
|
-
return annotation === null || annotation === void 0 ? void 0 : annotation.args[0];
|
|
12
|
-
}
|
|
13
|
-
function getExpressionFromOption(option) {
|
|
14
|
-
const [first, second] = option.split(".");
|
|
15
|
-
return second === undefined
|
|
16
|
-
? lua.createIdentifier(first)
|
|
17
|
-
: lua.createTableIndexExpression(lua.createIdentifier(first), lua.createStringLiteral(second));
|
|
18
|
-
}
|
|
19
|
-
function getJsxFactory(node, context) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const option = (_b = (_a = findAnnotationByType(node, annotations_1.AnnotationKind.Jsx)) !== null && _a !== void 0 ? _a : context.options.jsxFactory) !== null && _b !== void 0 ? _b : "React.createElement";
|
|
22
|
-
return getExpressionFromOption(option);
|
|
23
|
-
}
|
|
24
|
-
function getJsxFragmentName(node, context) {
|
|
25
|
-
var _a, _b;
|
|
26
|
-
const option = (_b = (_a = findAnnotationByType(node, annotations_1.AnnotationKind.JsxFrag)) !== null && _a !== void 0 ? _a : context.options.jsxFragmentFactory) !== null && _b !== void 0 ? _b : "React.Fragment";
|
|
27
|
-
return getExpressionFromOption(option);
|
|
28
|
-
}
|
|
29
|
-
/*
|
|
30
|
-
The following 3 functions for jsx text processing modified from sucrase (https://github.com/alangpierce/sucrase), which
|
|
31
|
-
is published with the MIT licence:
|
|
32
|
-
|
|
33
|
-
The MIT License (MIT)
|
|
34
|
-
|
|
35
|
-
Copyright (c) 2012-2018 various contributors (see AUTHORS)
|
|
36
|
-
|
|
37
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
38
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
39
|
-
in the Software without restriction, including without limitation the rights
|
|
40
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
41
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
42
|
-
furnished to do so, subject to the following conditions:
|
|
43
|
-
|
|
44
|
-
The above copyright notice and this permission notice shall be included in all
|
|
45
|
-
copies or substantial portions of the Software.
|
|
46
|
-
|
|
47
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
48
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
49
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
50
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
51
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
52
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
53
|
-
SOFTWARE.
|
|
54
|
-
*/
|
|
55
|
-
const HEX_NUMBER = /^[\da-fA-F]+$/;
|
|
56
|
-
const DECIMAL_NUMBER = /^\d+$/;
|
|
57
|
-
/**
|
|
58
|
-
* Turn the given jsxText string into a JS string literal. Leading and trailing
|
|
59
|
-
* whitespace on lines is removed, except immediately after the open-tag and
|
|
60
|
-
* before the close-tag. Empty lines are completely removed, and spaces are
|
|
61
|
-
* added between lines after that.
|
|
62
|
-
*
|
|
63
|
-
* We trim the start and end of each line and remove blank lines.
|
|
64
|
-
*/
|
|
65
|
-
function formatJSXTextLiteral(text) {
|
|
66
|
-
let result = "";
|
|
67
|
-
let whitespace = "";
|
|
68
|
-
let isInInitialLineWhitespace = false;
|
|
69
|
-
let seenNonWhitespace = false;
|
|
70
|
-
for (let i = 0; i < text.length; i++) {
|
|
71
|
-
const c = text[i];
|
|
72
|
-
if (c === " " || c === "\t" || c === "\r") {
|
|
73
|
-
if (!isInInitialLineWhitespace) {
|
|
74
|
-
whitespace += c;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else if (c === "\n") {
|
|
78
|
-
whitespace = "";
|
|
79
|
-
isInInitialLineWhitespace = true;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
if (seenNonWhitespace && isInInitialLineWhitespace) {
|
|
83
|
-
result += " ";
|
|
84
|
-
}
|
|
85
|
-
result += whitespace;
|
|
86
|
-
whitespace = "";
|
|
87
|
-
if (c === "&") {
|
|
88
|
-
const { entity, newI } = processEntity(text, i + 1);
|
|
89
|
-
i = newI - 1;
|
|
90
|
-
result += entity;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
result += c;
|
|
94
|
-
}
|
|
95
|
-
seenNonWhitespace = true;
|
|
96
|
-
isInInitialLineWhitespace = false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (!isInInitialLineWhitespace) {
|
|
100
|
-
result += whitespace;
|
|
101
|
-
}
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Format a string in the value position of a JSX prop.
|
|
106
|
-
*
|
|
107
|
-
* Use the same implementation as convertAttribute from
|
|
108
|
-
* babel-helper-builder-react-jsx.
|
|
109
|
-
*/
|
|
110
|
-
// changes from sucrase: no multi-line flattening of prop strings in typescript.
|
|
111
|
-
function formatJSXStringValueLiteral(text) {
|
|
112
|
-
let result = "";
|
|
113
|
-
for (let i = 0; i < text.length; i++) {
|
|
114
|
-
const c = text[i];
|
|
115
|
-
if (c === "&") {
|
|
116
|
-
const { entity, newI } = processEntity(text, i + 1);
|
|
117
|
-
result += entity;
|
|
118
|
-
i = newI - 1;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
result += c;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return result;
|
|
125
|
-
}
|
|
126
|
-
exports.formatJSXStringValueLiteral = formatJSXStringValueLiteral;
|
|
127
|
-
/**
|
|
128
|
-
* Modified from jsxReadString in Babylon.
|
|
129
|
-
*/
|
|
130
|
-
function processEntity(text, indexAfterAmpersand) {
|
|
131
|
-
let str = "";
|
|
132
|
-
let count = 0;
|
|
133
|
-
let entity;
|
|
134
|
-
let i = indexAfterAmpersand;
|
|
135
|
-
while (i < text.length && count++ < 10) {
|
|
136
|
-
const ch = text[i];
|
|
137
|
-
i++;
|
|
138
|
-
if (ch === ";") {
|
|
139
|
-
if (str.startsWith("#")) {
|
|
140
|
-
if (str[1] === "x") {
|
|
141
|
-
str = str.substr(2);
|
|
142
|
-
if (HEX_NUMBER.test(str)) {
|
|
143
|
-
entity = String.fromCodePoint(Number.parseInt(str, 16));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
str = str.substr(1);
|
|
148
|
-
if (DECIMAL_NUMBER.test(str)) {
|
|
149
|
-
entity = String.fromCodePoint(Number.parseInt(str, 10));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
entity = xhtml_1.XHTMLEntities[str];
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
str += ch;
|
|
159
|
-
}
|
|
160
|
-
if (!entity) {
|
|
161
|
-
return { entity: "&", newI: indexAfterAmpersand };
|
|
162
|
-
}
|
|
163
|
-
return { entity, newI: i };
|
|
164
|
-
}
|
|
165
|
-
// end functions copied from sucrase
|
|
166
|
-
function processJsxText(jsxText) {
|
|
167
|
-
const text = formatJSXTextLiteral(jsxText.text);
|
|
168
|
-
if (text === "")
|
|
169
|
-
return undefined;
|
|
170
|
-
return ts.factory.createStringLiteral(text);
|
|
171
|
-
}
|
|
172
|
-
const charCodes = {
|
|
173
|
-
a: 0x61,
|
|
174
|
-
z: 0x7a,
|
|
175
|
-
};
|
|
176
|
-
// how typescript does it
|
|
177
|
-
function isIntrinsicJsxName(escapedName) {
|
|
178
|
-
const name = escapedName;
|
|
179
|
-
const ch = name.charCodeAt(0);
|
|
180
|
-
return (ch >= charCodes.a && ch <= charCodes.z) || name.includes("-") || name.includes(":");
|
|
181
|
-
}
|
|
182
|
-
function transformTagName(name, context) {
|
|
183
|
-
if (ts.isIdentifier(name) && isIntrinsicJsxName(name.escapedText)) {
|
|
184
|
-
return lua.createStringLiteral(ts.idText(name), name);
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
return context.transformExpression(name);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
function transformJsxChildren(children, context) {
|
|
191
|
-
if (!children)
|
|
192
|
-
return undefined;
|
|
193
|
-
return children
|
|
194
|
-
.map(child => {
|
|
195
|
-
if (ts.isJsxText(child)) {
|
|
196
|
-
return processJsxText(child);
|
|
197
|
-
}
|
|
198
|
-
if (ts.isJsxExpression(child)) {
|
|
199
|
-
return child.expression;
|
|
200
|
-
}
|
|
201
|
-
return child;
|
|
202
|
-
})
|
|
203
|
-
.filter(child => child !== undefined)
|
|
204
|
-
.map(child => context.transformExpression(child));
|
|
205
|
-
}
|
|
206
|
-
function createJsxFactoryCall(tagName, props, tsChildren, tsOriginal, context) {
|
|
207
|
-
const transformedChildren = transformJsxChildren(tsChildren, context);
|
|
208
|
-
const jsxFactory = getJsxFactory(tsOriginal, context);
|
|
209
|
-
const args = [tagName];
|
|
210
|
-
if (props) {
|
|
211
|
-
args.push(props);
|
|
212
|
-
}
|
|
213
|
-
if (transformedChildren && transformedChildren.length > 0) {
|
|
214
|
-
if (!props) {
|
|
215
|
-
args.push(lua.createNilLiteral());
|
|
216
|
-
}
|
|
217
|
-
args.push(...transformedChildren);
|
|
218
|
-
}
|
|
219
|
-
return lua.createCallExpression(jsxFactory, args, tsOriginal);
|
|
220
|
-
}
|
|
221
|
-
function transformJsxOpeningLikeElement(node, children, context) {
|
|
222
|
-
const tagName = transformTagName(node.tagName, context);
|
|
223
|
-
const props = node.attributes.properties.length !== 0 ? literal_1.transformJsxAttributes(node.attributes, context) : undefined;
|
|
224
|
-
return createJsxFactoryCall(tagName, props, children, node, context);
|
|
225
|
-
}
|
|
226
|
-
const transformJsxElement = (node, context) => transformJsxOpeningLikeElement(node.openingElement, node.children, context);
|
|
227
|
-
const transformSelfClosingJsxElement = (node, context) => transformJsxOpeningLikeElement(node, undefined, context);
|
|
228
|
-
const transformJsxFragment = (node, context) => {
|
|
229
|
-
const tagName = getJsxFragmentName(node, context);
|
|
230
|
-
return createJsxFactoryCall(tagName, undefined, node.children, node, context);
|
|
231
|
-
};
|
|
232
|
-
exports.jsxVisitors = {
|
|
233
|
-
[ts.SyntaxKind.JsxElement]: transformJsxElement,
|
|
234
|
-
[ts.SyntaxKind.JsxSelfClosingElement]: transformSelfClosingJsxElement,
|
|
235
|
-
[ts.SyntaxKind.JsxFragment]: transformJsxFragment,
|
|
236
|
-
};
|
|
237
|
-
//# sourceMappingURL=jsx.js.map
|