typescript-to-lua
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -7,3 +7,2 @@ "use strict"; | ||
const lua_ast_1 = require("../../../utils/lua-ast"); | ||
const preceding_statements_1 = require("../../../utils/preceding-statements"); | ||
const scope_1 = require("../../../utils/scope"); | ||
@@ -34,3 +33,3 @@ const function_1 = require("../../function"); | ||
const constructorFieldsDeclarations = statement.parameters.filter(p => p.modifiers !== undefined); | ||
const [fieldsPrecedingStatements, classInstanceFields] = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => (0, fields_1.transformClassInstanceFields)(context, instanceFields)); | ||
const classInstanceFields = (0, fields_1.transformClassInstanceFields)(context, instanceFields); | ||
// If there are field initializers and the first statement is a super call, | ||
@@ -60,3 +59,2 @@ // move super call between default assignments and initializers | ||
} | ||
bodyWithFieldInitializers.push(...fieldsPrecedingStatements); | ||
bodyWithFieldInitializers.push(...classInstanceFields); | ||
@@ -63,0 +61,0 @@ bodyWithFieldInitializers.push(...body); |
@@ -6,2 +6,3 @@ "use strict"; | ||
const lua_ast_1 = require("../../../utils/lua-ast"); | ||
const preceding_statements_1 = require("../../../utils/preceding-statements"); | ||
const literal_1 = require("../../literal"); | ||
@@ -21,10 +22,13 @@ const decorators_1 = require("../decorators"); | ||
for (const f of instanceFields) { | ||
// Get identifier | ||
const fieldName = (0, literal_1.transformPropertyName)(context, f.name); | ||
const value = f.initializer ? context.transformExpression(f.initializer) : undefined; | ||
// self[fieldName] | ||
const selfIndex = lua.createTableIndexExpression((0, lua_ast_1.createSelfIdentifier)(), fieldName); | ||
// self[fieldName] = value | ||
const assignClassField = lua.createAssignmentStatement(selfIndex, value, f); | ||
statements.push(assignClassField); | ||
const [precedingStatements, statement] = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => { | ||
// Get identifier | ||
const fieldName = (0, literal_1.transformPropertyName)(context, f.name); | ||
const value = f.initializer ? context.transformExpression(f.initializer) : undefined; | ||
// self[fieldName] | ||
const selfIndex = lua.createTableIndexExpression((0, lua_ast_1.createSelfIdentifier)(), fieldName); | ||
// self[fieldName] = value | ||
const assignClassField = lua.createAssignmentStatement(selfIndex, value, f); | ||
return assignClassField; | ||
}); | ||
statements.push(...precedingStatements, statement); | ||
} | ||
@@ -31,0 +35,0 @@ return statements; |
{ | ||
"name": "typescript-to-lua", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/TypeScriptToLua/TypeScriptToLua", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
866402
12874