Partial Application Syntax: Stage 1 (#9343)
* add partial application syntax and some tests * remove unnecessary error message and hasPartial function from parseNewArguments * add types for PartialExpression * Update the tests * rename PartialExpression to Partial * move Partial from expressions to types and rename to ArgumentPlaceholder * add tests for ArgumentPlaceholder in babel-generator * rename Partial to ArgumentPlaceholder * update the tests * remove alias from the type and undo changes in generated folder * adds a nice error message * better definition for the type * auto-generated files * update the conditional for allowPlaceholder message and tests * update CallExpression definition to accept ArgumentPlaceholder * change description * clean up * indent ArgumentPlaceholder entry and revert unwanted changes
This commit is contained in:
committed by
Nicolò Ribaudo
parent
37a427f692
commit
c60c4dd375
@@ -660,6 +660,12 @@ export function assertParenthesizedExpression(
|
||||
): void {
|
||||
assert("ParenthesizedExpression", node, opts);
|
||||
}
|
||||
export function assertArgumentPlaceholder(
|
||||
node: Object,
|
||||
opts?: Object = {},
|
||||
): void {
|
||||
assert("ArgumentPlaceholder", node, opts);
|
||||
}
|
||||
export function assertAwaitExpression(node: Object, opts?: Object = {}): void {
|
||||
assert("AwaitExpression", node, opts);
|
||||
}
|
||||
|
||||
@@ -596,6 +596,10 @@ export function ParenthesizedExpression(...args: Array<any>): Object {
|
||||
return builder("ParenthesizedExpression", ...args);
|
||||
}
|
||||
export { ParenthesizedExpression as parenthesizedExpression };
|
||||
export function ArgumentPlaceholder(...args: Array<any>): Object {
|
||||
return builder("ArgumentPlaceholder", ...args);
|
||||
}
|
||||
export { ArgumentPlaceholder as argumentPlaceholder };
|
||||
export function AwaitExpression(...args: Array<any>): Object {
|
||||
return builder("AwaitExpression", ...args);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,12 @@ defineType("CallExpression", {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(
|
||||
assertNodeType("Expression", "SpreadElement", "JSXNamespacedName"),
|
||||
assertNodeType(
|
||||
"Expression",
|
||||
"SpreadElement",
|
||||
"JSXNamespacedName",
|
||||
"ArgumentPlaceholder",
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
classMethodOrDeclareMethodCommon,
|
||||
} from "./es2015";
|
||||
|
||||
defineType("ArgumentPlaceholder", {});
|
||||
|
||||
defineType("AwaitExpression", {
|
||||
builder: ["argument"],
|
||||
visitor: ["argument"],
|
||||
|
||||
@@ -2093,6 +2093,20 @@ export function isParenthesizedExpression(
|
||||
|
||||
return false;
|
||||
}
|
||||
export function isArgumentPlaceholder(node: ?Object, opts?: Object): boolean {
|
||||
if (!node) return false;
|
||||
|
||||
const nodeType = node.type;
|
||||
if (nodeType === "ArgumentPlaceholder") {
|
||||
if (typeof opts === "undefined") {
|
||||
return true;
|
||||
} else {
|
||||
return shallowEqual(node, opts);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
export function isAwaitExpression(node: ?Object, opts?: Object): boolean {
|
||||
if (!node) return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user