How to write my Ionic 2 project Declaration Files (typings)

Hi all!
Anyone has an idea of the best way to declare my project’s types?
I’ve been reading and I know I can add this on my package.json:

  "typings": "./app/app.d.ts"

but I wonder what are the best practices here.

I would like to have a separated GIT project with them, to be used by other typescript code if needed, and I’m full of doubts on how to write the file(s), with namespaces like NodeJS’ .d.ts:

declare namespace NodeJS {
    export interface ErrnoException extends Error {
        errno?: number;
        code?: string;
        path?: string;
        syscall?: string;
        stack?: string;

or just pollute the global namespace…

Help please!
cc @mhartington

So for now, don’t start adding typings to the package.json.

While this is a feature coming in Typescript 2.0, it’s still in beta an not stable yet.

@matheo I’m simply declaring typings on a per-component basis, but my project is small, so this method works well.

@mhartington @itlr Thanks for the replies!

I’ve started to organize my models and interfaces on a single folder to be able to outsource them in a separated repo later.

Reading this: I thought we’re able to define our module and use across our package (Ionic 2 app) but it seems it only works for external modules (on node_modules/), so I referenced manually my index.d.ts on the ionicapp/typings/index.d.ts and it seems to work now :slight_smile:

What’s your method to let the TS compiler to resolve your definitions @itlr?