Skip to content

Incorrect typings for getSymbolAtLocation #15841

Closed
@donaldpipowitch

Description

@donaldpipowitch

TypeScript Version: 2.3.2

Code

From lib/typescript.d.ts#L1709:

        getSymbolAtLocation(node: Node): Symbol;

From src/services/goToDefinition.ts#L45:

        let symbol = typeChecker.getSymbolAtLocation(node);

        // Could not find a symbol e.g. node is string or number keyword,
        // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
        if (!symbol) {
            return undefined;
        }

Expected behavior:

Typings for getSymbolAtLocation should be getSymbolAtLocation(node: Node): Symbol | undefined;.

I just got undefined after using getSymbolAtLocation and didn't expected it.

Actual behavior:

Typings for getSymbolAtLocation don't include undefined as a possible return value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIRelates to the public API for TypeScriptBugA bug in TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions