0

The following code is working perfectly fine in development mode: ng serve --open

addDriver(driver: any) {
   return fromPromise(this.db.insert('driver', driver));
}

But fails with the following error when deployed to production with this error: ng build --prod

ERROR TypeError: Object(...) is not a function

Getting this error on this.db.insert

I am guessing it has something to do with ASI(Automatic Semicolon Insertion)

Any help is highly appreciated.

Thanks in advance.

Suraj Air
  • 2,063
  • 4
  • 22
  • 33

1 Answers1

0

As you guessed it correctly, ASI rule works only on specific statements as explained ECMAScript® 2016 Language Specification

It includes following cases -

  • empty statement
  • var statement
  • expression statement
  • do-while statement
  • continue statement
  • break statement
  • return statement
  • throw statement

Best solution is to avoid relying on ASI as it might not be able to work in all scenarios.

References -

SO Question 1

SO Question 2

planet_hunter
  • 3,866
  • 1
  • 26
  • 39
  • Thanks for the answer, but this was related to rxjs. Apparently fromPromise does not work correctly in rxjs6. I changed fromPromise to 'from' and it worked. – Suraj Air Jul 17 '18 at 14:39