I had typings
definition for faker, so I followed this instructions to use types
.
I have faker installed (npm install faker) and types@faker, also deleted typings.json
and typings directory.
It’s seem that is everything ok, but when I try to access a property or method of faker object lead to error.
This same code works with ionic beta + typings.
ionic serve output
[18:59:21] rollup: Export 'image' is not defined by '/Projects/src/pages/page/page.ts'
[18:59:21] rollup: Export 'helpers' is not defined by '/Projects/src/pages/page.ts'
[18:59:21] rollup: Export 'lorem' is not defined by '/Projects/src/pages/page.ts'
JS changed: www/build/main.js
[18:59:31] bundle dev update finished in 14.94 s
[18:59:31] sass started ...
[18:59:31] sass finished in 39 ms
code
import * as faker from "faker";
export class HomePage {
ngAfterViewInit() {
console.log(faker); // ok
console.log(faker.image.avatar); //error
}
}
console.log(faker)
Object {default: Faker, moduleExports: Faker}
moduleExports: Faker
address: Address
commerce: Commerce
company: Company
date: Datedefinitions: Object
fake: fake(str)_
finance: Finance_
hacker: Hacker_
helpers: Helpers_
image: Image_
internet: Internet_
…
console.log(faker.image.avatar)
error_handler.js:47 EXCEPTION: Error in … caused by: Cannot read property ‘avatar’ of undefined