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

Out of memory on React dynamic tag #31227

Closed
dragomirtitian opened this issue May 3, 2019 · 4 comments
Closed

Out of memory on React dynamic tag #31227

dragomirtitian opened this issue May 3, 2019 · 4 comments
Labels
Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: Performance Reports of unusually slow behavior Fixed A PR has been merged for this issue

Comments

@dragomirtitian
Copy link
Contributor

dragomirtitian commented May 3, 2019

TypeScript Version: 3.5.0-dev.20190503

Search Terms: performance, Out of memory, 3.4

Code

interface CompProps {
  tag: keyof JSX.IntrinsicElements;
}

const MyComponent: React.FunctionComponent<CompProps> = ({
  tag = "div",
  children
}) => {
  const Wrapper = tag;

  return <Wrapper>{children}</Wrapper>;
};

Expected behavior:
Code type checks

Actual behavior:
on 3.3: OK
on 3.4, 3.5: JavaScript heap out of memory

Playground Link: link

Related Issues: #30663 (which was closed), maybe #30819 or #30973 (not sure if same root cause with either)

Note: Found while answering this SO question

@confusingstraw
Copy link

I believe it is just the usage of keyof JSX.IntrinsicElements, as adding that to an interface in one of my projects causes the same issue.

@dragomirtitian
Copy link
Contributor Author

@rgfoley keyof JSX.IntrinsicElements is an unusually large union, there were several some issues 3.4 with unions and distributive conditional over them. Maybe you could also post the code that is causing issues for you ?

@weswigham weswigham added Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: Performance Reports of unusually slow behavior Needs Investigation This issue needs a team member to investigate its status. labels May 8, 2019
@confusingstraw
Copy link

@dragomirtitian Any usage of keyof JSX.IntrinsicElements is enough to cause the issue. I don't get any problems when using keyof HTMLElementTagNameMap. This code seems to reproduce it (the TSC language server bit of my editor stops providing autocompletion and memory usage spikes after adding it):

interface IProps {
  isOpen: boolean;
  tag?: keyof JSX.IntrinsicElements;
}

const foo: IProps = {
  isOpen: true,
  tag: 'span',
};

winsvold pushed a commit to navikt/modiapersonoversikt that referenced this issue May 14, 2019
…3.* til 3.4.* ble det noe tull med typesystemet som gjorde at typesjekkinga tok evigheter.

Følg med her for å se når det er løst: microsoft/TypeScript#31227, microsoft/TypeScript#30663
@dragomirtitian
Copy link
Contributor Author

Seems to have been fixed in latest nightly builds.

@RyanCavanaugh RyanCavanaugh added Fixed A PR has been merged for this issue and removed Needs Investigation This issue needs a team member to investigate its status. labels May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Domain: Performance Reports of unusually slow behavior Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants