[bug] declaration files have invalid class member generics with mixin & multiple layer inheritance

Open
#60,697 0 comments 0 reactions 1 assignee View on GitHub

@weswigham is already working on this.

Since Dec 6, 2024.

Assessment

This issue has not been assessed yet.

Description

Bug Domain: Declaration Emit
🔎 Search Terms

declaration .d.ts invalid class member field generic mixin inherit

🕗 Version & Regression Information
  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______
⏯ Playground Link

https://www.typescriptlang.org/play/?#code/MYGwhgzhAEBCkFMA8AVAfNA3gKGn6EArgA4IBOAsggLYBG50AvFgL7STQrYvbAD2AOwgAXaBQCWAD3ECm0JABEwwsABpoAYXBRoCScIQCAJjAEIA7tAAUAOjtHlYAFzsBATwDaAXQCUTDPAQyEoqaGi4+FYAyiTkLlqQEH6MGKCJuvqGJtAxpGRYEfj41FIyVHQMzACMhdAsQA

💻 Code
class Base<T> {
    superMember = {} as T
}
const Mixin = <Data, Class extends new (...data: any[]) => Base<Data>>
    (Super: Class) => class extends Super {
        mixinMember = 1
    }
🙁 Actual behavior
declare class Base<T> {
    superMember: T;
}
declare const Mixin: <Data, Class extends new (...data: any[]) => Base<Data>>(Super: Class) => {
    new (...data: any[]): {
        mixinMember: number;
        superMember: T;  // invalid generic variable in .d.ts
    };
} & Class;
🙂 Expected behavior

tsc generates completely valid .d.ts files with mixin inheritance.

Additional information about the issue

No response

Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/TypeScript

All issues in microsoft/TypeScript

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.