Skip to content

Commit 8c7ca65

Browse files
committed
accept baselines of failing tests
1 parent 669e96b commit 8c7ca65

File tree

3 files changed

+879
-0
lines changed

3 files changed

+879
-0
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(23,15): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
2+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(36,19): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
3+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(53,21): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
4+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(53,45): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
5+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(65,17): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
6+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(78,38): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
7+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(94,21): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
8+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(94,42): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
9+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(94,84): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
10+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(94,129): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
11+
tests/cases/compiler/conditionalTypeDoesntSpinForever.ts(97,71): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
12+
13+
14+
==== tests/cases/compiler/conditionalTypeDoesntSpinForever.ts (11 errors) ====
15+
// A *self-contained* demonstration of the problem follows...
16+
// Test this by running `tsc --target es6` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
17+
18+
export enum PubSubRecordIsStoredInRedisAsA {
19+
redisHash = "redisHash",
20+
jsonEncodedRedisString = "jsonEncodedRedisString"
21+
}
22+
23+
export interface PubSubRecord<NAME extends string, RECORD, IDENTIFIER extends Partial<RECORD>> {
24+
name: NAME;
25+
record: RECORD;
26+
identifier: IDENTIFIER;
27+
storedAs: PubSubRecordIsStoredInRedisAsA;
28+
maxMsToWaitBeforePublishing: number;
29+
}
30+
31+
type NameFieldConstructor<SO_FAR> =
32+
SO_FAR extends {name: any} ? {} : {
33+
name: <TYPE>(t?: TYPE) => BuildPubSubRecordType<SO_FAR & {name: TYPE}>
34+
}
35+
36+
const buildNameFieldConstructor = <SO_FAR>(soFar: SO_FAR) => (
37+
"name" in soFar ? {} : {
38+
~~~~~
39+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
40+
name: <TYPE>(instance: TYPE = undefined) =>
41+
buildPubSubRecordType(Object.assign({}, soFar, {name: instance as TYPE}) as SO_FAR & {name: TYPE}) as BuildPubSubRecordType<SO_FAR & {name: TYPE}>
42+
}
43+
);
44+
45+
type StoredAsConstructor<SO_FAR> =
46+
SO_FAR extends {storedAs: any} ? {} : {
47+
storedAsJsonEncodedRedisString: () => BuildPubSubRecordType<SO_FAR & {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString}>;
48+
storedRedisHash: () => BuildPubSubRecordType<SO_FAR & {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash}>;
49+
}
50+
51+
const buildStoredAsConstructor = <SO_FAR>(soFar: SO_FAR) => (
52+
"storedAs" in soFar ? {} : {
53+
~~~~~
54+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
55+
storedAsJsonEncodedRedisString: () =>
56+
buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString})) as
57+
BuildPubSubRecordType<SO_FAR & {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString}>,
58+
storedAsRedisHash: () =>
59+
buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash})) as
60+
BuildPubSubRecordType<SO_FAR & {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash}>,
61+
}
62+
);
63+
64+
type IdentifierFieldConstructor<SO_FAR> =
65+
SO_FAR extends {identifier: any} ? {} :
66+
SO_FAR extends {record: any} ? {
67+
identifier: <TYPE extends Partial<SO_FAR["record"]>>(t?: TYPE) => BuildPubSubRecordType<SO_FAR & {identifier: TYPE}>
68+
} : {}
69+
70+
const buildIdentifierFieldConstructor = <SO_FAR>(soFar: SO_FAR) => (
71+
"identifier" in soFar || (!("record" in soFar)) ? {} : {
72+
~~~~~
73+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
74+
~~~~~
75+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
76+
identifier: <TYPE>(instance: TYPE = undefined) =>
77+
buildPubSubRecordType(Object.assign({}, soFar, {identifier: instance as TYPE}) as SO_FAR & {identifier: TYPE}) as BuildPubSubRecordType<SO_FAR & {identifier: TYPE}>
78+
}
79+
);
80+
81+
type RecordFieldConstructor<SO_FAR> =
82+
SO_FAR extends {record: any} ? {} : {
83+
record: <TYPE>(t?: TYPE) => BuildPubSubRecordType<SO_FAR & {record: TYPE}>
84+
}
85+
86+
const buildRecordFieldConstructor = <SO_FAR>(soFar: SO_FAR) => (
87+
"record" in soFar ? {} : {
88+
~~~~~
89+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
90+
record: <TYPE>(instance: TYPE = undefined) =>
91+
buildPubSubRecordType(Object.assign({}, soFar, {record: instance as TYPE}) as SO_FAR & {record: TYPE}) as BuildPubSubRecordType<SO_FAR & {record: TYPE}>
92+
}
93+
);
94+
95+
type MaxMsToWaitBeforePublishingFieldConstructor<SO_FAR> =
96+
SO_FAR extends {maxMsToWaitBeforePublishing: any} ? {} : {
97+
maxMsToWaitBeforePublishing: (t: number) => BuildPubSubRecordType<SO_FAR & {maxMsToWaitBeforePublishing: number}>,
98+
neverDelayPublishing: () => BuildPubSubRecordType<SO_FAR & {maxMsToWaitBeforePublishing: 0}>,
99+
}
100+
101+
const buildMaxMsToWaitBeforePublishingFieldConstructor = <SO_FAR>(soFar: SO_FAR): MaxMsToWaitBeforePublishingFieldConstructor<SO_FAR> => (
102+
"maxMsToWaitBeforePublishing" in soFar ? {} : {
103+
~~~~~
104+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
105+
maxMsToWaitBeforePublishing: (instance: number = 0) =>
106+
buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: instance})) as BuildPubSubRecordType<SO_FAR & {maxMsToWaitBeforePublishing: number}>,
107+
neverDelayPublishing: () =>
108+
buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0})) as BuildPubSubRecordType<SO_FAR & {maxMsToWaitBeforePublishing: 0}>,
109+
}
110+
) as MaxMsToWaitBeforePublishingFieldConstructor<SO_FAR>;
111+
112+
type TypeConstructor<SO_FAR> =
113+
SO_FAR extends {identifier: any, record: any, maxMsToWaitBeforePublishing: number, storedAs: PubSubRecordIsStoredInRedisAsA} ? {
114+
type: SO_FAR,
115+
fields: Set<keyof SO_FAR>,
116+
hasField: (fieldName: string | number | symbol) => fieldName is keyof SO_FAR
117+
} : {}
118+
119+
const buildType = <SO_FAR>(soFar: SO_FAR) => (
120+
"identifier" in soFar && "object" in soFar && "maxMsToWaitBeforePublishing" in soFar && "PubSubRecordIsStoredInRedisAsA" in soFar ? {} : {
121+
~~~~~
122+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
123+
~~~~~
124+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
125+
~~~~~
126+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
127+
~~~~~
128+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
129+
type: soFar,
130+
fields: () => new Set(Object.keys(soFar) as (keyof SO_FAR)[]),
131+
hasField: (fieldName: string | number | symbol) => fieldName in soFar
132+
~~~~~
133+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
134+
}
135+
);
136+
137+
type BuildPubSubRecordType<SO_FAR> =
138+
NameFieldConstructor<SO_FAR> &
139+
IdentifierFieldConstructor<SO_FAR> &
140+
RecordFieldConstructor<SO_FAR> &
141+
StoredAsConstructor<SO_FAR> & // infinite loop goes away when you comment out this line
142+
MaxMsToWaitBeforePublishingFieldConstructor<SO_FAR> &
143+
TypeConstructor<SO_FAR>
144+
145+
const buildPubSubRecordType = <SO_FAR>(soFar: SO_FAR) => Object.assign(
146+
{},
147+
buildNameFieldConstructor(soFar),
148+
buildIdentifierFieldConstructor(soFar),
149+
buildRecordFieldConstructor(soFar),
150+
buildStoredAsConstructor(soFar),
151+
buildMaxMsToWaitBeforePublishingFieldConstructor(soFar),
152+
buildType(soFar)
153+
) as BuildPubSubRecordType<SO_FAR>;
154+
const PubSubRecordType = buildPubSubRecordType({});
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithValidOperands.ts(26,20): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
2+
tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithValidOperands.ts(30,20): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
3+
tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithValidOperands.ts(34,20): error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
4+
5+
6+
==== tests/cases/conformance/expressions/binaryOperators/inOperator/inOperatorWithValidOperands.ts (3 errors) ====
7+
var x: any;
8+
9+
// valid left operands
10+
// the left operand is required to be of type Any, the String primitive type, or the Number primitive type
11+
var a1: string;
12+
var a2: number;
13+
var a3: string | number | symbol;
14+
var a4: any;
15+
16+
var ra1 = x in x;
17+
var ra2 = a1 in x;
18+
var ra3 = a2 in x;
19+
var ra4 = '' in x;
20+
var ra5 = 0 in x;
21+
var ra6 = a3 in x;
22+
var ra7 = a4 in x;
23+
24+
// valid right operands
25+
// the right operand is required to be of type Any, an object type, or a type parameter type
26+
var b1: {};
27+
28+
var rb1 = x in b1;
29+
var rb2 = x in {};
30+
31+
function foo<T>(t: T) {
32+
var rb3 = x in t;
33+
~
34+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
35+
}
36+
37+
function unionCase<T, U>(t: T | U) {
38+
var rb4 = x in t;
39+
~
40+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
41+
}
42+
43+
function unionCase2<T>(t: T | object) {
44+
var rb5 = x in t;
45+
~
46+
!!! error TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.
47+
}
48+
49+
interface X { x: number }
50+
interface Y { y: number }
51+
52+
var c1: X | Y;
53+
var c2: X;
54+
var c3: Y;
55+
56+
var rc1 = x in c1;
57+
var rc2 = x in (c2 || c3);
58+

0 commit comments

Comments
 (0)