question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getDefinitionAtPosition doesn't distinguish different kinds in a merged declaration

See original GitHub issue

TypeScript Version: 2.7.2

Search Terms: getDefinitionAtPosition kind

Code

namespace A { export interface B {} }
class A {}
interface A {}

var x: A; // do getDefinitionAtPosition on the A reference here

Expected behavior: In the result, each of the individual declarations should have the appropriate kind:

[
    { fileName: 'test.ts', textSpan: { start: 10, length: 1 }, kind: 'module', name: 'A', ... },
    { fileName: 'test.ts', textSpan: { start: 44, length: 1 }, kind: 'class', name: 'A', ... },
    { fileName: 'test.ts', textSpan: { start: 59, length: 1 }, kind: 'interface', name: 'A', ... }
]

Actual behavior: All declarations have the same kind:

[
    { fileName: 'test.ts', textSpan: { start: 10, length: 1 }, kind: 'class', name: 'A', ... },
    { fileName: 'test.ts', textSpan: { start: 44, length: 1 }, kind: 'class', name: 'A', ... },
    { fileName: 'test.ts', textSpan: { start: 59, length: 1 }, kind: 'class', name: 'A', ... }
]

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mhegazycommented, May 15, 2018

I’ve narrowed it down to the getSymbolAtLocation function in checker.ts. Is that the right track so far?

You do not want to change this one. instead, when you have a definition you want to get its meaning, using getMeaningFromLocation and filtering the definitions you have to match the meaning you are looking for.

See the use of hasMatchingMeaning in findAllRefernces.ts

0reactions
kristielimcommented, Jan 29, 2021

it has not, feel free to take it on!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Declaration Merging - TypeScript
For the purposes of this article, “declaration merging” means that the compiler merges two separate declarations declared with the same name into a...
Read more >
Merging Declarations in TypeScript | by John Au-Yeung
The process of declaration merging is the combining of multiple members from different sources with overlapping member names or types.
Read more >
typescript - UNPKG
621, export interface Identifier extends PrimaryExpression, Declaration { ... 780, * Several node kinds share function-like features such as a signature,.
Read more >
In defense of interface: Using declaration merging to disable ...
This post explains what declaration merging is, why it is, ... not merged; see Item 13: Know the Differences Between type and interface...
Read more >
https://raw.githubusercontent.com/microsoft/TypeSc...
interface Push<T> { push(...values: T[]): void; } } declare namespace ts { export type Path = string & { __pathBrand: any; }; export...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found