microsoft / microsoft/TypeScript
Allow specifying only a subset of generic type parameters explicitly instead of all vs none
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 2.3.0
https://www.typescriptlang.org/play/
Code
class Greeter<T, S> {
greeting: T;
constructor(message: T, message2: S) {
this.greeting = message;
}
}
let greeter = new Greeter<string>("Hello", "world");
Expected behavior:
The compiler should infer S to be string.
Actual behavior:
Error:
Supplied parameters do not match any signature of call target.
The compiler expects either all generic parameters to be specified explicitly or none at all.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the TypeScript 2.3 generic class example in the issue and reproduce the error in the linked TypeScript playground. Investigate generic call-site inference for new Greeter<string>("Hello", "world"); done means the explicit T is accepted while S is inferred as string, with coverage for the reported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100