lundi 13 mars 2017

Typescript Reflect.getMetadata design:type returns Object instead of Date without angular testbed

I want to start by saying it is not a duplicate of Typescript Reflect.getMetadata('design:type'..) returns Object instead of Date if the Angular 2 Stack is used but is similar.

The following code:

import {} from 'reflect-metadata';
import 'core-js/es7/reflect';

function test(target: any, key: string) {
    console.log(key, Reflect.getMetadata('design:type', target, key).name);
}

class Class { }

class Test {
    @test item: String;
    @test date: Date;
    @test instance: Class;
}

if ran with ts-mocha test.ts outputs

item Object
date Object
instance Class

while if ran with karma start that is set up as a part of the angular2 projects outputs

item String
date Date
instance Class

Why is that and how to make the test results consistent?

http://ift.tt/2mkj3Fd (karma configuration is extracted from an angular2 project and is not cleaned)





Aucun commentaire:

Enregistrer un commentaire