Skip to content

class merge generic parameters #50313

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
lzxb opened this issue Aug 16, 2022 · 2 comments
Closed
5 tasks done

class merge generic parameters #50313

lzxb opened this issue Aug 16, 2022 · 2 comments

Comments

@lzxb
Copy link

lzxb commented Aug 16, 2022

Suggestion

class Component<Props extends {}> {
    public constructor (props: Props) {
        Object.assign(this, props);
    }
}

class App extends Component<{ name: string }> {
    public init() {
        // Property 'name' does not exist on type 'App'.ts(2339)
        this.name
    }
}

🔍 Search Terms

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

✅ 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

📃 Motivating Example

💻 Use Cases

@lzxb
Copy link
Author

lzxb commented Aug 16, 2022

Is there a way to make the above code work

@MartinJohns
Copy link
Contributor

Duplicate of #26792.

@lzxb lzxb closed this as completed Aug 16, 2022
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

2 participants