mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Added test.
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
// @strict: true
|
||||
|
||||
export type SomeObj1 = { a: number, b: number };
|
||||
|
||||
declare function valueOrGetter<T>(x: T, f: () => T): T;
|
||||
|
||||
namespace arrows {
|
||||
declare function consumeObj1(f: () => SomeObj1): void;
|
||||
consumeObj1(() => ({
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
}));
|
||||
|
||||
function obj1FactoryFactory(): () => SomeObj1 {
|
||||
return () => ({
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
});
|
||||
}
|
||||
|
||||
valueOrGetter({ a: 100, b: 200 }, () => ({
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
}));
|
||||
|
||||
valueOrGetter<SomeObj1>({ a: 100, b: 200, c: 300 }, () => ({
|
||||
a: 100,
|
||||
b: 200,
|
||||
}));
|
||||
|
||||
valueOrGetter<SomeObj1>({ a: 100, b: 200 }, () => ({
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
}));
|
||||
|
||||
valueOrGetter({ a: 100, b: 200, c: 300 }, () => ({
|
||||
a: 100,
|
||||
b: 200,
|
||||
}));
|
||||
}
|
||||
|
||||
namespace funcExprs {
|
||||
declare function consumeObj1(f: () => SomeObj1): void;
|
||||
consumeObj1(function() {
|
||||
return {
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
};
|
||||
});
|
||||
|
||||
function obj1FactoryFactory(): () => SomeObj1 {
|
||||
return function() {
|
||||
return {
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
valueOrGetter({ a: 100, b: 200 }, function() {
|
||||
return {
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
};
|
||||
});
|
||||
|
||||
valueOrGetter<SomeObj1>({ a: 100, b: 200, c: 300 }, function() {
|
||||
return {
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
};
|
||||
});
|
||||
|
||||
valueOrGetter<SomeObj1>({ a: 100, b: 200 }, function() {
|
||||
return {
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
};
|
||||
});
|
||||
|
||||
valueOrGetter({ a: 100, b: 200, c: 300 }, function() {
|
||||
return {
|
||||
a: 100,
|
||||
b: 200,
|
||||
c: 300,
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user