2014-10-09 20:02:57 +02:00
|
|
|
/// <reference path='fourslash.ts'/>
|
|
|
|
|
|
|
|
////interface A {
|
|
|
|
//// a: number;
|
|
|
|
//// common: string;
|
|
|
|
////}
|
|
|
|
////
|
|
|
|
////interface B {
|
2017-01-27 17:59:33 +01:00
|
|
|
//// [|{| "isWriteAccess": true, "isDefinition": true |}b|]: number;
|
2014-10-09 20:02:57 +02:00
|
|
|
//// common: number;
|
|
|
|
////}
|
|
|
|
////
|
|
|
|
////// Assignment
|
|
|
|
////var v1: A | B = { a: 0, common: "" };
|
2017-01-27 17:59:33 +01:00
|
|
|
////var v2: A | B = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 3 };
|
2014-10-09 20:02:57 +02:00
|
|
|
////
|
|
|
|
////// Function call
|
|
|
|
////function consumer(f: A | B) { }
|
2017-01-27 17:59:33 +01:00
|
|
|
////consumer({ a: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 1 });
|
2014-10-09 20:02:57 +02:00
|
|
|
////
|
2017-01-27 17:59:33 +01:00
|
|
|
////// Type cast
|
|
|
|
////var c = <A | B> { common: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0 };
|
2014-10-09 20:02:57 +02:00
|
|
|
////
|
|
|
|
////// Array literal
|
2017-01-27 17:59:33 +01:00
|
|
|
////var ar: Array<A|B> = [{ a: 0, common: "" }, { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 0 }];
|
2014-10-09 20:02:57 +02:00
|
|
|
////
|
|
|
|
////// Nested object literal
|
2017-01-27 17:59:33 +01:00
|
|
|
////var ob: { aorb: A|B } = { aorb: { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 0 } };
|
2014-10-09 20:02:57 +02:00
|
|
|
////
|
|
|
|
////// Widened type
|
2017-01-27 17:59:33 +01:00
|
|
|
////var w: A|B = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined" |}b|]:undefined, common: undefined };
|
2014-10-09 20:02:57 +02:00
|
|
|
////
|
|
|
|
////// Untped -- should not be included
|
|
|
|
////var u1 = { a: 0, b: 0, common: "" };
|
|
|
|
////var u2 = { b: 0, common: 0 };
|
|
|
|
|
2017-01-27 17:59:33 +01:00
|
|
|
const ranges = test.ranges();
|
|
|
|
verify.referenceGroups(ranges[0], [{ definition: "(property) B.b: number", ranges }]);
|
|
|
|
for (const reference of ranges.slice(1)) {
|
|
|
|
const type = reference.marker.data.type;
|
|
|
|
verify.referenceGroups(reference, [
|
|
|
|
{ definition: "(property) B.b: number", ranges: ranges.filter(r => r !== reference) },
|
|
|
|
{ definition: `(property) b: ${type}`, ranges: [reference] }
|
|
|
|
]);
|
|
|
|
}
|