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

Handle Recursive Interfaces #28

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Handle Recursive Interfaces #28

wants to merge 8 commits into from

Conversation

anthonyjoeseph
Copy link
Owner

Closes #27

@anthonyjoeseph
Copy link
Owner Author

anthonyjoeseph commented Apr 28, 2022

Progress report:

  • basic method is to track all parent interfaces for each path, and if a parent extends its child, break the recursion
  • Since we can't put the original type in the 'check' type (A extends Document ? true : false is safe, Document extends A ? true : false is not), we use a helper type called B_extends_A that is functionally equivalent and safe
  • Paths seems to work for types as complex as Paths<HTMLInputElement>, but Paths<Document> and Paths<Window> still crash
  • This is strange, because HTMLInputElement["ownerDocument"] = Document. This simplifies to Path<{ ownerDocument: Document }>, which does compile
  • Next step is to dig into why Paths<{ ownerDocument: Document }> cancels recursion 'better' than Paths<Document>
    • I suspect it's some implementation error with B_extends_A
    • pin down which path(s) are being 'broken' by the parent type { ownerDocument: Document }
  • Alternately, continue to investigate the boundary of types that crash - what does 'better' recursion cancellation mean?
    • I don't think it's type instantiation depth - Paths is only calling itself 5 or 6 times deep, far from the 1000-deep limit. Nothing else is recursive
    • could it be because Document is so wide? (i.e. has so many keys - as opposed to 'deep')
    • if width is an issue, maybe consider rejecting recursive types altogether
      • is 'detecting' recursive types less complex than 'handling' them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recursive Interfaces Cause Infinite Paths
1 participant