File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ export function isStaticNode(node: ts.Node): boolean {
135135export function isStringType ( type : ts . Type , checker : ts . TypeChecker , program : ts . Program ) : boolean {
136136 if ( type . symbol ) {
137137 const baseConstraint = checker . getBaseConstraintOfType ( type ) ;
138- if ( baseConstraint ) {
138+ if ( baseConstraint && baseConstraint !== type ) {
139139 return isStringType ( baseConstraint , checker , program ) ;
140140 }
141141 }
@@ -166,7 +166,7 @@ export function isNumberType(type: ts.Type): boolean {
166166export function isExplicitArrayType ( type : ts . Type , checker : ts . TypeChecker , program : ts . Program ) : boolean {
167167 if ( type . symbol ) {
168168 const baseConstraint = checker . getBaseConstraintOfType ( type ) ;
169- if ( baseConstraint ) {
169+ if ( baseConstraint && baseConstraint !== type ) {
170170 return isExplicitArrayType ( baseConstraint , checker , program ) ;
171171 }
172172 }
Original file line number Diff line number Diff line change @@ -172,3 +172,27 @@ test("Const enum index identifier chain", () => {
172172
173173 expect ( result ) . toBe ( 4 ) ;
174174} ) ;
175+
176+ test ( "enum toString" , ( ) => {
177+ const code = `
178+ enum TestEnum {
179+ A,
180+ B,
181+ C,
182+ }
183+ let test = TestEnum.A;
184+ return test.toString();` ;
185+ expect ( util . transpileAndExecute ( code ) ) . toBe ( 0 ) ;
186+ } ) ;
187+
188+ test ( "enum concat" , ( ) => {
189+ const code = `
190+ enum TestEnum {
191+ A,
192+ B,
193+ C,
194+ }
195+ let test = TestEnum.A;
196+ return test + "_foobar";` ;
197+ expect ( util . transpileAndExecute ( code ) ) . toBe ( "0_foobar" ) ;
198+ } ) ;
You can’t perform that action at this time.
0 commit comments