How to use TypeScript definitions @types in ionic2 project

Ionic2 now use @types to support for third-party libraries.
I installed
npm install --save @types/gapi.auth2
But I don’t know how to add my project and how to use it. Please help me

That should already do the trick. No need for any custom references, if you added it through npm it should all work fine.

@luukschoen I try but it got gapi is not defined

home.ts
import { Component } from ‘@angular/core’;

import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
	auth: any;

  constructor(public navCtrl: NavController) {

  }

  test_init(){
  let auth = gapi.auth2.init({
    client_id: 'xxx.apps.googleusercontent.com',
    cookie_policy: 'single_host_origin',
    scope: 'https://www.googleapis.com/auth/plus.login',
    fetch_basic_profile: true
  });
}
}

home.html
<button ion-button (click)="test_init()">Test auth</button>

What’s wrong?

Thats odd. And you’re sure the typings are added correctly inside the node_modules/@types folder?

If you are upgrading an old project, see if you have typings folder with gapi, in case you have installed before using typings

Oh, so stupid, I didn’t load gapi before initing it.

        gapi.load('auth2', () => {
               this.auth2 = gapi.auth2.init({
                client_id: 'xxx.apps.googleusercontent.com',
               
              });
            });
          };

I am a newbie of angular and ionic2. Thank you so much for helping <3 @luukschoen @ecureuill