Richard
Richard

Reputation: 8955

Ionic 2 Upgrade where to put Typings

I am upgrading my app from Ionic 2.0.0-beta.20 to Ionic 2.0.0-rc.3 using this guide.

I am trying to figure out how to to typings.

I a making use of this which has typings.

In the older Ionic version (Ionic 2.0.0-beta.20), it had a folder called typings

enter image description here

This contained all the typings, however in the new version (Ionic 2.0.0-rc.3), there is no typings folder.

Where do all the typings go in the new version?

Thers is a src/declarations.d.ts in the new version tjat just contains the following:

/*
  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 '*';

In my code I have the folloiwng:

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

In the old version this references typings/models.d.ts as expected. But in the new version, this references src/declarations.d.ts (which has no definitions).

UPDATE

In RC3, where can I define the typing object?

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

Upvotes: 3

Views: 1368

Answers (1)

Suraj Rao
Suraj Rao

Reputation: 29625

Typings is not used in rc-3. All type declarations are in npm. Installation is done as npm install @types/package_name You can check node_modules/@types folder. Links for adding type modules: docs

and

discussion

Upvotes: 1

Related Questions