Skip to content

Add trivia for idlTypes #192

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

Merged
merged 4 commits into from
Jun 9, 2018
Merged

Add trivia for idlTypes #192

merged 4 commits into from
Jun 9, 2018

Conversation

saschanaz
Copy link
Member

These four commits are mutually related (so I couldn't fix writer.js for each commit), but still each commit has its own baseline changes.

Copy link
Member

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

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

Looks good, just a question about nullable and null.

@@ -195,9 +195,13 @@

const EMPTY_IDLTYPE = Object.freeze({
generic: null,
nullable: false,
nullable: null,
Copy link
Member

Choose a reason for hiding this comment

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

Can you help me understand why we don’t default to false? Null seems a little odd here.

obj.nullable = !!consume("?");
const nullable = consume("?");
if (nullable) {
obj.nullable = { trivia: nullable.trivia };
Copy link
Member Author

@saschanaz saschanaz Jun 9, 2018

Choose a reason for hiding this comment

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

Can you help me understand why we don’t default to false?

@marcoscaceres I had to determine where should information about optional "modifier" tokens go, and the result is this.

I could do idlType.trivia.nullable === null, but then we would have two fields about nullable token being absent, and causes inconsistency (some trivia fields sometimes being null, others never). Having two fields also may cause bugs as we should manage those simultaneously.

The null way keeps compatibility with if (idlType.nullable) and can also benefit from future optional chaining syntax: idlType.nullable?.trivia.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the clarification, makes sense.

@saschanaz saschanaz merged commit ecebf30 into develop Jun 9, 2018
@saschanaz saschanaz deleted the type-trivia branch June 9, 2018 11:16
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