Skip to content

Commit 78a2882

Browse files
committed
Forgotten export
1 parent 2888f0f commit 78a2882

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

etc/types.api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,6 @@ export type PropertyInfo<T extends Type<unknown> = Type<unknown>> = {
427427
type: T;
428428
};
429429

430-
// Warning: (ae-forgotten-export) The symbol "Unwidened" needs to be exported by the entry point index.d.ts
431-
//
432430
// @public
433431
export function record<KeyType extends number | string, ValueType>(...args: [name: string, keyType: BaseTypeImpl<KeyType>, valueType: BaseTypeImpl<Unwidened<ValueType>>, strict?: boolean] | [keyType: BaseTypeImpl<KeyType>, valueType: BaseTypeImpl<Unwidened<ValueType>>, strict?: boolean]): TypeImpl<RecordType<BaseTypeImpl<KeyType>, KeyType, BaseTypeImpl<ValueType>, ValueType>>;
434432

@@ -615,6 +613,9 @@ export type unknownRecord = Record<string, unknown>;
615613
// @public
616614
export const unknownRecord: Type<unknownRecord>;
617615

616+
// @public
617+
export type Unwidened<T> = T extends T ? T : never;
618+
618619
// @public
619620
export type ValidationDetails = {
620621
type: BaseTypeImpl<unknown>;

markdown/types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Runtime type-validation with derived TypeScript types.
136136
| [UnbrandValues](./types.unbrandvalues.md) | |
137137
| [unknownArray](./types.unknownarray.md) | Built-in validator that accepts all arrays. |
138138
| [unknownRecord](./types.unknownrecord.md) | Built-in validator that accepts all objects (<code>null</code> is not accepted). |
139+
| [Unwidened](./types.unwidened.md) | Small helper type that somehow nudges TS compiler to not widen branded string and number types to their base type. |
139140
| [ValidationDetails](./types.validationdetails.md) | Information about the performed validation for error-reporting. |
140141
| [ValidationMode](./types.validationmode.md) | The validation mode to use. |
141142
| [ValidationResult](./types.validationresult.md) | The possible return values inside validation and constraint functions. |

markdown/types.record.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ declare function record<KeyType extends number | string, ValueType>(
1818

1919
## Parameters
2020

21-
| Parameter | Type | Description |
22-
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
23-
| args | \[name: string, keyType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;KeyType&gt;, valueType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;Unwidened&lt;ValueType&gt;&gt;, strict?: boolean\] \| \[keyType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;KeyType&gt;, valueType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;Unwidened&lt;ValueType&gt;&gt;, strict?: boolean\] | |
21+
| Parameter | Type | Description |
22+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- |
23+
| args | \[name: string, keyType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;KeyType&gt;, valueType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;[Unwidened](./types.unwidened.md)<!-- -->&lt;ValueType&gt;&gt;, strict?: boolean\] \| \[keyType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;KeyType&gt;, valueType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;[Unwidened](./types.unwidened.md)<!-- -->&lt;ValueType&gt;&gt;, strict?: boolean\] | |
2424

2525
**Returns:**
2626

markdown/types.unwidened.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@skunkteam/types](./types.md) &gt; [Unwidened](./types.unwidened.md)
4+
5+
## Unwidened type
6+
7+
Small helper type that somehow nudges TS compiler to not widen branded string and number types to their base type.
8+
9+
**Signature:**
10+
11+
```typescript
12+
type Unwidened<T> = T extends T ? T : never;
13+
```

src/types/record.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ define(
9696
);
9797

9898
/** Small helper type that somehow nudges TS compiler to not widen branded string and number types to their base type. */
99-
type Unwidened<T> = T extends T ? T : never;
99+
export type Unwidened<T> = T extends T ? T : never;
100100
/**
101101
* Note: record has strict validation by default, while type does not have strict validation, both are strict in construction though. TODO: document
102102
*/

0 commit comments

Comments
 (0)