NativeScript / nativescript-schematics

nativescript, mobile, schematics, angular
Apache License 2.0
186 stars 26 forks source link

Uncaught ReferenceError: __decorate is not defined #304

Open macjohnny opened 3 years ago

macjohnny commented 3 years ago

Environment Provide the content of the package.json file in the project:

@nativescript/schematics@10.1.0

Describe the bug When starting the newly created app, the error Uncaught ReferenceError: __decorate is not defined occurs in the browser and the app crashes.

To Reproduce

ng new -c=@nativescript/schematics dummy-nativescript --shared
cd dummy-nativescript
ng serve

Expected behavior No error

Additional context The solution is to remove the following lines from the tsconfig.json:

    "noEmitHelpers": true, 

(Credits: https://stackoverflow.com/a/64088843)

rob4226 commented 3 years ago

I just had the same issue but I wasn't sure if the NativeScript mobile part of the shared app needs the "noEmitHelpers": true, so instead I put "noEmitHelpers": false, into the "tsconfig.app.json" file so it would only affect the typescript compiler options of the web browser portion of the project which also fixed this issue.

steamwings commented 3 years ago

For my newly created code-sharing Angular project, ng serve first gave me

ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es7/reflect' in ...

which I resolved by editing polyfills.ts to have import 'core-js/es/reflect'; instead of import 'core-js/es7/reflect';. (Note: my package.json has "core-js": "^3.6.0",.)

After that change, I now got Uncaught ReferenceError: __decorate is not defined, which was resolved as discussed above. After both changes, the demo app ran as expected.

EDIT: I opened #306 regarding the polyfills error. The better fix is actually to add the missing .browserslistrc file.