"__assign is not defined" - NativeScript Object Spread Woes "__assign is not defined" - NativeScript Object Spread Woes typescript typescript

"__assign is not defined" - NativeScript Object Spread Woes


I'm happy to report I found the solution to this. This GitHub repo explains things quite nicely, but here's a quick rundown:

The flag noEmitHelpers in tsconfig.json tells Typescript to omit these 'helpers' (such as __assign) in every file that needs them.

{  "compilerOptions": {    // changing this to false does the job, but duplicates helpers across every file    "noEmitHelpers": false  }}

The latest Typescript offers a better way to manage this, using the flag importHelpers (see compiler options):

{  "compilerOptions": {    "noEmitHelpers": true,    "importHelpers": true // better  }}

This'll get object spread working, and avoid code duplication across files.

You might also need to npm install tslib --save to stop IDE errors.


Have you tried adding "lib": "es6" to your tsconfig?