Skip to content

A Constructor type #54428

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

Closed
5 tasks done
Malix-Labs opened this issue May 28, 2023 · 2 comments
Closed
5 tasks done

A Constructor type #54428

Malix-Labs opened this issue May 28, 2023 · 2 comments

Comments

@Malix-Labs
Copy link

Malix-Labs commented May 28, 2023

Suggestion

πŸ” Search Terms

Class, Constructor, Function, lib

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

A Constructor type

πŸ“ƒ Motivating Example

There are currently a lot of elements being typed as Function instead of Constructor (see #implementation bellow)

πŸ’» Implementation

https://github.com/Malix-Off/oop-utility/blob/ab0b593f0a7039582ea2876a6eb1c980f4262fd4/src/constructor.ts#L1

export type Constructor<T extends Object = object> = new (...args: any[]) => T;
@jcalz
Copy link
Contributor

jcalz commented May 28, 2023

This will be declined. TS doesn't add new utility types anymore unless they are required for emitting declaration files. See this comment on #51841 and the things to which it links.

@Malix-Labs Malix-Labs closed this as not planned Won't fix, can't repro, duplicate, stale May 28, 2023
@MartinJohns
Copy link
Contributor

Also a duplicate of #41656 / #20256.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants