Ionic 2 升级放置打字的位置

Ionic 2 Upgrade where to put Typings

我正在使用 this guide.

将我的应用程序从 Ionic 2.0.0-beta.20 升级到 Ionic 2.0.0-rc.3

我正在想办法typings

我正在使用 this 其中有 typings.

在旧的 Ionic 版本 (Ionic 2.0.0-beta.20) 中,它有一个名为 typings

的文件夹

这包含所有 typings,但是在新版本 (Ionic 2.0.0-rc.3) 中,没有 typings 文件夹。

新版本中所有的打字都去了哪里?

Thers是一个src/declarations.d.ts新版本的tjat只包含以下内容:

/*
  Declaration files are how the Typescript compiler knows about the type information(or shape) of an object.
  They're what make intellisense work and make Typescript know all about your code.

  A wildcard module is declared below to allow third party libraries to be used in an app even if they don't
  provide their own type declarations.

  To learn more about using third party libraries in an Ionic app, check out the docs here:
  http://ionicframework.com/docs/v2/resources/third-party-libs/

  For more info on type definition files, check out the Typescript docs here:
  https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html
*/
declare module '*';

在我的代码中有以下内容:

import { Chat, Message } from 'api/models';

在旧版本中,这按预期引用了 typings/models.d.ts。但在新版本中,this 引用 src/declarations.d.ts(没有定义)。

更新

在 RC3 中,我可以在哪里定义类型对象?

models.d.ts

declare module 'api/models' {
  interface Chat {
    _id?: string;
    memberIds?: string[];
    title?: string;
    subTitle?: string;
    picture?: string;
    lastMessage?: Message;
    lastMessageCreatedAt?: Date;
    receiverComp?: Tracker.Computation;
    lastMessageComp?: Tracker.Computation;
  }

  interface Message {
    _id?: string;
    chatId?: string;
    senderId?: string;
    ownership?: string;
    content?: string;
    createdAt?: Date;
    changeDate?: boolean;
    readByReceiver?: boolean;
  }
}

rc-3 中不使用类型化。 所有类型声明都在 npm 中。 安装完成为 npm install @types/package_name 您可以检查 node_modules/@types 文件夹。 添加类型模块的链接: docs

discussion