如何在没有打字稿定义文件的情况下使用Aurelia第三方插件? [英] How to use Aurelia third party plugin with without typescript definition file?

查看:79
本文介绍了如何在没有打字稿定义文件的情况下使用Aurelia第三方插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Aurelia和Typescript的新手.我正在尝试在我的项目中使用aurelia-dialog插件.我已经按照所有必要的步骤进行操作,并且收到错误消息找不到模块"aurelia-dialog".令人反感的行是

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?

推荐答案

看起来aurelia-dialog构建尚未配置为生成TypeScript定义文件.这可能会很快添加.同时,您可以使用以下命令将aurelia-dialog.d.ts文件添加到您的项目中:

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);
  }
}

这篇关于如何在没有打字稿定义文件的情况下使用Aurelia第三方插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆