Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upPropertyDecorator factory with generic type is not so intelligent #31917
Labels
Comments
This comment has been minimized.
This comment has been minimized.
Maybe this is the same Issue as I have. I would expect that this would cry a river at function testProperty<T>(otherProperty: keyof T): PropertyDecorator {
return (target, propertyKey) => {
// ... some code
};
}
class Test {
@testProperty('shouldWork')
test: boolean = true;
@testProperty('shouldNotWork')
test2: boolean = true;
shouldWork: boolean = true;
} My current workaround is to define the type manually like this: class Test2 {
@testProperty<Test2>('shouldWork')
test: boolean = true;
@testProperty<Test2>('shouldNotWork')
test2: boolean = true;
shouldWork: boolean = true;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeScript Version: 3.5.1
Search Terms:
Code
Expected behavior:
Automatically detect
this
should be type ofTest
, andname
should be type ofstring
Actual behavior:
Argument of type '"name"' is not assignable to parameter of type 'never'.
Playground Link:
Playground Link
Related Issues: