Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsickle should emit goog.reflect.objectProperty for property names passed to __rest tslib helper #1047

Open
mitchellwills opened this issue Jul 23, 2019 · 3 comments
Assignees

Comments

@mitchellwills
Copy link
Contributor

rest destructuring assignments are not safe for closure compiler because tsc/tsickle emits property names as quoted strings. It looks like it should be pretty simple to apply goog.reflect.objectProperty here

Example Input:

const input = {x: 1, y: 2, z: 3};
const {x, ...rest} = input;

Current Emit:

const input = { x: 1, y: 2, z: 3 };
const { x } = input, rest = __rest(input, ["x"]);

Proposed Emit:

const input = { x: 1, y: 2, z: 3 };
const { x } = input, rest = __rest(input, [goog.reflect.objectProperty("x", input)]);

Related: #241
This probably applies to other emit too

@evmar
Copy link
Contributor

evmar commented Jul 23, 2019

To hook this, I think we'd need to postprocess the JS output to look for calls to __rest (really tslib's rest).

@jplaisted
Copy link

Alternatively can tsickle just emit the same code? Why is it lowering the language level?

theseanl added a commit to theseanl/tscc that referenced this issue Sep 25, 2019
Typescript when target is less than ES2018 emits `__rest` helper for object spread syntax,
which references properties' name via string literal hence breaks Closure Compilation.
We transforms such names to appropriate `goog.reflect.objectProperty` calls to make it compatible with
Closure Compiler, as described in  angular/tsickle#1047.
theseanl added a commit to theseanl/tscc that referenced this issue Sep 25, 2019
Typescript when target is less than ES2018 emits `__rest` helper for object spread syntax,
which references properties' name via string literal hence breaks Closure Compilation.
We transforms such names to appropriate `goog.reflect.objectProperty` calls to make it compatible with
Closure Compiler, as described in  angular/tsickle#1047.
@brad4d
Copy link
Contributor

brad4d commented Nov 3, 2020

Internal issue created http://b/171341422

@brad4d brad4d self-assigned this Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants