Microsoft/TypeScript

Please Allow Mixins to function properly with new-able types

Open

#53.737 geöffnet am 11. Apr. 2023

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: JSDocHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide