Skip to content

Commit 461863e

Browse files
committed
Changed typescript version
1 parent eb65053 commit 461863e

File tree

6 files changed

+41
-50
lines changed

6 files changed

+41
-50
lines changed

dist/TSHelper.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,30 @@ var TSHelper = /** @class */ (function () {
4545
return (type.flags & ts.TypeFlags.Object) != 0
4646
&& type.typeArguments != undefined;
4747
};
48-
TSHelper.isCompileMembersOnlyEnum = function (type) {
48+
TSHelper.isCompileMembersOnlyEnum = function (type, checker) {
4949
return type.symbol
5050
&& ((type.symbol.flags & ts.SymbolFlags.Enum) != 0)
51-
&& type.symbol.getDocumentationComment()[0] != undefined
52-
&& this.hasCustomDecorator(type, "!CompileMembersOnly");
51+
&& type.symbol.getDocumentationComment(checker)[0] != undefined
52+
&& this.hasCustomDecorator(type, checker, "!CompileMembersOnly");
5353
};
54-
TSHelper.isPureAbstractClass = function (type) {
54+
TSHelper.isPureAbstractClass = function (type, checker) {
5555
return type.symbol
5656
&& ((type.symbol.flags & ts.SymbolFlags.Class) != 0)
57-
&& this.hasCustomDecorator(type, "!PureAbstract");
57+
&& this.hasCustomDecorator(type, checker, "!PureAbstract");
5858
};
59-
TSHelper.isExtensionClass = function (type) {
59+
TSHelper.isExtensionClass = function (type, checker) {
6060
return type.symbol
6161
&& ((type.symbol.flags & ts.SymbolFlags.Class) != 0)
62-
&& this.hasCustomDecorator(type, "!Extension");
62+
&& this.hasCustomDecorator(type, checker, "!Extension");
6363
};
64-
TSHelper.isPhantom = function (type) {
64+
TSHelper.isPhantom = function (type, checker) {
6565
return type.symbol
6666
&& ((type.symbol.flags & ts.SymbolFlags.Namespace) != 0)
67-
&& this.hasCustomDecorator(type, "!Phantom");
67+
&& this.hasCustomDecorator(type, checker, "!Phantom");
6868
};
69-
TSHelper.hasCustomDecorator = function (type, decorator) {
69+
TSHelper.hasCustomDecorator = function (type, checker, decorator) {
7070
if (type.symbol) {
71-
var comment = type.symbol.getDocumentationComment();
71+
var comment = type.symbol.getDocumentationComment(checker);
7272
var decorators = comment.filter(function (_) { return _.kind == "text"; }).map(function (_) { return _.text.trim(); }).filter(function (_) { return _[0] == "!"; });
7373
return decorators.indexOf(decorator) > -1;
7474
}

dist/Transpiler.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ var LuaTranspiler = /** @class */ (function () {
137137
};
138138
LuaTranspiler.prototype.transpileNamespace = function (node) {
139139
// If phantom namespace just transpile the body as normal
140-
if (TSHelper_1.TSHelper.isPhantom(this.checker.getTypeAtLocation(node)))
140+
if (TSHelper_1.TSHelper.isPhantom(this.checker.getTypeAtLocation(node), this.checker))
141141
return this.transpileNode(node.body);
142142
var defName = this.definitionName(node.name.text);
143143
var result = this.indent + (defName + " = {}\n");
@@ -151,7 +151,7 @@ var LuaTranspiler = /** @class */ (function () {
151151
var val = 0;
152152
var result = "";
153153
var type = this.checker.getTypeAtLocation(node);
154-
var membersOnly = TSHelper_1.TSHelper.isCompileMembersOnlyEnum(type);
154+
var membersOnly = TSHelper_1.TSHelper.isCompileMembersOnlyEnum(type, this.checker);
155155
if (!membersOnly) {
156156
var defName = this.definitionName(node.name.escapedText);
157157
result += this.indent + (defName + "={}\n");
@@ -572,7 +572,7 @@ var LuaTranspiler = /** @class */ (function () {
572572
return this.transpileArrayProperty(node);
573573
}
574574
// Do not output path for member only enums
575-
if (TSHelper_1.TSHelper.isCompileMembersOnlyEnum(type)) {
575+
if (TSHelper_1.TSHelper.isCompileMembersOnlyEnum(type, this.checker)) {
576576
return property;
577577
}
578578
var path = this.transpileExpression(node.expression);
@@ -705,16 +705,16 @@ var LuaTranspiler = /** @class */ (function () {
705705
if (clause.token == ts.SyntaxKind.ExtendsKeyword) {
706706
var superType = _this.checker.getTypeAtLocation(clause.types[0]);
707707
// Ignore purely abstract types (decorated with /** @PureAbstract */)
708-
if (!TSHelper_1.TSHelper.isPureAbstractClass(superType)) {
708+
if (!TSHelper_1.TSHelper.isPureAbstractClass(superType, _this.checker)) {
709709
extendsType = clause.types[0];
710710
}
711-
noClassOr = TSHelper_1.TSHelper.hasCustomDecorator(superType, "!NoClassOr");
711+
noClassOr = TSHelper_1.TSHelper.hasCustomDecorator(superType, _this.checker, "!NoClassOr");
712712
}
713713
});
714714
var className = node.name.escapedText;
715715
var result = "";
716716
// Skip header if this is an extension class
717-
var isExtension = TSHelper_1.TSHelper.isExtensionClass(this.checker.getTypeAtLocation(node));
717+
var isExtension = TSHelper_1.TSHelper.isExtensionClass(this.checker.getTypeAtLocation(node), this.checker);
718718
if (!isExtension) {
719719
// Write class declaration
720720
var classOr = noClassOr ? "" : className + " or ";

package-lock.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": {
3+
"alsatian": "^2.1.0",
4+
"ts-node": "^4.1.0",
5+
"typescript": "^2.7.1"
6+
}
7+
}

src/TSHelper.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,34 @@ export class TSHelper {
5050
&& (<ts.TypeReference>type).typeArguments != undefined;
5151
}
5252

53-
static isCompileMembersOnlyEnum(type: ts.Type): boolean {
53+
static isCompileMembersOnlyEnum(type: ts.Type, checker: ts.TypeChecker): boolean {
5454
return type.symbol
5555
&& ((type.symbol.flags & ts.SymbolFlags.Enum) != 0)
56-
&& type.symbol.getDocumentationComment()[0] != undefined
57-
&& this.hasCustomDecorator(type, "!CompileMembersOnly");
56+
&& type.symbol.getDocumentationComment(checker)[0] != undefined
57+
&& this.hasCustomDecorator(type, checker, "!CompileMembersOnly");
5858
}
5959

60-
static isPureAbstractClass(type: ts.Type): boolean {
60+
static isPureAbstractClass(type: ts.Type, checker: ts.TypeChecker): boolean {
6161
return type.symbol
6262
&& ((type.symbol.flags & ts.SymbolFlags.Class) != 0)
63-
&& this.hasCustomDecorator(type, "!PureAbstract");
63+
&& this.hasCustomDecorator(type, checker, "!PureAbstract");
6464
}
6565

66-
static isExtensionClass(type: ts.Type): boolean {
66+
static isExtensionClass(type: ts.Type, checker: ts.TypeChecker): boolean {
6767
return type.symbol
6868
&& ((type.symbol.flags & ts.SymbolFlags.Class) != 0)
69-
&& this.hasCustomDecorator(type, "!Extension");
69+
&& this.hasCustomDecorator(type, checker, "!Extension");
7070
}
7171

72-
static isPhantom(type: ts.Type): boolean {
72+
static isPhantom(type: ts.Type, checker: ts.TypeChecker): boolean {
7373
return type.symbol
7474
&& ((type.symbol.flags & ts.SymbolFlags.Namespace) != 0)
75-
&& this.hasCustomDecorator(type, "!Phantom");
75+
&& this.hasCustomDecorator(type, checker, "!Phantom");
7676
}
7777

78-
static hasCustomDecorator(type: ts.Type, decorator: string): boolean {
78+
static hasCustomDecorator(type: ts.Type, checker: ts.TypeChecker, decorator: string): boolean {
7979
if (type.symbol) {
80-
var comment = type.symbol.getDocumentationComment();
80+
var comment = type.symbol.getDocumentationComment(checker);
8181
var decorators = comment.filter(_ => _.kind == "text").map(_ => _.text.trim()).filter(_ => _[0] == "!");
8282
return decorators.indexOf(decorator) > -1;
8383
}

src/Transpiler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class LuaTranspiler {
137137

138138
transpileNamespace(node: ts.ModuleDeclaration): string {
139139
// If phantom namespace just transpile the body as normal
140-
if (tsEx.isPhantom(this.checker.getTypeAtLocation(node))) return this.transpileNode(node.body);
140+
if (tsEx.isPhantom(this.checker.getTypeAtLocation(node), this.checker)) return this.transpileNode(node.body);
141141

142142
const defName = this.definitionName(node.name.text);
143143
let result = this.indent + `${defName} = {}\n`;
@@ -152,7 +152,7 @@ export class LuaTranspiler {
152152
let result = "";
153153

154154
const type = this.checker.getTypeAtLocation(node);
155-
const membersOnly = tsEx.isCompileMembersOnlyEnum(type);
155+
const membersOnly = tsEx.isCompileMembersOnlyEnum(type, this.checker);
156156

157157
if (!membersOnly) {
158158
const defName = this.definitionName(node.name.escapedText)
@@ -629,7 +629,7 @@ export class LuaTranspiler {
629629
}
630630

631631
// Do not output path for member only enums
632-
if (tsEx.isCompileMembersOnlyEnum(type)) {
632+
if (tsEx.isCompileMembersOnlyEnum(type, this.checker)) {
633633
return property;
634634
}
635635

@@ -774,18 +774,18 @@ export class LuaTranspiler {
774774
if (clause.token == ts.SyntaxKind.ExtendsKeyword) {
775775
const superType = this.checker.getTypeAtLocation(clause.types[0]);
776776
// Ignore purely abstract types (decorated with /** @PureAbstract */)
777-
if (!tsEx.isPureAbstractClass(superType)) {
777+
if (!tsEx.isPureAbstractClass(superType, this.checker)) {
778778
extendsType = clause.types[0];
779779
}
780-
noClassOr = tsEx.hasCustomDecorator(superType, "!NoClassOr");
780+
noClassOr = tsEx.hasCustomDecorator(superType, this.checker, "!NoClassOr");
781781
}
782782
});
783783

784784
let className = <string>node.name.escapedText;
785785
let result = "";
786786

787787
// Skip header if this is an extension class
788-
var isExtension = tsEx.isExtensionClass(this.checker.getTypeAtLocation(node));
788+
var isExtension = tsEx.isExtensionClass(this.checker.getTypeAtLocation(node), this.checker);
789789
if (!isExtension) {
790790
// Write class declaration
791791
const classOr = noClassOr ? "" : `${className} or `;

0 commit comments

Comments
 (0)