Skip to content
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

Use a more specific type for mapped types #75

Closed
OpportunityLiu opened this issue Jun 12, 2020 · 2 comments
Closed

Use a more specific type for mapped types #75

OpportunityLiu opened this issue Jun 12, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@OpportunityLiu
Copy link
Contributor

I'm submitting a...


[ ] Regression 
[ ] Bug report
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

class A {
    constructor(a: string) {}
}

class B {
    constructor(b: number) {}
}

class C extends IntersectionType(A, B) {
    constructor() {
        super();// <- hint `Type(...args: any[]): A & B` shown here
    }
}

I've checked the source code, found that for each mapped type, a new class with no constructor is created, and "base"(?) classes's constructor are never called.

Expected behavior

Add a new type

export type MappedType<T> = new () => T

as return type of mapped types.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

This can clearify the constuctor parameter of mapped types, implies that constructors of base classes will not be called.

Environment


Nest version: 7.1.3

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue @OpportunityLiu? :)

@kamilmysliwiec kamilmysliwiec added the enhancement New feature or request label Jun 18, 2020
@OpportunityLiu
Copy link
Contributor Author

I'll have a try in weekend.

kamilmysliwiec added a commit that referenced this issue Jun 29, 2020
fix(): Use MappedType<T> as return type for mapped types, fix #75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants