Skip to content

Commit 31c7a25

Browse files
committed
adventure-pack to ESM
1 parent 55ea304 commit 31c7a25

File tree

123 files changed

+319
-427
lines changed

Some content is hidden

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

123 files changed

+319
-427
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"prettier.prettierPath": "./node_modules/prettier",
4+
"typescript.tsdk": "./node_modules/typescript/lib"
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/index.d.ts b/index.d.ts
2+
index 77c12444ac3adf293518e92c07e1680f7d954cb2..8b8da3a4fe0405d81e14998045f8047b1822ac12 100644
3+
--- a/index.d.ts
4+
+++ b/index.d.ts
5+
@@ -11,6 +11,7 @@ export declare const isEquals: any;
6+
export declare const extend: <T>(directive: string, fn: (param: any, old: T) => T) => void;
7+
declare const _default: <T, C extends CustomCommands<object> = never>(object: T, $spec: Spec<T, C>) => T;
8+
export default _default;
9+
+export = _default;
10+
export declare type CustomCommands<T> = T & {
11+
__noInferenceCustomCommandsBrand: any;
12+
};
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
diff --git a/nullthrows.d.ts b/nullthrows.d.ts
2-
index d4953f2f47b79701e5f125b9c041fb185668dd53..a39a37b30cd206e037ecbbb66bc90dacd6adb3af 100644
2+
index d4953f2f47b79701e5f125b9c041fb185668dd53..5c48891acb35ca7ac8a3393e54cd89a158000de5 100644
33
--- a/nullthrows.d.ts
44
+++ b/nullthrows.d.ts
5-
@@ -1,5 +1,15 @@
5+
@@ -1,5 +1,12 @@
66
/**
77
* Throws if value is null or undefined, otherwise returns value.
88
*/
99
+declare function nullthrows<T>(
1010
+ value?: T | null,
1111
+ message?: string,
1212
+): NonNullable<T>;
13-
+
13+
14+
-export default function nullthrows<T>(value?: T | null, message?: string): T;
1415
+// Patched based on https://github.com/microsoft/TypeScript/issues/46770#issuecomment-1039459991 and https://github.com/zertosh/nullthrows/pull/15
1516
+
16-
+declare namespace nullthrows {
17-
+ export { nullthrows as default };
18-
+}
17+
+export default nullthrows;
1918
+export = nullthrows;
20-
21-
-export default function nullthrows<T>(value?: T | null, message?: string): T;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"workspaces/repository-scripts",
1919
"workspaces/util"
2020
],
21+
"type": "module",
2122
"scripts": {
2223
"format": "yarn workspace @code-chronicles/repository-scripts start format",
2324
"lint": "yarn workspace @code-chronicles/repository-scripts start lint",

tsconfig-base.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
3636
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
3737
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
38+
"allowImportingTsExtensions": true /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */,
3939
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
4040
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
4141
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
@@ -89,7 +89,7 @@
8989
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
9090
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
9191
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
92-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
92+
"useUnknownInCatchVariables": true /* Default catch clause variables as 'unknown' instead of 'any'. */,
9393
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
9494
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
9595
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */

workspaces/adventure-pack/goodies/typescript/Array.prototype.slidingWindows/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "@jest/globals";
22

3-
import "./index";
3+
import "./index.ts";
44

55
describe("Array.prototype.slidingWindows", () => {
66
it("can slide over an array", () => {

workspaces/adventure-pack/goodies/typescript/Array.prototype.slidingWindows/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type IndexableArraySlice, ArraySlice } from "../ArraySlice";
1+
import { type IndexableArraySlice, ArraySlice } from "../ArraySlice/index.ts";
22

33
declare global {
44
interface Array<T> {

workspaces/adventure-pack/goodies/typescript/BinaryHeap/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import "../Array.prototype.swap";
1+
import "../Array.prototype.swap/index.ts";
22

33
export class BinaryHeap<T> {
44
private readonly elements: T[] = [];

workspaces/adventure-pack/goodies/typescript/Function.returnThis/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from "@jest/globals";
22

3-
import "./index";
3+
import "./index.ts";
44

55
const VALUES = [
66
42,

workspaces/adventure-pack/goodies/typescript/Iterator.prototype.drop/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { describe, expect, it } from "@jest/globals";
22

3-
import "../Iterator.prototype.take";
3+
import "../Iterator.prototype.take/index.ts";
44

5-
import { iteratorPrototype } from "../Iterator.prototype";
5+
import { iteratorPrototype } from "../Iterator.prototype/index.ts";
66
delete (iteratorPrototype as unknown as Record<string, unknown>).drop;
77
// eslint-disable-next-line import-x/first -- This has to happen after we delete the built-in implementation.
8-
import "./index";
8+
import "./index.ts";
99

1010
describe("Iterator.prototype.drop", () => {
1111
it("drops the specified number of elements from the iterator", () => {

0 commit comments

Comments
 (0)