Added test.

This commit is contained in:
Daniel Rosenwasser
2020-08-28 22:42:57 +00:00
parent 10fb9c9381
commit a7d564d3bb
@@ -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,
};
});
}