Skip to content

Commit 153634f

Browse files
lib Types and Documentations Fix
1 parent c289718 commit 153634f

134 files changed

Lines changed: 1324 additions & 1492 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/lib/es2015.collection.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface WeakMap<K extends object, V> {
3030
}
3131

3232
interface WeakMapConstructor {
33-
new <K extends object = object, V = any>(entries?: readonly [K, V][] | null): WeakMap<K, V>;
33+
new <K extends object = object, V = any>(entries?: readonly (readonly [K, V])[] | null): WeakMap<K, V>;
3434
readonly prototype: WeakMap<object, any>;
3535
}
3636
declare var WeakMap: WeakMapConstructor;

src/lib/es2015.core.d.ts

Lines changed: 76 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ interface Array<T> {
88
* @param thisArg If provided, it will be used as the this value for each invocation of
99
* predicate. If it is not provided, undefined is used instead.
1010
*/
11-
find<S extends T>(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
11+
find<S extends T>(predicate: (value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
12+
13+
/**
14+
* Returns the value of the first element in the array where predicate is true, and undefined
15+
* otherwise.
16+
* @param predicate find calls predicate once for each element of the array, in ascending
17+
* order, until it finds one where predicate returns true. If such an element is found, find
18+
* immediately returns that element value. Otherwise, find returns undefined.
19+
* @param thisArg If provided, it will be used as the this value for each invocation of
20+
* predicate. If it is not provided, undefined is used instead.
21+
*/
1222
find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined;
1323

1424
/**
@@ -26,44 +36,44 @@ interface Array<T> {
2636
* Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
2737
* @param value value to fill array section with
2838
* @param start index to start filling the array at. If start is negative, it is treated as
29-
* length+start where length is the length of the array.
39+
* length + start where length is the length of the array.
3040
* @param end index to stop filling the array at. If end is negative, it is treated as
31-
* length+end.
41+
* length + end.
3242
*/
3343
fill(value: T, start?: number, end?: number): this;
3444

3545
/**
3646
* Returns the this object after copying a section of the array identified by start and end
3747
* to the same array starting at position target
38-
* @param target If target is negative, it is treated as length+target where length is the
48+
* @param target If target is negative, it is treated as length + target where length is the
3949
* length of the array.
40-
* @param start If start is negative, it is treated as length+start. If end is negative, it
41-
* is treated as length+end.
50+
* @param start If start is negative, it is treated as length + start. If end is negative, it
51+
* is treated as length + end.
4252
* @param end If not specified, length of the this object is used as its default value.
4353
*/
4454
copyWithin(target: number, start: number, end?: number): this;
4555
}
4656

4757
interface ArrayConstructor {
4858
/**
49-
* Creates an array from an array-like object.
50-
* @param arrayLike An array-like object to convert to an array.
59+
* Creates an array from an array-like or iterable object.
60+
* @param source An array-like or iterable object to convert to an array.
5161
*/
52-
from<T>(arrayLike: ArrayLike<T>): T[];
62+
from<T>(source: ArrayLike<T>): T[];
5363

5464
/**
55-
* Creates an array from an iterable object.
56-
* @param arrayLike An array-like object to convert to an array.
65+
* Creates an array from an array-like or iterable object.
66+
* @param source An array-like or iterable object to convert to an array.
5767
* @param mapfn A mapping function to call on every element of the array.
5868
* @param thisArg Value of 'this' used to invoke the mapfn.
5969
*/
60-
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
70+
from<T, U>(source: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
6171

6272
/**
6373
* Returns a new array from a set of elements.
6474
* @param items A set of elements to include in the new array object.
6575
*/
66-
of<T>(...items: T[]): T[];
76+
of<T extends any[]>(...items: T): T;
6777
}
6878

6979
interface DateConstructor {
@@ -194,7 +204,7 @@ interface NumberConstructor {
194204
/**
195205
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
196206
* that is representable as a Number value, which is approximately:
197-
* 2.2204460492503130808472633361816 x 10‍−‍16.
207+
* 2.2204460492503130808472633361816E−‍16 (2^-52).
198208
*/
199209
readonly EPSILON: number;
200210

@@ -229,14 +239,14 @@ interface NumberConstructor {
229239
/**
230240
* The value of the largest integer n such that n and n + 1 are both exactly representable as
231241
* a Number value.
232-
* The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.
242+
* The value of Number.MAX_SAFE_INTEGER is 9007199254740991 (2^53 − 1).
233243
*/
234244
readonly MAX_SAFE_INTEGER: number;
235245

236246
/**
237247
* The value of the smallest integer n such that n and n − 1 are both exactly representable as
238248
* a Number value.
239-
* The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
249+
* The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−2^53 + 1).
240250
*/
241251
readonly MIN_SAFE_INTEGER: number;
242252

@@ -257,13 +267,20 @@ interface NumberConstructor {
257267
}
258268

259269
interface ObjectConstructor {
270+
/**
271+
* Copy the values of all of the enumerable own properties from one or more source objects to a
272+
* target object. Returns the target object.
273+
* @param target The target object to copy to.
274+
*/
275+
assign<T extends {}>(target: T): T;
276+
260277
/**
261278
* Copy the values of all of the enumerable own properties from one or more source objects to a
262279
* target object. Returns the target object.
263280
* @param target The target object to copy to.
264281
* @param source The source object from which to copy properties.
265282
*/
266-
assign<T extends {}, U>(target: T, source: U): T & U;
283+
assign<T extends {}, U>(target: T, source: U): T & Writable<U>;
267284

268285
/**
269286
* Copy the values of all of the enumerable own properties from one or more source objects to a
@@ -272,7 +289,7 @@ interface ObjectConstructor {
272289
* @param source1 The first source object from which to copy properties.
273290
* @param source2 The second source object from which to copy properties.
274291
*/
275-
assign<T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
292+
assign<T extends {}, U, V>(target: T, source1: U, source2: V): T & Writable<U> & Writable<V>;
276293

277294
/**
278295
* Copy the values of all of the enumerable own properties from one or more source objects to a
@@ -282,21 +299,21 @@ interface ObjectConstructor {
282299
* @param source2 The second source object from which to copy properties.
283300
* @param source3 The third source object from which to copy properties.
284301
*/
285-
assign<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
302+
assign<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & Writable<U> & Writable<V> & Writable<W>;
286303

287304
/**
288305
* Copy the values of all of the enumerable own properties from one or more source objects to a
289306
* target object. Returns the target object.
290307
* @param target The target object to copy to.
291-
* @param sources One or more source objects from which to copy properties
308+
* @param sources One or more source objects from which to copy properties.
292309
*/
293-
assign(target: object, ...sources: any[]): any;
310+
assign(target: {}, ...sources: any[]): any;
294311

295312
/**
296313
* Returns an array of all symbol properties found directly on object o.
297314
* @param o Object to retrieve the symbols from.
298315
*/
299-
getOwnPropertySymbols(o: any): symbol[];
316+
getOwnPropertySymbols(o: {}): symbol[];
300317

301318
/**
302319
* Returns the names of the enumerable string properties and methods of an object.
@@ -316,7 +333,7 @@ interface ObjectConstructor {
316333
* @param o The object to change its prototype.
317334
* @param proto The value of the new prototype or null.
318335
*/
319-
setPrototypeOf(o: any, proto: object | null): any;
336+
setPrototypeOf(o: {}, proto: object | null): any;
320337
}
321338

322339
interface ReadonlyArray<T> {
@@ -329,7 +346,17 @@ interface ReadonlyArray<T> {
329346
* @param thisArg If provided, it will be used as the this value for each invocation of
330347
* predicate. If it is not provided, undefined is used instead.
331348
*/
332-
find<S extends T>(predicate: (this: void, value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined;
349+
find<S extends T>(predicate: (value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined;
350+
351+
/**
352+
* Returns the value of the first element in the array where predicate is true, and undefined
353+
* otherwise.
354+
* @param predicate find calls predicate once for each element of the array, in ascending
355+
* order, until it finds one where predicate returns true. If such an element is found, find
356+
* immediately returns that element value. Otherwise, find returns undefined.
357+
* @param thisArg If provided, it will be used as the this value for each invocation of
358+
* predicate. If it is not provided, undefined is used instead.
359+
*/
333360
find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined;
334361

335362
/**
@@ -379,11 +406,11 @@ interface RegExpConstructor {
379406

380407
interface String {
381408
/**
382-
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
383-
* value of the UTF-16 encoded code point starting at the string element at position pos in
384-
* the String resulting from converting this object to a String.
385-
* If there is no element at that position, the result is undefined.
386-
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
409+
* Returns a non-negative integer less than 1114112 (0x110000) that is the code point value
410+
* starting at the string element at the specified position.
411+
* @param pos The zero-based index of the desired code point. If there is no character at the
412+
* specified index, undefined is returned. If a UTF-16 surrogate pair does not begin at pos,
413+
* the result is the code unit at pos.
387414
*/
388415
codePointAt(pos: number): number | undefined;
389416

@@ -397,46 +424,38 @@ interface String {
397424
includes(searchString: string, position?: number): boolean;
398425

399426
/**
400-
* Returns true if the sequence of elements of searchString converted to a String is the
401-
* same as the corresponding elements of this object (converted to a String) starting at
402-
* endPosition – length(this). Otherwise returns false.
427+
* Determines whether the string ends with a substring, ending at the specified index.
428+
* @param searchString The string to search for.
429+
* @param endPosition The index at which to begin searching for. The default value is the
430+
* length of searchString.
403431
*/
404432
endsWith(searchString: string, endPosition?: number): boolean;
405433

406434
/**
407435
* Returns the String value result of normalizing the string into the normalization form
408436
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
409-
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
410-
* is "NFC"
411-
*/
412-
normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
413-
414-
/**
415-
* Returns the String value result of normalizing the string into the normalization form
416-
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
417-
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
418-
* is "NFC"
437+
* @param form The normalization form to be used. The default value is "NFC".
419438
*/
420-
normalize(form?: string): string;
439+
normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
421440

422441
/**
423442
* Returns a String value that is made from count copies appended together. If count is 0,
424443
* the empty string is returned.
425-
* @param count number of copies to append
444+
* @param count The number of copies to append
426445
*/
427446
repeat(count: number): string;
428447

429448
/**
430-
* Returns true if the sequence of elements of searchString converted to a String is the
431-
* same as the corresponding elements of this object (converted to a String) starting at
432-
* position. Otherwise returns false.
449+
* Determines whether the string starts with a substring, beginning at the specified index.
450+
* @param searchString The string to search for.
451+
* @param position The index at which to begin searching for. The default value is 0.
433452
*/
434453
startsWith(searchString: string, position?: number): boolean;
435454

436455
/**
437-
* Returns an `<a>` HTML anchor element and sets the name attribute to the text value
456+
* Returns an `<a>` HTML anchor element and sets the name attribute value
438457
* @deprecated A legacy feature for browser compatibility
439-
* @param name
458+
* @param name The name attribute value
440459
*/
441460
anchor(name: string): string;
442461

@@ -467,20 +486,16 @@ interface String {
467486
/**
468487
* Returns a `<font>` HTML element and sets the color attribute value
469488
* @deprecated A legacy feature for browser compatibility
489+
* @param color The color attribute value
470490
*/
471491
fontcolor(color: string): string;
472492

473493
/**
474494
* Returns a `<font>` HTML element and sets the size attribute value
475495
* @deprecated A legacy feature for browser compatibility
496+
* @param size The size attribute value
476497
*/
477-
fontsize(size: number): string;
478-
479-
/**
480-
* Returns a `<font>` HTML element and sets the size attribute value
481-
* @deprecated A legacy feature for browser compatibility
482-
*/
483-
fontsize(size: string): string;
498+
fontsize(size: number | string): string;
484499

485500
/**
486501
* Returns an `<i>` HTML element
@@ -491,6 +506,7 @@ interface String {
491506
/**
492507
* Returns an `<a>` HTML element and sets the href attribute value
493508
* @deprecated A legacy feature for browser compatibility
509+
* @param url The href attribute value
494510
*/
495511
link(url: string): string;
496512

@@ -521,8 +537,9 @@ interface String {
521537

522538
interface StringConstructor {
523539
/**
524-
* Return the String value whose elements are, in order, the elements in the List elements.
525-
* If length is 0, the empty string is returned.
540+
* Returns a string created by a sequence of code points.
541+
* If no arguments are given, the empty string is returned.
542+
* @param codePoints A sequence of code points.
526543
*/
527544
fromCodePoint(...codePoints: number[]): string;
528545

@@ -535,5 +552,5 @@ interface StringConstructor {
535552
* @param template A well-formed template string call site representation.
536553
* @param substitutions A set of substitution values.
537554
*/
538-
raw(template: { raw: readonly string[] | ArrayLike<string>}, ...substitutions: any[]): string;
555+
raw(template: { raw: readonly string[] | ArrayLike<string> }, ...substitutions: any[]): string;
539556
}

0 commit comments

Comments
 (0)