TypeScript Version: nightly(2.1.0-dev.20161103)
Code
function prop<S, K extends keyof S>(name: K): (s: S) => any {
return s => s[name]
}
const getProp = prop('test')
const a = getProp({test: 123})
Expected behavior:
Code compiles, getProp is typed as (v: {test: {}}) => any
Actual behavior:
Argument of type "test" is not assignable to parameter of type 'never'
I don't know whether it is an intended behavior. As a comparison, flow seems to, well, cough partly, cough, support it.
https://flowtype.org/try/#0PQKgBAAgZgNg9gdzCYAoVUCuA7AxgFwEs5swAHAJzjIB4BlALjAHkAjAKwFMCAaMAaSYASfpwCeAZ3oA+aQApsAQwC2nJvwCUTORKZ0NYALzSwi7GLABvVGDAVO+TBVI69B42AkBtJaoC6qAC+6LgkEvhgAOYOAApUZEbk8XIA5Pic4SkaqKHY4aaJ0fhx1HKW6eFMAIwATADMgdlAA