Skip to content

Commit 651acad

Browse files
Restore Interface Documentation
1 parent 16e8eb7 commit 651acad

15 files changed

+266
-551
lines changed

build/logic/generate.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ export function generate(
2828
const replacementTargets = scanBetterFile(printer, libFile);
2929

3030
if (replacementTargets.size === 0) {
31-
for (const statement of originalFile.statements) {
32-
result += statement.getFullText(originalFile);
33-
}
34-
result += originalFile.text.slice(originalFile.endOfFileToken.pos);
35-
return result;
31+
return originalFile.text;
3632
}
3733

3834
const consumedReplacements = new Set<string>();
@@ -133,7 +129,7 @@ export function generate(
133129
},
134130
];
135131
});
136-
result += printInterface(printer, statement, memberList);
132+
result += printInterface(printer, statement, memberList, originalFile);
137133

138134
if (emitOriginalAsComment) {
139135
result += "\n";
@@ -327,10 +323,12 @@ function isPartialReplacement(
327323
function printInterface(
328324
printer: ts.Printer,
329325
originalNode: ts.InterfaceDeclaration,
330-
members: readonly { text: string }[]
326+
members: readonly { text: string }[],
327+
originalSourceFile: ts.SourceFile
331328
): string {
332-
const originalSourceFile = originalNode.getSourceFile();
333-
let result = "";
329+
let result = originalNode
330+
.getFullText(originalSourceFile)
331+
.slice(0, originalNode.getLeadingTriviaWidth(originalSourceFile));
334332
for (const dec of originalNode.decorators ?? []) {
335333
result += printer.printNode(
336334
ts.EmitHint.Unspecified,

docs/diff/es2015.collection.d.ts.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Index: es2015.collection.d.ts
55
===================================================================
66
--- es2015.collection.d.ts
77
+++ es2015.collection.d.ts
8-
@@ -1,28 +1,25 @@
8+
@@ -1,28 +1,27 @@
99
interface Map<K, V> {
1010
clear(): void;
1111
delete(key: K): boolean;
@@ -21,15 +21,15 @@ Index: es2015.collection.d.ts
2121
set(key: K, value: V): this;
2222
readonly size: number;
2323
}
24-
-
24+
2525
interface MapConstructor {
2626
- new (): Map<any, any>;
2727
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
2828
- readonly prototype: Map<any, any>;
2929
+ readonly prototype: Map<unknown, unknown>;
3030
}
3131
declare var Map: MapConstructor;
32-
-
32+
3333
interface ReadonlyMap<K, V> {
3434
- forEach(
3535
- callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void,
@@ -41,12 +41,10 @@ Index: es2015.collection.d.ts
4141
get(key: K): V | undefined;
4242
has(key: K): boolean;
4343
readonly size: number;
44-
@@ -33,39 +30,35 @@
45-
get(key: K): V | undefined;
46-
has(key: K): boolean;
44+
@@ -35,37 +34,37 @@
4745
set(key: K, value: V): this;
4846
}
49-
-
47+
5048
interface WeakMapConstructor {
5149
- new <K extends object = object, V = any>(
5250
- entries?: readonly [K, V][] | null
@@ -57,7 +55,7 @@ Index: es2015.collection.d.ts
5755
+ readonly prototype: WeakMap<object, unknown>;
5856
}
5957
declare var WeakMap: WeakMapConstructor;
60-
-
58+
6159
interface Set<T> {
6260
add(value: T): this;
6361
clear(): void;
@@ -72,15 +70,15 @@ Index: es2015.collection.d.ts
7270
has(value: T): boolean;
7371
readonly size: number;
7472
}
75-
-
73+
7674
interface SetConstructor {
7775
- new <T = any>(values?: readonly T[] | null): Set<T>;
7876
- readonly prototype: Set<any>;
7977
+ new <T>(values?: readonly T[] | null): Set<T>;
8078
+ readonly prototype: Set<unknown>;
8179
}
8280
declare var Set: SetConstructor;
83-
-
81+
8482
interface ReadonlySet<T> {
8583
- forEach(
8684
- callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void,

docs/diff/es2015.core.d.ts.md

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ Index: es2015.core.d.ts
5252

5353
/**
5454
* Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
55-
@@ -51,26 +61,25 @@
56-
* @param end If not specified, length of the this object is used as its default value.
57-
*/
58-
copyWithin(target: number, start: number, end?: number): this;
55+
@@ -54,23 +64,23 @@
5956
}
60-
-
57+
6158
interface ArrayConstructor {
6259
/**
6360
- * Creates an array from an array-like object.
@@ -88,15 +85,7 @@ Index: es2015.core.d.ts
8885

8986
/**
9087
* Returns a new array from a set of elements.
91-
@@ -201,44 +210,42 @@
92-
* @param x A numeric expression.
93-
*/
94-
cbrt(x: number): number;
95-
}
96-
-
97-
interface NumberConstructor {
98-
/**
99-
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
88+
@@ -209,36 +219,35 @@
10089
* that is representable as a Number value, which is approximately:
10190
* 2.2204460492503130808472633361816 x 10‍−‍16.
10291
*/
@@ -137,13 +126,7 @@ Index: es2015.core.d.ts
137126
/**
138127
* The value of the largest integer n such that n and n + 1 are both exactly representable as
139128
* a Number value.
140-
@@ -267,51 +274,31 @@
141-
* All other strings are considered decimal.
142-
*/
143-
parseInt(string: string, radix?: number): number;
144-
}
145-
-
146-
interface ObjectConstructor {
129+
@@ -273,45 +282,26 @@
147130
/**
148131
* Copy the values of all of the enumerable own properties from one or more source objects to a
149132
* target object. Returns the target object.
@@ -203,7 +186,7 @@ Index: es2015.core.d.ts
203186
* @param o Object to retrieve the symbols from.
204187
*/
205188
getOwnPropertySymbols(o: any): symbol[];
206-
@@ -326,18 +313,24 @@
189+
@@ -326,16 +316,23 @@
207190
* Returns true if the values are the same value, false otherwise.
208191
* @param value1 The first value.
209192
* @param value2 The second value.
@@ -226,12 +209,10 @@ Index: es2015.core.d.ts
226209
+ */
227210
+ setPrototypeOf<T extends object>(o: T, proto: null): T;
228211
}
229-
-
212+
230213
interface ReadonlyArray<T> {
231214
/**
232-
* Returns the value of the first element in the array where predicate is true, and undefined
233-
* otherwise.
234-
@@ -346,20 +339,25 @@
215+
@@ -346,20 +343,25 @@
235216
* immediately returns that element value. Otherwise, find returns undefined.
236217
* @param thisArg If provided, it will be used as the this value for each invocation of
237218
* predicate. If it is not provided, undefined is used instead.
@@ -268,7 +249,7 @@ Index: es2015.core.d.ts
268249

269250
/**
270251
* Returns the index of the first element in the array where predicate is true, and -1
271-
@@ -369,11 +367,11 @@
252+
@@ -369,11 +371,11 @@
272253
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
273254
* @param thisArg If provided, it will be used as the this value for each invocation of
274255
* predicate. If it is not provided, undefined is used instead.
@@ -283,17 +264,7 @@ Index: es2015.core.d.ts
283264
}
284265

285266
interface RegExp {
286-
@@ -407,9 +405,8 @@
287-
interface RegExpConstructor {
288-
new (pattern: RegExp | string, flags?: string): RegExp;
289-
(pattern: RegExp | string, flags?: string): RegExp;
290-
}
291-
-
292-
interface String {
293-
/**
294-
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
295-
* value of the UTF-16 encoded code point starting at the string element at position pos in
296-
@@ -433,26 +430,17 @@
267+
@@ -433,26 +435,17 @@
297268
* same as the corresponding elements of this object (converted to a String) starting at
298269
* endPosition – length(this). Otherwise returns false.
299270
*/

0 commit comments

Comments
 (0)