Sto provando a comporre alcune classi usando la sintassi del modulo ES2015 con TypeScript. Ogni classe implementa un'interfaccia in un file .d.ts
.TypeScript TS2322: il tipo 'typeof Foo' non è assegnabile al tipo 'IFoo'
Ecco un problema del MWE.
In un file .d.ts
ho:
interface IBar {
foo: IFoo;
// ...
}
interface IFoo {
someFunction(): void;
// ...
}
mia esportazione:
// file: foo.ts
export default class Foo implements IFoo {
someFunction(): void {}
// ...
}
// no errors yet.
E la mia importazione è:
import Foo from "./foo";
export class Bar implements IBar {
foo: IFoo = Foo;
}
L'errore qui è:
error TS2322: Type 'typeof Foo' is not assignable to type 'IFoo'.
Property 'someFunction' is missing in type 'typeof Foo'.
Qualche idea qui?
Rookie errore, pensato che stavo facendo qualcosa di sbagliato con il dattiloscritto, quando era un problema con i JS effettivi ... Grazie. – azz
Cheers. Si prega di contrassegnare come risposta – basarat
Naturalmente. SO ti fa aspettare 10 minuti prima di accettare. – azz