Fix typings

This commit is contained in:
Pokey Rule 2021-05-02 18:23:29 +01:00
parent ae6fb8e0eb
commit dfd704101f
3 changed files with 9 additions and 7 deletions

View File

@ -182,14 +182,14 @@ const nodeMatchers = {
return null;
}
return simpleSelectionExtractor(node.keyNode);
return simpleSelectionExtractor(node.keyNode!);
},
pairValue(editor: TextEditor, node: SyntaxNode) {
if (node.type !== "pair") {
return null;
}
return simpleSelectionExtractor(node.valueNode);
return simpleSelectionExtractor(node.valueNode!);
},
argumentOrParameter: delimitedMatcher(
(node) =>
@ -217,8 +217,7 @@ const nodeMatchers = {
// }
if (
node.type === "public_field_definition" &&
// @ts-ignore
node.valueNode.type === "arrow_function"
node.valueNode!.type === "arrow_function"
) {
return simpleSelectionExtractor(node);
}
@ -234,8 +233,7 @@ const nodeMatchers = {
if (
child.type === "variable_declarator" &&
// @ts-ignore
child.valueNode.type === "arrow_function"
child.valueNode!.type === "arrow_function"
) {
return simpleSelectionExtractor(node);
}

View File

@ -190,7 +190,7 @@ function transformSelection(
.parent!.children.map((sibling) =>
nodeMatcher(selection.editor, sibling)
)
.filter((selection) => selection != null);
.filter((selection) => selection != null) as SelectionWithContext[];
} else {
matchedSelections = [matchedSelection];
}

View File

@ -87,6 +87,10 @@ declare module "tree-sitter" {
previousSibling: SyntaxNode | null;
previousNamedSibling: SyntaxNode | null;
// Added these because they sometimes exist
valueNode: SyntaxNode | null;
keyNode: SyntaxNode | null;
hasChanges(): boolean;
hasError(): boolean;
isMissing(): boolean;