-
-
Notifications
You must be signed in to change notification settings - Fork 852
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove dependency on spec.ts to fix build issue (#1104)
- Loading branch information
1 parent
8fd0481
commit 44363f7
Showing
7 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {assert, _} from "spec.ts" | ||
import {assert, _} from "./spec_ts" | ||
import { | ||
produce, | ||
applyPatches, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* This file is literally copied from https://github.com/aleclarson/spec.ts/blob/master/index.d.ts. | ||
* For the sole reason, that the package somehow fails to install in our GitHub workflow. | ||
* It is unclear why, but all credits to @aleclarson! | ||
*/ | ||
|
||
// Give "any" its own class | ||
export class Any { | ||
// @ts-ignore | ||
private _: true | ||
} | ||
|
||
// Conditional returns can enforce identical types. | ||
// See here: https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650 | ||
// prettier-ignore | ||
type TestExact<Left, Right> = | ||
(<U>() => U extends Left ? 1 : 0) extends (<U>() => U extends Right ? 1 : 0) ? Any : never; | ||
|
||
type IsAny<T> = Any extends T ? ([T] extends [Any] ? 1 : 0) : 0 | ||
|
||
export type Test<Left, Right> = IsAny<Left> extends 1 | ||
? IsAny<Right> extends 1 | ||
? 1 | ||
: "❌ Left type is 'any' but right type is not" | ||
: IsAny<Right> extends 1 | ||
? "❌ Right type is 'any' but left type is not" | ||
: [Left] extends [Right] | ||
? [Right] extends [Left] | ||
? Any extends TestExact<Left, Right> | ||
? 1 | ||
: "❌ Unexpected or missing 'readonly' property" | ||
: "❌ Right type is not assignable to left type" | ||
: "❌ Left type is not assignable to right type" | ||
|
||
type Assert<T, U> = U extends 1 | ||
? T // No error. | ||
: IsAny<T> extends 1 | ||
? never // Ensure "any" is refused. | ||
: U // Return the error message. | ||
|
||
/** | ||
* Raise a compiler error when both argument types are not identical. | ||
*/ | ||
export const assert: <Left, Right>( | ||
left: Assert<Left, Test<Left, Right>>, | ||
right: Assert<Right, Test<Left, Right>> | ||
) => Right = x => x as any | ||
|
||
/** | ||
* Placeholder value followed by "as T" | ||
*/ | ||
export const _: any = Symbol("spec.ts placeholder") | ||
|
||
test("empty test to silence jest", () => { | ||
expect(true).toBeTruthy() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters