chore: remove dependency on spec.ts to fix build issue (#1104)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Michel Weststrate · committed by GitHub · parent 8fd0481 · Browse files · 7 files·+60 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+60 added−10 removed
- tests:+60 added−4 removed
- other:+0 added−6 removed
Provenance
- Commit
44363f7- Tree
ace2e4d- Author
Michel Weststrate <mweststrate@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
8fd0481
7 files changed+60 added−10 removed
modified:__tests__/draft.ts+1 added-1 removed
1-import {assert, _} from "spec.ts"1+import {assert, _} from "./spec_ts"2 import {produce, Draft, castDraft, original} from "../src/immer"3 4 // For checking if a type is assignable to its draft type (and vice versa)5 const toDraft: <T>(value: T) => Draft<T> = x => x as any323 unmodified linesmodified:__tests__/immutable.ts+1 added-1 removed
112345112 unmodified linesExpand allimport {assert, _} from "spec.ts"import {assert, _} from "./spec_ts"import {produce, Immutable, castImmutable} from "../src/immer"
test("types are ok", () => { // array in tuple112 unmodified linesExpand allmodified:__tests__/produce.ts+1 added-1 removed
1-import {assert, _} from "spec.ts"1+import {assert, _} from "./spec_ts"2 import {3 produce,4 applyPatches,5 Patch,740 unmodified linesmodified:__tests__/redux.ts+1 added-1 removed
1-import {assert, _} from "spec.ts"1+import {assert, _} from "./spec_ts"2 import {produce, Draft} from "../src/immer"3 import * as redux from "redux"4 5 // Mutable Redux227 unmodified linesadded:__tests__/spec_ts.ts+56 added
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556/** * 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 classexport class Any { // @ts-ignore private _: true}
// Conditional returns can enforce identical types.// See here: https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650// prettier-ignoretype 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()})modified:package.json-1 removed
77 unmodified lines78 "redux": "^4.0.5",79 "rimraf": "^2.6.2",80 "seamless-immutable": "^7.1.3",81 "semantic-release": "^17.0.2",82- "spec.ts": "^1.1.0",82 "ts-jest": "^29.0.0",83 "tsup": "^6.7.0",84 "typescript": "^5.0.2"85 }1 unmodified linemodified:yarn.lock-5 removed
8299 unmodified lines8300 version "3.0.13"8301 resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.13.tgz#7189a474c46f8d47c7b0da4b987bb45e908bd2d5"8302 integrity sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==8303 8304-spec.ts@^1.1.0:8305- version "1.1.3"8306- resolved "https://registry.yarnpkg.com/spec.ts/-/spec.ts-1.1.3.tgz#2951ed40a984386fdd5bb287719e67a1ceaafff1"8307- integrity sha512-xDzHAwbHqe9OIHT1c+pnVpVuYSHNC5vk51aFKKoql2aH1RCzHplkd7MoSV7uLfzgm3GmlfpAfwLtfH2T3lQMmw==8308-8304 split-string@^3.0.1, split-string@^3.0.2:8305 version "3.1.0"8306 resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"8307 integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==1073 unmodified lines