Repository navigation
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63425 |
|
commit: |
fd2c403 to
09e4df1
Compare
| interface ArgumentPlaceholder <: Node { | ||
| type: "ArgumentPlaceholder"; | ||
| type: "ArgumentPlaceholder"; | ||
| ordinal?: NumericLiteral; |
There was a problem hiding this comment.
I am not fully convinces that NumericLiteral is the right node type to put in an argument placeholder. It has different parsing and printing rules, and any possible plugin logic that applies to NumericLiteral likely does not apply here.
I wonder if we could directly put it in the AST, like
interface ArgumentPlaceholder {
ordinal?: number;
}
(or even : bigint / : string)
There was a problem hiding this comment.
Good question. In estree/estree#334, I chose ordinal: NumericLiteral (Literal for estree) because:
- Whitespaces are allowed between
?and number, an AST node here provides better comment attachment as we don't have to fallback to the inner comments - Supports loose comparision for consumers:
if (node.ordinal) { /* process ordinal /* }just works, otherwise one would have toif (node.ordinal != null) { ... }to properly differentiate between?0and?. IIRC Other than NumericLiteral and NumberLiteralTypeAnnotation, we don't have other AST nodes that includes a number field, so it is error-prone for consumers here.
Like you said, they do have different parsing and printing rules, what do you think if we introduce a new AST type?
interface ArgumentPlaceholder <: Node {
type: "ArgumentPlaceholder";
ordinal: PlaceholderOrdinal | null;
}
interface PlaceholderOrdinal <: Node {
type: "PlaceholderOrdinal";
value: number;
}There was a problem hiding this comment.
That PlaceholderOrdinal node seems ok to me 👍
| // Placeholder ordinals must be decimal integer literals, so neither | ||
| // `jsescOption.numbers` nor the exponent form of large numbers applies | ||
| this.number( | ||
| raw ?? (Number.isInteger(value) ? BigInt(value).toString() : str), |
There was a problem hiding this comment.
In which case is the value not a Number.isInteger?
There was a problem hiding this comment.
Good qeustion, the parser does not accept floats, however currently the builder does not properly validate the invalid case such as t.argumentPlaceholder(t.numericLiteral(1.5)). I think we should fix that in the builder instead.
| this.next(); // eat `?` | ||
| if (this.match(tt.num)) { | ||
| if (disallowOrdinal) { | ||
| this.raise( |
There was a problem hiding this comment.
We should make this error unrecoverable, similar to the "missing plugin" error where we don't recover and silently enable it.
Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
09e4df1 to
3f729cf
Compare
2021-10version of the partial-application proposalThis PR includes parse & print supports of the
2021-10version. The Babel parser will now acceptsversion: "2021-10"as a valid candidate of thepartialApplicationparser plugin options. The parser will throw when users used the2018-07syntax within the2021-10syntax or vice. See thespec.mdfor the proposed AST change.