Skip to content

Commit d611a88

Browse files
committed
fix: add no-default-lib to generated lib files
1 parent 80ea8e1 commit d611a88

File tree

146 files changed

+1179
-164
lines changed

Some content is hidden

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

146 files changed

+1179
-164
lines changed

build/logic/generate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ export function generate(
2323

2424
const printer = ts.createPrinter();
2525

26-
let result = "";
26+
// This is used as a good indicator of being a default lib file
27+
let result = `/// <reference no-default-lib="true"/>
28+
`;
2729

2830
const replacementTargets = scanBetterFile(printer, libFile);
2931

3032
if (replacementTargets.size === 0) {
31-
return originalFile.text;
33+
return result + originalFile.text;
3234
}
3335

3436
const consumedReplacements = new Set<string>();

docs/diff.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,75 @@
33

44
The following files are improved in better-typescript-lib:
55

6+
- [dom.generated.d.ts](./diff/dom.generated.d.ts.md)
7+
- [dom.iterable.d.ts](./diff/dom.iterable.d.ts.md)
8+
- [dom.iterable.generated.d.ts](./diff/dom.iterable.generated.d.ts.md)
69
- [es2015.collection.d.ts](./diff/es2015.collection.d.ts.md)
710
- [es2015.core.d.ts](./diff/es2015.core.d.ts.md)
11+
- [es2015.d.ts](./diff/es2015.d.ts.md)
12+
- [es2015.full.d.ts](./diff/es2015.full.d.ts.md)
813
- [es2015.generator.d.ts](./diff/es2015.generator.d.ts.md)
914
- [es2015.iterable.d.ts](./diff/es2015.iterable.d.ts.md)
1015
- [es2015.promise.d.ts](./diff/es2015.promise.d.ts.md)
1116
- [es2015.proxy.d.ts](./diff/es2015.proxy.d.ts.md)
1217
- [es2015.reflect.d.ts](./diff/es2015.reflect.d.ts.md)
18+
- [es2015.symbol.d.ts](./diff/es2015.symbol.d.ts.md)
1319
- [es2015.symbol.wellknown.d.ts](./diff/es2015.symbol.wellknown.d.ts.md)
20+
- [es2016.array.include.d.ts](./diff/es2016.array.include.d.ts.md)
21+
- [es2016.d.ts](./diff/es2016.d.ts.md)
22+
- [es2016.full.d.ts](./diff/es2016.full.d.ts.md)
23+
- [es2017.d.ts](./diff/es2017.d.ts.md)
24+
- [es2017.full.d.ts](./diff/es2017.full.d.ts.md)
25+
- [es2017.intl.d.ts](./diff/es2017.intl.d.ts.md)
1426
- [es2017.object.d.ts](./diff/es2017.object.d.ts.md)
27+
- [es2017.sharedmemory.d.ts](./diff/es2017.sharedmemory.d.ts.md)
28+
- [es2017.string.d.ts](./diff/es2017.string.d.ts.md)
29+
- [es2017.typedarrays.d.ts](./diff/es2017.typedarrays.d.ts.md)
1530
- [es2018.asyncgenerator.d.ts](./diff/es2018.asyncgenerator.d.ts.md)
1631
- [es2018.asynciterable.d.ts](./diff/es2018.asynciterable.d.ts.md)
32+
- [es2018.d.ts](./diff/es2018.d.ts.md)
33+
- [es2018.full.d.ts](./diff/es2018.full.d.ts.md)
34+
- [es2018.intl.d.ts](./diff/es2018.intl.d.ts.md)
35+
- [es2018.promise.d.ts](./diff/es2018.promise.d.ts.md)
36+
- [es2018.regexp.d.ts](./diff/es2018.regexp.d.ts.md)
37+
- [es2019.array.d.ts](./diff/es2019.array.d.ts.md)
38+
- [es2019.d.ts](./diff/es2019.d.ts.md)
39+
- [es2019.full.d.ts](./diff/es2019.full.d.ts.md)
40+
- [es2019.intl.d.ts](./diff/es2019.intl.d.ts.md)
1741
- [es2019.object.d.ts](./diff/es2019.object.d.ts.md)
42+
- [es2019.string.d.ts](./diff/es2019.string.d.ts.md)
43+
- [es2019.symbol.d.ts](./diff/es2019.symbol.d.ts.md)
1844
- [es2020.bigint.d.ts](./diff/es2020.bigint.d.ts.md)
45+
- [es2020.d.ts](./diff/es2020.d.ts.md)
46+
- [es2020.date.d.ts](./diff/es2020.date.d.ts.md)
47+
- [es2020.full.d.ts](./diff/es2020.full.d.ts.md)
48+
- [es2020.intl.d.ts](./diff/es2020.intl.d.ts.md)
49+
- [es2020.number.d.ts](./diff/es2020.number.d.ts.md)
50+
- [es2020.promise.d.ts](./diff/es2020.promise.d.ts.md)
51+
- [es2020.sharedmemory.d.ts](./diff/es2020.sharedmemory.d.ts.md)
52+
- [es2020.string.d.ts](./diff/es2020.string.d.ts.md)
53+
- [es2020.symbol.wellknown.d.ts](./diff/es2020.symbol.wellknown.d.ts.md)
54+
- [es2021.d.ts](./diff/es2021.d.ts.md)
55+
- [es2021.full.d.ts](./diff/es2021.full.d.ts.md)
56+
- [es2021.intl.d.ts](./diff/es2021.intl.d.ts.md)
1957
- [es2021.promise.d.ts](./diff/es2021.promise.d.ts.md)
2058
- [es2021.string.d.ts](./diff/es2021.string.d.ts.md)
59+
- [es2021.weakref.d.ts](./diff/es2021.weakref.d.ts.md)
60+
- [es2022.array.d.ts](./diff/es2022.array.d.ts.md)
61+
- [es2022.d.ts](./diff/es2022.d.ts.md)
62+
- [es2022.error.d.ts](./diff/es2022.error.d.ts.md)
63+
- [es2022.full.d.ts](./diff/es2022.full.d.ts.md)
64+
- [es2022.intl.d.ts](./diff/es2022.intl.d.ts.md)
2165
- [es2022.object.d.ts](./diff/es2022.object.d.ts.md)
66+
- [es2022.sharedmemory.d.ts](./diff/es2022.sharedmemory.d.ts.md)
67+
- [es2022.string.d.ts](./diff/es2022.string.d.ts.md)
2268
- [es5.d.ts](./diff/es5.d.ts.md)
69+
- [es5.full.d.ts](./diff/es5.full.d.ts.md)
70+
- [esnext.d.ts](./diff/esnext.d.ts.md)
71+
- [esnext.full.d.ts](./diff/esnext.full.d.ts.md)
72+
- [esnext.intl.d.ts](./diff/esnext.intl.d.ts.md)
73+
- [header.d.ts](./diff/header.d.ts.md)
74+
- [scripthost.d.ts](./diff/scripthost.d.ts.md)
75+
- [webworker.generated.d.ts](./diff/webworker.generated.d.ts.md)
76+
- [webworker.importscripts.d.ts](./diff/webworker.importscripts.d.ts.md)
77+
- [webworker.iterable.generated.d.ts](./diff/webworker.iterable.generated.d.ts.md)

docs/diff/dom.generated.d.ts.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# dom.generated.d.ts Diffs
2+
3+
```diff
4+
Index: dom.generated.d.ts
5+
===================================================================
6+
--- dom.generated.d.ts
7+
+++ dom.generated.d.ts
8+
@@ -1,4 +1,5 @@
9+
+/// <reference no-default-lib="true"/>
10+
/////////////////////////////
11+
/// Window APIs
12+
/////////////////////////////
13+
14+
15+
```

docs/diff/dom.iterable.d.ts.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# dom.iterable.d.ts Diffs
2+
3+
```diff
4+
Index: dom.iterable.d.ts
5+
===================================================================
6+
--- dom.iterable.d.ts
7+
+++ dom.iterable.d.ts
8+
@@ -1,4 +1,5 @@
9+
+/// <reference no-default-lib="true"/>
10+
/// <reference lib="dom" />
11+
12+
interface DOMTokenList {
13+
[Symbol.iterator](): IterableIterator<string>;
14+
15+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# dom.iterable.generated.d.ts Diffs
2+
3+
```diff
4+
Index: dom.iterable.generated.d.ts
5+
===================================================================
6+
--- dom.iterable.generated.d.ts
7+
+++ dom.iterable.generated.d.ts
8+
@@ -1,4 +1,5 @@
9+
+/// <reference no-default-lib="true"/>
10+
/////////////////////////////
11+
/// Window Iterable APIs
12+
/////////////////////////////
13+
14+
15+
```

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ Index: es2015.collection.d.ts
55
===================================================================
66
--- es2015.collection.d.ts
77
+++ es2015.collection.d.ts
8-
@@ -6,11 +6,11 @@
8+
@@ -1,4 +1,5 @@
9+
+/// <reference no-default-lib="true"/>
10+
interface Map<K, V> {
11+
clear(): void;
12+
/**
13+
* @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
14+
@@ -6,11 +7,11 @@
915
delete(key: K): boolean;
1016
/**
1117
* Executes a provided function once per each key/value pair in the Map, in insertion order.
@@ -20,7 +26,7 @@ Index: es2015.collection.d.ts
2026
/**
2127
* Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
2228
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
23-
@@ -30,18 +30,17 @@
29+
@@ -30,18 +31,17 @@
2430
readonly size: number;
2531
}
2632

@@ -43,7 +49,7 @@ Index: es2015.collection.d.ts
4349
get(key: K): V | undefined;
4450
has(key: K): boolean;
4551
readonly size: number;
46-
@@ -68,12 +67,12 @@
52+
@@ -68,12 +68,12 @@
4753
set(key: K, value: V): this;
4854
}
4955

@@ -59,7 +65,7 @@ Index: es2015.collection.d.ts
5965
declare var WeakMap: WeakMapConstructor;
6066

6167
interface Set<T> {
62-
@@ -90,11 +89,11 @@
68+
@@ -90,11 +90,11 @@
6369
delete(value: T): boolean;
6470
/**
6571
* Executes a provided function once per each value in the Set object, in insertion order.
@@ -74,7 +80,7 @@ Index: es2015.collection.d.ts
7480
/**
7581
* @returns a boolean indicating whether an element with the specified value exists in the Set or not.
7682
*/
77-
@@ -105,17 +104,17 @@
83+
@@ -105,17 +105,17 @@
7884
readonly size: number;
7985
}
8086

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ Index: es2015.core.d.ts
55
===================================================================
66
--- es2015.core.d.ts
77
+++ es2015.core.d.ts
8-
@@ -7,15 +7,25 @@
8+
@@ -1,4 +1,5 @@
9+
+/// <reference no-default-lib="true"/>
10+
interface Array<T> {
11+
/**
12+
* Returns the value of the first element in the array where predicate is true, and undefined
13+
* otherwise.
14+
@@ -7,15 +8,25 @@
915
* immediately returns that element value. Otherwise, find returns undefined.
1016
* @param thisArg If provided, it will be used as the this value for each invocation of
1117
* predicate. If it is not provided, undefined is used instead.
@@ -37,7 +43,7 @@ Index: es2015.core.d.ts
3743

3844
/**
3945
* Returns the index of the first element in the array where predicate is true, and -1
40-
@@ -25,11 +35,11 @@
46+
@@ -25,11 +36,11 @@
4147
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
4248
* @param thisArg If provided, it will be used as the this value for each invocation of
4349
* predicate. If it is not provided, undefined is used instead.
@@ -52,7 +58,7 @@ Index: es2015.core.d.ts
5258

5359
/**
5460
* Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
55-
@@ -54,23 +64,23 @@
61+
@@ -54,23 +65,23 @@
5662
}
5763

5864
interface ArrayConstructor {
@@ -85,7 +91,7 @@ Index: es2015.core.d.ts
8591

8692
/**
8793
* Returns a new array from a set of elements.
88-
@@ -273,49 +283,20 @@
94+
@@ -273,49 +284,20 @@
8995
/**
9096
* Copy the values of all of the enumerable own properties from one or more source objects to a
9197
* target object. Returns the target object.
@@ -140,7 +146,7 @@ Index: es2015.core.d.ts
140146
/**
141147
* Returns the names of the enumerable string properties and methods of an object.
142148
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
143-
@@ -326,16 +307,23 @@
149+
@@ -326,16 +308,23 @@
144150
* Returns true if the values are the same value, false otherwise.
145151
* @param value1 The first value.
146152
* @param value2 The second value.
@@ -166,7 +172,7 @@ Index: es2015.core.d.ts
166172

167173
interface ReadonlyArray<T> {
168174
/**
169-
@@ -346,20 +334,25 @@
175+
@@ -346,20 +335,25 @@
170176
* immediately returns that element value. Otherwise, find returns undefined.
171177
* @param thisArg If provided, it will be used as the this value for each invocation of
172178
* predicate. If it is not provided, undefined is used instead.
@@ -203,7 +209,7 @@ Index: es2015.core.d.ts
203209

204210
/**
205211
* Returns the index of the first element in the array where predicate is true, and -1
206-
@@ -369,11 +362,11 @@
212+
@@ -369,11 +363,11 @@
207213
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
208214
* @param thisArg If provided, it will be used as the this value for each invocation of
209215
* predicate. If it is not provided, undefined is used instead.
@@ -218,7 +224,7 @@ Index: es2015.core.d.ts
218224
}
219225

220226
interface RegExp {
221-
@@ -433,26 +426,17 @@
227+
@@ -433,26 +427,17 @@
222228
* same as the corresponding elements of this object (converted to a String) starting at
223229
* endPosition – length(this). Otherwise returns false.
224230
*/

docs/diff/es2015.d.ts.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# es2015.d.ts Diffs
2+
3+
```diff
4+
Index: es2015.d.ts
5+
===================================================================
6+
--- es2015.d.ts
7+
+++ es2015.d.ts
8+
@@ -1,4 +1,5 @@
9+
+/// <reference no-default-lib="true"/>
10+
/// <reference lib="es5" />
11+
/// <reference lib="es2015.core" />
12+
/// <reference lib="es2015.collection" />
13+
/// <reference lib="es2015.iterable" />
14+
15+
```

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# es2015.full.d.ts Diffs
2+
3+
```diff
4+
Index: es2015.full.d.ts
5+
===================================================================
6+
--- es2015.full.d.ts
7+
+++ es2015.full.d.ts
8+
@@ -1,4 +1,5 @@
9+
+/// <reference no-default-lib="true"/>
10+
/// <reference lib="es2015" />
11+
/// <reference lib="dom" />
12+
/// <reference lib="dom.iterable" />
13+
/// <reference lib="webworker.importscripts" />
14+
15+
```

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Index: es2015.generator.d.ts
55
===================================================================
66
--- es2015.generator.d.ts
77
+++ es2015.generator.d.ts
8-
@@ -1,7 +1,7 @@
8+
@@ -1,7 +1,8 @@
9+
+/// <reference no-default-lib="true"/>
910
/// <reference lib="es2015.iterable" />
1011

1112
-interface Generator<T = unknown, TReturn = any, TNext = unknown>

0 commit comments

Comments
 (0)