@@ -20,6 +20,7 @@ export enum LuaTarget {
2020}
2121
2222export enum LuaLibFeature {
23+ ArrayConcat = "ArrayConcat" ,
2324 ArrayEvery = "ArrayEvery" ,
2425 ArrayFilter = "ArrayFilter" ,
2526 ArrayForEach = "ArrayForEach" ,
@@ -329,7 +330,16 @@ export abstract class LuaTranspiler {
329330 let result = `local ${ fileImportTable } = ${ reqKeyword } (${ resolvedImportPath } )\n` ;
330331 this . importCount ++ ;
331332
332- imports . elements . forEach ( element => {
333+ const filteredElements = imports . elements . filter ( e => {
334+ const decs = tsHelper . getCustomDecorators ( this . checker . getTypeAtLocation ( e ) , this . checker ) ;
335+ return ! decs . has ( DecoratorKind . Extension ) && ! decs . has ( DecoratorKind . MetaExtension ) ;
336+ } ) ;
337+
338+ if ( filteredElements . length === 0 ) {
339+ return "" ;
340+ }
341+
342+ filteredElements . forEach ( element => {
333343 const nameText = this . transpileIdentifier ( element . name ) ;
334344 if ( element . propertyName ) {
335345 const propertyText = this . transpileIdentifier ( element . propertyName ) ;
@@ -793,7 +803,9 @@ export abstract class LuaTranspiler {
793803 case ts . SyntaxKind . TypeOfExpression :
794804 return this . transpileTypeOfExpression ( node as ts . TypeOfExpression ) ;
795805 case ts . SyntaxKind . EmptyStatement :
796- return "" ;
806+ return "" ;
807+ case ts . SyntaxKind . SpreadElement :
808+ return this . transpileSpreadElement ( node as ts . SpreadElement ) ;
797809 default :
798810 throw TSTLErrors . UnsupportedKind ( "expression" , node . kind , node ) ;
799811 }
@@ -1036,6 +1048,10 @@ export abstract class LuaTranspiler {
10361048
10371049 this . checkForLuaLibType ( type ) ;
10381050
1051+ if ( classDecorators . has ( DecoratorKind . Extension ) || classDecorators . has ( DecoratorKind . MetaExtension ) ) {
1052+ throw TSTLErrors . InvalidNewExpressionOnExtension ( node ) ;
1053+ }
1054+
10391055 if ( classDecorators . has ( DecoratorKind . CustomConstructor ) ) {
10401056 const customDecorator = classDecorators . get ( DecoratorKind . CustomConstructor ) ;
10411057 if ( ! customDecorator . args [ 0 ] ) {
@@ -1193,6 +1209,8 @@ export abstract class LuaTranspiler {
11931209 const caller = this . transpileExpression ( expression . expression ) ;
11941210 const expressionName = this . transpileIdentifier ( expression . name ) ;
11951211 switch ( expressionName ) {
1212+ case "concat" :
1213+ return this . transpileLuaLibFunction ( LuaLibFeature . ArrayConcat , caller , params ) ;
11961214 case "push" :
11971215 return this . transpileLuaLibFunction ( LuaLibFeature . ArrayPush , caller , params ) ;
11981216 case "forEach" :
@@ -1371,6 +1389,10 @@ export abstract class LuaTranspiler {
13711389 return escapedText ;
13721390 }
13731391
1392+ public transpileSpreadElement ( node : ts . SpreadElement ) : string {
1393+ return "unpack(" + this . transpileExpression ( node . expression ) + ")" ;
1394+ }
1395+
13741396 public transpileArrayBindingElement ( name : ts . ArrayBindingElement ) : string {
13751397 if ( ts . isOmittedExpression ( name ) ) {
13761398 return "__" ;
0 commit comments