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

fix(jsii): Correctly handle singleton enums #535

Merged
merged 2 commits into from
Jun 14, 2019

Conversation

RomainMuller
Copy link
Contributor

When an enum has only one option, TypeScript handles it in a special way
and tries very hard to hide the enum declaration in favor of the sole
member. This caused incorrect type names and kinds to be emitted in the
JSII assembly, resulting in incorrect behavior.

This uses a non-public part of the TSC API (possibly an omission from
the hand-written type model), so it includes an additional guard check
to fail explicitly in case the API's behavior happens to change in a
breaking way.

Fixes #231


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When an enum has only one option, TypeScript handles it in a special way
and tries very hard to hide the enum declaration in favor of the sole
member. This caused incorrect type names and kinds to be emitted in the
JSII assembly, resulting in incorrect behavior.

This uses a non-public part of the TSC API (possibly an omission from
the hand-written type model), so it includes an additional guard check
to fail explicitly in case the API's behavior happens to change in a
breaking way.

Fixes #231
@RomainMuller RomainMuller requested a review from a team as a code owner June 13, 2019 16:07
@RomainMuller RomainMuller merged commit 01aed03 into master Jun 14, 2019
@RomainMuller RomainMuller deleted the rmuller/fix-single-value-enums branch June 14, 2019 08:28
RomainMuller added a commit that referenced this pull request Jun 18, 2019
* **jsii:** Correctly handle singleton enums ([#535](#535)) ([01aed03](01aed03)), closes [#231](#231)
* **jsii:** Correctly ignore private properties from ctor ([#531](#531)) ([e804cab](e804cab))
RomainMuller added a commit that referenced this pull request Jun 19, 2019
* **jsii:** Correctly handle singleton enums ([#535](#535)) ([01aed03](01aed03)), closes [#231](#231)
* **jsii:** Correctly ignore private properties from ctor ([#531](#531)) ([e804cab](e804cab))
RomainMuller added a commit that referenced this pull request Jun 19, 2019
* **jsii-reflect:** Expose Assembly metadata field ([#542](#542)) ([9b35e98](9b35e98))
* **jsii:** Correctly handle singleton enums ([#535](#535)) ([01aed03](01aed03)), closes [#231](#231)
* **jsii:** Correctly ignore private properties from ctor ([#531](#531)) ([e804cab](e804cab))
@RomainMuller RomainMuller mentioned this pull request Jun 19, 2019
RomainMuller added a commit that referenced this pull request Jun 19, 2019
* **jsii-reflect:** Expose Assembly metadata field ([#542](#542)) ([9b35e98](9b35e98))
* **jsii:** Correctly handle singleton enums ([#535](#535)) ([01aed03](01aed03)), closes [#231](#231)
* **jsii:** Correctly ignore private properties from ctor ([#531](#531)) ([e804cab](e804cab))
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

Successfully merging this pull request may close these issues.

Singleton enums are not typed properly
2 participants