FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Execution of JS code stops when using Destructuring assignment(NativeScript + Angular) · Issue #4434 · NativeScript/NativeScript · GitHub

Execution of JS code stops when using Destructuring assignment(NativeScript + Angular) #4434

Description

Please, provide the details below:

I am using TypeScript
When using the destructuring assignment in JS, any code below that line will not be executed.

  console.log('About to destructure an object')
  const user = { ...response, token: undefined }
  console.log('hi')

Compiled JS:

  var user = __assign({}, response, { token: undefined }); // Where is __assign defined?

Output:

JS: About to destructure an object

It's not just with console.log, simply any code is not executed, but no errors are thrown(on Android).

Fix with:

  console.log('About to destructure an object')
  const user = response
  user.token = undefined
  console.log('hi')

Compiled JS:

  var user = response;
  user.token = undefined;

Output:

JS: About to destructure an object
JS: hi // works

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yeah, nothing there

Tell us about the problem

Cannot use destructuring assignment in code. Although there is an easy workaround, it is not very obvious. It took me a couple of hours to go back and forth to the faulty code attempting to fix my app.

Which platform(s) does your issue occur on?

On Android, the app DOES NOT throw any errors, but code does not get executed below that line
On iOS, the app will crash of segmentation fault(not sure if this is really caused by the destructuring assignment, might be an emulator bug) <- I'll get back to this.

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.0.3
  • Cross-platform modules: 3.0.1
  • Runtime(s): 3.0.1 (Android + iOS)
  • Plugin(s): The issue is not related to a plugin

Please tell us how to recreate the issue in as much detail as possible.

To replicate my situation, paste in the code below into a button's (tap) event.

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

Simply copy this code, preferably in a button's (tap) event:

response is a response object from server. It contains some user data and the token:

const response = {
  name: 'Jane',
  last_name: 'Doe',
  token: 'ewqrewru0r7eyr87y87y43287r832yr8uye8uh82en8rxh8'
}
  console.log('About to destructure an object')
  const user = { ...response, token: undefined }
  console.log('hi')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL