Skip to content
New issue

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

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

Already on GitHub? # to your account

[BUG] typescript complier RangeError: Maximum call stack size exceeded #2066

Closed
Jordan-Hall opened this issue May 26, 2022 · 7 comments · Fixed by #2070
Closed

[BUG] typescript complier RangeError: Maximum call stack size exceeded #2066

Jordan-Hall opened this issue May 26, 2022 · 7 comments · Fixed by #2070

Comments

@Jordan-Hall
Copy link

Repo: https://github.com/communitiesuk/gov-uk-dash-react-components/tree/move-to-ts

Output:

c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:52545
                        return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes);
                                                                                       ^

RangeError: Maximum call stack size exceeded
    at typeToTypeNodeHelper (c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:52545:88)
    at serializeTypeForDeclaration (c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:53892:30)
    at symbolToParameterDeclaration (c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:53321:41)
    at c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:53231:274
    at Array.map (<anonymous>)
    at signatureToSignatureDeclarationHelper (c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:53231:240)
    at createTypeNodesFromResolvedType (c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:52990:43)
    at createTypeNodeFromObjectType (c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:52837:35)
    at visitAndTransformType (c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:52764:34)
    at createAnonymousTypeNode (c:\dev\clients\communitiesuk\uk_gov_dash_components\node_modules\typescript\lib\typescript.js:52702:36)

Error generating metadata in uk_gov_dash_components (status=1)
@Jordan-Hall
Copy link
Author

@T4rk1n I can take a look soon. I assume its you that will be dealing with TS complier at plotly

@Jordan-Hall Jordan-Hall changed the title [BUG] typescript complier exceed call stack [BUG] typescript complier RangeError: Maximum call stack size exceeded May 26, 2022
@T4rk1n
Copy link
Contributor

T4rk1n commented May 26, 2022

@Jordan-Hall I had a look at your repo, in the Autocomplete, you have this prop: https://github.com/communitiesuk/gov-uk-dash-react-components/blob/7e31d073aeca2cc5f7eb3b28686bc6c2112cc632/src/ts/components/AutoComplete.tsx#L127

Its the default typescript lib.dom.d.ts HTMLSelectElement and that is where the error come, I don't think those are supported as props.

@alexcjohnson
Copy link
Collaborator

That's an awfully cryptic way to tell you a type is unsupported! If that's indeed the issue, is there any way we can make that friendlier?

@Jordan-Hall
Copy link
Author

Its the default typescript lib.dom.d.ts HTMLSelectElement and that is where the error come, I don't think those are supported as props.

Tried changing that to any and still getting same issue

@T4rk1n
Copy link
Contributor

T4rk1n commented May 27, 2022

This error is with nested types when resolving the type of the properties of shapes, the behavior can be reproduced with a nested type like this:

type Nested = {
    nested: Nested;
}

type Props = {
   nested: Nested;
}

Some types in the dom lib are nested so they bug:

const NESTED_TYPES = [
    'ChildNode',
    'HTMLElement',
    'ParentNode',
    'HTMLSlotElement',
    'CSSRule'
];

Can also add Document and ShadowRoot to types that incur a nesting in their type tree.

@Jordan-Hall
Copy link
Author

@T4rk1n Its now saying

    Object.entries(doc.props).forEach(([name, p]) =>
           ^

TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)

Any suggestions. Sorry to be a pain

@Jordan-Hall
Copy link
Author

Aww never mind its a completely different bug. I've found the reason and I know the solutions (I think) Its because of exporting mutiple things in the file (which I think should be allowed. I'll come up with a solution and create PR

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

Successfully merging a pull request may close this issue.

3 participants