We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript Version: 3.3.0-dev
Code
function test<T extends { a: string }>(obj: T) { let { a, ...rest } = obj; return { ...rest, b: a }; } let o1 = { a: 'hello', x: 42 }; let o2: { b: string, x: number } = test(o1); // Error, but shouldn't be
Expected behavior:
No error.
Actual behavior:
Error as shown above.
Playground Link:
https://www.typescriptlang.org/play/index.html#src=function%20test%3CT%20extends%20%7B%20a%3A%20string%20%7D%3E(obj%3A%20T)%20%7B%0D%0A%20%20%20%20let%20%7B%20a%2C%20...rest%20%7D%20%3D%20obj%3B%0D%0A%20%20%20%20return%20%7B%20...rest%2C%20b%3A%20a%20%7D%3B%0D%0A%7D%0D%0A%0D%0Alet%20o1%20%3D%20%7B%20a%3A%20'hello'%2C%20x%3A%2042%20%7D%3B%0D%0Alet%20o2%3A%20%7B%20b%3A%20string%2C%20x%3A%20number%20%7D%20%3D%20test(o1)%3B%0D%0A
Related Issues:
Found while investigating #29062.
The text was updated successfully, but these errors were encountered:
ahejlsberg
No branches or pull requests
TypeScript Version: 3.3.0-dev
Code
Expected behavior:
No error.
Actual behavior:
Error as shown above.
Playground Link:
https://www.typescriptlang.org/play/index.html#src=function%20test%3CT%20extends%20%7B%20a%3A%20string%20%7D%3E(obj%3A%20T)%20%7B%0D%0A%20%20%20%20let%20%7B%20a%2C%20...rest%20%7D%20%3D%20obj%3B%0D%0A%20%20%20%20return%20%7B%20...rest%2C%20b%3A%20a%20%7D%3B%0D%0A%7D%0D%0A%0D%0Alet%20o1%20%3D%20%7B%20a%3A%20'hello'%2C%20x%3A%2042%20%7D%3B%0D%0Alet%20o2%3A%20%7B%20b%3A%20string%2C%20x%3A%20number%20%7D%20%3D%20test(o1)%3B%0D%0A
Related Issues:
Found while investigating #29062.
The text was updated successfully, but these errors were encountered: