Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update core.js types #5067

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
/* JS primitives
cf. http://typescript.codeplex.com/sourcecontrol/latest#typings/lib.d.ts
cf. https://github.com/Microsoft/TypeScript/blob/master/lib/lib.d.ts
*/

declare var NaN: number;
Expand All @@ -21,6 +21,19 @@ declare function decodeURIComponent(encodedURIComponent: string): string;
declare function encodeURI(uri: string): string;
declare function encodeURIComponent(uriComponent: string): string;

type PropertyDescriptor<T> = {
enumerable?: boolean;
configurable?: boolean;
writable?: boolean;
value?: T;
get?: () => T;
set?: (value: T) => void;
};

type PropertyDescriptorMap = {
[s: string]: PropertyDescriptor<*>;
}

// TODO: instance
declare class Object {
static (o: ?void): {[key: any]: any};
Expand All @@ -29,12 +42,12 @@ declare class Object {
static (o: string): String;
static <T: Object>(o: T): T;
static assign: Object$Assign;
static create(o: any, properties?: any): any; // compiler magic
static defineProperties(o: any, properties: any): any;
static defineProperty(o: any, p: any, attributes: any): any;
static create(o: any, properties?: PropertyDescriptorMap): any; // compiler magic
static defineProperties(o: any, properties: PropertyDescriptorMap): any;
static defineProperty(o: any, p: any, attributes: PropertyDescriptor<*>): any;
static entries(object: any): Array<[string, mixed]>;
static freeze<T>(o: T): T;
static getOwnPropertyDescriptor(o: any, p: any): any;
static getOwnPropertyDescriptor(o: any, p: any): PropertyDescriptor<*> | void;
static getOwnPropertyNames(o: any): Array<string>;
static getOwnPropertySymbols(o: any): Symbol[];
static getPrototypeOf: Object$GetPrototypeOf;
Expand All @@ -43,8 +56,8 @@ declare class Object {
static isFrozen(o: any): boolean;
static isSealed(o: any): boolean;
static keys(o: any): Array<string>;
static preventExtensions(o: any): any;
static seal(o: any): any;
static preventExtensions<T>(o: T): T;
static seal<T>(o: T): T;
static setPrototypeOf(o: any, proto: ?Object): bool;
static values(object: any): Array<mixed>;
hasOwnProperty(prop: any): boolean;
Expand Down Expand Up @@ -94,6 +107,7 @@ declare class Function {
apply: Function$Prototype$Apply; // (thisArg: any, argArray?: any) => any
bind: Function$Prototype$Bind; // (thisArg: any, ...argArray: Array<any>) => any;
call: Function$Prototype$Call; // (thisArg: any, ...argArray: Array<any>) => any
toString(): string;
arguments: any;
caller: Function | null;
length: number;
Expand Down Expand Up @@ -729,8 +743,8 @@ declare function unescape(str: string): string;

declare function clearInterval(intervalId?: number): void;
declare function clearTimeout(timeoutId?: any): void;
declare function setTimeout(callback: any, ms?: number, ...args: Array<any>): number;
declare function setInterval(callback: any, ms?: number, ...args: Array<any>): number;
declare function setTimeout(callback: Function, ms?: number, ...args: Array<any>): number;
declare function setInterval(callback: Function, ms?: number, ...args: Array<any>): number;

/* Reflect API */

Expand All @@ -757,8 +771,8 @@ type Proxy$traps<T> = {
setPrototypeOf?: (target: T, prototype: Object|null) => boolean;
isExtensible?: (target: T) => boolean;
preventExtensions?: (target: T) => boolean;
getOwnPropertyDescriptor?: (target: T, property: string) => void | Object;
defineProperty?: (target: T, property: string, descriptor: Object) => boolean;
getOwnPropertyDescriptor?: (target: T, property: string) => void | PropertyDescriptor<*>;
defineProperty?: (target: T, property: string, descriptor: PropertyDescriptor<*>) => boolean;
has?: (target: T, key: string) => boolean;
get?: (target: T, property: string, receiver: Proxy<T>) => any;
set?: (target: T, property: string, value: any, receiver: Proxy<T>) => boolean;
Expand Down
4 changes: 2 additions & 2 deletions newtests/array_literal_tuple_spread/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ export default suite(({addFile, addFiles, addCode}) => [
3: const arr: Array<number> = [..."hello"];
^^^^^^^^^^^^^ array type
Type argument \`T\` is incompatible:
288: @@iterator(): Iterator<string>;
^^^^^^ string. This type is incompatible with. See lib: [LIB] core.js:288
302: @@iterator(): Iterator<string>;
^^^^^^ string. This type is incompatible with. See lib: [LIB] core.js:302
3: const arr: Array<number> = [..."hello"];
^^^^^^ number
`,
Expand Down
Loading