mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
fix(43313): add parentheses to a type assertions (#43315)
This commit is contained in:
@@ -2516,8 +2516,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function needsParentheses(expression: Expression) {
|
||||
return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken || isObjectLiteralExpression(expression);
|
||||
export function needsParentheses(expression: Expression): boolean {
|
||||
return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken
|
||||
|| isObjectLiteralExpression(expression)
|
||||
|| isAsExpression(expression) && isObjectLiteralExpression(expression.expression);
|
||||
}
|
||||
|
||||
export function getContextualTypeFromParent(node: Expression, checker: TypeChecker): Type | undefined {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////const a = /*a*/()/*b*/ => {
|
||||
//// return {} as {}
|
||||
////};
|
||||
|
||||
goTo.select("a", "b");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Add or remove braces in an arrow function",
|
||||
actionName: "Remove braces from arrow function",
|
||||
actionDescription: "Remove braces from arrow function",
|
||||
newContent: `const a = () => ({} as {});`,
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////const a = /*a*/()/*b*/ => {
|
||||
//// return {} as object
|
||||
////};
|
||||
|
||||
goTo.select("a", "b");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Add or remove braces in an arrow function",
|
||||
actionName: "Remove braces from arrow function",
|
||||
actionDescription: "Remove braces from arrow function",
|
||||
newContent: `const a = () => ({} as object);`,
|
||||
});
|
||||
Reference in New Issue
Block a user