typescript-to-lua
Advanced tools
Comparing version 0.24.0 to 0.25.0
# Changelog | ||
## 0.24.0 | ||
- Returns in try/catch statements now properly return from the current function. | ||
- TypeScript's `globalThis` is now translated to lua's `_G`. Lualib functions were updated where relevant. | ||
- Fixed issue where string/table literals were missing parentheses and caused lua syntax errors. | ||
- Various improvements/refactorings across the codebase. | ||
- Fixed syntax error in for...of loops with empty destructuring argument. | ||
- Fixed issue with `do ... while` scope. | ||
- Fixed a bug with [@combileMembersOnly](https://github.com/TypeScriptToLua/TypeScriptToLua/wiki/Compiler-Directives#compilemembersonly) where it would ignore anything before the enum name. | ||
## 0.23.0 | ||
@@ -4,0 +15,0 @@ |
@@ -219,3 +219,3 @@ import * as ts from "typescript"; | ||
protected importLuaLibFeature(feature: LuaLibFeature): void; | ||
protected createImmediatelyInvokedFunctionExpression(statements: tstl.Statement[], result: tstl.Expression | tstl.Expression[], tsOriginal: ts.Node): tstl.CallExpression; | ||
protected createImmediatelyInvokedFunctionExpression(statements: tstl.Statement[], result: tstl.Expression | tstl.Expression[], tsOriginal?: ts.Node): tstl.CallExpression; | ||
protected createUnpackCall(expression: tstl.Expression | undefined, tsOriginal?: ts.Node): tstl.Expression; | ||
@@ -239,2 +239,3 @@ protected getAbsoluteImportPath(relativePath: string): string; | ||
protected createSafeName(name: string): string; | ||
protected trackSymbolReference(symbol: ts.Symbol, identifier: ts.Identifier): tstl.SymbolId | undefined; | ||
protected getIdentifierSymbolId(identifier: ts.Identifier): tstl.SymbolId | undefined; | ||
@@ -241,0 +242,0 @@ protected findScope(scopeTypes: ScopeType): Scope | undefined; |
@@ -20,3 +20,3 @@ import * as ts from "typescript"; | ||
export declare function isStaticNode(node: ts.Node): boolean; | ||
export declare function isStringType(type: ts.Type): boolean; | ||
export declare function isStringType(type: ts.Type, checker: ts.TypeChecker, program: ts.Program): boolean; | ||
export declare function isNumberType(type: ts.Type): boolean; | ||
@@ -23,0 +23,0 @@ export declare function isExplicitArrayType(type: ts.Type, checker: ts.TypeChecker, program: ts.Program): boolean; |
@@ -122,3 +122,15 @@ "use strict"; | ||
exports.isStaticNode = isStaticNode; | ||
function isStringType(type) { | ||
function isStringType(type, checker, program) { | ||
if (type.symbol) { | ||
const baseConstraint = checker.getBaseConstraintOfType(type); | ||
if (baseConstraint) { | ||
return isStringType(baseConstraint, checker, program); | ||
} | ||
} | ||
if (type.isUnion()) { | ||
return type.types.every(t => isStringType(t, checker, program)); | ||
} | ||
if (type.isIntersection()) { | ||
return type.types.some(t => isStringType(t, checker, program)); | ||
} | ||
return ((type.flags & ts.TypeFlags.String) !== 0 || | ||
@@ -136,10 +148,16 @@ (type.flags & ts.TypeFlags.StringLike) !== 0 || | ||
function isExplicitArrayType(type, checker, program) { | ||
if (type.symbol) { | ||
const baseConstraint = checker.getBaseConstraintOfType(type); | ||
if (baseConstraint) { | ||
return isExplicitArrayType(baseConstraint, checker, program); | ||
} | ||
} | ||
if (type.isUnionOrIntersection()) { | ||
return type.types.some(t => isExplicitArrayType(t, checker, program)); | ||
} | ||
if (isStandardLibraryType(type, "ReadonlyArray", program)) { | ||
return true; | ||
const flags = ts.NodeBuilderFlags.InTypeAlias | ts.NodeBuilderFlags.AllowEmptyTuple; | ||
let typeNode = checker.typeToTypeNode(type, undefined, flags); | ||
if (typeNode && ts.isTypeOperatorNode(typeNode) && typeNode.operator === ts.SyntaxKind.ReadonlyKeyword) { | ||
typeNode = typeNode.type; | ||
} | ||
const flags = ts.NodeBuilderFlags.InTypeAlias | ts.NodeBuilderFlags.AllowEmptyTuple; | ||
const typeNode = checker.typeToTypeNode(type, undefined, flags); | ||
return typeNode !== undefined && (ts.isArrayTypeNode(typeNode) || ts.isTupleTypeNode(typeNode)); | ||
@@ -146,0 +164,0 @@ } |
{ | ||
"name": "typescript-to-lua", | ||
"version": "0.24.0", | ||
"version": "0.25.0", | ||
"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", |
Sorry, the diff of this file is too big to display
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
511192
8232
1619