Skip to content
Myr

Some final cleanup

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent 12c38c6 · Browse files · 5 files+5 added−17 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+5 added−17 removed

  • other:+5 added−17 removed

5 files+5 added−17 removed

modified:src/common.ts+1 added-2 removed
11 unmodified lines
1213/** Use a class type for `nothing` so its type is unique */14export class Nothing {15 // This lets us do `Exclude<T, Nothing>`16 // TODO: do this better, use unique symbol instead16 // @ts-ignore18 private _: any17 private _!: unique symbol18}1920const hasSymbol = typeof Symbol !== "undefined"21export const hasMap = typeof Map !== "undefined"
222 unmodified lines
modified:src/map.ts+2 added-4 removed
modified:src/proxy.ts+2 added
92 unmodified lines
93 target = [state] as any94 traps = arrayTraps95 }9697 // TODO: optimization: might be faster, cheaper if we created a non-revocable proxy98 // and administrate revoking ourselves99 const {revoke, proxy} = Proxy.revocable(target, traps)100 state.draft = proxy as any101 state.revoke = revoke102 return proxy as any
157 unmodified lines
modified:src/set.ts-2 removed
4 unmodified lines
5import {assertUnrevoked} from "./es5"67export interface SetState extends ImmerBaseState {8 type: ProxyType.Set9 finalizing: boolean // TODO: kill?9 copy: AnySet | undefined10 base: AnySet11 drafts: Map<any, Drafted> // maps the original value to the draft value in the new set12 revoked: boolean
13 unmodified lines
26 parent,27 scope: parent ? parent.scope : ImmerScope.current!,28 modified: false,29 finalized: false,31 finalizing: false,30 copy: undefined,31 base: target,32 draft: this,33 drafts: new Map(),
111 unmodified lines
modified:src/types.ts-9 removed
212 unmodified lines
213 base: Base,214 recipe: (draft: D) => Return215 ): [Produced<Base, Return>, Patch[], Patch[]]216}217218// Backward compatibility with --target es5219// TODO: still needed?220// declare global {221// interface Set<T> {}222// interface Map<K, V> {}223// interface WeakSet<T> {}224// interface WeakMap<K extends object, V> {}225// }