From c38ac7f4845f2d8c0542a8dd59ffd0801760fabe Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 7 May 2018 11:35:04 -0700 Subject: [PATCH] es6-shim: Avoid conflict with global PropertyKey type (#25421) --- types/es6-shim/es6-shim-tests.ts | 8 ++++---- types/es6-shim/index.d.ts | 31 ++++++++++++++++--------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/types/es6-shim/es6-shim-tests.ts b/types/es6-shim/es6-shim-tests.ts index 87f6fba0e5..7d7fdc6db2 100644 --- a/types/es6-shim/es6-shim-tests.ts +++ b/types/es6-shim/es6-shim-tests.ts @@ -17,7 +17,7 @@ let r: RegExp = /a/; let sym: symbol = {} as symbol; let e: Error = new Error(); let date: Date; -let key: PropertyKey; +let key: KeyOfProperty; let point: Point = { x: 1, y: 2 }; let point3d: Point3D = { x: 1, y: 2, z: 3 }; let point3dOrUndef: Point3D | undefined; @@ -25,7 +25,7 @@ let pointOrUndef: Point | undefined; let arrayOfPoint: Point[] = []; let arrayOfPoint3D: Point3D[]; let arrayOfSymbol: symbol[]; -let arrayOfPropertyKey: PropertyKey[]; +let arrayOfPropertyKey: KeyOfProperty[]; let arrayOfAny: any[]; let arrayOfStringAny: [string, any][]; let arrayLikeOfAny: ArrayLike = []; @@ -40,8 +40,8 @@ let iterableIteratorOfPointPoint: IterableIteratorShim<[Point, Point]>; let iterableIteratorOfNode: IterableIteratorShim; let iterableIteratorOfStringPoint: IterableIteratorShim<[string, Point]>; let iterableIteratorOfAny: IterableIteratorShim; -let iterableIteratorOfPropertyKey: IterableIteratorShim; -let iterableIteratorOfPropertyKeyPoint: IterableIteratorShim<[PropertyKey, Point]>; +let iterableIteratorOfPropertyKey: IterableIteratorShim; +let iterableIteratorOfPropertyKeyPoint: IterableIteratorShim<[KeyOfProperty, Point]>; let nodeList: NodeList; let pd: PropertyDescriptor = {}; let pdm: PropertyDescriptorMap = {}; diff --git a/types/es6-shim/index.d.ts b/types/es6-shim/index.d.ts index 2cf61a9362..e2c1a01f3d 100644 --- a/types/es6-shim/index.d.ts +++ b/types/es6-shim/index.d.ts @@ -4,7 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -declare type PropertyKey = string | number | symbol; +// TODO: As of TypeScript@2.9 there is a global type PropertyKey that should be used instead of this. +declare type KeyOfProperty = string | number | symbol; interface IteratorResult { done: boolean; @@ -625,17 +626,17 @@ declare var WeakSet: WeakSetConstructor; declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; function construct(target: Function, argumentsList: ArrayLike): any; - function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; - function deleteProperty(target: any, propertyKey: PropertyKey): boolean; + function defineProperty(target: any, propertyKey: KeyOfProperty, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: any, propertyKey: KeyOfProperty): boolean; function enumerate(target: any): IterableIteratorShim; - function get(target: any, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + function get(target: any, propertyKey: KeyOfProperty, receiver?: any): any; + function getOwnPropertyDescriptor(target: any, propertyKey: KeyOfProperty): PropertyDescriptor; function getPrototypeOf(target: any): any; - function has(target: any, propertyKey: PropertyKey): boolean; + function has(target: any, propertyKey: KeyOfProperty): boolean; function isExtensible(target: any): boolean; - function ownKeys(target: any): Array; + function ownKeys(target: any): Array; function preventExtensions(target: any): boolean; - function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function set(target: any, propertyKey: KeyOfProperty, value: any, receiver?: any): boolean; function setPrototypeOf(target: any, proto: any): boolean; } @@ -653,17 +654,17 @@ declare module "es6-shim" { namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; function construct(target: Function, argumentsList: ArrayLike): any; - function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; - function deleteProperty(target: any, propertyKey: PropertyKey): boolean; + function defineProperty(target: any, propertyKey: KeyOfProperty, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: any, propertyKey: KeyOfProperty): boolean; function enumerate(target: any): Iterator; - function get(target: any, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + function get(target: any, propertyKey: KeyOfProperty, receiver?: any): any; + function getOwnPropertyDescriptor(target: any, propertyKey: KeyOfProperty): PropertyDescriptor; function getPrototypeOf(target: any): any; - function has(target: any, propertyKey: PropertyKey): boolean; + function has(target: any, propertyKey: KeyOfProperty): boolean; function isExtensible(target: any): boolean; - function ownKeys(target: any): Array; + function ownKeys(target: any): Array; function preventExtensions(target: any): boolean; - function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function set(target: any, propertyKey: KeyOfProperty, value: any, receiver?: any): boolean; function setPrototypeOf(target: any, proto: any): boolean; } }