Skip to content

Regression in DTS generation between TypeScript 5.6 and 5.7Β #60506

Closed

Description

πŸ”Ž 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

Activity

  1. alxhub commented on Nov 15, 2024

    @alxhub

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

  2. weswigham commented on Dec 4, 2024

    @weswigham
    Member

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

  3. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions