Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/TSHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function isStaticNode(node: ts.Node): boolean {
export function isStringType(type: ts.Type, checker: ts.TypeChecker, program: ts.Program): boolean {
if (type.symbol) {
const baseConstraint = checker.getBaseConstraintOfType(type);
if (baseConstraint) {
if (baseConstraint && baseConstraint !== type) {
return isStringType(baseConstraint, checker, program);
}
}
Expand All @@ -158,7 +158,7 @@ export function isNumberType(type: ts.Type): boolean {
export function isExplicitArrayType(type: ts.Type, checker: ts.TypeChecker, program: ts.Program): boolean {
if (type.symbol) {
const baseConstraint = checker.getBaseConstraintOfType(type);
if (baseConstraint) {
if (baseConstraint && baseConstraint !== type) {
return isExplicitArrayType(baseConstraint, checker, program);
}
}
Expand Down
24 changes: 24 additions & 0 deletions test/unit/enum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,27 @@ test("Const enum index identifier chain", () => {

expect(result).toBe(4);
});

test("enum toString", () => {
const code = `
enum TestEnum {
A,
B,
C,
}
let test = TestEnum.A;
return test.toString();`;
expect(util.transpileAndExecute(code)).toBe(0);
});

test("enum concat", () => {
const code = `
enum TestEnum {
A,
B,
C,
}
let test = TestEnum.A;
return test + "_foobar";`;
expect(util.transpileAndExecute(code)).toBe("0_foobar");
});