@@ -751,16 +751,14 @@ export class TypeParser {
751
751
) : ConstExprIntegerNode | ConstExprStringNode | IdentifierTypeNode {
752
752
const startLine = tokens . currentTokenLine ( ) ;
753
753
const startIndex = tokens . currentTokenIndex ( ) ;
754
+ let key : ConstExprIntegerNode | IdentifierTypeNode | ConstExprStringNode ;
754
755
755
756
if ( tokens . isCurrentTokenType ( Lexer . TOKEN_INTEGER ) ) {
756
- const key = new ConstExprIntegerNode (
757
+ key = new ConstExprIntegerNode (
757
758
tokens . currentTokenValue ( ) . replaceAll ( '_' , '' ) ,
758
759
) ;
759
760
tokens . next ( ) ;
760
- return this . enrichWithAttributes ( tokens , key , startLine , startIndex ) ;
761
- }
762
- let key : ConstExprIntegerNode | IdentifierTypeNode | ConstExprStringNode ;
763
- if ( tokens . isCurrentTokenType ( Lexer . TOKEN_SINGLE_QUOTED_STRING ) ) {
761
+ } else if ( tokens . isCurrentTokenType ( Lexer . TOKEN_SINGLE_QUOTED_STRING ) ) {
764
762
if ( this . quoteAwareConstExprString ) {
765
763
key = new QuoteAwareConstExprStringNode (
766
764
StringUnescaper . unescapeString ( tokens . currentTokenValue ( ) ) ,
@@ -772,8 +770,7 @@ export class TypeParser {
772
770
) ;
773
771
}
774
772
tokens . next ( ) ;
775
- }
776
- if ( tokens . isCurrentTokenType ( Lexer . TOKEN_DOUBLE_QUOTED_STRING ) ) {
773
+ } else if ( tokens . isCurrentTokenType ( Lexer . TOKEN_DOUBLE_QUOTED_STRING ) ) {
777
774
if ( this . quoteAwareConstExprString ) {
778
775
key = new QuoteAwareConstExprStringNode (
779
776
StringUnescaper . unescapeString ( tokens . currentTokenValue ( ) ) ,
@@ -784,10 +781,12 @@ export class TypeParser {
784
781
tokens . currentTokenValue ( ) . replace ( / ( ^ " | " $ ) / g, '' ) ,
785
782
) ;
786
783
}
784
+ tokens . next ( ) ;
787
785
} else {
788
786
key = new IdentifierTypeNode ( tokens . currentTokenValue ( ) ) ;
789
787
tokens . consumeTokenType ( Lexer . TOKEN_IDENTIFIER ) ;
790
788
}
789
+
791
790
return this . enrichWithAttributes <
792
791
ConstExprIntegerNode | IdentifierTypeNode | ConstExprStringNode
793
792
> ( tokens , key , startLine , startIndex ) ;
@@ -839,8 +838,8 @@ export class TypeParser {
839
838
) : ConstExprStringNode | IdentifierTypeNode {
840
839
const startLine = tokens . currentTokenLine ( ) ;
841
840
const startIndex = tokens . currentTokenIndex ( ) ;
842
-
843
841
let key : ConstExprStringNode | IdentifierTypeNode ;
842
+
844
843
if ( tokens . isCurrentTokenType ( Lexer . TOKEN_SINGLE_QUOTED_STRING ) ) {
845
844
if ( this . quoteAwareConstExprString ) {
846
845
key = new QuoteAwareConstExprStringNode (
@@ -849,12 +848,11 @@ export class TypeParser {
849
848
) ;
850
849
} else {
851
850
key = new ConstExprStringNode (
852
- tokens . currentTokenValue ( ) . replace ( / ( ^ " | " $ ) / g, '' ) ,
851
+ tokens . currentTokenValue ( ) . replace ( / ( ^ ' | ' $ ) / g, '' ) ,
853
852
) ;
854
853
}
855
854
tokens . next ( ) ;
856
- }
857
- if ( tokens . isCurrentTokenType ( Lexer . TOKEN_DOUBLE_QUOTED_STRING ) ) {
855
+ } else if ( tokens . isCurrentTokenType ( Lexer . TOKEN_DOUBLE_QUOTED_STRING ) ) {
858
856
if ( this . quoteAwareConstExprString ) {
859
857
key = new QuoteAwareConstExprStringNode (
860
858
StringUnescaper . unescapeString ( tokens . currentTokenValue ( ) ) ,
@@ -865,12 +863,12 @@ export class TypeParser {
865
863
tokens . currentTokenValue ( ) . replace ( / ( ^ " | " $ ) / g, '' ) ,
866
864
) ;
867
865
}
868
-
869
866
tokens . next ( ) ;
870
867
} else {
871
868
key = new IdentifierTypeNode ( tokens . currentTokenValue ( ) ) ;
872
869
tokens . consumeTokenType ( Lexer . TOKEN_IDENTIFIER ) ;
873
870
}
871
+
874
872
return this . enrichWithAttributes ( tokens , key , startLine , startIndex ) ;
875
873
}
876
874
}
0 commit comments