A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
1.5k
stars
309
forks
source link
Usage of nullish coalescing syntax errors when running in some browser versions #1792
Closed
jfernandezgersol closed 1 week ago
Hi,
I updated the library to a newer version in my project (3.0.0) and I was getting some strange errors running tests with Karma and Jasmine:
Chrome 68.0.3419.0 (Windows 10) ERROR An error was thrown in afterAll Uncaught SyntaxError: Unexpected token ? Chrome 68.0.3419.0 (Windows 10) ERROR An error was thrown in afterAll Uncaught SyntaxError: Unexpected token ? SyntaxError: Unexpected token ? Chrome 68.0.3419.0 (Windows 10): Executed 0 of 0 ERROR (0 secs / 0 secs) Chrome 68.0.3419.0 (Windows 10) ERROR An error was thrown in afterAll Uncaught SyntaxError: Unexpected token ? SyntaxError: Unexpected token ?
After some research, I detected that the problem was related with the apollo-angular library, concretely with the following line:
options.useMutationLoading ?? this.useMutationLoading
referenced in:
https://github.com/kamilkisiela/apollo-angular/blob/dee1c98a97181378f969b480d45a048abee522e1/packages/apollo-angular/src/apollo.ts#L73
I am using Chrome Headles v68.0.3419.0 to run the tests and the nullish coalescing operator is not recognized.
After some further research, I realized that the support of this operator is relatively new in Safari for iOS too (from iOS version 13.3).
https://caniuse.com/mdn-javascript_operators_nullish_coalescing
I suppose, that this line can be changed to not use ?? and then the browser compatibility won't be reduced.
Thanks in advance!