microsoft / microsoft/TypeScript
PropertyDecorator factory with generic type is not so intelligent
Open
@rbuckton is already working on this.
Since Jun 26, 2019.
Needs Investigation
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.5.1
Search Terms:
Code
export const Reactive = <T, K extends keyof T>(
setter?: (this: T, value?: T[K]) => boolean | void,
) => (target: T, propertyKey: K) => {
// do something
};
class Test {
@Reactive(function(name) {
// error
})
name: string
}
Expected behavior:
Automatically detect this should be type of Test, and name should be type of string
Actual behavior:
Argument of type '"name"' is not assignable to parameter of type 'never'.
Playground Link:
Playground Link
Related Issues:
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.
Assessment
This issue has not been assessed yet.