Open blai30 opened 3 years ago
Not right now, To be honest, I don't know how to add the types.
About ES6 modules, the package.json should be modified? Right?
I think package.json would have "type": "module"
but I'm sure there is more to it than just that.
For what it's worth, I got it working right out of the box with Typescript + Angular.
pokedex.service.ts
and added the PokeAPI wrapper in it:import { Injectable } from '@angular/core';
import * as Pokedex from 'pokeapi-js-wrapper';
@Injectable({
providedIn: 'root'
})
export class PokedexService {
pokedex: Pokedex;
constructor() {
this.pokedex = new Pokedex.Pokedex();
}
async getPokemon() {
const golduck = await this.pokedex.getPokemonByName("golduck");
console.log(golduck);
}
}
I added my service file in my app.component.ts constructor:
constructor(private pokedexService: PokedexService) {
...
}
I called the getPokemon method in the ngOnInit:
ngOnInit(): void {
this.pokedexService.getPokemon();
}
Are there any plans to add typings for use with TypeScript and/or ES6 modules (import/export)?