Skip to content

Bug Report: Wrong Documentation of Type Hint #488

@fuyuzheju

Description

@fuyuzheju

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 arguments has 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions