Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Library Beta] TypeScript DOM lib types used in Omit<> aren't linked #1386

Closed
MasterKale opened this issue Oct 28, 2020 · 5 comments
Closed
Labels
bug Functionality does not match expectation

Comments

@MasterKale
Copy link

MasterKale commented Oct 28, 2020

Search terms

lib.dom.d.ts interfaces

Expected Behavior

DOM lib interfaces used in an Omit<> should be included in doc output and clickable to jump down to that section of the page.

Actual Behavior

Doc output does not include the base DOM lib interface I'm extending via an Omit<>:

export interface PublicKeyCredentialCreationOptionsJSON
  extends Omit<PublicKeyCredentialCreationOptions, 'challenge' | 'user' | 'excludeCredentials'> {
  // ...
}

Screen Shot 2020-10-28 at 8 01 10 AM

TypeDoc handles basic extends just fine, though:

export interface AssertionCredential extends PublicKeyCredential {
  // ...
}

Screen Shot 2020-10-28 at 7 37 43 AM

Both PublicKeyCredentialCreationOptions and PublicKeyCredential are declared in TypeScript's lib.dom.d.ts

Steps to reproduce the bug

I've created a minimal reproduction repo here: https://github.com/MasterKale/typedoc-bug-repro-1386

Environment

  • Typedoc version: 0.20.0-beta.4
  • TypeScript version: 3.9.7
  • Node.js version: v14.9.0
  • OS: macOS 10.15.7
@MasterKale MasterKale added the bug Functionality does not match expectation label Oct 28, 2020
@MasterKale MasterKale changed the title TypeScript DOM lib types used in Omit<> aren't linked [Library Beta] TypeScript DOM lib types used in Omit<> aren't linked Oct 28, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 31, 2020

I spent a bit of time looking into this, and unfortunately making it work properly is going to be rather tricky... The way TypeDoc currently handles inheritance is... horrible. This will be first on my list for next week, but I doubt I'll get it this week.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 6, 2020

Well, a couple hours in... and this is a systematic problem. TypeDoc's converters work according to nodes, which is fine, until you start using more complicated types. Pick/Omit is bad enough. It's going to get worse with TS 4.1's key remapping features... I think to fix this I need to rework the converters to ask the type checker what properties a given symbol has, and work on that.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 25, 2020

image

v0.20.0-beta.9 fixes this :)

@MasterKale
Copy link
Author

MasterKale commented Nov 26, 2020

@Gerrit0 That's great progress! 🤩

Now, what would it take to get things like AttestationConveyancePreference and AuthenticatorSelectionCriteria in that screenshot clickable so that you can see what those values are? Is that something devs like me would need to change about our code to get TypeDoc to include them in our docs? Ideally it'd be possible to click down until you get to the primitive types of the values that actually need to be specified without having to open up the TypeScript DOM lib separately.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 26, 2020

TypeDoc 0.20 documents items based on what you export, so you'd have to export those interfaces. Unfortunately... TS doesn't like that.

Error: C:/Users/gtbir/Desktop/library-tests/src/gh1386.ts(7)
 Cannot export 'PublicKeyCredentialCreationOptions'. Only local declarations can be exported from a module.

I don't have a good way around this yet. I'd really like to link dom values to MDN, @types/node values to the node docs... etc. But every single library has their own docs site, own link style... and those might change, which makes maintenance next to impossible. @bennypowers has a script that does this for MDN, but it's horribly hacky...

I think it should be possible to define a plugin which handles creating these links in a reasonable manner, with codegen that makes updates mostly automatic... but that's a project unto itself. It would make TypeDoc a much better tool though... Can't commit to looking into that right now. Maybe during end of year shutdown?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants