-
Notifications
You must be signed in to change notification settings - Fork 558
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
Integrating and providing Enum Objects #1375
base: main
Are you sure you want to change the base?
Conversation
This pull request is automatically being deployed by Amplify Hosting (learn more). |
Will do a full review in a bit.. or maybe you want to first address the above answers and I review after the changes you do as a result of my answers? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did a quick glance and in general I think we can:
- go for brevity for some of these enum names, so they are less wieldy to use/write for people
- destructure/dedupe repeated elements/enum members
And we'll need to add a small barrel file: lib/enums/index.js
that we can point to in our package.json -> exports -> "./enums": "./lib/enums/index.js"
I'll give a more detailed thorough and detailed review eventually when the broader stuff is aligned a bit more
0e18b62
to
87cb861
Compare
@jorenbroekema I added most of the discussed changes/updates except for the following, which is still a TODO:
Maybe you want to wait with a next review, until I have done these last changes, as well? |
bea5162
to
279358e
Compare
@jorenbroekema So I think now would be a good moment to make a more in depth review, if you have time. Following points should get a close inspection:
// lib/enums/commentPositions.d.ts
export namespace commentPositions {
let above: string;
let inline: string;
} |
I didn't end up getting to this yesterday/today due to other prios but I'll try to get on this Monday! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :)
Three things:
- We should have a docs page -> Enums, and refer to it where necessary when we refer to the enums in other places in our docs
- really wanna call fileFormats formats to be honest, just because that's consistent with the name of the hook "formats"
- I think the enums members currently are loosely typed as just "string", in JSDocs it seems like from my experimentation the only way to strictly type the enum members is to cast every member to the exact string value. I was hoping @readonly or @enum tags in JSDocs would do it, especially @readonly I expected to work as enum but TypeScript doesn't agree with me :\ I pushed a commit to your branch just to show an example of how you would do this so that's three parts:
- adjust the enums to be strict
- remove typecasts in the JS source files where they are no longer needed
- adjust the types TS files where needed to essentially use
(typeof <enum>)[keyof typeof <enum>]
to type the properties as "value of enum"
ea74bb2
to
6258f36
Compare
7954e5b
to
5687c5d
Compare
Further, do you think there is anything for the import { formats } from '../lib/enums/index.js';
type formats = typeof formats;
export interface Format {
name: string | formats[keyof formats];
format: FormatFn;
} |
And one more thing, which I noticed in the docs of the format-helpers. There are existing different |
5687c5d
to
bc01ddd
Compare
I am not sure what causes the CI pipeline to fail atm!? Maybe someone can see more of the AWS Amplify logs than me? |
Yeah that seems like a good idea for a bit better autocomplete if possible.
I'll take a look at the merge conflicts and the pipeline failure and commit a fix if needed. |
@jorenbroekema If you like I can also rebase this branch to the current main and resolve the conflicts that way? Most of it should be in the import paths with the |
I'll take another look this weekend/Monday (probably) and get this PR over the finish line, including rebase etc. 👍🏻 |
1e2e088
to
ab3bf4d
Compare
Alright I just squashed and rebased and fixed all of the stuff I encountered during thorough review, summary of what I adjusted, which can be viewed separately here 1e2e088 (note however that GitHub will eventually garbage collect this orphan commit):
To wrap this up we just need a review from @dbanksdesign but from my perspective this PR is now ready :) thanks again for contributing @DarioSoller |
There are some broken links in the docs with this PR:
|
@dbanksdesign thanks for sharing the Amplify error logs. Yeah, I see these page anchors need to be dasherized. I just pushed a fix. 🤞 |
@dbanksdesign as it is still failing, could you share the Amplify error logs one more time with me? |
This PR proposes enum like JS objects for most hardcoded string configuration values. As discussed in the related issue #1367 .
A few remarks for the review of this PR:
style-dictionary
or maybe similar like the typesstyle-dictionary/types
something likestyle-dictionary/enums
?lib/buildInEnums.js
, but I can also make a folder with one file per enum object?'json/nested'
), which seems to be used internally, but should probably be not available as a "public" file format configuration option and therefore not part of the enum!? I am talking about https://github.com/amzn/style-dictionary/blob/main/lib/common/formats.js#L1538logging
,commentStyle
,commentPosition
have split up all subsequent changes in their separate commits. If wanted, I can interactively rebase and split up changes further, or I can also squash things accordingly, depending on how you want to see the changes in commits for the generated changelog later on?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.