I am new to Aurelia and Typescript. I am trying to use a the aurelia-dialog plugin inside of my project. I have follow all the necessary steps and am getting an error "cannot find module "aurelia-dialog". The offending line is
import {DialogService, DialogController} from "aurelia-dialog";
I am pretty sure all of the config is set up correctly because this is my only error. I have
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-dialog');
Do I need to create a typescript definition file for this to work, if so how? Or am I missing something and this should work as-is?
Looks like the aurelia-dialog build hasn't been configured to produce TypeScript definition files yet. This will probably be added soon. In the meantime you could add an aurelia-dialog.d.ts
file to your project with the following:
declare module 'aurelia-dialog' {
export class DialogService {
open(settings: any): Promise;
}
export class DialogController {
constructor(renderer, settings, resolve, reject);
ok(result: any): Promise<DialogResult>;
cancel(result: any): Promise<DialogResult>;
error(message): Promise<DialogResult>;
close(ok: boolean, result: any): Promise<DialogResult>;
settings: {lock: boolean, centerHorizontalOnly: boolean };
}
export class DialogResult {
wasCancelled: boolean;
output: any;
constructor(cancelled: boolean, result: any);
}
}
来源:https://stackoverflow.com/questions/33046339/how-to-use-aurelia-third-party-plugin-with-without-typescript-definition-file