Dexie.js: angular 2 unable to extend dexie

Created on 2 May 2017  路  5Comments  路  Source: dfahlander/Dexie.js

I'm using "dexie": "2.0.0-beta.10" and extending my class as export class appCache extends Dexie
but this is thowing type error as Uncaught TypeError: Object prototype may only be an Object or null: undefined

I'm using webpack , awesome-typscript-loader plugin and [email protected] and have set "moduleResolution": "node"

I'm getting error from this call extendStatics(d, b); in complied javascript where d is appCache and b is undefined
I think it should be Dexie but it is not getting set

All 5 comments

even manually creating appCache by new appCache throws same error but new Dexie('db') works

Maybe a problem with your import or your config? There is an example here albeit a bit old https://github.com/dfahlander/Dexie.js/tree/master/samples/angular2.
This https://github.com/jsperts/workshop_unterlagen/tree/master/angular/examples/Redux example is newer and also works with extends.

Thanks for hint i was importing dexie by import {Dexie} from 'dexie';

It should be import Dexie from 'dexie'; // no brackets

Thanks again I'm closing this issue now

Hi, I also ran into this problem, maybe explicitly state in the docs that you have to use the default import? Or is this super-obvious?

@stombeur I wouldn't call it super-obvious but all our examples (at least the ones I know of and definitely the ones in the README) use a default import. So if anyone misses that, I doubt that mentioning it somewhere in the docs would help much..

As far as I know all older libraries which were just global objects prior to ECMAScript modules are using a default export. So trying to use default import would be my first choice with dexie.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PalmerAL picture PalmerAL  路  12Comments

jboulmal picture jboulmal  路  21Comments

ghost picture ghost  路  13Comments

dfahlander picture dfahlander  路  16Comments

acicali picture acicali  路  43Comments