Skip to content

Conversation

drwpow
Copy link
Contributor

@drwpow drwpow commented Apr 27, 2020

Ditches the JSON.parse() approach which was limiting in 2 major ways:

At the end of the day, TypeScript isn’t JSON 🤷. And it turns out the original codebase was closer to what it needed to be. This PR refactors the output generation a little to be even simpler than before.

// 3. open nullable
if (value.nullable) {
output += "(";
}
Copy link
Contributor Author

@drwpow drwpow Apr 27, 2020

Choose a reason for hiding this comment

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

cc @antonk52 sorry about doing this for you, but your PR pointed a flaw in the design. And I wanted to make sure I was solving for nullable (and it seems to be!).

So this doesn’t break, and it looks correct, but I actually didn’t add robust unit tests in this PR which we desperately need to ensure that nullable works in all cases. Are nullable tests (and potentially fixing some edge cases) something you’re interested in writing in a followup PR? 👍 / 👎 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries man, whatever gets the job done =)

IMHO I think the existing cases covered the nullable fairly well. If you can point out a few extra test cases where the explicit test cases are needed I have no problem sending a pr later on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, fair. Thanks for understanding.

Also, a new version is up on npm with the changes, so I’d love to see if the new @next version works for your schemas :)

shipDate?: string
/**
* Order Status
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR adds comment support! 🎉

| "individual"
| "non_profit";
| ("company" | "government_entity" | "individual" | "non_profit")
| null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe nullable has been added, but we can’t be sure before we write unit tests.

@drwpow drwpow merged commit 93c4409 into master Apr 27, 2020
@drwpow drwpow deleted the dangodev/refactor branch April 27, 2020 01:02
@drwpow drwpow mentioned this pull request Apr 27, 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

Successfully merging this pull request may close these issues.

2 participants