@@ -2178,15 +2178,17 @@ module ts {
2178
2178
}
2179
2179
}
2180
2180
2181
- function isBinaryOrOctalIntegerLiteral ( text : string ) : boolean {
2182
- if ( text . length <= 0 ) {
2183
- return false ;
2184
- }
2185
-
2186
- if ( text . charCodeAt ( 1 ) === CharacterCodes . B || text . charCodeAt ( 1 ) === CharacterCodes . b ||
2187
- text . charCodeAt ( 1 ) === CharacterCodes . O || text . charCodeAt ( 1 ) === CharacterCodes . o ) {
2188
- return true ;
2181
+ function isBinaryOrOctalIntegerLiteral ( node : LiteralExpression , text : string ) : boolean {
2182
+ if ( node . kind === SyntaxKind . NumericLiteral && text . length > 1 ) {
2183
+ switch ( text . charCodeAt ( 1 ) ) {
2184
+ case CharacterCodes . b :
2185
+ case CharacterCodes . B :
2186
+ case CharacterCodes . o :
2187
+ case CharacterCodes . O :
2188
+ return true ;
2189
+ }
2189
2190
}
2191
+
2190
2192
return false ;
2191
2193
}
2192
2194
@@ -2195,13 +2197,15 @@ module ts {
2195
2197
? getDoubleQuotedStringTextOfLiteral ( node )
2196
2198
: node . parent
2197
2199
? getSourceTextOfNodeFromSourceFile ( currentSourceFile , node )
2198
- : node . text ; // TODO(drosen): Is this correct?
2200
+ : node . kind === SyntaxKind . NumericLiteral
2201
+ ? node . text
2202
+ : getDoubleQuotedStringTextOfLiteral ( node ) ;
2199
2203
2200
2204
if ( compilerOptions . sourceMap && ( node . kind === SyntaxKind . StringLiteral || isTemplateLiteralKind ( node . kind ) ) ) {
2201
2205
writer . writeLiteral ( text ) ;
2202
2206
}
2203
- // For version below ES6, emit binary integer literal and octal integer literal in canonical form
2204
- else if ( languageVersion < ScriptTarget . ES6 && node . kind === SyntaxKind . NumericLiteral && isBinaryOrOctalIntegerLiteral ( text ) ) {
2207
+ // For versions below ES6, emit binary & octal literals in their canonical decimal form.
2208
+ else if ( languageVersion < ScriptTarget . ES6 && isBinaryOrOctalIntegerLiteral ( node , text ) ) {
2205
2209
write ( node . text ) ;
2206
2210
}
2207
2211
else {
0 commit comments