mardi 5 novembre 2019

TypeScript – TypeError: Alice_1.Alice is not a constructor

I've got a file alice.ts with the implementation of a class called Alice and an interface called IAlice:

export interface IAlice {
    readonly prop: number;
}

export class Alice {
    static fromJSON(json:string) {
        const par = ...
        return new Alice(par);
    }

    readonly prop: IAlice;

    constructor(prop: IAlice) {
        this.prop = prop;
    }
}

In my test when I run:

import { Alice, IAlice } from "filepath";
...
const alice: Alice = new Alice(object);
...

I got as output an error:

TypeError: alice_1.Alice is not a constructor

Does anybody have an idea why this error is raised?

Thanks!

Aucun commentaire:

Enregistrer un commentaire