@@ -3978,29 +3978,34 @@ export class LuaTransformer {
39783978 const value = Number ( propertyName . text ) ;
39793979 return tstl . createNumericLiteral ( value , propertyName ) ;
39803980 } else {
3981- return tstl . createStringLiteral ( this . transformIdentifier ( propertyName ) . text ) ;
3981+ return tstl . createStringLiteral ( this . getIdentifierText ( propertyName ) ) ;
39823982 }
39833983 }
39843984
3985- public transformIdentifier ( expression : ts . Identifier ) : tstl . Identifier {
3986- if ( expression . originalKeywordKind === ts . SyntaxKind . UndefinedKeyword ) {
3987- return tstl . createIdentifier ( "nil" ) ; // TODO this is a hack that allows use to keep Identifier
3988- // as return time as changing that would break a lot of stuff.
3989- // But this should be changed to retun tstl.createNilLiteral()
3990- // at some point.
3991- }
3992-
3993- let escapedText = expression . escapedText as string ;
3985+ public getIdentifierText ( identifier : ts . Identifier ) : string {
3986+ let escapedText = identifier . escapedText as string ;
39943987 const underScoreCharCode = "_" . charCodeAt ( 0 ) ;
39953988 if ( escapedText . length >= 3 && escapedText . charCodeAt ( 0 ) === underScoreCharCode &&
39963989 escapedText . charCodeAt ( 1 ) === underScoreCharCode && escapedText . charCodeAt ( 2 ) === underScoreCharCode ) {
39973990 escapedText = escapedText . substr ( 1 ) ;
39983991 }
39993992
40003993 if ( this . luaKeywords . has ( escapedText ) ) {
4001- throw TSTLErrors . KeywordIdentifier ( expression ) ;
3994+ throw TSTLErrors . KeywordIdentifier ( identifier ) ;
3995+ }
3996+
3997+ return escapedText ;
3998+ }
3999+
4000+ public transformIdentifier ( expression : ts . Identifier ) : tstl . Identifier {
4001+ if ( expression . originalKeywordKind === ts . SyntaxKind . UndefinedKeyword ) {
4002+ return tstl . createIdentifier ( "nil" ) ; // TODO this is a hack that allows use to keep Identifier
4003+ // as return time as changing that would break a lot of stuff.
4004+ // But this should be changed to retun tstl.createNilLiteral()
4005+ // at some point.
40024006 }
40034007
4008+ const escapedText = this . getIdentifierText ( expression ) ;
40044009 const symbolId = this . getIdentifierSymbolId ( expression ) ;
40054010 return tstl . createIdentifier ( escapedText , expression , symbolId ) ;
40064011 }
0 commit comments