From 68ce69a351ad9100b7bd44f3791908bb7e09ff13 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 9 Apr 2018 07:45:55 -1000 Subject: [PATCH] Move 'PropertyKey' from es2015.core.d.ts to es5.d.ts --- src/lib/es2015.core.d.ts | 35 ----------------------------------- src/lib/es5.d.ts | 12 +++++++----- 2 files changed, 7 insertions(+), 40 deletions(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 68be040c29d..cfb300c784d 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -1,5 +1,3 @@ -declare type PropertyKey = string | number | symbol; - interface Array { /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -258,20 +256,6 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface Object { - /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - hasOwnProperty(v: PropertyKey): boolean; - - /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ - propertyIsEnumerable(v: PropertyKey): boolean; -} - interface ObjectConstructor { /** * Copy the values of all of the enumerable own properties from one or more source objects to a @@ -327,25 +311,6 @@ interface ObjectConstructor { * @param proto The value of the new prototype or null. */ setPrototypeOf(o: any, proto: object | null): any; - - /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not - * inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ - getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor | undefined; - - /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript - * object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor - * property. - */ - defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; } interface ReadonlyArray { diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 1f352cd6f39..9d38f3c2c7c 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -74,6 +74,8 @@ declare function escape(string: string): string; */ declare function unescape(string: string): string; +declare type PropertyKey = string | number | symbol; + interface PropertyDescriptor { configurable?: boolean; enumerable?: boolean; @@ -104,7 +106,7 @@ interface Object { * Determines whether an object has a property with the specified name. * @param v A property name. */ - hasOwnProperty(v: string): boolean; + hasOwnProperty(v: PropertyKey): boolean; /** * Determines whether an object exists in another object's prototype chain. @@ -116,7 +118,7 @@ interface Object { * Determines whether a specified property is enumerable. * @param v A property name. */ - propertyIsEnumerable(v: string): boolean; + propertyIsEnumerable(v: PropertyKey): boolean; } interface ObjectConstructor { @@ -139,7 +141,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor | undefined; + getOwnPropertyDescriptor(o: any, p: PropertyKey): PropertyDescriptor | undefined; /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly @@ -167,7 +169,7 @@ interface ObjectConstructor { * @param p The property name. * @param attributes Descriptor for the property. It can be for a data property or an accessor property. */ - defineProperty(o: any, p: string, attributes: PropertyDescriptor & ThisType): any; + defineProperty(o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType): any; /** * Adds one or more properties to an object, and/or modifies attributes of existing properties. @@ -1341,7 +1343,7 @@ type Pick = { /** * Construct a type with a set of properties K of type T */ -type Record = { +type Record = { [P in K]: T; };