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

Regression in DTS generation between TypeScript 5.6 and 5.7 #60506

Closed
crisbeto opened this issue Nov 15, 2024 · 3 comments
Closed

Regression in DTS generation between TypeScript 5.6 and 5.7 #60506

crisbeto opened this issue Nov 15, 2024 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@crisbeto
Copy link

crisbeto commented Nov 15, 2024

πŸ”Ž Search Terms

.d.ts generation, TypeScript 5.7

πŸ•— Version & Regression Information

  • This changed between versions 5.6.3 and 5.7.1-rc

⏯ Playground Link

Note: look at the ".D.TS" tab in the playground

https://www.typescriptlang.org/play/?ts=5.7.1-rc#code/KYDwDg9gTgLgBAYwDYEMDOa4DFoFsDCEAdjFBEgDwAqAfHAN4BQccAbikgK7ACEAXHCoBuRgF9GoSLESoM2PAHEynMNTpMWCYqXJp+gkeMbJ0mHFFwAhTgEskAE2BQGzOAHNlqqnFAxgRe0x6URoACldNbTIkNAEqABpXAEoBc1wlCBUKegBtAGk4GyI4AGtgAE8IADNBAF1UvEISaOp82poQlxYWKGAYTihiok4kJB4RFnEjLSI0eCqAIzgAXjgiYAB3eQtrO0coUKSRRgB6E7gAOnsLmExe-sG4GHKwYELMIq0oXoR4IrgAKwXADsFwAjABaKAIOCZGBgTgwPinc4sNIZLL0ewoGAoARzKBFNw5WpwAA+axGSBCKLgAElikCAGwXADMyLO3XRnmy2NxDQsTR0lAJRJJ5Mpow6NAk4Gg804RF+NmI7j6GLAhy6cHuA2KiwuHkymo03T5eLg4vQcFFRGJpIpw1GiUmRzEjFpAHUbDAABb-P02TBVOzAeJPX1vZ6vWE1AAGbnVnkOcfecA4GxQ5UwXx+MHDaAgtMDmBQCAQwDkGazmA20BKaAujETMA1hwuM2FjfNF3YXGAQiAA

πŸ’» Code

export class FormControl<T> {
  value!: T;
}
export class FormGroup<T> {
  controls!: T;
}

class FormBuilder {
  group<T extends {}>(
    controls: T,
  ): FormGroup<{[K in keyof T]: FormControl<T[K]>}> {
    return null!;
  }
}

const fb = new FormBuilder();

export function getGroup() {
  return fb.group({
    data: [] as string[] | null,
  });
}

πŸ™ Actual behavior

Given the code above, TypeScript 5.7 produces a .d.ts file that looks like this:

export declare function getGroup(fb: FormBuilder): FormGroup<{
    data: string[] | null; // <----- Incorrect
}>;

πŸ™‚ Expected behavior

It should produce something like this:

export declare function getGroup(fb: FormBuilder): FormGroup<{
    data: FormControl<string[] | null>;
}>;

Additional information about the issue

Source code of Angular's FormBuilder: https://github.com/angular/angular/blob/main/packages/forms/src/form_builder.ts

@alxhub
Copy link

alxhub commented Nov 15, 2024

Note that within the file, getGroup()'s type is correct. It's only the .d.ts emit that shows the bug.

crisbeto added a commit to crisbeto/angular that referenced this issue Nov 19, 2024
Adjusts the return type of `FormBuilder.group` to work around microsoft/TypeScript#60506.
AndrewKushnir pushed a commit to angular/angular that referenced this issue Nov 19, 2024
Adjusts the return type of `FormBuilder.group` to work around microsoft/TypeScript#60506.

PR Close #58731
AndrewKushnir pushed a commit to angular/angular that referenced this issue Nov 19, 2024
Adjusts the return type of `FormBuilder.group` to work around microsoft/TypeScript#60506.

PR Close #58731
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Dec 2, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.8.0 milestone Dec 2, 2024
@weswigham
Copy link
Member

This was fixed by #60576 (ref #60573 which dupes this)

@weswigham weswigham added the Fixed A PR has been merged for this issue label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

5 participants