mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
remove hasBraceShell and add namedBindings check
This commit is contained in:
@@ -478,20 +478,13 @@ namespace ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
function hasBraceShell(node: Node) {
|
||||
let children = node.getChildren();
|
||||
let last = children.length - 1;
|
||||
// Check if node looks like a block
|
||||
return children[0] && children[0].kind === SyntaxKind.OpenBraceToken &&
|
||||
children[last] && children[last].kind === SyntaxKind.CloseBraceToken;
|
||||
}
|
||||
|
||||
export function isIndentationPrevented(node: TextRangeWithKind) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.NamedExports:
|
||||
return hasBraceShell(<NamedExports>node);
|
||||
return true;
|
||||
// Allow indentation only when namedBindings is NamespaceImport.
|
||||
case SyntaxKind.ImportClause:
|
||||
return hasBraceShell((<ImportClause>node).namedBindings);
|
||||
return (<ImportClause>node).namedBindings.kind === SyntaxKind.NamedImports;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user