How to use faker.js in typescript?

piernik picture piernik · Jul 24, 2017 · Viewed 13k times · Source

As in topic. I cannot handle it :/ I've installed npm i faker and also npm i @types/faker --save-dev

my IDE found fakerStatic.name.findName() but browser not recognizes fakerStatic.

import 'faker'; does not help.

Answer

Saravana picture Saravana · Jul 24, 2017

You have to import it like:

import * as faker from 'faker';

And use it like:

faker.name.findName()