-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
[estree] Use null for optional fields in estree #15052
Conversation
estree/flow.d.ts to author (@RReverser). Could you review this PR? Checklist
estree/index.d.ts to author (@RReverser). Could you review this PR? Checklist
|
While I'm on board with allowing explicit
While we potentially might go through each type and make decisions on whether it's ok to have such field optional or we want explicit |
So @RReverser and @ivogabe is this PR ready to go or not? |
@mhegazy It's not. |
The spec says the following:
Though I understand that the spec could be interpreted less strictly. So I've looked at implementations in various projects. It appears that parsers (Babylon, Esprima, Acorn) do explicitly set Some consumers check for So I'm not sure what the best approach would be. I'd like to have it as strict as possible; maybe mark only |
@ivogabe ESLint and Babili can allow themselves to perform stricter checks as they're getting information directly from parser, but in general for the format explicit Problem with marking fields as non-optional and with type of |
Do you have concrete examples of transforms which do set |
@ivogabe It's not about setting |
FWIW, this is also how Babel (which uses fork of ESTree, but still pretty close) defines such fields: https://github.com/babel/babel/blob/d33d02359474296402b1577ef53f20d94e9085c4/lib/types.js#L75-L78 |
Ok, I've marked them optional again in af72627. I think that the spec could be clarified on this topic, so I opened estree/estree#158. Are the changes here ok? |
@RReverser good to go now? |
@ivogabe Can you please change some of tests back so that they would cover both optional and explicit null syntaxes? |
We've recently updated the repository structure. |
Repository change structure just in time :( |
@ivogabe last ping on fixing merge conflicts |
Sorry for the long delay, will update this today |
master
branch.tsc
without errors.npm run lint package-name
if atslint.json
is present.Select one of these and delete the others:
If changing an existing definition:
tslint.json
containing{ "extends": "../tslint.json" }
.Optional fields are currently marked with
?
, meaning that the field may beundefined
, but notnull
. Though the specification at https://github.com/estree/estree/blob/master/es5.md#node-objects uses| null
for optional fields (and they really meannull
, notnull | undefined
). This PR fixes this.One exception:
async
andgenerator
are marked optional and I kept it that way, since they are optional since they were added in a language extension. So these properties can be absent when using a tool that works with ES5.@RReverser Do you agree?