forked from endojs/endo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
25 lines (20 loc) · 806 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Type definitions for @agoric/harden 0.0.4
// Project: Agoric, Inc.
// Definitions by: Michael FIG <[email protected]>
export = harden;
// FIXME: Would like to return harden.Hardened<T>, but that doesn't yet behave properly.
declare function harden<T>(root: T): T;
declare namespace harden {
type Primitive = undefined | null | boolean | string | number;
export type Hardened<T> =
T extends Function ? HardenedFunction<T> :
T extends Primitive ? Readonly<T> :
T extends Array<infer U> ? HardenedArray<U> :
// All others are manually hardened.
HardenedObject<T>;
type HardenedFunction<T> = T; // FIXME: Escape hatch.
interface HardenedArray<T> extends Readonly<Array<Hardened<T>>> {}
type HardenedObject<T> = {
readonly [K in keyof T]: Hardened<T[K]>
};
}