File tree 1 file changed +49
-0
lines changed 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,55 @@ var x = 0;`,
220
220
expectedOutput : output
221
221
} ) ;
222
222
} ) ;
223
+
224
+ it ( "Transpile with emit decorators and emit metadata" , ( ) => {
225
+ let input =
226
+ `import {db} from './db';\n` +
227
+ `function someDecorator(target) {\n` +
228
+ ` return target;\n` +
229
+ `} \n` +
230
+ `@someDecorator\n` +
231
+ `class MyClass {\n` +
232
+ ` db: db;\n` +
233
+ ` constructor(db: db) {\n` +
234
+ ` this.db = db;\n` +
235
+ ` this.db.doSomething(); \n` +
236
+ ` }\n` +
237
+ `}\n` +
238
+ `export {MyClass}; \n`
239
+ let output =
240
+ `var db_1 = require(\'./db\');\n` +
241
+ `function someDecorator(target) {\n` +
242
+ ` return target;\n` +
243
+ `}\n` +
244
+ `var MyClass = (function () {\n` +
245
+ ` function MyClass(db) {\n` +
246
+ ` this.db = db;\n` +
247
+ ` this.db.doSomething();\n` +
248
+ ` }\n` +
249
+ ` MyClass = __decorate([\n` +
250
+ ` someDecorator, \n` +
251
+ ` __metadata(\'design:paramtypes\', [(typeof (_a = typeof db_1.db !== \'undefined\' && db_1.db) === \'function\' && _a) || Object])\n` +
252
+ ` ], MyClass);\n` +
253
+ ` return MyClass;\n` +
254
+ ` var _a;\n` +
255
+ `})();\n` +
256
+ `exports.MyClass = MyClass;\n` ;
223
257
258
+ test ( input ,
259
+ {
260
+ options : {
261
+ compilerOptions : {
262
+ module : ModuleKind . CommonJS ,
263
+ newLine : NewLineKind . LineFeed ,
264
+ noEmitHelpers : true ,
265
+ emitDecoratorMetadata : true ,
266
+ experimentalDecorators : true ,
267
+ target : ScriptTarget . ES5 ,
268
+ }
269
+ } ,
270
+ expectedOutput : output
271
+ } ) ;
272
+ } ) ;
224
273
} ) ;
225
274
}
You can’t perform that action at this time.
0 commit comments