mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
8 lines
261 B
TypeScript
8 lines
261 B
TypeScript
function foo<T>(x: { bar: T; baz: T }) {
|
|
return x;
|
|
}
|
|
|
|
var r = foo({ bar: 1, baz: '' }); // error
|
|
var r2 = foo({ bar: 1, baz: 1 }); // T = number
|
|
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
|
|
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
|