816abb19e4
Conflicts: src/compiler/checker.ts src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json src/compiler/emitter.ts src/compiler/parser.ts src/compiler/types.ts src/services/navigationBar.ts tests/baselines/reference/assignmentLHSIsValue.errors.txt tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt tests/baselines/reference/parserErrorRecovery_ParameterList2.errors.txt
25 lines
1 KiB
Plaintext
25 lines
1 KiB
Plaintext
tests/cases/conformance/types/union/unionTypeEquivalence.ts(5,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'C', but here has type 'C | D'.
|
|
|
|
|
|
==== tests/cases/conformance/types/union/unionTypeEquivalence.ts (1 errors) ====
|
|
// A | B is equivalent to A if B is a subtype of A
|
|
class C { }
|
|
class D extends C { foo() { } }
|
|
var x: C;
|
|
var x : C | D;
|
|
~
|
|
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'C', but here has type 'C | D'.
|
|
|
|
// A | B is equivalent to B | A.
|
|
var y: string | number;
|
|
var y : number | string;
|
|
|
|
// AB | C is equivalent to A | BC, where AB is A | B and BC is B | C.
|
|
var z : string | number | boolean;
|
|
var z : (string | number) | boolean;
|
|
var z : string | (number | boolean);
|
|
var AB : string | number;
|
|
var BC : number | boolean;
|
|
var z1: typeof AB | boolean;
|
|
var z1: string | typeof BC;
|
|
|