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(format): 'typescript/es6-declarations' return type #681

Merged
merged 1 commit into from
Aug 19, 2021

Conversation

Dru89
Copy link
Contributor

@Dru89 Dru89 commented Aug 14, 2021

This change fixes an issue where all variables exported from 'typescript/es6-declarations' are assumed to be of type string.

Before this, if you had an input type like:

{
  "color": {
    "blue": { "value": "#0000ff" },
  },
  "size": {
    "padding": { "value": 2 }
  }
}

Your output ES6 module would be:

export const ColorBlue = "#0000ff";
export const SizePadding = 2;

But your output TypeScript module would be:

export const ColorBlue : string;
export const SizePadding : string;

This adds some basic type checking for a few known values, and will fall back to any if the type can't be easily determined. It will look for:

  • strings
  • numbers
  • booleans
  • or arrays of any of those things

If it can't determine the type, it will fall back to any (or any[] if we know it's an array).

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

This change fixes an issue where all variables exported from
'typescript/es6-declarations' are assumed to be of type `string`.

Instead, it adds some *basic* type checking for a few known values, and
will fall back to `any` if the type can't be easily determined.
Copy link
Member

@dbanksdesign dbanksdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! :shipit:

@dbanksdesign dbanksdesign merged commit 0cf6c52 into amzn:main Aug 19, 2021
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.

3 participants