@agoric/internal 0.3.3-dev-8f019c0.0 → 0.3.3-dev-bc48a8b.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/tagged.d.ts +10 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/internal",
3
- "version": "0.3.3-dev-8f019c0.0+8f019c0",
3
+ "version": "0.3.3-dev-bc48a8b.0+bc48a8b",
4
4
  "description": "Externally unsupported utilities internal to agoric-sdk",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -20,7 +20,7 @@
20
20
  "lint:types": "tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@agoric/base-zone": "0.1.1-dev-8f019c0.0+8f019c0",
23
+ "@agoric/base-zone": "0.1.1-dev-bc48a8b.0+bc48a8b",
24
24
  "@endo/common": "^1.2.2",
25
25
  "@endo/errors": "^1.2.2",
26
26
  "@endo/far": "^1.1.2",
@@ -36,7 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@endo/init": "^1.1.2",
38
38
  "ava": "^5.3.0",
39
- "tsd": "^0.30.7"
39
+ "tsd": "^0.31.1"
40
40
  },
41
41
  "ava": {
42
42
  "require": [
@@ -58,5 +58,5 @@
58
58
  "typeCoverage": {
59
59
  "atLeast": 93.89
60
60
  },
61
- "gitHead": "8f019c091902561290e54ebe2900f12e2e5fbdf8"
61
+ "gitHead": "bc48a8b2d76799c9c07a0888c496039c29049194"
62
62
  }
package/src/tagged.d.ts CHANGED
@@ -21,13 +21,13 @@ A tag's name is usually a string (and must be a string, number, or symbol), but
21
21
 
22
22
  A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
23
23
  - the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
24
- - `A` contains at least all the tags `B` has;
25
- - and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
24
+ - `A` contains at least all the tags `B` has;
25
+ - and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
26
26
 
27
27
  There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
28
- - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
29
- - [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
30
- - [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
28
+ - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
29
+ - [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
30
+ - [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
31
31
 
32
32
  @example
33
33
  ```
@@ -37,12 +37,12 @@ type AccountNumber = Tagged<number, 'AccountNumber'>;
37
37
  type AccountBalance = Tagged<number, 'AccountBalance'>;
38
38
 
39
39
  function createAccountNumber(): AccountNumber {
40
- // As you can see, casting from a `number` (the underlying type being tagged) is allowed.
41
- return 2 as AccountNumber;
40
+ // As you can see, casting from a `number` (the underlying type being tagged) is allowed.
41
+ return 2 as AccountNumber;
42
42
  }
43
43
 
44
44
  function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance {
45
- return 4 as AccountBalance;
45
+ return 4 as AccountBalance;
46
46
  }
47
47
 
48
48
  // This will compile successfully.
@@ -69,8 +69,6 @@ type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
69
69
  // You can also pass a union of tag names, so this is equivalent to the above, although it doesn't give you the ability to assign distinct metadata to each tag.
70
70
  type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
71
71
  ```
72
-
73
- @category Type
74
72
  */
75
73
  export type Tagged<
76
74
  Type,
@@ -102,8 +100,6 @@ function parse<T extends JsonOf<unknown>>(it: T) {
102
100
  const x = stringify({ hello: 'world' });
103
101
  const parsed = parse(x); // The type of `parsed` is { hello: string }
104
102
  ```
105
-
106
- @category Type
107
103
  */
108
104
  export type GetTagMetadata<
109
105
  Type extends Tag<TagName, unknown>,
@@ -125,8 +121,8 @@ import type {Tagged, UnwrapTagged} from 'type-fest';
125
121
  type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
126
122
 
127
123
  const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
128
- SAVINGS: 99,
129
- CHECKING: 0.1
124
+ SAVINGS: 99,
125
+ CHECKING: 0.1
130
126
  };
131
127
 
132
128
  // Without UnwrapTagged, the following expression would throw a type error.
@@ -135,8 +131,6 @@ const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does n
135
131
  // Attempting to pass an non-Tagged type to UnwrapTagged will raise a type error.
136
132
  type WontWork = UnwrapTagged<string>;
137
133
  ```
138
-
139
- @category Type
140
134
  */
141
135
  export type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> =
142
136
  RemoveAllTags<TaggedType>;