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

TypeDoc out of memory error in 0.15 #1150

Closed
Gerrit0 opened this issue Dec 24, 2019 · 5 comments · Fixed by #1153
Closed

TypeDoc out of memory error in 0.15 #1150

Gerrit0 opened this issue Dec 24, 2019 · 5 comments · Fixed by #1153
Assignees
Labels
bug Functionality does not match expectation

Comments

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 24, 2019

Hi @Gerrit0, I'm also getting the same error on my repo

https://github.com/pirix-gh/ts-toolbelt

npm run build:docs

This happens since my last update, where I made type distribution a default. So I suspect that typedoc tries to unfold types too much. I'd be nice if it could preserve the type "as it is" in the code.

Originally posted by @pirix-gh in #835 (comment)

@Gerrit0 Gerrit0 self-assigned this Dec 24, 2019
@Gerrit0 Gerrit0 added bug Functionality does not match expectation Priority: 1 labels Dec 24, 2019
@Gerrit0
Copy link
Collaborator Author

Gerrit0 commented Dec 24, 2019

This is happening because we call TypeScript's typeToString helper and compilerOptions.noTruncation is set. The _Assign type is recursive (against all of the TS's team recommendations, but ideally we shouldn't break on this), so we then go into an infinite loop expanding it.

https://github.com/pirix-gh/ts-toolbelt/blob/bd1c8914265d2206998348537dedbf9147fb1c50/src/Object/Assign.ts#L13-L20

@Gerrit0
Copy link
Collaborator Author

Gerrit0 commented Dec 24, 2019

It looks like fixing this specific case just requires adding a new type converter for types with kind IndexedAccessType

@millsp
Copy link

millsp commented Dec 24, 2019

Well, believe it or not, those same types are powering ramda. They are recursive types that are crafted not to overflow, the docs were generating properly before I started forcing distribution.

In any case, it's my bad, I was distributing a type that ended in a redistribution loop. So this is not a bug, it's my mistake and typedoc is working correctly 🎉

@Gerrit0
Copy link
Collaborator Author

Gerrit0 commented Dec 24, 2019

TypeDoc should still handle it correctly, so it is a bug I'd like to fix :) I have a fix for the JSON output, I just also need to verify that it works as expected when generating html.

The recursive types won't overflow - so long as they are passed a type. The issue here is TypeScript assumes they aren't recursive and can be fully expanded without a value.

Gerrit0 added a commit that referenced this issue Dec 26, 2019
closes #1150
closes #831 

* Added test for conditional types. i.e. `X extends A ? B : C`
  Currently results in { "type": "unknown", "name": "X extends A ? B : C" }
  See #831
* Add support for conditional type.
* add a test for infer
* feat: Add support for indexed access types

Co-authored-by: Adrian Leonhard <[email protected]>
@Gerrit0
Copy link
Collaborator Author

Gerrit0 commented Dec 26, 2019

Fix has been merged, I should get a release out later today :)

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

Successfully merging a pull request may close this issue.

2 participants