Skip to content

Commit

Permalink
Merge pull request #10 from graphemecluster/master
Browse files Browse the repository at this point in the history
Several Improvements
  • Loading branch information
uhyo authored May 21, 2022
2 parents 0bb4da3 + 78c7247 commit 5ee1b5f
Show file tree
Hide file tree
Showing 34 changed files with 2,076 additions and 607 deletions.
3 changes: 3 additions & 0 deletions build/replacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export const replacement = new Map([
"eval",
"ObjectConstructor",
"CallableFunction",
"NewableFunction",
"IArguments",
"String",
"JSON",
"ArrayConstructor",
"ReadonlyArray",
Expand Down Expand Up @@ -45,6 +47,7 @@ export const replacement = new Map([
["es2015.promise.d.ts", new Set(["PromiseConstructor"])],
["es2015.proxy.d.ts", new Set(["ProxyHandler"])],
["es2015.reflect.d.ts", new Set(["Reflect"])],
["es2015.symbol.wellknown.d.ts", new Set(["Array", "RegExp", "String"])],
["es2017.object.d.ts", new Set(["ObjectConstructor"])],
["es2018.asyncgenerator.d.ts", new Set(["AsyncGenerator"])],
["es2018.asynciterable.d.ts", new Set(["AsyncIterator"])],
Expand Down
1 change: 1 addition & 0 deletions docs/diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The following files are improved in better-typescript-lib:
- [es2015.promise.d.ts](./diff/es2015.promise.d.ts.md)
- [es2015.proxy.d.ts](./diff/es2015.proxy.d.ts.md)
- [es2015.reflect.d.ts](./diff/es2015.reflect.d.ts.md)
- [es2015.symbol.wellknown.d.ts](./diff/es2015.symbol.wellknown.d.ts.md)
- [es2017.object.d.ts](./diff/es2017.object.d.ts.md)
- [es2018.asyncgenerator.d.ts](./diff/es2018.asyncgenerator.d.ts.md)
- [es2018.asynciterable.d.ts](./diff/es2018.asynciterable.d.ts.md)
Expand Down
19 changes: 11 additions & 8 deletions docs/diff/es2015.collection.d.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ Index: es2015.collection.d.ts
===================================================================
--- es2015.collection.d.ts
+++ es2015.collection.d.ts
@@ -1,28 +1,28 @@
@@ -1,28 +1,30 @@
+/// <reference no-default-lib="true"/>
+
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
- forEach(
- callbackfn: (value: V, key: K, map: Map<K, V>) => void,
- thisArg?: any
+ forEach<This>(
+ forEach<This = undefined>(
+ callbackfn: (this: This, value: V, key: K, map: Map<K, V>) => void,
+ thisArg?: This
): void;
Expand All @@ -36,14 +38,14 @@ Index: es2015.collection.d.ts
- forEach(
- callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void,
- thisArg?: any
+ forEach<This>(
+ forEach<This = undefined>(
+ callbackfn: (this: This, value: V, key: K, map: ReadonlyMap<K, V>) => void,
+ thisArg?: This
): void;
get(key: K): V | undefined;
has(key: K): boolean;
readonly size: number;
@@ -33,39 +33,39 @@
@@ -33,39 +35,39 @@
get(key: K): V | undefined;
has(key: K): boolean;
set(key: K, value: V): this;
Expand All @@ -52,8 +54,9 @@ Index: es2015.collection.d.ts

interface WeakMapConstructor {
- new <K extends object = object, V = any>(
+ new <K extends object = object, V = unknown>(
entries?: readonly [K, V][] | null
- entries?: readonly [K, V][] | null
+ new <K extends object, V>(
+ entries?: readonly (readonly [K, V])[] | null
): WeakMap<K, V>;
- readonly prototype: WeakMap<object, any>;
+ readonly prototype: WeakMap<object, unknown>;
Expand All @@ -67,7 +70,7 @@ Index: es2015.collection.d.ts
- forEach(
- callbackfn: (value: T, value2: T, set: Set<T>) => void,
- thisArg?: any
+ forEach<This>(
+ forEach<This = undefined>(
+ callbackfn: (this: This, value: T, value2: T, set: Set<T>) => void,
+ thisArg?: This
): void;
Expand All @@ -88,7 +91,7 @@ Index: es2015.collection.d.ts
- forEach(
- callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void,
- thisArg?: any
+ forEach<This>(
+ forEach<This = undefined>(
+ callbackfn: (this: This, value: T, value2: T, set: ReadonlySet<T>) => void,
+ thisArg?: This
): void;
Expand Down
112 changes: 29 additions & 83 deletions docs/diff/es2015.core.d.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ Index: es2015.core.d.ts
===================================================================
--- es2015.core.d.ts
+++ es2015.core.d.ts
@@ -201,9 +201,8 @@
@@ -200,9 +200,9 @@
* Returns an implementation-dependent approximation to the cube root of number.
* @param x A numeric expression.
*/
cbrt(x: number): number;
}
-
-}
+} /// <reference no-default-lib="true"/>

interface NumberConstructor {
/**
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
* that is representable as a Number value, which is approximately:
@@ -216,29 +215,29 @@
@@ -216,29 +216,29 @@
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
* number. Only finite values of the type number, result in true.
* @param number A numeric value.
Expand Down Expand Up @@ -49,18 +50,7 @@ Index: es2015.core.d.ts
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as
* a Number value.
@@ -261,9 +260,9 @@

/**
* Converts A string to an integer.
* @param string A string to convert into a number.
- * @param radix A value between 2 and 36 that specifies the base of the number in `string`.
+ * @param radix A value between 2 and 36 that specifies the base of the number in numString.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
parseInt(string: string, radix?: number): number;
@@ -273,45 +272,16 @@
@@ -273,45 +273,16 @@
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
Expand Down Expand Up @@ -95,7 +85,7 @@ Index: es2015.core.d.ts
- source3: W
- ): T & U & V & W;
+ ...sources: Ts
+ ): UnionToIntersection<T | Ts[number]>;
+ ): First<UnionToIntersection<[T] | { [K in keyof Ts]: [Ts[K]] }[number]>>;

/**
- * Copy the values of all of the enumerable own properties from one or more source objects to a
Expand All @@ -110,18 +100,33 @@ Index: es2015.core.d.ts
* @param o Object to retrieve the symbols from.
*/
getOwnPropertySymbols(o: any): symbol[];
@@ -333,9 +303,9 @@
@@ -326,16 +297,23 @@
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
- is(value1: any, value2: any): boolean;
+ is<T>(value1: T, value2: T): boolean;

/**
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
* @param o The object to change its prototype.
* @param proto The value of the new prototype or null.
*/
- setPrototypeOf(o: any, proto: object | null): any;
+ setPrototypeOf<T>(o: T, proto: object | null): T;
+ setPrototypeOf<T extends object, U extends object>(o: T, proto: U): T & U;
+
+ /**
+ * Sets the prototype of a specified object o to object proto or null. Returns the object o.
+ * @param o The object to change its prototype.
+ * @param proto The value of the new prototype or null.
+ */
+ setPrototypeOf<T extends object>(o: T, proto: null): T;
}

interface ReadonlyArray<T> {
/**
@@ -440,19 +410,11 @@
@@ -440,19 +418,11 @@
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
* is "NFC"
Expand All @@ -142,7 +147,7 @@ Index: es2015.core.d.ts
* the empty string is returned.
* @param count number of copies to append
*/
@@ -466,33 +428,33 @@
@@ -466,10 +436,10 @@
startsWith(searchString: string, position?: number): boolean;

/**
Expand All @@ -154,75 +159,16 @@ Index: es2015.core.d.ts
anchor(name: string): string;

/**
- * Returns a `<big>` HTML element
+ * Returns a `<big>` HTML element
* @deprecated A legacy feature for browser compatibility
*/
big(): string;

/**
- * Returns a `<blink>` HTML element
+ * Returns a `<blink>` HTML element
* @deprecated A legacy feature for browser compatibility
*/
blink(): string;

/**
- * Returns a `<b>` HTML element
+ * Returns a `<bold>` HTML element
* @deprecated A legacy feature for browser compatibility
*/
bold(): string;

/**
- * Returns a `<tt>` HTML element
+ * Returns a `<tt>` HTML element
* @deprecated A legacy feature for browser compatibility
*/
fixed(): string;

@@ -514,9 +476,9 @@
@@ -514,9 +484,9 @@
*/
fontsize(size: string): string;

/**
- * Returns an `<i>` HTML element
+ * Returns a `<i>` HTML element
+ * Returns a `<i>` HTML element
* @deprecated A legacy feature for browser compatibility
*/
italics(): string;

@@ -526,27 +488,27 @@
*/
link(url: string): string;

/**
- * Returns a `<small>` HTML element
+ * Returns a `<small>` HTML element
* @deprecated A legacy feature for browser compatibility
*/
small(): string;

/**
- * Returns a `<strike>` HTML element
+ * Returns a `<strike>` HTML element
* @deprecated A legacy feature for browser compatibility
*/
strike(): string;

/**
- * Returns a `<sub>` HTML element
+ * Returns a `<sub>` HTML element
* @deprecated A legacy feature for browser compatibility
*/
sub(): string;

/**
- * Returns a `<sup>` HTML element
+ * Returns a `<sup>` HTML element
* @deprecated A legacy feature for browser compatibility
*/
sup(): string;
}

```
39 changes: 16 additions & 23 deletions docs/diff/es2015.proxy.d.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,14 @@ Index: es2015.proxy.d.ts
===================================================================
--- es2015.proxy.d.ts
+++ es2015.proxy.d.ts
@@ -1,25 +1,28 @@
@@ -1,25 +1,27 @@
+/// <reference no-default-lib="true"/>
+
interface ProxyHandler<T extends object> {
- apply?(target: T, thisArg: any, argArray: any[]): any;
- construct?(target: T, argArray: any[], newTarget: Function): object;
+ getPrototypeOf?(target: T): object | null;
+ setPrototypeOf?(target: T, v: unknown): boolean;
+ isExtensible?(target: T): boolean;
+ preventExtensions?(target: T): boolean;
+ getOwnPropertyDescriptor?(
+ target: T,
+ p: PropertyKey
+ ): PropertyDescriptor | undefined;
+ has?(target: T, p: PropertyKey): boolean;
+ get?(target: T, p: PropertyKey, receiver: unknown): any;
+ set?(target: T, p: PropertyKey, value: unknown, receiver: unknown): boolean;
+ deleteProperty?(target: T, p: PropertyKey): boolean;
+ apply?(target: T, thisArg: unknown, argArray: unknown[]): any;
+ construct?(target: T, argArray: unknown[], newTarget: unknown): object;
defineProperty?(
target: T,
- p: string | symbol,
Expand All @@ -31,21 +21,24 @@ Index: es2015.proxy.d.ts
): boolean;
- deleteProperty?(target: T, p: string | symbol): boolean;
- get?(target: T, p: string | symbol, receiver: any): any;
- getOwnPropertyDescriptor?(
- target: T,
+ deleteProperty?(target: T, p: PropertyKey): boolean;
+ get?(target: T, p: PropertyKey, receiver: unknown): any;
getOwnPropertyDescriptor?(
target: T,
- p: string | symbol
- ): PropertyDescriptor | undefined;
- getPrototypeOf?(target: T): object | null;
+ p: PropertyKey
): PropertyDescriptor | undefined;
getPrototypeOf?(target: T): object | null;
- has?(target: T, p: string | symbol): boolean;
- isExtensible?(target: T): boolean;
+ has?(target: T, p: PropertyKey): boolean;
isExtensible?(target: T): boolean;
- ownKeys?(target: T): ArrayLike<string | symbol>;
- preventExtensions?(target: T): boolean;
+ ownKeys?(target: T): PropertyKey[];
preventExtensions?(target: T): boolean;
- set?(target: T, p: string | symbol, value: any, receiver: any): boolean;
- setPrototypeOf?(target: T, v: object | null): boolean;
+ enumerate?(target: T): PropertyKey[];
+ ownKeys?(target: T): PropertyKey[];
+ apply?(target: T, thisArg: unknown, argArray: unknown[]): any;
+ construct?(target: T, argArray: unknown[], newTarget: unknown): object;
+ set?(target: T, p: PropertyKey, value: unknown, receiver: unknown): boolean;
+ setPrototypeOf?(target: T, v: unknown): boolean;
}

interface ProxyConstructor {
Expand Down
Loading

0 comments on commit 5ee1b5f

Please sign in to comment.