TypeScript Version: 3.2.1
Search Terms:
strucutre spread + generic
Code
function id<T>(input: T): T { return input }
function getFoo ({ foo = 42 }) {
return foo
}
const newGetFoo = id(getFoo)
const newGetFoo2 = id(function getFoo ({ foo = 42 }) {
return foo
})
Expected behavior:
newGetFoo and newGetFoo2 should have the same signature
Actual behavior:
newGetFoo is:
({ foo }: {
foo?: number | undefined;
}) => number
but newGetFoo2 is
Playground Link:
http://www.typescriptlang.org/play/index.html#src=function%20id%3CT%3E(input%3A%20T)%3A%20T%20%7B%20return%20input%20%7D%0A%0Afunction%20getFoo%20(%7B%20foo%20%3D%2042%20%7D)%20%7B%0A%20%20return%20foo%0A%7D%0A%0Aconst%20newGetFoo%20%3D%20id(getFoo)%0Aconst%20newGetFoo2%20%3D%20id(function%20getFoo%20(%7B%20foo%20%3D%2042%20%7D)%20%7B%0A%20%20return%20foo%0A%7D)%0A
Related Issues:
TypeScript Version: 3.2.1
Search Terms:
strucutre spread + generic
Code
Expected behavior:
newGetFoo and newGetFoo2 should have the same signature
Actual behavior:
newGetFoois:but
newGetFoo2isPlayground Link:
http://www.typescriptlang.org/play/index.html#src=function%20id%3CT%3E(input%3A%20T)%3A%20T%20%7B%20return%20input%20%7D%0A%0Afunction%20getFoo%20(%7B%20foo%20%3D%2042%20%7D)%20%7B%0A%20%20return%20foo%0A%7D%0A%0Aconst%20newGetFoo%20%3D%20id(getFoo)%0Aconst%20newGetFoo2%20%3D%20id(function%20getFoo%20(%7B%20foo%20%3D%2042%20%7D)%20%7B%0A%20%20return%20foo%0A%7D)%0A
Related Issues: