Skip to content

Bug that kill TypeScript build time #57075

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

Closed
nisimjoseph opened this issue Jan 16, 2024 · 6 comments
Closed

Bug that kill TypeScript build time #57075

nisimjoseph opened this issue Jan 16, 2024 · 6 comments
Labels
Not a Defect This behavior is one of several equally-correct options

Comments

@nisimjoseph
Copy link

πŸ”Ž Search Terms

"long time", "stuck build"

πŸ•— Version & Regression Information

  • Occur on all versions.

⏯ Playground Link

No response

πŸ’» Code

export type HtmlAnchorTarget = '_self' | '_blank' | '_parent' | '_top';

type CssAbsoluteUnit = 'cm' | 'mm' | 'in' | 'px' | 'pt' | 'pc';
type CssRelativeUnit = 'em' | 'ex' | 'ch' | 'rem' | 'vw' | 'vh' | 'vmin' | 'vmax' | '%';

export type CssLength = `${number}${CssAbsoluteUnit | CssRelativeUnit}`;
export type CssMargin = CssLength | `${CssLength} ${CssLength}` | `${CssLength} ${CssLength} ${CssLength} ${CssLength}`;

πŸ™ Actual behavior

the build time grow exponential because of the amount of permutations we have and it Stuck the IDE completely and make the TSC to take 4-5x more build time.

πŸ™‚ Expected behavior

run faster

Additional information about the issue

just change the line:

export type CssMargin = CssLength | `${CssLength} ${CssLength}` | `${CssLength} ${CssLength} ${CssLength} ${CssLength}`;

to:

export type CssMargin = CssLength | string;

and all run fast.

@RyanCavanaugh
Copy link
Member

    `${CssLength} ${CssLength} ${CssLength} ${CssLength}`

This type is a shorthand for writing the 50,000+-member expansion of all its possible values, so its performance is the same as if you had written a 50,000-member type.

@RyanCavanaugh RyanCavanaugh added the Not a Defect This behavior is one of several equally-correct options label Jan 16, 2024
@nisimjoseph
Copy link
Author

You are right, this is not a defect or a bug.
We discovered that today, but the issue is we didn't know about it until we tracked back in all the code for the last 2 weeks, and it lot of code.
it was good to have some kind of warning in the compile time to note there is a potential issue with X that can cause a long build time, or something like that.

@RyanCavanaugh
Copy link
Member

There is a threshold for an error, but this sample is slightly below it

@nisimjoseph
Copy link
Author

so the threshold is 50k and we reach to little lower. ok.
can we config this threshold? 50k is too much and pretty kill the compiler time.

@MartinJohns
Copy link
Contributor

It's not configurable, and likely won't be: #44997 (comment)

@nisimjoseph
Copy link
Author

10x for the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a Defect This behavior is one of several equally-correct options
Projects
None yet
Development

No branches or pull requests

3 participants