Skip to content

Commit

Permalink
fix: unhandled object binding pattern node
Browse files Browse the repository at this point in the history
  • Loading branch information
plantain-00 committed Jan 14, 2018
1 parent d47b6fe commit 9502818
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
14 changes: 5 additions & 9 deletions spec/result.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ src/index.ts:29:49: version
src/index.ts:35:26: suppressError
src/index.ts:37:34: p
src/index.ts:37:44: project
174
src/index.ts:51:13: config
src/index.ts:55:43: config
src/index.ts:55:50: include
src/index.ts:56:43: config
Expand All @@ -16,18 +16,16 @@ src/index.ts:65:49: config
src/index.ts:65:56: compilerOptions
src/index.ts:71:11: detail
src/index.ts:71:25: detail
174
src/index.ts:78:51: intrinsicName
src/index.ts:79:21: detail
174
src/index.ts:78:51: intrinsicName
src/index.ts:79:21: detail
src/index.ts:29:39: v
src/index.ts:29:49: version
src/index.ts:35:26: suppressError
src/index.ts:37:34: p
src/index.ts:37:44: project
174
src/index.ts:51:13: config
src/index.ts:55:43: config
src/index.ts:55:50: include
src/index.ts:56:43: config
Expand All @@ -40,13 +38,11 @@ src/index.ts:65:49: config
src/index.ts:65:56: compilerOptions
src/index.ts:71:11: detail
src/index.ts:71:25: detail
174
src/index.ts:78:51: intrinsicName
src/index.ts:79:21: detail
174
src/index.ts:78:51: intrinsicName
src/index.ts:79:21: detail
src/index.ts:336:9: error
src/index.ts:339:21: error
3122 / 3166 99%
src/index.ts:349:9: error
src/index.ts:352:21: error
3260 / 3306 99%
type-coverage success.
15 changes: 14 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,19 @@ async function executeCommandLine() {
}
} else if (node.kind === ts.SyntaxKind.Identifier) {
collectData(node, file, sourceFile);
} else if (node.kind === ts.SyntaxKind.ObjectBindingPattern) {
const objectBindingPattern = node as ts.ObjectBindingPattern;
if (objectBindingPattern.elements) {
for (const element of objectBindingPattern.elements) {
handleNode(element, file, sourceFile);
}
}
} else if (node.kind === ts.SyntaxKind.BindingElement) {
const bindingElement = node as ts.BindingElement;
collectData(bindingElement.name, file, sourceFile);
if (bindingElement.initializer) {
collectData(bindingElement.initializer, file, sourceFile);
}
} else if (node.kind === ts.SyntaxKind.EndOfFileToken
|| node.kind === ts.SyntaxKind.NumericLiteral
|| node.kind === ts.SyntaxKind.StringLiteral
Expand All @@ -310,7 +323,7 @@ async function executeCommandLine() {
|| node.kind === ts.SyntaxKind.RegularExpressionLiteral) {
// do nothing
} else {
console.log(node.kind);
console.log(`warning: unhandled node kind: ${node.kind}`);
}
}

Expand Down

0 comments on commit 9502818

Please sign in to comment.