typescript-to-lua
Advanced tools
Comparing version 0.12.0 to 0.12.1
@@ -10,2 +10,3 @@ import * as ts from "typescript"; | ||
static isInDestructingAssignment(node: ts.Node): boolean; | ||
static forTypeOrAnySupertype(type: ts.Type, checker: ts.TypeChecker, callback: (type: ts.Type) => boolean): boolean; | ||
static isStringType(type: ts.Type): boolean; | ||
@@ -19,3 +20,5 @@ static isArrayTypeNode(typeNode: ts.TypeNode): boolean; | ||
static findFirstNodeAbove<T extends ts.Node>(node: ts.Node, callback: (n: ts.Node) => n is T): T; | ||
static hasExplicitGetAccessor(type: ts.Type, name: ts.__String): boolean; | ||
static hasGetAccessor(node: ts.Node, checker: ts.TypeChecker): boolean; | ||
static hasExplicitSetAccessor(type: ts.Type, name: ts.__String): boolean; | ||
static hasSetAccessor(node: ts.Node, checker: ts.TypeChecker): boolean; | ||
@@ -22,0 +25,0 @@ static isBinaryAssignmentToken(token: ts.SyntaxKind): [boolean, ts.BinaryOperator]; |
@@ -75,2 +75,20 @@ "use strict"; | ||
} | ||
// iterate over a type and its bases until the callback returns true. | ||
static forTypeOrAnySupertype(type, checker, callback) { | ||
if (callback(type)) { | ||
return true; | ||
} | ||
if (!type.isClassOrInterface() && type.symbol) { | ||
type = checker.getDeclaredTypeOfSymbol(type.symbol); | ||
} | ||
const baseTypes = type.getBaseTypes(); | ||
if (baseTypes) { | ||
for (const baseType of baseTypes) { | ||
if (this.forTypeOrAnySupertype(baseType, checker, callback)) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
static isStringType(type) { | ||
@@ -92,11 +110,3 @@ return (type.flags & ts.TypeFlags.String) !== 0 | ||
static isArrayType(type, checker) { | ||
const baseTypes = type.getBaseTypes(); | ||
if (baseTypes) { | ||
for (const baseType of baseTypes) { | ||
if (this.isExplicitArrayType(baseType, checker)) { | ||
return true; | ||
} | ||
} | ||
} | ||
return this.isExplicitArrayType(type, checker); | ||
return this.forTypeOrAnySupertype(type, checker, t => this.isExplicitArrayType(t, checker)); | ||
} | ||
@@ -167,2 +177,8 @@ static isTupleReturnCall(node, checker) { | ||
} | ||
static hasExplicitGetAccessor(type, name) { | ||
if (type && type.symbol && type.symbol.members) { | ||
const field = type.symbol.members.get(name); | ||
return field && (field.flags & ts.SymbolFlags.GetAccessor) !== 0; | ||
} | ||
} | ||
static hasGetAccessor(node, checker) { | ||
@@ -172,9 +188,12 @@ if (ts.isPropertyAccessExpression(node)) { | ||
const type = checker.getTypeAtLocation(node.expression); | ||
if (type && type.symbol && type.symbol.members) { | ||
const field = type.symbol.members.get(name); | ||
return field && (field.flags & ts.SymbolFlags.GetAccessor) !== 0; | ||
} | ||
return this.forTypeOrAnySupertype(type, checker, t => this.hasExplicitGetAccessor(t, name)); | ||
} | ||
return false; | ||
} | ||
static hasExplicitSetAccessor(type, name) { | ||
if (type && type.symbol && type.symbol.members) { | ||
const field = type.symbol.members.get(name); | ||
return field && (field.flags & ts.SymbolFlags.SetAccessor) !== 0; | ||
} | ||
} | ||
static hasSetAccessor(node, checker) { | ||
@@ -184,6 +203,3 @@ if (ts.isPropertyAccessExpression(node)) { | ||
const type = checker.getTypeAtLocation(node.expression); | ||
if (type && type.symbol && type.symbol.members) { | ||
const field = type.symbol.members.get(name); | ||
return field && (field.flags & ts.SymbolFlags.SetAccessor) !== 0; | ||
} | ||
return this.forTypeOrAnySupertype(type, checker, t => this.hasExplicitSetAccessor(t, name)); | ||
} | ||
@@ -190,0 +206,0 @@ return false; |
{ | ||
"name": "typescript-to-lua", | ||
"license": "MIT", | ||
"version": "0.12.0", | ||
"version": "0.12.1", | ||
"repository": "https://github.com/Perryvw/TypescriptToLua", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
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
174253
2981