Skip to content

Commit

Permalink
Updated API docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
untio11 committed Nov 18, 2024
1 parent a282744 commit 2888f0f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 21 deletions.
4 changes: 3 additions & 1 deletion etc/types.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,10 @@ export type PropertyInfo<T extends Type<unknown> = Type<unknown>> = {
type: T;
};

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

// @public
export class RecordType<KeyTypeImpl extends BaseTypeImpl<KeyType>, KeyType extends number | string, ValueTypeImpl extends BaseTypeImpl<ValueType>, ValueType, ResultType extends Record<KeyType, ValueType> = Record<KeyType, ValueType>> extends BaseTypeImpl<ResultType> {
Expand Down
10 changes: 5 additions & 5 deletions markdown/types.record.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ Note: record has strict validation by default, while type does not have strict v
```typescript
declare function record<KeyType extends number | string, ValueType>(
...args:
| [name: string, keyType: BaseTypeImpl<KeyType>, valueType: BaseTypeImpl<ValueType>, strict?: boolean]
| [keyType: BaseTypeImpl<KeyType>, valueType: BaseTypeImpl<ValueType>, strict?: boolean]
| [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>>;
```

## Parameters

| Parameter | Type | Description |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| args | \[name: string, keyType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;KeyType&gt;, valueType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ValueType&gt;, strict?: boolean\] \| \[keyType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;KeyType&gt;, valueType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ValueType&gt;, strict?: boolean\] | |
| Parameter | Type | Description |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| 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\] | |

**Returns:**

Expand Down
5 changes: 1 addition & 4 deletions src/types/intersection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ export class IntersectionType<Types extends OneOrMore<BaseObjectLikeTypeImpl<unk
/** {@inheritdoc BaseTypeImpl.typeConfig} */
readonly typeConfig: undefined;

constructor(
readonly types: Types,
name?: string,
) {
constructor(readonly types: Types, name?: string) {
super();
this.isDefaultName = !name;
this.name = name || defaultName(types);
Expand Down
2 changes: 1 addition & 1 deletion src/types/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type Bound<T extends 'min' | 'max'> = {
function selectBound<T extends 'min' | 'max'>(key: T, current: NumberTypeConfig, update: NumberTypeConfig): Bound<T> {
const exclKey = `${key}Exclusive` as const;

const onlyTheBound = (c: NumberTypeConfig) => ({ [key]: c[key], [exclKey]: c[exclKey] }) as Bound<T>;
const onlyTheBound = (c: NumberTypeConfig) => ({ [key]: c[key], [exclKey]: c[exclKey] } as Bound<T>);

const currentPosition: number | undefined = current[key] ?? current[exclKey];
if (currentPosition == null) return onlyTheBound(update);
Expand Down
7 changes: 1 addition & 6 deletions src/types/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ export class RecordType<
/** {@inheritdoc BaseTypeImpl.typeConfig} */
readonly typeConfig: undefined;

constructor(
readonly keyType: KeyTypeImpl,
readonly valueType: ValueTypeImpl,
name?: string,
readonly strict = true,
) {
constructor(readonly keyType: KeyTypeImpl, readonly valueType: ValueTypeImpl, name?: string, readonly strict = true) {
super();
this.isDefaultName = !name;
this.name = name || `Record<${keyType.name}, ${valueType.name}>`;
Expand Down
5 changes: 1 addition & 4 deletions src/types/union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ export class UnionType<
/** {@inheritdoc BaseTypeImpl.typeConfig} */
readonly typeConfig: undefined;

constructor(
readonly types: Types,
name?: string,
) {
constructor(readonly types: Types, name?: string) {
super();
this.isDefaultName = !name;
this.name = name || types.map(type => bracketsIfNeeded(type.name, '|')).join(' | ');
Expand Down

0 comments on commit 2888f0f

Please sign in to comment.