Microsoft/TypeScript

Please Allow Mixins to function properly with new-able types

Open

#53,737 创建于 2023年4月11日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: JSDocHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

Bug Report

If we declare a new-able type, that is a mixin with the generic parameter it uses, the whole type is not processed. For example, doing this, won't work

// In types.d.ts
namespace test.ts.bug{
    var MyType: {
        new <T>(): T & {
            additional: "somevalue"
        };
    }
}
// Then, in VS code, we make use of the type as such
/** @extends {test.ts.bug.MyType<{tsc: "cool"|"sweet"}>} */
class SomeClass extends Object{
}
const myVar = new SomeClass()

Suppose you try to use myVar, you won't see the any of the properties corrected listed, and auto-completed.

However, if you declared it like this

// In types.d.ts
namespace test.ts.working{
    var MyType: {
        new <T>():  {
            additional: "somevalue";
            main: T
        };
    }
}

And obviously, did the following in js

// Then, in VS code, we make use of the type as such
/** @extends {test.ts.working.MyType<{tsc: "cool"|"sweet"}>} */
class SomeClass extends Object{
}
const myVar = new SomeClass()

then with const myVar = new SomeClass(), the properties additional, and main.tsc are auto-completed very well.

🔎 Search Terms

mixins new-able newable types

🕗 Version & Regression Information

Same version with vs code

⏯ Playground Link

Playground link with relevant code

🙁 Actual behavior

const myVar = new SomeClass() doesn't auto-complete in VS code

🙂 Expected behavior

const myVar = new SomeClass() is supposed to have the tsc, and additional set to true

贡献者指南