TypeScript: Support conditional types syntax (#7404)
Microsoft/TypeScript#21316 and Microsoft/TypeScript#21496
This commit is contained in:
@@ -801,6 +801,15 @@ export function assertTSIntersectionType(
|
||||
): void {
|
||||
assert("TSIntersectionType", node, opts);
|
||||
}
|
||||
export function assertTSConditionalType(
|
||||
node: Object,
|
||||
opts?: Object = {},
|
||||
): void {
|
||||
assert("TSConditionalType", node, opts);
|
||||
}
|
||||
export function assertTSInferType(node: Object, opts?: Object = {}): void {
|
||||
assert("TSInferType", node, opts);
|
||||
}
|
||||
export function assertTSParenthesizedType(
|
||||
node: Object,
|
||||
opts?: Object = {},
|
||||
|
||||
@@ -774,6 +774,16 @@ export function TSIntersectionType(...args: Array<any>): Object {
|
||||
}
|
||||
export { TSIntersectionType as tsIntersectionType };
|
||||
export { TSIntersectionType as tSIntersectionType };
|
||||
export function TSConditionalType(...args: Array<any>): Object {
|
||||
return builder("TSConditionalType", ...args);
|
||||
}
|
||||
export { TSConditionalType as tsConditionalType };
|
||||
export { TSConditionalType as tSConditionalType };
|
||||
export function TSInferType(...args: Array<any>): Object {
|
||||
return builder("TSInferType", ...args);
|
||||
}
|
||||
export { TSInferType as tsInferType };
|
||||
export { TSInferType as tSInferType };
|
||||
export function TSParenthesizedType(...args: Array<any>): Object {
|
||||
return builder("TSParenthesizedType", ...args);
|
||||
}
|
||||
|
||||
@@ -223,6 +223,25 @@ const unionOrIntersection = {
|
||||
defineType("TSUnionType", unionOrIntersection);
|
||||
defineType("TSIntersectionType", unionOrIntersection);
|
||||
|
||||
defineType("TSConditionalType", {
|
||||
aliases: ["TSType"],
|
||||
visitor: ["checkType", "extendsType", "trueType", "falseType"],
|
||||
fields: {
|
||||
checkType: validateType("TSType"),
|
||||
extendsType: validateType("TSType"),
|
||||
trueType: validateType("TSType"),
|
||||
falseType: validateType("TSType"),
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TSInferType", {
|
||||
aliases: ["TSType"],
|
||||
visitor: ["typeParameter"],
|
||||
fields: {
|
||||
typeParameter: validateType("TSType"),
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TSParenthesizedType", {
|
||||
aliases: ["TSType"],
|
||||
visitor: ["typeAnnotation"],
|
||||
|
||||
@@ -608,6 +608,12 @@ export function isTSUnionType(node: Object, opts?: Object): boolean {
|
||||
export function isTSIntersectionType(node: Object, opts?: Object): boolean {
|
||||
return is("TSIntersectionType", node, opts);
|
||||
}
|
||||
export function isTSConditionalType(node: Object, opts?: Object): boolean {
|
||||
return is("TSConditionalType", node, opts);
|
||||
}
|
||||
export function isTSInferType(node: Object, opts?: Object): boolean {
|
||||
return is("TSInferType", node, opts);
|
||||
}
|
||||
export function isTSParenthesizedType(node: Object, opts?: Object): boolean {
|
||||
return is("TSParenthesizedType", node, opts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user