export class AppDatabase extends Dexie {
  public contacts: Dexie.Table<Contact, number>;
  public emails: Dexie.Table<IEmailAddress, number>;
  public phones: Dexie.Table<IPhoneNumber, number>;
  ...

This got me the following error in strict typescript:

Error: src/app/core/services/database/interface.ts:4:10 - error TS2564: Property 'contacts' has no initializer and is not definitely assigned in the constructor.

Solution

Strict typescript requires the use of 'Definite Assignment Assertion' to tell typescript that this variable will have a value at runtime as follows. Add an exclamation point after the variables to fix:

export class AppDatabase extends Dexie {
  public contacts!: Dexie.Table<Contact, number>;
  public emails!: Dexie.Table<IEmailAddress, number>;
  public phones!: Dexie.Table<IPhoneNumber, number>;

 

 

Tags