Skip to content

Commit

Permalink
Update keyof tests to reflect microsoft#12425
Browse files Browse the repository at this point in the history
Removes number from all the keyof types, and adds a test that numeric
indexes are ignored.
  • Loading branch information
ethanresnick committed Nov 28, 2016
1 parent 88b7d53 commit 8b7252c
Show file tree
Hide file tree
Showing 4 changed files with 479 additions and 446 deletions.
21 changes: 14 additions & 7 deletions tests/baselines/reference/keyofAndIndexedAccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ class Options {
}

type Dictionary<T> = { [x: string]: T };
type NumericallyIndexed<T> = { [x: number]: T };

const enum E { A, B, C }

type K00 = keyof any; // string | number
type K01 = keyof string; // number | "toString" | "charAt" | ...
type K00 = keyof any; // string
type K01 = keyof string; // "toString" | "charAt" | ...
type K02 = keyof number; // "toString" | "toFixed" | "toExponential" | ...
type K03 = keyof boolean; // "valueOf"
type K04 = keyof void; // never
Expand All @@ -34,19 +35,20 @@ type K06 = keyof null; // never
type K07 = keyof never; // never

type K10 = keyof Shape; // "name" | "width" | "height" | "visible"
type K11 = keyof Shape[]; // number | "length" | "toString" | ...
type K12 = keyof Dictionary<Shape>; // string | number
type K11 = keyof Shape[]; // "length" | "toString" | ...
type K12 = keyof Dictionary<Shape>; // string
type K13 = keyof {}; // never
type K14 = keyof Object; // "constructor" | "toString" | ...
type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ...
type K16 = keyof [string, number]; // number | "0" | "1" | "length" | "toString" | ...
type K16 = keyof [string, number]; // "0" | "1" | "length" | "toString" | ...
type K17 = keyof (Shape | Item); // "name"
type K18 = keyof (Shape & Item); // "name" | "width" | "height" | "visible" | "price"
type K19 = keyof NumericallyIndexed<Shape> // never

type KeyOf<T> = keyof T;

type K20 = KeyOf<Shape>; // "name" | "width" | "height" | "visible"
type K21 = KeyOf<Dictionary<Shape>>; // string | number
type K21 = KeyOf<Dictionary<Shape>>; // string

type NAME = "name";
type WIDTH_OR_HEIGHT = "width" | "height";
Expand Down Expand Up @@ -247,7 +249,8 @@ class OtherPerson {
getParts() {
return getProperty(this, "parts")
}
}
}


//// [keyofAndIndexedAccess.js]
var __extends = (this && this.__extends) || function (d, b) {
Expand Down Expand Up @@ -449,6 +452,9 @@ declare class Options {
declare type Dictionary<T> = {
[x: string]: T;
};
declare type NumericallyIndexed<T> = {
[x: number]: T;
};
declare const enum E {
A = 0,
B = 1,
Expand All @@ -471,6 +477,7 @@ declare type K15 = keyof E;
declare type K16 = keyof [string, number];
declare type K17 = keyof (Shape | Item);
declare type K18 = keyof (Shape & Item);
declare type K19 = keyof NumericallyIndexed<Shape>;
declare type KeyOf<T> = keyof T;
declare type K20 = KeyOf<Shape>;
declare type K21 = KeyOf<Dictionary<Shape>>;
Expand Down
Loading

0 comments on commit 8b7252c

Please sign in to comment.