phryneas / remark-typescript-tools

MIT License
129 stars 7 forks source link

Nested identifiers don't work with `Type`, only `Interface` #4

Closed Shrugsy closed 3 years ago

Shrugsy commented 3 years ago

Description

Nested identifiers will work for an Interface, but not a Type. The plugin is unable to locate the nested properties for a Type.

Example

export interface TestInterface {
  /**
   * A summary for foo
   */
  foo: () => void;
}

export type TestType = {
  /**
   * A summary for foo
   */
  foo: () => void;
};

Working link

[summary](docblock://test.ts?token=TestInterface.foo]

Broken link

[summary](docblock://test.ts?token=TestType.foo]

This would show:

could not find overload 0 for TestType.foo in test.ts
phryneas commented 3 years ago

Yeah, there's not really an easy fix for that. The plugin works on AST level (so reaslistically speaking, still on "string level"), and while an interface is easy to parse there, a type like type X = A ? B : C is impossible to parse to make any sense. What I usually do is move out parts of a type into an interface and reference that.

Shrugsy commented 3 years ago

Yeah, there's not really an easy fix for that. The plugin works on AST level (so reaslistically speaking, still on "string level"), and while an interface is easy to parse there, a type like type X = A ? B : C is impossible to parse to make any sense. What I usually do is move out parts of a type into an interface and reference that.

Sounds good to me, thanks