-
-
Notifications
You must be signed in to change notification settings - Fork 70
Description
I found the type inference provided in the documentation wrong when i tried to use show_documentation() to view it.
In my example, here TreeOperationInterfaces should be Arrays of arguments, but the documentation given by occ-tsserver said it should be Functions, just the same documentation given by as TreeOperations.
As a test, I wrote an A type to check the type inference. the documentation of A is false, which is correct. But the documentation given by coc-tsserver of TreeOperationInterfaces was wrong.
I also checked VSCode, the LSP there gave the correct answer: TreeOperationInterfaces as Arrays of arguments.
Actually here every method has only one argument(an object), and the
Array of argumentshas only one elements
I met with this problem with the code below:
export default class Tree {
constructor() {
}
addNode = ({parentNodeId,
newNodeName,
newNodeId = "ABC"}:
{parentNodeId: string, newNodeName: string, newNodeId?: string,}
): number => {
return 0;
}
reopenNode = ({nodeId}: {nodeId: string}): number => {
return 0;
}
completeNode = ({nodeId}: {nodeId: string}): number => {
return 0;
}
removeNode = ({nodeId}: {nodeId: string}): number => {
return 0;
}
removeSubtree = ({nodeId}: {nodeId: string}): number => {
return 0;
}
moveNode = ({nodeId, newParentId}: {nodeId: string, newParentId: string}): number => {
return 0;
}
}
type TreeOperations = {
[P in keyof Tree as
Tree[P] extends (args: any) => number ?
P : never]: Tree[P]
};
type TreeOperationInterfaces = {
[P in keyof TreeOperations]:
Tree[P] extends (...args: infer U) => number ?
U : never
}
type A = TreeOperationInterfaces["removeNode"] extends Function ? true : false