From 886191390ed413ce70277e70063a5fa65c3fe901 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 2 Mar 2018 09:27:07 -0800 Subject: [PATCH] Accept new baselines --- .../baselines/reference/keyofIntersection.js | 56 ++++++++++ .../reference/keyofIntersection.symbols | 105 ++++++++++++++++++ .../reference/keyofIntersection.types | 105 ++++++++++++++++++ 3 files changed, 266 insertions(+) create mode 100644 tests/baselines/reference/keyofIntersection.js create mode 100644 tests/baselines/reference/keyofIntersection.symbols create mode 100644 tests/baselines/reference/keyofIntersection.types diff --git a/tests/baselines/reference/keyofIntersection.js b/tests/baselines/reference/keyofIntersection.js new file mode 100644 index 00000000000..3b6fc7eea1b --- /dev/null +++ b/tests/baselines/reference/keyofIntersection.js @@ -0,0 +1,56 @@ +//// [keyofIntersection.ts] +type A = { a: string }; +type B = { b: string }; + +type T01 = keyof (A & B); // "a" | "b" +type T02 = keyof (T & B); // "b" | keyof T +type T03 = keyof (A & U); // "a" | keyof U +type T04 = keyof (T & U); // keyof T | keyof U +type T05 = T02; // "a" | "b" +type T06 = T03; // "a" | "b" +type T07 = T04; // "a" | "b" + +// Repros from #22291 + +type Example1 = keyof (Record & Record); +type Result1 = Example1<'x', 'y'>; // "x" | "y" + +type Result2 = keyof (Record<'x', any> & Record<'y', any>); // "x" | "y" + +type Example3 = keyof (Record); +type Result3 = Example3<'x' | 'y'>; // "x" | "y" + +type Example4 = (Record & Record); +type Result4 = keyof Example4<'x', 'y'>; // "x" | "y" + +type Example5 = keyof (T & U); +type Result5 = Example5, Record<'y', any>>; // "x" | "y" + + +//// [keyofIntersection.js] +"use strict"; + + +//// [keyofIntersection.d.ts] +declare type A = { + a: string; +}; +declare type B = { + b: string; +}; +declare type T01 = keyof (A & B); +declare type T02 = keyof (T & B); +declare type T03 = keyof (A & U); +declare type T04 = keyof (T & U); +declare type T05 = T02; +declare type T06 = T03; +declare type T07 = T04; +declare type Example1 = keyof (Record & Record); +declare type Result1 = Example1<'x', 'y'>; +declare type Result2 = keyof (Record<'x', any> & Record<'y', any>); +declare type Example3 = keyof (Record); +declare type Result3 = Example3<'x' | 'y'>; +declare type Example4 = (Record & Record); +declare type Result4 = keyof Example4<'x', 'y'>; +declare type Example5 = keyof (T & U); +declare type Result5 = Example5, Record<'y', any>>; diff --git a/tests/baselines/reference/keyofIntersection.symbols b/tests/baselines/reference/keyofIntersection.symbols new file mode 100644 index 00000000000..aac8341f363 --- /dev/null +++ b/tests/baselines/reference/keyofIntersection.symbols @@ -0,0 +1,105 @@ +=== tests/cases/conformance/types/keyof/keyofIntersection.ts === +type A = { a: string }; +>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0)) +>a : Symbol(a, Decl(keyofIntersection.ts, 0, 10)) + +type B = { b: string }; +>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23)) +>b : Symbol(b, Decl(keyofIntersection.ts, 1, 10)) + +type T01 = keyof (A & B); // "a" | "b" +>T01 : Symbol(T01, Decl(keyofIntersection.ts, 1, 23)) +>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0)) +>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23)) + +type T02 = keyof (T & B); // "b" | keyof T +>T02 : Symbol(T02, Decl(keyofIntersection.ts, 3, 25)) +>T : Symbol(T, Decl(keyofIntersection.ts, 4, 9)) +>T : Symbol(T, Decl(keyofIntersection.ts, 4, 9)) +>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23)) + +type T03 = keyof (A & U); // "a" | keyof U +>T03 : Symbol(T03, Decl(keyofIntersection.ts, 4, 28)) +>U : Symbol(U, Decl(keyofIntersection.ts, 5, 9)) +>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0)) +>U : Symbol(U, Decl(keyofIntersection.ts, 5, 9)) + +type T04 = keyof (T & U); // keyof T | keyof U +>T04 : Symbol(T04, Decl(keyofIntersection.ts, 5, 28)) +>T : Symbol(T, Decl(keyofIntersection.ts, 6, 9)) +>U : Symbol(U, Decl(keyofIntersection.ts, 6, 11)) +>T : Symbol(T, Decl(keyofIntersection.ts, 6, 9)) +>U : Symbol(U, Decl(keyofIntersection.ts, 6, 11)) + +type T05 = T02; // "a" | "b" +>T05 : Symbol(T05, Decl(keyofIntersection.ts, 6, 31)) +>T02 : Symbol(T02, Decl(keyofIntersection.ts, 3, 25)) +>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0)) + +type T06 = T03; // "a" | "b" +>T06 : Symbol(T06, Decl(keyofIntersection.ts, 7, 18)) +>T03 : Symbol(T03, Decl(keyofIntersection.ts, 4, 28)) +>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23)) + +type T07 = T04; // "a" | "b" +>T07 : Symbol(T07, Decl(keyofIntersection.ts, 8, 18)) +>T04 : Symbol(T04, Decl(keyofIntersection.ts, 5, 28)) +>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0)) +>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23)) + +// Repros from #22291 + +type Example1 = keyof (Record & Record); +>Example1 : Symbol(Example1, Decl(keyofIntersection.ts, 9, 21)) +>T : Symbol(T, Decl(keyofIntersection.ts, 13, 14)) +>U : Symbol(U, Decl(keyofIntersection.ts, 13, 31)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(keyofIntersection.ts, 13, 14)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>U : Symbol(U, Decl(keyofIntersection.ts, 13, 31)) + +type Result1 = Example1<'x', 'y'>; // "x" | "y" +>Result1 : Symbol(Result1, Decl(keyofIntersection.ts, 13, 92)) +>Example1 : Symbol(Example1, Decl(keyofIntersection.ts, 9, 21)) + +type Result2 = keyof (Record<'x', any> & Record<'y', any>); // "x" | "y" +>Result2 : Symbol(Result2, Decl(keyofIntersection.ts, 14, 34)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) + +type Example3 = keyof (Record); +>Example3 : Symbol(Example3, Decl(keyofIntersection.ts, 16, 59)) +>T : Symbol(T, Decl(keyofIntersection.ts, 18, 14)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(keyofIntersection.ts, 18, 14)) + +type Result3 = Example3<'x' | 'y'>; // "x" | "y" +>Result3 : Symbol(Result3, Decl(keyofIntersection.ts, 18, 57)) +>Example3 : Symbol(Example3, Decl(keyofIntersection.ts, 16, 59)) + +type Example4 = (Record & Record); +>Example4 : Symbol(Example4, Decl(keyofIntersection.ts, 19, 35)) +>T : Symbol(T, Decl(keyofIntersection.ts, 21, 14)) +>U : Symbol(U, Decl(keyofIntersection.ts, 21, 31)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(keyofIntersection.ts, 21, 14)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>U : Symbol(U, Decl(keyofIntersection.ts, 21, 31)) + +type Result4 = keyof Example4<'x', 'y'>; // "x" | "y" +>Result4 : Symbol(Result4, Decl(keyofIntersection.ts, 21, 86)) +>Example4 : Symbol(Example4, Decl(keyofIntersection.ts, 19, 35)) + +type Example5 = keyof (T & U); +>Example5 : Symbol(Example5, Decl(keyofIntersection.ts, 22, 40)) +>T : Symbol(T, Decl(keyofIntersection.ts, 24, 14)) +>U : Symbol(U, Decl(keyofIntersection.ts, 24, 16)) +>T : Symbol(T, Decl(keyofIntersection.ts, 24, 14)) +>U : Symbol(U, Decl(keyofIntersection.ts, 24, 16)) + +type Result5 = Example5, Record<'y', any>>; // "x" | "y" +>Result5 : Symbol(Result5, Decl(keyofIntersection.ts, 24, 36)) +>Example5 : Symbol(Example5, Decl(keyofIntersection.ts, 22, 40)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) +>Record : Symbol(Record, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/keyofIntersection.types b/tests/baselines/reference/keyofIntersection.types new file mode 100644 index 00000000000..f9c312b4120 --- /dev/null +++ b/tests/baselines/reference/keyofIntersection.types @@ -0,0 +1,105 @@ +=== tests/cases/conformance/types/keyof/keyofIntersection.ts === +type A = { a: string }; +>A : A +>a : string + +type B = { b: string }; +>B : B +>b : string + +type T01 = keyof (A & B); // "a" | "b" +>T01 : "b" | "a" +>A : A +>B : B + +type T02 = keyof (T & B); // "b" | keyof T +>T02 : keyof T | "b" +>T : T +>T : T +>B : B + +type T03 = keyof (A & U); // "a" | keyof U +>T03 : "a" | keyof U +>U : U +>A : A +>U : U + +type T04 = keyof (T & U); // keyof T | keyof U +>T04 : keyof T | keyof U +>T : T +>U : U +>T : T +>U : U + +type T05 = T02; // "a" | "b" +>T05 : "b" | "a" +>T02 : keyof T | "b" +>A : A + +type T06 = T03; // "a" | "b" +>T06 : "b" | "a" +>T03 : "a" | keyof U +>B : B + +type T07 = T04; // "a" | "b" +>T07 : "b" | "a" +>T04 : keyof T | keyof U +>A : A +>B : B + +// Repros from #22291 + +type Example1 = keyof (Record & Record); +>Example1 : T | U +>T : T +>U : U +>Record : Record +>T : T +>Record : Record +>U : U + +type Result1 = Example1<'x', 'y'>; // "x" | "y" +>Result1 : "x" | "y" +>Example1 : T | U + +type Result2 = keyof (Record<'x', any> & Record<'y', any>); // "x" | "y" +>Result2 : "x" | "y" +>Record : Record +>Record : Record + +type Example3 = keyof (Record); +>Example3 : T +>T : T +>Record : Record +>T : T + +type Result3 = Example3<'x' | 'y'>; // "x" | "y" +>Result3 : "x" | "y" +>Example3 : T + +type Example4 = (Record & Record); +>Example4 : Record & Record +>T : T +>U : U +>Record : Record +>T : T +>Record : Record +>U : U + +type Result4 = keyof Example4<'x', 'y'>; // "x" | "y" +>Result4 : "x" | "y" +>Example4 : Record & Record + +type Example5 = keyof (T & U); +>Example5 : keyof T | keyof U +>T : T +>U : U +>T : T +>U : U + +type Result5 = Example5, Record<'y', any>>; // "x" | "y" +>Result5 : "x" | "y" +>Example5 : keyof T | keyof U +>Record : Record +>Record : Record +